Skip to content

Commit

Permalink
fix font mangling (#18)
Browse files Browse the repository at this point in the history
fix font mangling
  • Loading branch information
IDisposable committed Oct 16, 2019
2 parents 54e93c6 + 2a000af commit d3ee842
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/dom-to-image-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,27 @@
function cloneStyle() {
copyStyle(window.getComputedStyle(original), clone.style);

function copyFont(source, target) {
target.font = source.font;
target.fontFamily = source.fontFamily;
target.fontFeatureSettings = source.fontFeatureSettings;
target.fontKerning = source.fontKerning;
target.fontSize = source.fontSize;
target.fontStretch = source.fontStretch;
target.fontStyle = source.fontStyle;
target.fontVariant = source.fontVariant;
target.fontVariantCaps = source.fontVariantCaps;
target.fontVariantEastAsian = source.fontVariantEastAsian;
target.fontVariantLigatures = source.fontVariantLigatures;
target.fontVariantNumeric = source.fontVariantNumeric;
target.fontVariationSettings = source.fontVariationSettings;
target.fontWeight = source.fontWeight;
}

function copyStyle(source, target) {
if (source.cssText) {
target.cssText = source.cssText;
target.font = source.font; // here, we re-assign the font prop.
copyFont(source, target); // here we re-assign the font props.
} else copyProperties(source, target);

function copyProperties(source, target) {
Expand Down

0 comments on commit d3ee842

Please sign in to comment.