@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/module.js CHANGED
@@ -1216,7 +1216,11 @@ var Logger = {
1216
1216
  }
1217
1217
  if (width > 0 && height > 0 && data) {
1218
1218
  charInfo.bufferOffset = new Vector2(this._curX, this._curY);
1219
- texture.setPixelBuffer(data, 0, this._curX, this._curY, width, height);
1219
+ if (_instanceof(data, Uint8Array)) {
1220
+ texture.setPixelBuffer(data, 0, this._curX, this._curY, width, height);
1221
+ } else {
1222
+ texture.setImageSource(data, 0, false, false, this._curX, this._curY);
1223
+ }
1220
1224
  texture.generateMipmaps();
1221
1225
  }
1222
1226
  var textureSizeReciprocal = 1.0 / textureSize;
@@ -1573,6 +1577,7 @@ FontAtlas.textureSize = 256;
1573
1577
  context.clearRect(0, 0, width, height);
1574
1578
  context.textBaseline = "middle";
1575
1579
  context.fillStyle = "#fff";
1580
+ context.lineJoin = 'round';
1576
1581
  if (actualBoundingBoxLeft > 0) {
1577
1582
  context.fillText(measureString, actualBoundingBoxLeft, baseline);
1578
1583
  } else {
@@ -1588,19 +1593,24 @@ FontAtlas.textureSize = 256;
1588
1593
  var size = 0;
1589
1594
  var integerW = canvas.width;
1590
1595
  var integerWReciprocal = 1.0 / integerW;
1591
- for(var i = 0; i < len; i += 4){
1592
- if (colorData[i + 3] !== 0) {
1593
- var idx = i * 0.25;
1594
- y = ~~(idx * integerWReciprocal);
1595
- if (top === -1) {
1596
- top = y;
1597
- }
1598
- if (y > bottom) {
1599
- bottom = y;
1596
+ if (this.useImageData) {
1597
+ for(var i = 0; i < len; i += 4){
1598
+ if (colorData[i + 3] !== 0) {
1599
+ var idx = i * 0.25;
1600
+ y = ~~(idx * integerWReciprocal);
1601
+ if (top === -1) {
1602
+ top = y;
1603
+ }
1604
+ if (y > bottom) {
1605
+ bottom = y;
1606
+ }
1607
+ } else {
1608
+ colorData[i] = colorData[i + 1] = colorData[i + 2] = 255;
1600
1609
  }
1601
- } else {
1602
- colorData[i] = colorData[i + 1] = colorData[i + 2] = 255;
1603
1610
  }
1611
+ } else {
1612
+ top = 0;
1613
+ bottom = height - 1;
1604
1614
  }
1605
1615
  if (top !== -1 && bottom !== -1) {
1606
1616
  ascent = baseline - top;
@@ -1611,9 +1621,13 @@ FontAtlas.textureSize = 256;
1611
1621
  if (isChar) {
1612
1622
  var data = null;
1613
1623
  if (size > 0) {
1614
- var lineIntegerW = integerW * 4;
1615
- // gl.texSubImage2D uploading data of type Uint8ClampedArray is not supported in some devices(eg: IphoneX IOS 13.6.1).
1616
- data = new Uint8Array(colorData.buffer, top * lineIntegerW, size * lineIntegerW);
1624
+ if (this.useImageData) {
1625
+ // gl.texSubImage2D uploading data of type Uint8ClampedArray is not supported in some devices(eg: IphoneX IOS 13.6.1).
1626
+ var lineIntegerW = integerW * 4;
1627
+ data = new Uint8Array(colorData.buffer, top * lineIntegerW, size * lineIntegerW);
1628
+ } else {
1629
+ data = canvas;
1630
+ }
1617
1631
  }
1618
1632
  return {
1619
1633
  char: measureString,
@@ -1676,6 +1690,7 @@ FontAtlas.textureSize = 256;
1676
1690
  "emoji",
1677
1691
  "fangsong"
1678
1692
  ];
1693
+ TextUtils.useImageData = true;
1679
1694
  // _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
1680
1695
  /** @internal */ TextUtils._extendHeight = 0;
1681
1696
  /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|ÉqÅ";
@@ -1778,7 +1793,11 @@ TextUtils._textContext = null;
1778
1793
  var data = TextUtils.measureChar(charInfo.char, nativeFontString).data;
1779
1794
  if (charInfo.w > 0 && charInfo.h > 0 && data) {
1780
1795
  var bufferOffset = charInfo.bufferOffset;
1781
- texture.setPixelBuffer(data, 0, bufferOffset.x, bufferOffset.y, charInfo.w, charInfo.h);
1796
+ if (_instanceof(data, Uint8Array)) {
1797
+ texture.setPixelBuffer(data, 0, bufferOffset.x, bufferOffset.y, charInfo.w, charInfo.h);
1798
+ } else {
1799
+ texture.setImageSource(data, 0, false, false, bufferOffset.x, bufferOffset.y);
1800
+ }
1782
1801
  }
1783
1802
  }
1784
1803
  texture.generateMipmaps();