mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
IfcText - different text sizes in viewport
This commit is contained in:
@@ -182,3 +182,36 @@ class DecoratorData:
|
||||
|
||||
cls.data[obj.name] = display_data
|
||||
return display_data
|
||||
|
||||
@classmethod
|
||||
def get_ifc_text_font_size(cls, obj):
|
||||
"""returns font size in mm for current ifc text object"""
|
||||
result = cls.data.get(obj.name, None)
|
||||
if result is not None:
|
||||
return result
|
||||
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
return
|
||||
|
||||
classes = ifcopenshell.util.element.get_pset(element, "EPset_Annotation", "Classes")
|
||||
|
||||
font_sizes = {
|
||||
'small': 1.8,
|
||||
'regular': 2.5,
|
||||
'large': 3.5,
|
||||
'header': 5,
|
||||
'title': 7,
|
||||
}
|
||||
|
||||
# use `regular` as default
|
||||
if classes:
|
||||
tags = classes.split()
|
||||
# prioritize smaller font sizes just like in svg
|
||||
font_size_type = next((font_size_type for font_size_type in font_sizes if font_size_type in tags), 'regular')
|
||||
else:
|
||||
font_size_type = 'regular'
|
||||
|
||||
font_size = font_sizes[font_size_type]
|
||||
cls.data[obj.name] = font_size
|
||||
return font_size
|
||||
|
||||
@@ -2072,7 +2072,7 @@ class TextDecorator(BaseDecorator):
|
||||
# TODO: support text rotation
|
||||
dir = Vector((1, 0))
|
||||
pos = location_3d_to_region_2d(region, region3d, obj.matrix_world.translation)
|
||||
font_size = 2.5
|
||||
font_size = DecoratorData.get_ifc_text_font_size(obj)
|
||||
for line_i, line in enumerate(obj.BIMTextProperties.value.split("\\n")):
|
||||
self.draw_label(
|
||||
context, line, pos, dir, gap=0, center=False, vcenter=False, font_size=font_size, line_no=line_i
|
||||
|
||||
Reference in New Issue
Block a user