Skip to content

Commit

Permalink
Add FontSize parameter to BOMContent object
Browse files Browse the repository at this point in the history
  • Loading branch information
SurajDadral committed May 10, 2020
1 parent 5c4dee5 commit feef08a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion BillOfMaterial/BillOfMaterialContent.py
Expand Up @@ -32,6 +32,18 @@ def setProperties(self, obj):
)
obj.Font = "DejaVu Sans"

if "FontSize" not in pl:
obj.addProperty(
"App::PropertyLength",
"FontSize",
"BOMContent",
QT_TRANSLATE_NOOP(
"App::Property",
"The font size of Bill of Material content.",
),
)
obj.FontSize = 3

def onDocumentRestored(self, obj):
"""Upgrade BOMContent object."""
self.setProperties(obj)
Expand All @@ -45,7 +57,16 @@ def execute(self, obj):
if obj.Font:
obj.Symbol = re.sub(
'font-family="([^"]+)"',
'font-family="{}"'.format(str(obj.Font)),
'font-family="{}"'.format(obj.Font),
obj.Symbol,
)
obj.ViewObject.update()

if hasattr(obj, "FontSize"):
if obj.FontSize:
obj.Symbol = re.sub(
'font-size="([^"]+)"',
'font-size="{}"'.format(obj.FontSize.Value),
obj.Symbol,
)
obj.ViewObject.update()
Expand Down
1 change: 1 addition & 0 deletions BillOfMaterial/BillOfMaterial_SVG.py
Expand Up @@ -931,6 +931,7 @@ def makeBillOfMaterialSVG(
bom_content_obj = bom_obj.Views[0]
bom_content_obj.Symbol = svg_output
bom_content_obj.Font = font_family
bom_content_obj.FontSize = font_size
bom_content_obj.X = bom_width * scaling_factor / 2 + bom_left_offset
bom_content_obj.Y = (
template_height - bom_height * scaling_factor / 2 - bom_top_offset
Expand Down

0 comments on commit feef08a

Please sign in to comment.