Skip to content

Commit

Permalink
Merge pull request #707 from fargyriou/702-font-parsing
Browse files Browse the repository at this point in the history
Issue 702: Fixed font parsing when defined as "font" and not through …
  • Loading branch information
gabelerner committed May 8, 2019
2 parents cef40f0 + 55d67f0 commit fbebf8e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/canvg.js
Expand Up @@ -1096,17 +1096,21 @@ function build(opts) {

// font
if (typeof ctx.font != 'undefined') {
ctx.font = svg.Font.CreateFont(
this.style('font-style').value,
this.style('font-variant').value,
this.style('font-weight').value,
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
this.style('font-family').value).toString();

// update em size if needed
var currentFontSize = this.style('font-size', false, false);
if (currentFontSize.isPixels()) {
svg.emSize = currentFontSize.toPixels();
if (this.style('font').hasValue()) {
ctx.font = this.style('font').value;
} else {
ctx.font = svg.Font.CreateFont(
this.style('font-style').value,
this.style('font-variant').value,
this.style('font-weight').value,
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
this.style('font-family').value).toString();

// update em size if needed
var currentFontSize = this.style('font-size', false, false);
if (currentFontSize.isPixels()) {
svg.emSize = currentFontSize.toPixels();
}
}
}

Expand Down

0 comments on commit fbebf8e

Please sign in to comment.