Adding a 'magic_font_scale'

https://community.osarch.org/discussion/2202/blenderbim-edit-text-preview-size
This commit is contained in:
Ryan Schultz
2024-06-05 08:12:22 -05:00
parent b92e78b137
commit b57a1e5ea8
3 changed files with 7 additions and 2 deletions
@@ -415,12 +415,14 @@ class BaseDecorator:
factor = self.camera_zoom_to_factor(context.space_data.region_3d.view_camera_zoom)
camera_width_px = factor * context.region.width
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.
# It probably should be dynamically calculated using system.dpi or something.
# font_size = 16 <-- this is a good default
# 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]
blf.size(font_id, font_size_px)
@@ -370,6 +370,7 @@ class DocProperties(PropertyGroup):
)
shadingstyle_default: StringProperty(default="Blender Default", name="Default Shading Style")
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):
+2
View File
@@ -341,6 +341,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
row.prop(context.scene.DocProperties, "shadingstyle_default")
row = self.layout.row()
row.prop(context.scene.DocProperties, "drawing_font")
row = self.layout.row()
row.prop(context.scene.DocProperties, "magic_font_scale")
# Scene panel groups