mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Better text-shadow parsing
This commit is contained in:
parent
79d4dd0410
commit
2173c277ae
15
src/Parse.js
15
src/Parse.js
@ -75,6 +75,8 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reuse the regex
|
||||||
|
var PARSE_TEXT_SHADOW = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;
|
||||||
function setTextVariables(ctx, el, text_decoration, color) {
|
function setTextVariables(ctx, el, text_decoration, color) {
|
||||||
var align = false,
|
var align = false,
|
||||||
bold = getCSS(el, "fontWeight"),
|
bold = getCSS(el, "fontWeight"),
|
||||||
@ -96,14 +98,11 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
ctx.setVariable("textAlign", (align) ? "right" : "left");
|
ctx.setVariable("textAlign", (align) ? "right" : "left");
|
||||||
|
|
||||||
if (shadow !== "none") {
|
if (shadow !== "none") {
|
||||||
|
var s = shadow.match(PARSE_TEXT_SHADOW),
|
||||||
// TODO: better text-shadow parsing
|
color = s[0],
|
||||||
var parseShadow = /(rgba\([^)]*\))\s([^\s]*)\s([^\s]*)\s([^\s]*)/;
|
sX = s[1] ? s[1].replace('px', '') : 0,
|
||||||
var bits = parseShadow.exec(shadow);
|
sY = s[2] ? s[2].replace('px', '') : 0,
|
||||||
var color = bits[1],
|
blur = s[3] ? s[3].replace('px', '') : 0;
|
||||||
sX = bits[2].replace('px', ''),
|
|
||||||
sY = bits[3].replace('px', ''),
|
|
||||||
blur = bits[4].replace('px', '');
|
|
||||||
|
|
||||||
// apply the text shadow
|
// apply the text shadow
|
||||||
ctx.setVariable("shadowColor", color);
|
ctx.setVariable("shadowColor", color);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user