fabric 6.6.7 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +99 -79
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.min.mjs +1 -1
  7. package/dist/index.min.mjs.map +1 -1
  8. package/dist/index.mjs +99 -79
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +99 -79
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +99 -79
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/parser/constants.d.ts +1 -0
  17. package/dist/src/parser/constants.d.ts.map +1 -1
  18. package/dist/src/parser/constants.min.mjs +1 -1
  19. package/dist/src/parser/constants.min.mjs.map +1 -1
  20. package/dist/src/parser/constants.mjs +3 -1
  21. package/dist/src/parser/constants.mjs.map +1 -1
  22. package/dist/src/parser/getCSSRules.d.ts.map +1 -1
  23. package/dist/src/parser/getCSSRules.min.mjs +1 -1
  24. package/dist/src/parser/getCSSRules.min.mjs.map +1 -1
  25. package/dist/src/parser/getCSSRules.mjs +3 -5
  26. package/dist/src/parser/getCSSRules.mjs.map +1 -1
  27. package/dist/src/parser/normalizeValue.d.ts.map +1 -1
  28. package/dist/src/parser/normalizeValue.min.mjs +1 -1
  29. package/dist/src/parser/normalizeValue.min.mjs.map +1 -1
  30. package/dist/src/parser/normalizeValue.mjs +2 -1
  31. package/dist/src/parser/normalizeValue.mjs.map +1 -1
  32. package/dist/src/shapes/Text/Text.d.ts +14 -1
  33. package/dist/src/shapes/Text/Text.d.ts.map +1 -1
  34. package/dist/src/shapes/Text/Text.min.mjs +1 -1
  35. package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
  36. package/dist/src/shapes/Text/Text.mjs +16 -8
  37. package/dist/src/shapes/Text/Text.mjs.map +1 -1
  38. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
  39. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs +1 -1
  40. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
  41. package/dist/src/shapes/Text/TextSVGExportMixin.mjs +14 -5
  42. package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
  43. package/dist/src/shapes/Text/constants.d.ts +3 -2
  44. package/dist/src/shapes/Text/constants.d.ts.map +1 -1
  45. package/dist/src/shapes/Text/constants.min.mjs +1 -1
  46. package/dist/src/shapes/Text/constants.min.mjs.map +1 -1
  47. package/dist/src/shapes/Text/constants.mjs +21 -17
  48. package/dist/src/shapes/Text/constants.mjs.map +1 -1
  49. package/dist/src/util/misc/objectEnlive.d.ts +1 -1
  50. package/dist/src/util/misc/textStyles.d.ts.map +1 -1
  51. package/dist/src/util/misc/textStyles.min.mjs +1 -1
  52. package/dist/src/util/misc/textStyles.min.mjs.map +1 -1
  53. package/dist/src/util/misc/textStyles.mjs +1 -1
  54. package/dist/src/util/misc/textStyles.mjs.map +1 -1
  55. package/dist-extensions/src/parser/constants.d.ts +1 -0
  56. package/dist-extensions/src/parser/constants.d.ts.map +1 -1
  57. package/dist-extensions/src/parser/getCSSRules.d.ts.map +1 -1
  58. package/dist-extensions/src/parser/normalizeValue.d.ts.map +1 -1
  59. package/dist-extensions/src/shapes/Text/Text.d.ts +14 -1
  60. package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -1
  61. package/dist-extensions/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
  62. package/dist-extensions/src/shapes/Text/constants.d.ts +3 -2
  63. package/dist-extensions/src/shapes/Text/constants.d.ts.map +1 -1
  64. package/dist-extensions/src/util/misc/textStyles.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/src/parser/constants.ts +2 -0
  67. package/src/parser/getCSSRules.spec.ts +19 -0
  68. package/src/parser/getCSSRules.ts +3 -5
  69. package/src/parser/normalizeValue.ts +2 -1
  70. package/src/shapes/Text/Text.ts +44 -11
  71. package/src/shapes/Text/TextSVGExportMixin.ts +16 -8
  72. package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +4 -3
  73. package/src/shapes/Text/constants.ts +22 -15
  74. package/src/shapes/__snapshots__/Textbox.spec.ts.snap +2 -0
  75. package/src/util/misc/textStyles.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [6.7.1]
4
+
5
+ - fix(SVGParser): Corrected CSS rule parsing for multiple style tags. [#10688](https://github.com/fabricjs/fabric.js/issues/10683)
6
+
7
+ ## [6.7.0]
8
+
9
+ - feat(Text): Add support for text decoration tickness [#10643](https://github.com/fabricjs/fabric.js/pull/10643)
10
+
3
11
  ## [6.6.7]
4
12
 
5
13
  - fix(): Fix regex to parse the viewbox attribute to be more strict [#10636](https://github.com/fabricjs/fabric.js/pull/10636)
package/dist/index.js CHANGED
@@ -411,7 +411,7 @@
411
411
  }
412
412
  const cache = new Cache();
413
413
 
414
- var version = "6.6.7";
414
+ var version = "6.7.1";
415
415
 
416
416
  // use this syntax so babel plugin see this import here
417
417
  const VERSION = version;
@@ -4837,6 +4837,68 @@
4837
4837
  return new RegExp('^(' + arr.join('|') + ')\\b', 'i');
4838
4838
  }
4839
4839
 
4840
+ const TEXT_DECORATION_THICKNESS = 'textDecorationThickness';
4841
+ const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
4842
+ const textDecorationProperties = ['underline', 'overline', 'linethrough'];
4843
+ const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
4844
+ const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction', TEXT_DECORATION_THICKNESS];
4845
+ const styleProperties = [...fontProperties, ...textDecorationProperties, STROKE, 'strokeWidth', FILL, 'deltaY', 'textBackgroundColor', TEXT_DECORATION_THICKNESS];
4846
+
4847
+ // @TODO: Many things here are configuration related and shouldn't be on the class nor prototype
4848
+ // regexes, list of properties that are not suppose to change by instances, magic consts.
4849
+ // this will be a separated effort
4850
+ const textDefaultValues = {
4851
+ _reNewline: reNewline,
4852
+ _reSpacesAndTabs: /[ \t\r]/g,
4853
+ _reSpaceAndTab: /[ \t\r]/,
4854
+ _reWords: /\S+/g,
4855
+ fontSize: 40,
4856
+ fontWeight: 'normal',
4857
+ fontFamily: 'Times New Roman',
4858
+ underline: false,
4859
+ overline: false,
4860
+ linethrough: false,
4861
+ textAlign: LEFT,
4862
+ fontStyle: 'normal',
4863
+ lineHeight: 1.16,
4864
+ textBackgroundColor: '',
4865
+ stroke: null,
4866
+ shadow: null,
4867
+ path: undefined,
4868
+ pathStartOffset: 0,
4869
+ pathSide: LEFT,
4870
+ pathAlign: 'baseline',
4871
+ charSpacing: 0,
4872
+ deltaY: 0,
4873
+ direction: 'ltr',
4874
+ CACHE_FONT_SIZE: 400,
4875
+ MIN_TEXT_WIDTH: 2,
4876
+ // Text magic numbers
4877
+ superscript: {
4878
+ size: 0.6,
4879
+ // fontSize factor
4880
+ baseline: -0.35 // baseline-shift factor (upwards)
4881
+ },
4882
+ subscript: {
4883
+ size: 0.6,
4884
+ // fontSize factor
4885
+ baseline: 0.11 // baseline-shift factor (downwards)
4886
+ },
4887
+ _fontSizeFraction: 0.222,
4888
+ offsets: {
4889
+ underline: 0.1,
4890
+ linethrough: -0.28167,
4891
+ // added 1/30 to original number
4892
+ overline: -0.81333 // added 1/15 to original number
4893
+ },
4894
+ _fontSizeMult: 1.13,
4895
+ [TEXT_DECORATION_THICKNESS]: 66.667 // before implementation was 1/15
4896
+ };
4897
+ const JUSTIFY = 'justify';
4898
+ const JUSTIFY_LEFT = 'justify-left';
4899
+ const JUSTIFY_RIGHT = 'justify-right';
4900
+ const JUSTIFY_CENTER = 'justify-center';
4901
+
4840
4902
  var _templateObject$1, _templateObject2$1, _templateObject3$1;
4841
4903
 
4842
4904
  // matches, e.g.: +14.56e-12, etc.
@@ -4878,7 +4940,8 @@
4878
4940
  'clip-path': 'clipPath',
4879
4941
  'clip-rule': 'clipRule',
4880
4942
  'vector-effect': 'strokeUniform',
4881
- 'image-rendering': 'imageSmoothing'
4943
+ 'image-rendering': 'imageSmoothing',
4944
+ 'text-decoration-thickness': TEXT_DECORATION_THICKNESS
4882
4945
  },
4883
4946
  fSize = 'font-size',
4884
4947
  cPath = 'clip-path';
@@ -10368,7 +10431,7 @@
10368
10431
  */
10369
10432
  const hasStyleChanged = function (prevStyle, thisStyle) {
10370
10433
  let forTextSpans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
10371
- return prevStyle.fill !== thisStyle.fill || prevStyle.stroke !== thisStyle.stroke || prevStyle.strokeWidth !== thisStyle.strokeWidth || prevStyle.fontSize !== thisStyle.fontSize || prevStyle.fontFamily !== thisStyle.fontFamily || prevStyle.fontWeight !== thisStyle.fontWeight || prevStyle.fontStyle !== thisStyle.fontStyle || prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor || prevStyle.deltaY !== thisStyle.deltaY || forTextSpans && (prevStyle.overline !== thisStyle.overline || prevStyle.underline !== thisStyle.underline || prevStyle.linethrough !== thisStyle.linethrough);
10434
+ return prevStyle.fill !== thisStyle.fill || prevStyle.stroke !== thisStyle.stroke || prevStyle.strokeWidth !== thisStyle.strokeWidth || prevStyle.fontSize !== thisStyle.fontSize || prevStyle.fontFamily !== thisStyle.fontFamily || prevStyle.fontWeight !== thisStyle.fontWeight || prevStyle.fontStyle !== thisStyle.fontStyle || prevStyle.textDecorationThickness !== thisStyle.textDecorationThickness || prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor || prevStyle.deltaY !== thisStyle.deltaY || forTextSpans && (prevStyle.overline !== thisStyle.overline || prevStyle.underline !== thisStyle.underline || prevStyle.linethrough !== thisStyle.linethrough);
10372
10435
  };
10373
10436
 
10374
10437
  /**
@@ -10656,7 +10719,7 @@
10656
10719
  }
10657
10720
  } else if (attr === 'textAnchor' /* text-anchor */) {
10658
10721
  ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;
10659
- } else if (attr === 'charSpacing') {
10722
+ } else if (attr === 'charSpacing' || attr === TEXT_DECORATION_THICKNESS) {
10660
10723
  // parseUnit returns px and we convert it to em
10661
10724
  parsed = parseUnit(value, fontSize) / fontSize * 1000;
10662
10725
  } else if (attr === 'paintFirst') {
@@ -18410,64 +18473,6 @@
18410
18473
  classRegistry.setClass(Polygon);
18411
18474
  classRegistry.setSVGClass(Polygon);
18412
18475
 
18413
- const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
18414
- const textDecorationProperties = ['underline', 'overline', 'linethrough'];
18415
- const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
18416
- const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction'];
18417
- const styleProperties = [...fontProperties, ...textDecorationProperties, STROKE, 'strokeWidth', FILL, 'deltaY', 'textBackgroundColor'];
18418
-
18419
- // @TODO: Many things here are configuration related and shouldn't be on the class nor prototype
18420
- // regexes, list of properties that are not suppose to change by instances, magic consts.
18421
- // this will be a separated effort
18422
- const textDefaultValues = {
18423
- _reNewline: reNewline,
18424
- _reSpacesAndTabs: /[ \t\r]/g,
18425
- _reSpaceAndTab: /[ \t\r]/,
18426
- _reWords: /\S+/g,
18427
- fontSize: 40,
18428
- fontWeight: 'normal',
18429
- fontFamily: 'Times New Roman',
18430
- underline: false,
18431
- overline: false,
18432
- linethrough: false,
18433
- textAlign: LEFT,
18434
- fontStyle: 'normal',
18435
- lineHeight: 1.16,
18436
- superscript: {
18437
- size: 0.6,
18438
- // fontSize factor
18439
- baseline: -0.35 // baseline-shift factor (upwards)
18440
- },
18441
- subscript: {
18442
- size: 0.6,
18443
- // fontSize factor
18444
- baseline: 0.11 // baseline-shift factor (downwards)
18445
- },
18446
- textBackgroundColor: '',
18447
- stroke: null,
18448
- shadow: null,
18449
- path: undefined,
18450
- pathStartOffset: 0,
18451
- pathSide: LEFT,
18452
- pathAlign: 'baseline',
18453
- _fontSizeFraction: 0.222,
18454
- offsets: {
18455
- underline: 0.1,
18456
- linethrough: -0.315,
18457
- overline: -0.88
18458
- },
18459
- _fontSizeMult: 1.13,
18460
- charSpacing: 0,
18461
- deltaY: 0,
18462
- direction: 'ltr',
18463
- CACHE_FONT_SIZE: 400,
18464
- MIN_TEXT_WIDTH: 2
18465
- };
18466
- const JUSTIFY = 'justify';
18467
- const JUSTIFY_LEFT = 'justify-left';
18468
- const JUSTIFY_RIGHT = 'justify-right';
18469
- const JUSTIFY_CENTER = 'justify-center';
18470
-
18471
18476
  class StyledText extends FabricObject {
18472
18477
  /**
18473
18478
  * Returns true if object has no styling or no styling in a line
@@ -18782,7 +18787,7 @@
18782
18787
  } = _ref;
18783
18788
  const noShadow = true,
18784
18789
  textDecoration = this.getSvgTextDecoration(this);
18785
- return [textBgRects.join(''), '\t\t<text xml:space="preserve" ', this.fontFamily ? "font-family=\"".concat(this.fontFamily.replace(dblQuoteRegex, "'"), "\" ") : '', this.fontSize ? "font-size=\"".concat(this.fontSize, "\" ") : '', this.fontStyle ? "font-style=\"".concat(this.fontStyle, "\" ") : '', this.fontWeight ? "font-weight=\"".concat(this.fontWeight, "\" ") : '', textDecoration ? "text-decoration=\"".concat(textDecoration, "\" ") : '', this.direction === 'rtl' ? "direction=\"".concat(this.direction, "\" ") : '', 'style="', this.getSvgStyles(noShadow), '"', this.addPaintOrder(), ' >', textSpans.join(''), '</text>\n'];
18790
+ return [textBgRects.join(''), '\t\t<text xml:space="preserve" ', "font-family=\"".concat(this.fontFamily.replace(dblQuoteRegex, "'"), "\" "), "font-size=\"".concat(this.fontSize, "\" "), this.fontStyle ? "font-style=\"".concat(this.fontStyle, "\" ") : '', this.fontWeight ? "font-weight=\"".concat(this.fontWeight, "\" ") : '', textDecoration ? "text-decoration=\"".concat(textDecoration, "\" ") : '', this.direction === 'rtl' ? "direction=\"".concat(this.direction, "\" ") : '', 'style="', this.getSvgStyles(noShadow), '"', this.addPaintOrder(), ' >', textSpans.join(''), '</text>\n'];
18786
18791
  }
18787
18792
 
18788
18793
  /**
@@ -18939,7 +18944,7 @@
18939
18944
  * @return {String}
18940
18945
  */
18941
18946
  getSvgStyles(skipShadow) {
18942
- return "".concat(super.getSvgStyles(skipShadow), " white-space: pre;");
18947
+ return "".concat(super.getSvgStyles(skipShadow), " text-decoration-thickness: ").concat(toFixed(this.textDecorationThickness * this.getObjectScaling().y / 10, config.NUM_FRACTION_DIGITS), "%; white-space: pre;");
18943
18948
  }
18944
18949
 
18945
18950
  /**
@@ -18957,10 +18962,19 @@
18957
18962
  fontSize,
18958
18963
  fontStyle,
18959
18964
  fontWeight,
18960
- deltaY
18965
+ deltaY,
18966
+ textDecorationThickness,
18967
+ linethrough,
18968
+ overline,
18969
+ underline
18961
18970
  } = style;
18962
- const textDecoration = this.getSvgTextDecoration(style);
18963
- return [stroke ? colorPropToSVG(STROKE, stroke) : '', strokeWidth ? "stroke-width: ".concat(strokeWidth, "; ") : '', fontFamily ? "font-family: ".concat(!fontFamily.includes("'") && !fontFamily.includes('"') ? "'".concat(fontFamily, "'") : fontFamily, "; ") : '', fontSize ? "font-size: ".concat(fontSize, "px; ") : '', fontStyle ? "font-style: ".concat(fontStyle, "; ") : '', fontWeight ? "font-weight: ".concat(fontWeight, "; ") : '', textDecoration ? "text-decoration: ".concat(textDecoration, "; ") : textDecoration, fill ? colorPropToSVG(FILL, fill) : '', deltaY ? "baseline-shift: ".concat(-deltaY, "; ") : '', useWhiteSpace ? 'white-space: pre; ' : ''].join('');
18971
+ const textDecoration = this.getSvgTextDecoration({
18972
+ underline: underline !== null && underline !== void 0 ? underline : this.underline,
18973
+ overline: overline !== null && overline !== void 0 ? overline : this.overline,
18974
+ linethrough: linethrough !== null && linethrough !== void 0 ? linethrough : this.linethrough
18975
+ });
18976
+ const thickness = textDecorationThickness || this.textDecorationThickness;
18977
+ return [stroke ? colorPropToSVG(STROKE, stroke) : '', strokeWidth ? "stroke-width: ".concat(strokeWidth, "; ") : '', fontFamily ? "font-family: ".concat(!fontFamily.includes("'") && !fontFamily.includes('"') ? "'".concat(fontFamily, "'") : fontFamily, "; ") : '', fontSize ? "font-size: ".concat(fontSize, "px; ") : '', fontStyle ? "font-style: ".concat(fontStyle, "; ") : '', fontWeight ? "font-weight: ".concat(fontWeight, "; ") : '', textDecoration ? "text-decoration: ".concat(textDecoration, "; text-decoration-thickness: ").concat(toFixed(thickness * this.getObjectScaling().y / 10, config.NUM_FRACTION_DIGITS), "%; ") : '', fill ? colorPropToSVG(FILL, fill) : '', deltaY ? "baseline-shift: ".concat(-deltaY, "; ") : '', useWhiteSpace ? 'white-space: pre; ' : ''].join('');
18964
18978
  }
18965
18979
 
18966
18980
  /**
@@ -19977,6 +19991,7 @@
19977
19991
  const leftOffset = this._getLeftOffset(),
19978
19992
  path = this.path,
19979
19993
  charSpacing = this._getWidthOfCharSpacing(),
19994
+ offsetAligner = type === 'linethrough' ? 0.5 : type === 'overline' ? 1 : 0,
19980
19995
  offsetY = this.offsets[type];
19981
19996
  for (let i = 0, len = this._textLines.length; i < len; i++) {
19982
19997
  const heightOfLine = this.getHeightOfLine(i);
@@ -19991,8 +20006,10 @@
19991
20006
  let boxWidth = 0;
19992
20007
  let lastDecoration = this.getValueOfPropertyAt(i, 0, type);
19993
20008
  let lastFill = this.getValueOfPropertyAt(i, 0, FILL);
19994
- let currentDecoration;
19995
- let currentFill;
20009
+ let lastTickness = this.getValueOfPropertyAt(i, 0, TEXT_DECORATION_THICKNESS);
20010
+ let currentDecoration = lastDecoration;
20011
+ let currentFill = lastFill;
20012
+ let currentTickness = lastTickness;
19996
20013
  const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
19997
20014
  let size = this.getHeightOfChar(i, 0);
19998
20015
  let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');
@@ -20000,29 +20017,33 @@
20000
20017
  const charBox = this.__charBounds[i][j];
20001
20018
  currentDecoration = this.getValueOfPropertyAt(i, j, type);
20002
20019
  currentFill = this.getValueOfPropertyAt(i, j, FILL);
20020
+ currentTickness = this.getValueOfPropertyAt(i, j, TEXT_DECORATION_THICKNESS);
20003
20021
  const currentSize = this.getHeightOfChar(i, j);
20004
20022
  const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');
20005
20023
  if (path && currentDecoration && currentFill) {
20024
+ const finalTickness = this.fontSize * currentTickness / 1000;
20006
20025
  ctx.save();
20007
20026
  // bug? verify lastFill is a valid fill here.
20008
20027
  ctx.fillStyle = lastFill;
20009
20028
  ctx.translate(charBox.renderLeft, charBox.renderTop);
20010
20029
  ctx.rotate(charBox.angle);
20011
- ctx.fillRect(-charBox.kernedWidth / 2, offsetY * currentSize + currentDy, charBox.kernedWidth, this.fontSize / 15);
20030
+ ctx.fillRect(-charBox.kernedWidth / 2, offsetY * currentSize + currentDy - offsetAligner * finalTickness, charBox.kernedWidth, finalTickness);
20012
20031
  ctx.restore();
20013
- } else if ((currentDecoration !== lastDecoration || currentFill !== lastFill || currentSize !== size || currentDy !== dy) && boxWidth > 0) {
20032
+ } else if ((currentDecoration !== lastDecoration || currentFill !== lastFill || currentSize !== size || currentTickness !== lastTickness || currentDy !== dy) && boxWidth > 0) {
20033
+ const finalTickness = this.fontSize * lastTickness / 1000;
20014
20034
  let drawStart = leftOffset + lineLeftOffset + boxStart;
20015
20035
  if (this.direction === 'rtl') {
20016
20036
  drawStart = this.width - drawStart - boxWidth;
20017
20037
  }
20018
- if (lastDecoration && lastFill) {
20038
+ if (lastDecoration && lastFill && lastTickness) {
20019
20039
  // bug? verify lastFill is a valid fill here.
20020
20040
  ctx.fillStyle = lastFill;
20021
- ctx.fillRect(drawStart, top + offsetY * size + dy, boxWidth, this.fontSize / 15);
20041
+ ctx.fillRect(drawStart, top + offsetY * size + dy - offsetAligner * finalTickness, boxWidth, finalTickness);
20022
20042
  }
20023
20043
  boxStart = charBox.left;
20024
20044
  boxWidth = charBox.width;
20025
20045
  lastDecoration = currentDecoration;
20046
+ lastTickness = currentTickness;
20026
20047
  lastFill = currentFill;
20027
20048
  size = currentSize;
20028
20049
  dy = currentDy;
@@ -20035,7 +20056,8 @@
20035
20056
  drawStart = this.width - drawStart - boxWidth;
20036
20057
  }
20037
20058
  ctx.fillStyle = currentFill;
20038
- currentDecoration && currentFill && ctx.fillRect(drawStart, top + offsetY * size + dy, boxWidth - charSpacing, this.fontSize / 15);
20059
+ const finalTickness = this.fontSize * currentTickness / 1000;
20060
+ currentDecoration && currentFill && currentTickness && ctx.fillRect(drawStart, top + offsetY * size + dy - offsetAligner * finalTickness, boxWidth - charSpacing, finalTickness);
20039
20061
  topOffset += heightOfLine;
20040
20062
  }
20041
20063
  // if there is text background color no
@@ -25189,12 +25211,10 @@
25189
25211
  */
25190
25212
  function getCSSRules(doc) {
25191
25213
  const styles = doc.getElementsByTagName('style');
25192
- let i;
25193
- let len;
25194
25214
  const allRules = {};
25195
25215
 
25196
25216
  // very crude parsing of style contents
25197
- for (i = 0, len = styles.length; i < len; i++) {
25217
+ for (let i = 0; i < styles.length; i++) {
25198
25218
  const styleContents = (styles[i].textContent || '').replace(
25199
25219
  // remove comments
25200
25220
  /\/\*[\s\S]*?\*\//g, '');
@@ -25220,8 +25240,8 @@
25220
25240
  propertyValuePairs = declaration.split(';').filter(function (pair) {
25221
25241
  return pair.trim();
25222
25242
  });
25223
- for (i = 0, len = propertyValuePairs.length; i < len; i++) {
25224
- const pair = propertyValuePairs[i].split(':'),
25243
+ for (let j = 0; j < propertyValuePairs.length; j++) {
25244
+ const pair = propertyValuePairs[j].split(':'),
25225
25245
  property = pair[0].trim(),
25226
25246
  value = pair[1].trim();
25227
25247
  ruleObj[property] = value;