@galacean/engine-core 0.0.0-experimental-1.4-small-language.0 → 0.0.0-experimental-1.4-small-language.2

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
@@ -1220,7 +1220,11 @@ var Logger = {
1220
1220
  }
1221
1221
  if (width > 0 && height > 0 && data) {
1222
1222
  charInfo.bufferOffset = new engineMath.Vector2(this._curX, this._curY);
1223
- texture.setPixelBuffer(data, 0, this._curX, this._curY, width, height);
1223
+ if (_instanceof(data, Uint8Array)) {
1224
+ texture.setPixelBuffer(data, 0, this._curX, this._curY, width, height);
1225
+ } else {
1226
+ texture.setImageSource(data, 0, false, false, this._curX, this._curY);
1227
+ }
1224
1228
  texture.generateMipmaps();
1225
1229
  }
1226
1230
  var textureSizeReciprocal = 1.0 / textureSize;
@@ -1577,6 +1581,7 @@ FontAtlas.textureSize = 256;
1577
1581
  context.clearRect(0, 0, width, height);
1578
1582
  context.textBaseline = "middle";
1579
1583
  context.fillStyle = "#fff";
1584
+ context.lineJoin = 'round';
1580
1585
  if (actualBoundingBoxLeft > 0) {
1581
1586
  context.fillText(measureString, actualBoundingBoxLeft, baseline);
1582
1587
  } else {
@@ -1592,19 +1597,24 @@ FontAtlas.textureSize = 256;
1592
1597
  var size = 0;
1593
1598
  var integerW = canvas.width;
1594
1599
  var integerWReciprocal = 1.0 / integerW;
1595
- for(var i = 0; i < len; i += 4){
1596
- if (colorData[i + 3] !== 0) {
1597
- var idx = i * 0.25;
1598
- y = ~~(idx * integerWReciprocal);
1599
- if (top === -1) {
1600
- top = y;
1601
- }
1602
- if (y > bottom) {
1603
- bottom = y;
1600
+ if (this.useImageData) {
1601
+ for(var i = 0; i < len; i += 4){
1602
+ if (colorData[i + 3] !== 0) {
1603
+ var idx = i * 0.25;
1604
+ y = ~~(idx * integerWReciprocal);
1605
+ if (top === -1) {
1606
+ top = y;
1607
+ }
1608
+ if (y > bottom) {
1609
+ bottom = y;
1610
+ }
1611
+ } else {
1612
+ colorData[i] = colorData[i + 1] = colorData[i + 2] = 255;
1604
1613
  }
1605
- } else {
1606
- colorData[i] = colorData[i + 1] = colorData[i + 2] = 255;
1607
1614
  }
1615
+ } else {
1616
+ top = 0;
1617
+ bottom = height - 1;
1608
1618
  }
1609
1619
  if (top !== -1 && bottom !== -1) {
1610
1620
  ascent = baseline - top;
@@ -1615,9 +1625,13 @@ FontAtlas.textureSize = 256;
1615
1625
  if (isChar) {
1616
1626
  var data = null;
1617
1627
  if (size > 0) {
1618
- var lineIntegerW = integerW * 4;
1619
- // gl.texSubImage2D uploading data of type Uint8ClampedArray is not supported in some devices(eg: IphoneX IOS 13.6.1).
1620
- data = new Uint8Array(colorData.buffer, top * lineIntegerW, size * lineIntegerW);
1628
+ if (this.useImageData) {
1629
+ // gl.texSubImage2D uploading data of type Uint8ClampedArray is not supported in some devices(eg: IphoneX IOS 13.6.1).
1630
+ var lineIntegerW = integerW * 4;
1631
+ data = new Uint8Array(colorData.buffer, top * lineIntegerW, size * lineIntegerW);
1632
+ } else {
1633
+ data = canvas;
1634
+ }
1621
1635
  }
1622
1636
  return {
1623
1637
  char: measureString,
@@ -1680,6 +1694,7 @@ FontAtlas.textureSize = 256;
1680
1694
  "emoji",
1681
1695
  "fangsong"
1682
1696
  ];
1697
+ TextUtils.useImageData = true;
1683
1698
  // _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
1684
1699
  /** @internal */ TextUtils._extendHeight = 0;
1685
1700
  /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|ÉqÅ";
@@ -1782,7 +1797,11 @@ TextUtils._textContext = null;
1782
1797
  var data = TextUtils.measureChar(charInfo.char, nativeFontString).data;
1783
1798
  if (charInfo.w > 0 && charInfo.h > 0 && data) {
1784
1799
  var bufferOffset = charInfo.bufferOffset;
1785
- texture.setPixelBuffer(data, 0, bufferOffset.x, bufferOffset.y, charInfo.w, charInfo.h);
1800
+ if (_instanceof(data, Uint8Array)) {
1801
+ texture.setPixelBuffer(data, 0, bufferOffset.x, bufferOffset.y, charInfo.w, charInfo.h);
1802
+ } else {
1803
+ texture.setImageSource(data, 0, false, false, bufferOffset.x, bufferOffset.y);
1804
+ }
1786
1805
  }
1787
1806
  }
1788
1807
  texture.generateMipmaps();