mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
refactor scale_font_size as per developers feedback
This commit is contained in:
committed by
Bruno Perdigão
parent
dde6e2d62b
commit
ecaea5f776
@@ -29,7 +29,6 @@ import bpy
|
|||||||
import gpu
|
import gpu
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import mathutils
|
import mathutils
|
||||||
import sys
|
|
||||||
from bpy.types import SpaceView3D
|
from bpy.types import SpaceView3D
|
||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||||
@@ -467,14 +466,9 @@ class PolylineDecorator:
|
|||||||
|
|
||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
self.font_id = 0
|
self.font_id = 0
|
||||||
ui_style = context.preferences.ui_styles[0]
|
font_size = tool.Blender.scale_font_size(None)
|
||||||
widget_font_points = ui_style.widget.points
|
offset = tool.Blender.scale_font_size(None) * 1.5
|
||||||
ui_scale = context.preferences.view.ui_scale
|
line_height = tool.Blender.scale_font_size(None) * 1.25
|
||||||
platform_scale = 2 if sys.platform == "darwin" else 1
|
|
||||||
|
|
||||||
font_size = widget_font_points * ui_scale * platform_scale
|
|
||||||
offset = widget_font_points * ui_scale * (1.5 * platform_scale)
|
|
||||||
line_height = widget_font_points * ui_scale * (1.25 * platform_scale)
|
|
||||||
blf.size(self.font_id, font_size)
|
blf.size(self.font_id, font_size)
|
||||||
blf.enable(self.font_id, blf.SHADOW)
|
blf.enable(self.font_id, blf.SHADOW)
|
||||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||||
@@ -522,12 +516,7 @@ class PolylineDecorator:
|
|||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
self.font_id = 1
|
self.font_id = 1
|
||||||
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
||||||
ui_style = context.preferences.ui_styles[0]
|
font_size = tool.Blender.scale_font_size(None)
|
||||||
widget_font_points = ui_style.widget.points
|
|
||||||
ui_scale = context.preferences.view.ui_scale
|
|
||||||
platform_scale = 2 if sys.platform == "darwin" else 1
|
|
||||||
|
|
||||||
font_size = widget_font_points * ui_scale * platform_scale
|
|
||||||
blf.size(self.font_id, font_size)
|
blf.size(self.font_id, font_size)
|
||||||
blf.enable(self.font_id, blf.SHADOW)
|
blf.enable(self.font_id, blf.SHADOW)
|
||||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||||
@@ -1948,13 +1937,7 @@ class BoundingBoxDecorator:
|
|||||||
|
|
||||||
addon_prefs = tool.Blender.get_addon_preferences()
|
addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
font_id = 0
|
font_id = 0
|
||||||
# Get Blender's default UI widget font size from preferences
|
font_size = tool.Blender.scale_font_size(None)
|
||||||
ui_style = context.preferences.ui_styles[0]
|
|
||||||
widget_font_points = ui_style.widget.points
|
|
||||||
ui_scale = context.preferences.view.ui_scale
|
|
||||||
platform_scale = 2 if sys.platform == "darwin" else 1
|
|
||||||
|
|
||||||
font_size = widget_font_points * ui_scale * platform_scale
|
|
||||||
blf.size(font_id, font_size)
|
blf.size(font_id, font_size)
|
||||||
blf.enable(font_id, blf.SHADOW)
|
blf.enable(font_id, blf.SHADOW)
|
||||||
blf.shadow(font_id, 6, 0, 0, 0, 1)
|
blf.shadow(font_id, 6, 0, 0, 0, 1)
|
||||||
|
|||||||
@@ -1572,12 +1572,12 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def scale_font_size(cls, size):
|
def scale_font_size(cls, size):
|
||||||
default_dpi = 72
|
ui_style = bpy.context.preferences.ui_styles[0]
|
||||||
default_pixel_size = 1.0
|
base_size = ui_style.widget.points if size is None else size
|
||||||
default_scale = default_dpi * default_pixel_size
|
ui_scale = bpy.context.preferences.view.ui_scale
|
||||||
system = bpy.context.preferences.system
|
platform_scale = 2 if sys.platform == "darwin" else 1
|
||||||
system_scale = system.dpi * system.pixel_size
|
|
||||||
return (system_scale / default_scale) * size
|
return base_size * ui_scale * platform_scale
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_transform_as_local(cls, obj: bpy.types.Object) -> bool:
|
def apply_transform_as_local(cls, obj: bpy.types.Object) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user