pixi-glyphs 4.2.0 → 4.2.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.
package/dist/Glyphs.d.ts CHANGED
@@ -47,6 +47,7 @@ export default class Glyphs<TextType extends PixiTextTypes = PIXI.Text> extends
47
47
  get spriteContainer(): PIXI.Container;
48
48
  private _debugContainer;
49
49
  get debugContainer(): PIXI.Container;
50
+ private _maskGraphics;
50
51
  private logWarning;
51
52
  constructor(text?: string, tagStyles?: TextStyleSet, options?: TaggedTextOptions);
52
53
  destroyImgMap(): void;
@@ -889,10 +889,12 @@ const verticalAlignInLines = (lines, lineSpacing, overrideValign) => {
889
889
  let tallestToken = getTallestToken(line);
890
890
  let baseHeight = tallestToken.bounds?.height ?? 0;
891
891
  let baseTallestAscent = 0;
892
+ let baseTallestDescent = 0;
892
893
  const hasRealContent = line.flat(2).some(seg => !isWhitespaceToken(seg) && !isNewlineToken(seg));
893
894
  for (const word of line) {
894
895
  for (const segment of word) {
895
896
  let segAscent = segment.fontProperties?.ascent ?? 0;
897
+ const segDescent = segment.fontProperties?.descent ?? 0;
896
898
  const style = segment.style;
897
899
  const strokeWidth = typeof style?.stroke === 'object' ? style.stroke.width : 0;
898
900
  const legacyStrokeThickness = style.strokeThickness || 0;
@@ -914,9 +916,11 @@ const verticalAlignInLines = (lines, lineSpacing, overrideValign) => {
914
916
  }
915
917
  if (segAscent > baseTallestAscent) {
916
918
  baseTallestAscent = segAscent;
919
+ baseTallestDescent = segDescent;
917
920
  }
918
921
  }
919
922
  }
923
+ baseHeight = baseTallestAscent + baseTallestDescent;
920
924
  if (baseHeight === 0 && baseTallestAscent === 0) {
921
925
  baseHeight = lastNonEmptyTallestToken.bounds?.height ?? 0;
922
926
  baseTallestAscent = lastNonEmptyTallestToken.fontProperties?.ascent ?? 0;
@@ -1552,6 +1556,7 @@ class Glyphs extends PIXI__namespace.Container {
1552
1556
  this._decorationContainer = void 0;
1553
1557
  this._spriteContainer = void 0;
1554
1558
  this._debugContainer = void 0;
1559
+ this._maskGraphics = null;
1555
1560
  this.logWarning = (code, message) => logWarning(this.options.errorHandler, this.options.supressConsole, this)(code, message);
1556
1561
  this._textContainer = new PIXI__namespace.Container();
1557
1562
  this._spriteContainer = new PIXI__namespace.Container();
@@ -1632,6 +1637,9 @@ class Glyphs extends PIXI__namespace.Container {
1632
1637
  this._options = {};
1633
1638
  }
1634
1639
  resetChildren() {
1640
+ if (this._maskGraphics && this._maskGraphics.parent === this) {
1641
+ this.removeChild(this._maskGraphics);
1642
+ }
1635
1643
  if (this._highlightContainer) {
1636
1644
  this._highlightContainer.removeChildren().forEach(child => child.destroy());
1637
1645
  const removed = this.removeChild(this._highlightContainer);
@@ -1849,6 +1857,18 @@ class Glyphs extends PIXI__namespace.Container {
1849
1857
  if (drawWhitespace === false && drewDecorations) {
1850
1858
  this.logWarning("text-decoration-and-whitespace", "Text decorations, such as underlines, will not appear under whitespace unless the `drawWhitespace` option is set to `true`.");
1851
1859
  }
1860
+ if (!this._maskGraphics) {
1861
+ this._maskGraphics = new PIXI__namespace.Graphics();
1862
+ } else {
1863
+ this._maskGraphics.clear();
1864
+ }
1865
+ this._maskGraphics.rect(0, 0, 10000, 10000);
1866
+ this._maskGraphics.fill({
1867
+ color: 0xffffff
1868
+ });
1869
+ this._maskGraphics.alpha = 0;
1870
+ this.addChildAt(this._maskGraphics, 0);
1871
+ this.mask = this._maskGraphics;
1852
1872
  if (this.options.debug) {
1853
1873
  this.drawDebug();
1854
1874
  }