Skip to content

Commit 55d67f0

Browse files
committed
Issue 702: Fixed font parsing when defined as "font" and not through font properties
1 parent cef40f0 commit 55d67f0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/canvg.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,17 +1096,21 @@ function build(opts) {
10961096

10971097
// font
10981098
if (typeof ctx.font != 'undefined') {
1099-
ctx.font = svg.Font.CreateFont(
1100-
this.style('font-style').value,
1101-
this.style('font-variant').value,
1102-
this.style('font-weight').value,
1103-
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1104-
this.style('font-family').value).toString();
1105-
1106-
// update em size if needed
1107-
var currentFontSize = this.style('font-size', false, false);
1108-
if (currentFontSize.isPixels()) {
1109-
svg.emSize = currentFontSize.toPixels();
1099+
if (this.style('font').hasValue()) {
1100+
ctx.font = this.style('font').value;
1101+
} else {
1102+
ctx.font = svg.Font.CreateFont(
1103+
this.style('font-style').value,
1104+
this.style('font-variant').value,
1105+
this.style('font-weight').value,
1106+
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1107+
this.style('font-family').value).toString();
1108+
1109+
// update em size if needed
1110+
var currentFontSize = this.style('font-size', false, false);
1111+
if (currentFontSize.isPixels()) {
1112+
svg.emSize = currentFontSize.toPixels();
1113+
}
11101114
}
11111115
}
11121116

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy