mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Adding a 'magic_font_scale'
https://community.osarch.org/discussion/2202/blenderbim-edit-text-preview-size
This commit is contained in:
@@ -415,12 +415,14 @@ class BaseDecorator:
|
|||||||
factor = self.camera_zoom_to_factor(context.space_data.region_3d.view_camera_zoom)
|
factor = self.camera_zoom_to_factor(context.space_data.region_3d.view_camera_zoom)
|
||||||
camera_width_px = factor * context.region.width
|
camera_width_px = factor * context.region.width
|
||||||
mm_to_px = camera_width_px / self.get_camera_width_mm()
|
mm_to_px = camera_width_px / self.get_camera_width_mm()
|
||||||
# 0.004118616 is a magic constant number I visually discovered to get the right number.
|
# magic_font_scale's default of (0.004118616) is a magic constant number I visually discovered to get the right number.
|
||||||
# In particular it works only for the OpenGOST font and produces a 2.5mm font size.
|
# In particular it works only for the OpenGOST font and produces a 2.5mm font size.
|
||||||
# It probably should be dynamically calculated using system.dpi or something.
|
# It probably should be dynamically calculated using system.dpi or something.
|
||||||
# font_size = 16 <-- this is a good default
|
# font_size = 16 <-- this is a good default
|
||||||
# TODO: need to synchronize it better with svg
|
# TODO: need to synchronize it better with svg
|
||||||
font_size_px = int(0.004118616 * mm_to_px) * font_size_mm / 2.5
|
|
||||||
|
magic_font_scale = bpy.context.scene.DocProperties.magic_font_scale
|
||||||
|
font_size_px = int(magic_font_scale * mm_to_px) * font_size_mm / 2.5
|
||||||
pos = pos - line_no * font_size_px * rotation_matrix[1]
|
pos = pos - line_no * font_size_px * rotation_matrix[1]
|
||||||
|
|
||||||
blf.size(font_id, font_size_px)
|
blf.size(font_id, font_size_px)
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ class DocProperties(PropertyGroup):
|
|||||||
)
|
)
|
||||||
shadingstyle_default: StringProperty(default="Blender Default", name="Default Shading Style")
|
shadingstyle_default: StringProperty(default="Blender Default", name="Default Shading Style")
|
||||||
drawing_font: StringProperty(default="OpenGost Type B TT.ttf", name="Drawing Font")
|
drawing_font: StringProperty(default="OpenGost Type B TT.ttf", name="Drawing Font")
|
||||||
|
magic_font_scale: bpy.props.FloatProperty(default=0.004118616, name="Font Scale Factor")
|
||||||
|
|
||||||
|
|
||||||
class BIMCameraProperties(PropertyGroup):
|
class BIMCameraProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -341,6 +341,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
row.prop(context.scene.DocProperties, "shadingstyle_default")
|
row.prop(context.scene.DocProperties, "shadingstyle_default")
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(context.scene.DocProperties, "drawing_font")
|
row.prop(context.scene.DocProperties, "drawing_font")
|
||||||
|
row = self.layout.row()
|
||||||
|
row.prop(context.scene.DocProperties, "magic_font_scale")
|
||||||
|
|
||||||
|
|
||||||
# Scene panel groups
|
# Scene panel groups
|
||||||
|
|||||||
Reference in New Issue
Block a user