Skip to content

Commit 4b9dee3

Browse files
Gabe LernerGabe Lerner
authored andcommitted
build
1 parent 088abbe commit 4b9dee3

File tree

4 files changed

+66
-39
lines changed

4 files changed

+66
-39
lines changed

dist/browser/canvg.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/*
33
* canvg.js - Javascript SVG parser and renderer on Canvas
4-
* version 2.0.0-beta.1
4+
* version 2.0.0
55
* MIT Licensed
66
* Gabe Lerner (gabelerner@gmail.com)
77
* https://github.com/canvg/canvg
@@ -498,7 +498,7 @@
498498

499499
// points and paths
500500
svg.ToNumberArray = function (s) {
501-
var a = (s || '').match(/-?(\d+(\.\d+)?|\.\d+)(?=\D|$)/gm) || [];
501+
var a = (s || '').match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm) || [];
502502
for (var i = 0; i < a.length; i++) {
503503
a[i] = parseFloat(a[i]);
504504
}
@@ -1072,17 +1072,21 @@
10721072

10731073
// font
10741074
if (typeof ctx.font != 'undefined') {
1075-
ctx.font = svg.Font.CreateFont(
1076-
this.style('font-style').value,
1077-
this.style('font-variant').value,
1078-
this.style('font-weight').value,
1079-
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1080-
this.style('font-family').value).toString();
1081-
1082-
// update em size if needed
1083-
var currentFontSize = this.style('font-size', false, false);
1084-
if (currentFontSize.isPixels()) {
1085-
svg.emSize = currentFontSize.toPixels();
1075+
if (this.style('font').hasValue()) {
1076+
ctx.font = this.style('font').value;
1077+
} else {
1078+
ctx.font = svg.Font.CreateFont(
1079+
this.style('font-style').value,
1080+
this.style('font-variant').value,
1081+
this.style('font-weight').value,
1082+
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1083+
this.style('font-family').value).toString();
1084+
1085+
// update em size if needed
1086+
var currentFontSize = this.style('font-size', false, false);
1087+
if (currentFontSize.isPixels()) {
1088+
svg.emSize = currentFontSize.toPixels();
1089+
}
10861090
}
10871091
}
10881092

dist/browser/canvg.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node/canvg.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/*
33
* canvg.js - Javascript SVG parser and renderer on Canvas
4-
* version 2.0.0-beta.1
4+
* version 2.0.0
55
* MIT Licensed
66
* Gabe Lerner (gabelerner@gmail.com)
77
* https://github.com/canvg/canvg
@@ -497,7 +497,7 @@
497497

498498
// points and paths
499499
svg.ToNumberArray = function (s) {
500-
var a = (s || '').match(/-?(\d+(\.\d+)?|\.\d+)(?=\D|$)/gm) || [];
500+
var a = (s || '').match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm) || [];
501501
for (var i = 0; i < a.length; i++) {
502502
a[i] = parseFloat(a[i]);
503503
}
@@ -1071,17 +1071,21 @@
10711071

10721072
// font
10731073
if (typeof ctx.font != 'undefined') {
1074-
ctx.font = svg.Font.CreateFont(
1075-
this.style('font-style').value,
1076-
this.style('font-variant').value,
1077-
this.style('font-weight').value,
1078-
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1079-
this.style('font-family').value).toString();
1080-
1081-
// update em size if needed
1082-
var currentFontSize = this.style('font-size', false, false);
1083-
if (currentFontSize.isPixels()) {
1084-
svg.emSize = currentFontSize.toPixels();
1074+
if (this.style('font').hasValue()) {
1075+
ctx.font = this.style('font').value;
1076+
} else {
1077+
ctx.font = svg.Font.CreateFont(
1078+
this.style('font-style').value,
1079+
this.style('font-variant').value,
1080+
this.style('font-weight').value,
1081+
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
1082+
this.style('font-family').value).toString();
1083+
1084+
// update em size if needed
1085+
var currentFontSize = this.style('font-size', false, false);
1086+
if (currentFontSize.isPixels()) {
1087+
svg.emSize = currentFontSize.toPixels();
1088+
}
10851089
}
10861090
}
10871091

package-lock.json

Lines changed: 31 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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