Update canvas2svg.js
Added Helper function.
This commit is contained in:
parent
1aa1d69842
commit
39e147def7
@ -58,6 +58,12 @@
|
|||||||
return lookup;
|
return lookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//helper function to map canvas-textAlign to svg-textAnchor
|
||||||
|
function getTextAnchor(textAlign) {
|
||||||
|
var mapping = {"left":"start", "right":"end", "center":"middle", "start":"start", "end":"end"};
|
||||||
|
return mapping[textAlign] || mapping.start;
|
||||||
|
}
|
||||||
|
|
||||||
// Unpack entities lookup where the numbers are in radix 32 to reduce the size
|
// Unpack entities lookup where the numbers are in radix 32 to reduce the size
|
||||||
// entity mapping courtesy of tinymce
|
// entity mapping courtesy of tinymce
|
||||||
namedEntities = createNamedToNumberedLookup(
|
namedEntities = createNamedToNumberedLookup(
|
||||||
@ -747,7 +753,7 @@
|
|||||||
"text-decoration" : font.decoration,
|
"text-decoration" : font.decoration,
|
||||||
"x" : x,
|
"x" : x,
|
||||||
"y" : y,
|
"y" : y,
|
||||||
"text-anchor": this.textAlign.replace("left", "start").replace("right", "end").replace("center", "middle")
|
"text-anchor": getTextAnchor(this.textAlign)
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
textElement.appendChild(document.createTextNode(text));
|
textElement.appendChild(document.createTextNode(text));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user