@galacean/engine-core 0.0.0-experimental-1.4-small-language.1 → 0.0.0-experimental-1.4-small-language.3

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/module.js CHANGED
@@ -1558,7 +1558,7 @@ FontAtlas.textureSize = 256;
1558
1558
  // Safari gets data confusion through getImageData when the canvas width is not an integer.
1559
1559
  // The measure text width of some special invisible characters may be 0, so make sure the width is at least 1.
1560
1560
  // @todo: Text layout may vary from standard and not support emoji.
1561
- var _context_measureText = context.measureText(measureString), actualBoundingBoxLeft = _context_measureText.actualBoundingBoxLeft, actualBoundingBoxRight = _context_measureText.actualBoundingBoxRight, actualWidth = _context_measureText.width;
1561
+ var _context_measureText = context.measureText(measureString), actualBoundingBoxLeft = _context_measureText.actualBoundingBoxLeft, actualBoundingBoxRight = _context_measureText.actualBoundingBoxRight, fontBoundingBoxAscent = _context_measureText.fontBoundingBoxAscent, fontBoundingBoxDescent = _context_measureText.fontBoundingBoxDescent, actualWidth = _context_measureText.width;
1562
1562
  // In some case (ex: " "), actualBoundingBoxRight and actualBoundingBoxLeft will be 0, so use width.
1563
1563
  // TODO: With testing, actualBoundingBoxLeft + actualBoundingBoxRight is the actual rendering width
1564
1564
  // but the space rules between characters are unclear. Using actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft) is the closest to the native effect.
@@ -1567,6 +1567,10 @@ FontAtlas.textureSize = 256;
1567
1567
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
1568
1568
  var height = baseline * TextUtils._heightMultiplier;
1569
1569
  baseline = TextUtils._baselineMultiplier * baseline | 0;
1570
+ if (!this.useImageData) {
1571
+ height = Math.round(TextUtils._heightMultiplier * (fontBoundingBoxAscent + fontBoundingBoxDescent));
1572
+ baseline = Math.round(height / 4 + fontBoundingBoxAscent);
1573
+ }
1570
1574
  var _extendHeight = TextUtils._extendHeight;
1571
1575
  height += _extendHeight;
1572
1576
  baseline += _extendHeight * 0.5;