Skip to content

Commit 682005a

Browse files
committed
Fix - correctly handle #font[id] in latex
While this means embedding of the font, style and weight must be enforced
1 parent e400c99 commit 682005a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

modules/base/FontHandler.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class FontHandler {
7070
this.painter = painter;
7171
}
7272

73+
/** @summary Force setting of style and weight, used in latex */
74+
setUseFullStyle(flag) {
75+
this.full_style = flag;
76+
}
77+
7378
/** @summary Assigns font-related attributes */
7479
addCustomFontToSvg(svg) {
7580
if (!this.base64 || !this.name)
@@ -96,8 +101,8 @@ class FontHandler {
96101
selection.attr('font-family', this.name)
97102
.attr('font-size', this.size)
98103
.attr('xml:space', 'preserve')
99-
.attr('font-weight', this.weight || null)
100-
.attr('font-style', this.style || null);
104+
.attr('font-weight', this.weight || (this.full_style ? 'normal' : null))
105+
.attr('font-style', this.style || (this.full_style ? 'normal' : null));
101106
}
102107

103108
/** @summary Set font size (optional) */

modules/base/latex.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ function parseLatex(node, arg, label, curr) {
903903
subpos.color = curr.painter.getColor(foundarg);
904904
else if (found.name === '#font[') {
905905
subpos.font = new FontHandler(foundarg);
906+
subpos.font.setUseFullStyle(true); // while embedding - need to enforce full style
906907
subpos.ufont = true; // mark that custom font is applied
907908
} else
908909
subpos.fsize *= foundarg;

0 commit comments

Comments
 (0)