From 214c278fc5125822e3d0e224b9f7913339333ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Thu, 5 Sep 2024 14:12:59 -0300 Subject: [PATCH] Added a function to scale the font size according to preferences. The scale will be calculated in relation to the system dpi and Blender's interface resolution scale. --- src/bonsai/bonsai/tool/blender.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bonsai/bonsai/tool/blender.py b/src/bonsai/bonsai/tool/blender.py index cbec92a46f..38dd6d7cf2 100644 --- a/src/bonsai/bonsai/tool/blender.py +++ b/src/bonsai/bonsai/tool/blender.py @@ -1155,3 +1155,12 @@ class Blender(bonsai.core.tool.Blender): pass return sun_position + + @classmethod + def scale_font_size(cls, size): + default_dpi = 72 + default_pixel_size = 1.0 + default_scale = (default_dpi * default_pixel_size) + system = bpy.context.preferences.system + system_scale = (system.dpi * system.pixel_size) + return (system_scale / default_scale) * size