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

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