Skip to content

Commit

Permalink
Fix the bitmap image source check and text horizontal alignment (#8804)
Browse files Browse the repository at this point in the history
Fixes #7173
  • Loading branch information
adeas31 committed Apr 5, 2022
1 parent f6a81b2 commit 06a87ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 3 additions & 11 deletions OMCompiler/Examples/generate_icons.py
Expand Up @@ -457,15 +457,16 @@ def getGraphicsForClass(modelicaClass):
graphicsObj['origin'] = [float(g[1]), float(g[2])]
graphicsObj['rotation'] = float(g[3])
graphicsObj['extent'] = [[float(g[4]), float(g[5])], [float(g[6]), float(g[7])]]
if g[9] is not None:

if not g[9]:
graphicsObj['href'] = "data:image;base64,"+g[9].strip('"')
else:
fname = ask_omc('uriToFilename', g[8], parsed=False).strip().strip('"')
if not os.path.exists(fname):
fname = os.path.join(baseDir, g[8].strip('"'))
if os.path.exists(fname):
with open(fname, "rb") as f_p:
graphicsObj['href'] = "data:image;base64,"+str(base64.b64encode(f_p.read()))
graphicsObj['href'] = "data:image;base64,"+base64.b64encode(f_p.read()).decode()
else:
logger.error("Could not find bitmap file {0}".format(g[8]))
graphicsObj['href'] = g[8].strip('"')
Expand Down Expand Up @@ -809,10 +810,6 @@ def getSvgFromGraphics(dwg, graphics, minX, maxY, includeInvisibleText, transfor
x = x0
else:
x = x1
if y0 < y1:
y = y0
else:
y = y1
elif graphics['horizontalAlignment'] == "TextAlignment.Center":
extra['text_anchor'] = "middle"
elif graphics['horizontalAlignment'] == "TextAlignment.Right":
Expand All @@ -821,11 +818,6 @@ def getSvgFromGraphics(dwg, graphics, minX, maxY, includeInvisibleText, transfor
x = x1
else:
x = x0
if y0 < y1:
y = y1
else:
y = y0


shape = dwg.text(graphics['textString'].replace('%', ''), None, [x], [y], **extra)

Expand Down

0 comments on commit 06a87ab

Please sign in to comment.