Bonsai: add 1.3 mm and 1.5 mm annotation text sizes

Annotation text only offered 1.8/2.5/3.5/5.0/7.0 mm. Smaller sizes could be
added to a custom stylesheet, but the viewport still drew them at the regular
size because DecoratorData.get_text_data falls back to "regular" for any class
missing from FONT_SIZES.

Registers "mini" (1.3 mm) and "tiny" (1.5 mm) in FONT_SIZES, in the font_size
enum, and in the default stylesheet, so the sizes round-trip through
EPset_Annotation.Classes and render correctly both in the viewport and in SVG
output.

Builds on the work in PR #6437 by Jesse Roodhorst (@jes-r), whose class names,
mm values and CSS pixel values are kept as is. The unrelated whitespace changes
to operator.py from that PR are left out, and regression tests are added.

Fixes #6426

Generated with the assistance of an AI coding tool.
This commit is contained in:
Petru Conduraru
2026-07-20 10:20:25 +03:00
parent 55a2430d71
commit aa588cecd6
4 changed files with 25 additions and 0 deletions
@@ -79,6 +79,8 @@ text.header, tspan.header { /* 5mm */ font-size: 8.25px; }
text.large, tspan.large { /* 3.5mm */ font-size: 5.78px; }
text.regular, tspan.regular { /* 2.5mm */ font-size: 4.13px; }
text.small, tspan.small { /* 1.8mm */ font-size: 2.97px; }
text.tiny, tspan.tiny { /* 1.5mm */ font-size: 2.48px; }
text.mini, tspan.mini { /* 1.3mm */ font-size: 2.15px; }
text.GRID, tspan.GRID { /* 5mm */ font-size: 8.25px; }
.material-blank { fill: white; }
.material-diagonal1 { fill: url(#diagonal1); }
@@ -224,6 +224,8 @@ class DocumentsData:
FONT_SIZES = {
"mini": 1.3,
"tiny": 1.5,
"small": 1.8,
"regular": 2.5,
"large": 3.5,
@@ -917,6 +917,8 @@ class BIMTextProperties(PropertyGroup):
)
font_size: EnumProperty(
items=[
("1.3", "1.3 - Mini", ""),
("1.5", "1.5 - Tiny", ""),
("1.8", "1.8 - Small", ""),
("2.5", "2.5 - Regular", ""),
("3.5", "3.5 - Large", ""),
+19
View File
@@ -851,6 +851,25 @@ class TestEditText(NewFile):
assert "title" in annotation_classes
assert DecoratorData.get_text_data(obj)["FontSize"] == 7.0
@pytest.mark.parametrize("font_size, class_name", [("1.3", "mini"), ("1.5", "tiny")])
def test_change_text_font_size_to_small_sizes(self, font_size, class_name):
TestGetTextLiteral().test_run()
obj = bpy.data.objects["Object"]
with bpy.context.temp_override(active_object=obj):
bpy.ops.bim.enable_editing_text()
props = tool.Drawing.get_text_props(obj)
props.font_size = font_size
bpy.ops.bim.edit_text()
annotation_classes = ifcopenshell.util.element.get_pset(tool.Ifc.get_entity(obj), "EPset_Annotation", "Classes")
assert class_name in annotation_classes.split()
assert DecoratorData.get_text_data(obj)["FontSize"] == float(font_size)
# Font size round-trips back into the property.
subject.import_text_attributes(obj)
assert tool.Drawing.get_text_props(obj).font_size == font_size
def test_add_second_literal(self, setup=True):
if setup:
TestGetTextLiteral().test_run()