mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Basic implementation of text-shadow
This commit is contained in:
parent
62d27c20c3
commit
1a30167f6a
20
src/Parse.js
20
src/Parse.js
@ -79,7 +79,8 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
var align = false,
|
var align = false,
|
||||||
bold = getCSS(el, "fontWeight"),
|
bold = getCSS(el, "fontWeight"),
|
||||||
family = getCSS(el, "fontFamily"),
|
family = getCSS(el, "fontFamily"),
|
||||||
size = getCSS(el, "fontSize");
|
size = getCSS(el, "fontSize"),
|
||||||
|
shadow = getCSS(el, "textShadow");
|
||||||
|
|
||||||
switch(parseInt(bold, 10)){
|
switch(parseInt(bold, 10)){
|
||||||
case 401:
|
case 401:
|
||||||
@ -94,6 +95,23 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
ctx.setVariable("font", [getCSS(el, "fontStyle"), getCSS(el, "fontVariant"), bold, size, family].join(" "));
|
ctx.setVariable("font", [getCSS(el, "fontStyle"), getCSS(el, "fontVariant"), bold, size, family].join(" "));
|
||||||
ctx.setVariable("textAlign", (align) ? "right" : "left");
|
ctx.setVariable("textAlign", (align) ? "right" : "left");
|
||||||
|
|
||||||
|
if (shadow !== "none") {
|
||||||
|
|
||||||
|
// TODO: better text-shadow parsing
|
||||||
|
var parseShadow = /(rgba\([^)]*\))\s([^\s]*)\s([^\s]*)\s([^\s]*)/;
|
||||||
|
var bits = parseShadow.exec(shadow);
|
||||||
|
var color = bits[1],
|
||||||
|
sX = bits[2].replace('px', ''),
|
||||||
|
sY = bits[3].replace('px', ''),
|
||||||
|
blur = bits[4].replace('px', '');
|
||||||
|
|
||||||
|
// apply the text shadow
|
||||||
|
ctx.setVariable("shadowColor", color);
|
||||||
|
ctx.setVariable("shadowOffsetX", sX);
|
||||||
|
ctx.setVariable("shadowOffsetY", sY);
|
||||||
|
ctx.setVariable("shadowBlur", blur);
|
||||||
|
}
|
||||||
|
|
||||||
if (text_decoration !== "none"){
|
if (text_decoration !== "none"){
|
||||||
return _html2canvas.Util.Font(family, size, doc);
|
return _html2canvas.Util.Font(family, size, doc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user