@wcardinal/wcardinal-ui 0.425.0 → 0.427.0

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.
Files changed (65) hide show
  1. package/dist/types/wcardinal/ui/d-dynamic-text-geometry.d.ts +14 -3
  2. package/dist/types/wcardinal/ui/d-pane.d.ts +4 -4
  3. package/dist/types/wcardinal/ui/shape/e-shape-text.d.ts +3 -1
  4. package/dist/types/wcardinal/ui/shape/variant/build-text.d.ts +1 -1
  5. package/dist/types/wcardinal/ui/shape/variant/e-shape-text-impl.d.ts +6 -1
  6. package/dist/types/wcardinal/ui/util/character.d.ts +8 -0
  7. package/dist/types/wcardinal/ui/util/dynamic-font-atlas-character.d.ts +1 -0
  8. package/dist/types/wcardinal/ui/util/dynamic-font-atlas-characters.d.ts +1 -1
  9. package/dist/types/wcardinal/ui/util/dynamic-font-atlas.d.ts +5 -7
  10. package/dist/types/wcardinal/ui/util/dynamic-sdf-font-atlas.d.ts +4 -5
  11. package/dist/types/wcardinal/ui/util/dynamic-sdf-font-atlases.d.ts +2 -2
  12. package/dist/types/wcardinal/ui/util/index.d.ts +1 -0
  13. package/dist/types/wcardinal/ui/util/util-character-iterator.d.ts +0 -8
  14. package/dist/wcardinal/ui/d-dynamic-text-geometry.js +56 -49
  15. package/dist/wcardinal/ui/d-dynamic-text-geometry.js.map +1 -1
  16. package/dist/wcardinal/ui/d-dynamic-text-measure.js +11 -11
  17. package/dist/wcardinal/ui/d-dynamic-text-measure.js.map +1 -1
  18. package/dist/wcardinal/ui/d-pane.js +9 -21
  19. package/dist/wcardinal/ui/d-pane.js.map +1 -1
  20. package/dist/wcardinal/ui/shape/e-shape-renderer.js +3 -3
  21. package/dist/wcardinal/ui/shape/e-shape-renderer.js.map +1 -1
  22. package/dist/wcardinal/ui/shape/e-shape-text.js.map +1 -1
  23. package/dist/wcardinal/ui/shape/variant/build-text.js +13 -14
  24. package/dist/wcardinal/ui/shape/variant/build-text.js.map +1 -1
  25. package/dist/wcardinal/ui/shape/variant/builder-text.js +1 -1
  26. package/dist/wcardinal/ui/shape/variant/builder-text.js.map +1 -1
  27. package/dist/wcardinal/ui/shape/variant/e-shape-text-impl.js +88 -13
  28. package/dist/wcardinal/ui/shape/variant/e-shape-text-impl.js.map +1 -1
  29. package/dist/wcardinal/ui/util/character.js +13 -0
  30. package/dist/wcardinal/ui/util/character.js.map +1 -0
  31. package/dist/wcardinal/ui/util/dynamic-font-atlas-character.js +2 -1
  32. package/dist/wcardinal/ui/util/dynamic-font-atlas-character.js.map +1 -1
  33. package/dist/wcardinal/ui/util/dynamic-font-atlas-characters.js.map +1 -1
  34. package/dist/wcardinal/ui/util/dynamic-font-atlas.js +124 -108
  35. package/dist/wcardinal/ui/util/dynamic-font-atlas.js.map +1 -1
  36. package/dist/wcardinal/ui/util/dynamic-font-atlases.js +2 -1
  37. package/dist/wcardinal/ui/util/dynamic-font-atlases.js.map +1 -1
  38. package/dist/wcardinal/ui/util/dynamic-sdf-font-atlas.js +99 -112
  39. package/dist/wcardinal/ui/util/dynamic-sdf-font-atlas.js.map +1 -1
  40. package/dist/wcardinal/ui/util/dynamic-sdf-font-atlases.js +18 -26
  41. package/dist/wcardinal/ui/util/dynamic-sdf-font-atlases.js.map +1 -1
  42. package/dist/wcardinal/ui/util/index.js +1 -0
  43. package/dist/wcardinal/ui/util/index.js.map +1 -1
  44. package/dist/wcardinal/ui/util/util-character-iterator.js +0 -17
  45. package/dist/wcardinal/ui/util/util-character-iterator.js.map +1 -1
  46. package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
  47. package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
  48. package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
  49. package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
  50. package/dist/wcardinal-ui-theme-dark.js +1 -1
  51. package/dist/wcardinal-ui-theme-dark.min.js +1 -1
  52. package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
  53. package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
  54. package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
  55. package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
  56. package/dist/wcardinal-ui-theme-white.js +1 -1
  57. package/dist/wcardinal-ui-theme-white.min.js +1 -1
  58. package/dist/wcardinal-ui.cjs.js +508 -450
  59. package/dist/wcardinal-ui.js +508 -450
  60. package/dist/wcardinal-ui.min.js +2 -2
  61. package/dist/wcardinal-ui.min.js.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/types/wcardinal/ui/util/ascii.d.ts +0 -1
  64. package/dist/wcardinal/ui/util/ascii.js +0 -6
  65. package/dist/wcardinal/ui/util/ascii.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.425.0
2
+ Winter Cardinal UI v0.427.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -355,91 +355,6 @@
355
355
  uvs[++iuv] = textureUvs.y2;
356
356
  };
357
357
 
358
- /*
359
- * Copyright (C) 2019 Toshiba Corporation
360
- * SPDX-License-Identifier: Apache-2.0
361
- */
362
- var UtilCharacterIterator = /** @class */ (function () {
363
- function UtilCharacterIterator() {
364
- this.target = "";
365
- this.position = 0;
366
- }
367
- UtilCharacterIterator.prototype.init = function (target) {
368
- this.target = target;
369
- this.position = 0;
370
- };
371
- UtilCharacterIterator.prototype.hasNext = function () {
372
- return this.position < this.target.length;
373
- };
374
- UtilCharacterIterator.prototype.findNextBreak = function (target, istart) {
375
- var iend = target.length;
376
- for (var i = istart; i < iend; ++i) {
377
- var code = target.charCodeAt(i);
378
- if (!this.isLowSurrogate(code) && !this.isVariationSelector(code)) {
379
- return i;
380
- }
381
- }
382
- return iend;
383
- };
384
- UtilCharacterIterator.prototype.isHighSurrogate = function (code) {
385
- return 0xd800 <= code && code <= 0xdbff;
386
- };
387
- UtilCharacterIterator.prototype.isLowSurrogate = function (code) {
388
- return 0xdc00 <= code && code <= 0xdfff;
389
- };
390
- UtilCharacterIterator.prototype.isVariationSelector = function (code) {
391
- return 0xfe00 <= code && code <= 0xfe0f;
392
- };
393
- UtilCharacterIterator.prototype.next = function () {
394
- var target = this.target;
395
- var position = this.position;
396
- var nextBreak = this.findNextBreak(target, position + 1);
397
- var result = target.substring(position, nextBreak);
398
- this.position = nextBreak;
399
- return result;
400
- };
401
- /**
402
- * Advances the position if the next character is not equal to
403
- * the given `except`.
404
- *
405
- * @param except
406
- * @return true if the position is advanced
407
- */
408
- UtilCharacterIterator.prototype.advance = function (except) {
409
- var target = this.target;
410
- var position = this.position;
411
- var nextBreak = this.findNextBreak(target, position + 1);
412
- if (target.substring(position, nextBreak) !== except) {
413
- this.position = nextBreak;
414
- return true;
415
- }
416
- return false;
417
- };
418
- /**
419
- * Closes this iterator.
420
- *
421
- * @returns true if closed.
422
- */
423
- UtilCharacterIterator.prototype.close = function () {
424
- var length = this.target.length;
425
- if (this.position < length) {
426
- this.position = length;
427
- return true;
428
- }
429
- return false;
430
- };
431
- UtilCharacterIterator.from = function (target) {
432
- if (UtilCharacterIterator._instance == null) {
433
- UtilCharacterIterator._instance = new UtilCharacterIterator();
434
- }
435
- var instance = UtilCharacterIterator._instance;
436
- instance.init(target);
437
- return instance;
438
- };
439
- UtilCharacterIterator._instance = null;
440
- return UtilCharacterIterator;
441
- }());
442
-
443
358
  /*
444
359
  * Copyright (C) 2019 Toshiba Corporation
445
360
  * SPDX-License-Identifier: Apache-2.0
@@ -498,6 +413,19 @@
498
413
  return Math.sqrt(dx01 * dx01 + dy01 * dy01);
499
414
  };
500
415
 
416
+ /*
417
+ * Copyright (C) 2019 Toshiba Corporation
418
+ * SPDX-License-Identifier: Apache-2.0
419
+ */
420
+ var Character = {
421
+ ASCII: "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
422
+ SPACE: " ",
423
+ TAB: "\t",
424
+ SOFT_TAB: " ",
425
+ DOTS: "...",
426
+ NEW_LINE: "\n"
427
+ };
428
+
501
429
  var TEXT_VERTEX_COUNT = 4;
502
430
  var TEXT_VERTEX_COUNT_SHIFT = 2;
503
431
  var TEXT_INDEX_COUNT = 2;
@@ -844,7 +772,7 @@
844
772
  return EShapeTextAlignVertical.OUTSIDE_TOP;
845
773
  }
846
774
  };
847
- var buildTextVertex = function (vertices, uvs, voffset, vcount, originX, originY, sizeX, sizeY, textAtlas, textSize, textValue, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textFitting, textWorld, textureUvs, internalTransform) {
775
+ var buildTextVertex = function (vertices, uvs, voffset, vcount, originX, originY, sizeX, sizeY, textAtlas, textSize, textCharacters, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textFitting, textWorld, textureUvs, internalTransform) {
848
776
  // Calculate the transformed positions
849
777
  //
850
778
  // 0 1
@@ -936,15 +864,14 @@
936
864
  var lineWidth = 0;
937
865
  var lineCount = 1;
938
866
  var textAtlasCharacters = textAtlas.characters;
939
- var iterator = UtilCharacterIterator.from(textValue);
940
867
  var advancePrevious = 0;
941
- while (iterator.hasNext()) {
942
- var character = iterator.next();
943
- if (character !== "\n") {
868
+ for (var i = 0, imax = textCharacters.length; i < imax; ++i) {
869
+ var character = textCharacters[i];
870
+ if (character !== Character.NEW_LINE) {
944
871
  if (0 < advancePrevious) {
945
872
  lineWidth += Math.max(0, advancePrevious + textSpacingHorizontal);
946
873
  }
947
- var data = textAtlasCharacters[character];
874
+ var data = textAtlasCharacters.get(character);
948
875
  if (data) {
949
876
  advancePrevious = data.advance;
950
877
  heightChar = data.height;
@@ -1088,12 +1015,11 @@
1088
1015
  var cy3 = by3;
1089
1016
  lineWidth = 0;
1090
1017
  advancePrevious = 0;
1091
- iterator.position = 0;
1092
1018
  lineCount = 0;
1093
1019
  var iv = voffset * 2;
1094
- for (; iterator.hasNext(); iv += 8) {
1095
- var character = iterator.next();
1096
- if (character !== "\n") {
1020
+ for (var i = 0, imax = textCharacters.length; i < imax; i += 1, iv += 8) {
1021
+ var character = textCharacters[i];
1022
+ if (character !== Character.NEW_LINE) {
1097
1023
  var lineWidthPrevious = lineWidth;
1098
1024
  if (0 < advancePrevious) {
1099
1025
  lineWidth += Math.max(0, advancePrevious + textSpacingHorizontal);
@@ -1104,12 +1030,12 @@
1104
1030
  cy0 = by0 + ay;
1105
1031
  cx3 = bx3 + ax;
1106
1032
  cy3 = by3 + ay;
1107
- var data = textAtlasCharacters[character];
1033
+ var data = textAtlasCharacters.get(character);
1108
1034
  lineCount += 1;
1109
1035
  if (data) {
1110
1036
  var advance = data.advance;
1111
1037
  if (lineWidthMaximum < (lineWidth + advance) * scaleX) {
1112
- var dots = textAtlasCharacters["..."];
1038
+ var dots = textAtlasCharacters.get(Character.DOTS);
1113
1039
  if (dots) {
1114
1040
  if (1 < lineCount &&
1115
1041
  lineWidthMaximum < (lineWidth + dots.advance) * scaleX) {
@@ -1126,9 +1052,10 @@
1126
1052
  advancePrevious = dots.advance;
1127
1053
  writeCharacter(vertices, uvs, iv, dots, textAtlas, snx, sny, cx0, cy0, cx3, cy3, duvx01, duvy01, duvx03, duvy03, uvx0, uvy0);
1128
1054
  for (iv += 8; true; iv += 8) {
1129
- if (iterator.hasNext() && iterator.advance("\n")) {
1055
+ if (i + 1 < imax && textCharacters[i + 1] !== Character.NEW_LINE) {
1130
1056
  writeCharacterEmpty(vertices, uvs, iv, cx0, cy0, cx3, cy3, uvx0, uvy0, uvx3, uvy3);
1131
1057
  lineCount += 1;
1058
+ i += 1;
1132
1059
  }
1133
1060
  else {
1134
1061
  iv -= 8;
@@ -7797,6 +7724,9 @@
7797
7724
  this.padding = new EShapeTextOffsetImpl(parent, 10, 10);
7798
7725
  this._clipping = false;
7799
7726
  this._fitting = false;
7727
+ this._characters = [];
7728
+ this._nacharacters = [];
7729
+ this.updateCharacters(value);
7800
7730
  }
7801
7731
  Object.defineProperty(EShapeTextImpl.prototype, "enable", {
7802
7732
  get: function () {
@@ -7823,7 +7753,8 @@
7823
7753
  if (this._plength < length_1) {
7824
7754
  this._plength = length_1;
7825
7755
  }
7826
- if (this.isCompatible(value)) {
7756
+ this.updateCharacters(value);
7757
+ if (this.isCompatible()) {
7827
7758
  this._parent.updateUploaded();
7828
7759
  }
7829
7760
  else {
@@ -7835,7 +7766,78 @@
7835
7766
  enumerable: false,
7836
7767
  configurable: true
7837
7768
  });
7838
- EShapeTextImpl.prototype.isCompatible = function (value) {
7769
+ Object.defineProperty(EShapeTextImpl.prototype, "characters", {
7770
+ get: function () {
7771
+ return this._characters;
7772
+ },
7773
+ enumerable: false,
7774
+ configurable: true
7775
+ });
7776
+ Object.defineProperty(EShapeTextImpl.prototype, "nacharacters", {
7777
+ get: function () {
7778
+ return this._nacharacters;
7779
+ },
7780
+ enumerable: false,
7781
+ configurable: true
7782
+ });
7783
+ EShapeTextImpl.prototype.updateCharacters = function (value) {
7784
+ var characters = this._characters;
7785
+ var charactersLength = characters.length;
7786
+ var icharacters = 0;
7787
+ var nacharacters = this._nacharacters;
7788
+ var nacharactersLength = nacharacters.length;
7789
+ var inacharacters = 0;
7790
+ for (var i = 0, imax = value.length; i < imax;) {
7791
+ if (value.charCodeAt(i) <= 0xff) {
7792
+ // Add an ASCII character
7793
+ var ac = value.substring(i, i + 1);
7794
+ if (icharacters < charactersLength) {
7795
+ characters[icharacters] = ac;
7796
+ }
7797
+ else {
7798
+ characters.push(ac);
7799
+ }
7800
+ icharacters += 1;
7801
+ i += 1;
7802
+ continue;
7803
+ }
7804
+ var j = i + 1;
7805
+ for (; j < imax; ++j) {
7806
+ var cc = value.charCodeAt(j);
7807
+ if ((0xdc00 <= cc && cc <= 0xdfff) || (0xfe00 <= cc && cc <= 0xfe0f)) {
7808
+ // Low surrogate
7809
+ // Variation selector
7810
+ continue;
7811
+ }
7812
+ break;
7813
+ }
7814
+ // Add an non-ascii character
7815
+ var nac = value.substring(i, j);
7816
+ if (icharacters < charactersLength) {
7817
+ characters[icharacters] = nac;
7818
+ }
7819
+ else {
7820
+ characters.push(nac);
7821
+ }
7822
+ icharacters += 1;
7823
+ if (inacharacters < nacharactersLength) {
7824
+ nacharacters[inacharacters] = nac;
7825
+ }
7826
+ else {
7827
+ nacharacters.push(nac);
7828
+ }
7829
+ inacharacters += 1;
7830
+ // Go to the next
7831
+ i = j;
7832
+ }
7833
+ if (icharacters < charactersLength) {
7834
+ characters.length = icharacters;
7835
+ }
7836
+ if (inacharacters < nacharactersLength) {
7837
+ nacharacters.length = inacharacters;
7838
+ }
7839
+ };
7840
+ EShapeTextImpl.prototype.isCompatible = function () {
7839
7841
  // Compatibility check
7840
7842
  var parent = this._parent;
7841
7843
  var uploaded = parent.uploaded;
@@ -7844,18 +7846,17 @@
7844
7846
  }
7845
7847
  // Character code check
7846
7848
  var atlas = this.atlas;
7847
- var characters = atlas && atlas.characters;
7848
- if (characters != null) {
7849
- for (var i = 0, imax = value.length; i < imax; ++i) {
7850
- var char = value[i];
7851
- if (!(char in characters)) {
7852
- return false;
7853
- }
7854
- }
7855
- }
7856
- else {
7849
+ if (atlas == null) {
7857
7850
  return false;
7858
7851
  }
7852
+ var atlasCharacters = atlas.characters;
7853
+ var nacharacters = this._nacharacters;
7854
+ for (var i = 0, imax = nacharacters.length; i < imax; ++i) {
7855
+ if (!atlasCharacters.has(nacharacters[i])) {
7856
+ return false;
7857
+ }
7858
+ }
7859
+ // Done
7859
7860
  return true;
7860
7861
  };
7861
7862
  Object.defineProperty(EShapeTextImpl.prototype, "length", {
@@ -8010,7 +8011,8 @@
8010
8011
  if (this._plength < length_2) {
8011
8012
  this._plength = length_2;
8012
8013
  }
8013
- if (this.isCompatible(value)) {
8014
+ this.updateCharacters(value);
8015
+ if (this.isCompatible()) {
8014
8016
  isChangedUploaded = true;
8015
8017
  }
8016
8018
  else {
@@ -8841,7 +8843,7 @@
8841
8843
  textWorld = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
8842
8844
  text.world = textWorld;
8843
8845
  }
8844
- buildTextVertex(buffer.vertices, buffer.uvs, this.vertexOffset, this.vertexCount, 0, 0, shapeSize.x, shapeSize.y, textAtlas, textSize, textValue, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textFitting, textWorld, toTextureUvs(textTexture), shape.transform.internalTransform);
8846
+ buildTextVertex(buffer.vertices, buffer.uvs, this.vertexOffset, this.vertexCount, 0, 0, shapeSize.x, shapeSize.y, textAtlas, textSize, text.characters, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textFitting, textWorld, toTextureUvs(textTexture), shape.transform.internalTransform);
8845
8847
  }
8846
8848
  };
8847
8849
  BuilderText.prototype.updateColor = function (buffer, shape) {
@@ -21156,12 +21158,6 @@
21156
21158
  return DynamicAtlasItemFontAtlas;
21157
21159
  }(DynamicAtlasItem));
21158
21160
 
21159
- /*
21160
- * Copyright (C) 2019 Toshiba Corporation
21161
- * SPDX-License-Identifier: Apache-2.0
21162
- */
21163
- var ASCII_CHARACTERS = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
21164
-
21165
21161
  /*
21166
21162
  * Copyright (C) 2019 Toshiba Corporation
21167
21163
  * SPDX-License-Identifier: Apache-2.0
@@ -21181,7 +21177,7 @@
21181
21177
  var DynamicFontAtlasCharacter = /** @class */ (function () {
21182
21178
  function DynamicFontAtlasCharacter(type, character, x, y, width, height, advance) {
21183
21179
  this.ref = 1;
21184
- this.life = 10;
21180
+ this.life = DynamicFontAtlasCharacter.LIFE;
21185
21181
  this.character = character;
21186
21182
  this.x = x;
21187
21183
  this.y = y;
@@ -21191,6 +21187,7 @@
21191
21187
  this.origin = new DynamicFontAtlasCharacterOrigin(0, 0);
21192
21188
  this.type = type;
21193
21189
  }
21190
+ DynamicFontAtlasCharacter.LIFE = 10;
21194
21191
  return DynamicFontAtlasCharacter;
21195
21192
  }());
21196
21193
 
@@ -21610,11 +21607,20 @@
21610
21607
  this._generator = DynamicSDFFontGenerator.getInstance().init();
21611
21608
  this._canvas = document.createElement("canvas");
21612
21609
  this._font = new DynamicSDFFontAtlasFont(fontFamily);
21613
- this._characters = {};
21614
- this._length = 0;
21615
21610
  this._width = 1;
21616
21611
  this._height = 1;
21612
+ var characters = new Map();
21613
+ characters.set(Character.SPACE, this.newChar(Character.SPACE, DynamicFontAtlasCharacterType.SPACE_R));
21614
+ characters.set(Character.TAB, this.newChar(Character.SOFT_TAB, DynamicFontAtlasCharacterType.SPACE_R));
21615
+ characters.set(Character.DOTS, this.newChar(Character.DOTS, DynamicFontAtlasCharacterType.LETTER_RNB));
21616
+ for (var i = 0, imax = Character.ASCII.length; i < imax; ++i) {
21617
+ var ac = Character.ASCII[i];
21618
+ characters.set(ac, this.newChar(ac, DynamicFontAtlasCharacterType.LETTER_RNB));
21619
+ }
21620
+ this._characters = characters;
21617
21621
  this._isDirty = true;
21622
+ this._isTouched = false;
21623
+ this._life = DynamicFontAtlasCharacter.LIFE;
21618
21624
  }
21619
21625
  Object.defineProperty(DynamicSDFFontAtlas.prototype, "id", {
21620
21626
  get: function () {
@@ -21671,143 +21677,125 @@
21671
21677
  configurable: true
21672
21678
  });
21673
21679
  DynamicSDFFontAtlas.prototype.begin = function () {
21674
- this._length = 0;
21675
- var characters = this._characters;
21676
- for (var id in characters) {
21677
- characters[id].ref = 0;
21678
- }
21680
+ this._isTouched = false;
21681
+ this._characters.forEach(function (character) {
21682
+ if (!(character.type & DynamicFontAtlasCharacterType.RESERVED)) {
21683
+ character.ref = 0;
21684
+ }
21685
+ });
21679
21686
  };
21680
21687
  DynamicSDFFontAtlas.prototype.end = function () {
21688
+ var _this = this;
21681
21689
  var characters = this._characters;
21682
- for (var id in characters) {
21683
- var data = characters[id];
21684
- if (data.ref <= 0) {
21685
- data.life -= 1;
21686
- if (data.life <= 0) {
21687
- delete characters[id];
21688
- this._isDirty = true;
21690
+ if (this._isTouched) {
21691
+ this._life = DynamicFontAtlasCharacter.LIFE;
21692
+ characters.forEach(function (character, id) {
21693
+ if (character.ref <= 0 &&
21694
+ !(character.type & DynamicFontAtlasCharacterType.RESERVED)) {
21695
+ character.life -= 1;
21696
+ if (character.life <= 0) {
21697
+ characters.delete(id);
21698
+ _this._isDirty = true;
21699
+ }
21689
21700
  }
21701
+ });
21702
+ }
21703
+ else {
21704
+ this._life -= 1;
21705
+ if (this._life <= 0 && 0 < characters.size) {
21706
+ characters.clear();
21707
+ this._isDirty = true;
21690
21708
  }
21691
21709
  }
21692
21710
  };
21693
- DynamicSDFFontAtlas.prototype.addAscii = function () {
21694
- this.addChar(" ", " ", DynamicFontAtlasCharacterType.SPACE_R);
21695
- this.addChar("\t", " ", DynamicFontAtlasCharacterType.SPACE_R);
21696
- this.addChar("...", "...", DynamicFontAtlasCharacterType.LETTER_RNB);
21697
- for (var i = 0, imax = ASCII_CHARACTERS.length; i < imax; ++i) {
21698
- var char = ASCII_CHARACTERS[i];
21699
- this.addChar(char, char, DynamicFontAtlasCharacterType.LETTER_RNB);
21700
- }
21711
+ DynamicSDFFontAtlas.prototype.newChar = function (character, type) {
21712
+ return new DynamicFontAtlasCharacter(type, character, 0, 0, 1, 1, 0);
21701
21713
  };
21702
- DynamicSDFFontAtlas.prototype.addChar = function (id, character, type) {
21703
- var characters = this._characters;
21704
- if (!this.isIgnored(character)) {
21705
- var data = characters[id];
21714
+ DynamicSDFFontAtlas.prototype.add = function (characters, nacharacters) {
21715
+ var cs = this._characters;
21716
+ for (var i = 0, imax = nacharacters.length; i < imax; ++i) {
21717
+ var nac = nacharacters[i];
21718
+ var data = cs.get(nac);
21706
21719
  if (data != null) {
21707
- if (data.ref <= 0) {
21708
- this._length += 1;
21709
- }
21710
21720
  data.ref += 1;
21721
+ data.life = DynamicFontAtlasCharacter.LIFE;
21711
21722
  }
21712
21723
  else {
21713
- characters[id] = new DynamicFontAtlasCharacter(type, character, 0, 0, 1, 1, 0);
21714
- this._length += 1;
21724
+ cs.set(nac, this.newChar(nac, DynamicFontAtlasCharacterType.LETTER));
21715
21725
  this._isDirty = true;
21716
21726
  }
21717
21727
  }
21718
- };
21719
- DynamicSDFFontAtlas.prototype.isIgnored = function (character) {
21720
- switch (character) {
21721
- case "\n": // Line feed
21722
- return true;
21723
- case "\r": // Carriage return
21724
- return true;
21725
- case "\v": // Vertical tab
21726
- return true;
21727
- case "\f": // Form feed
21728
- return true;
21729
- case "\u0085": // Next line
21730
- return true;
21731
- }
21732
- return false;
21733
- };
21734
- DynamicSDFFontAtlas.prototype.add = function (characters, type) {
21735
- if (type === void 0) { type = DynamicFontAtlasCharacterType.LETTER; }
21736
- var iterator = UtilCharacterIterator.from(characters);
21737
- while (iterator.hasNext()) {
21738
- var character = iterator.next();
21739
- this.addChar(character, character, type);
21728
+ if (0 < characters.length) {
21729
+ this._isTouched = true;
21740
21730
  }
21741
21731
  };
21742
21732
  DynamicSDFFontAtlas.prototype.get = function (id) {
21743
- return this._characters[id];
21733
+ return this._characters.get(id);
21744
21734
  };
21745
21735
  DynamicSDFFontAtlas.prototype.update = function () {
21746
21736
  if (this._isDirty) {
21747
21737
  var canvas = this._canvas;
21748
21738
  var generator = this._generator;
21749
21739
  if (canvas != null && generator != null) {
21750
- var context = canvas.getContext("2d");
21751
- if (context != null) {
21740
+ var context_1 = canvas.getContext("2d");
21741
+ if (context_1 != null) {
21752
21742
  this._isDirty = false;
21753
21743
  var font = this._font;
21744
+ var fontSize_1 = font.size + 14;
21754
21745
  var characters = this._characters;
21755
- var characterSize = font.size + 14;
21756
- var width = this.toPowerOf2(Math.ceil(Math.sqrt(this._length)) * characterSize);
21757
- this._width = width;
21746
+ var width_1 = this.toPowerOf2(Math.ceil(Math.sqrt(characters.size)) * fontSize_1);
21747
+ this._width = width_1;
21758
21748
  var fontStyle = (font.italic ? "italic " : "") + (font.size + "px ") + font.id;
21759
- context.font = fontStyle;
21760
- context.textAlign = "left";
21761
- context.textBaseline = "alphabetic";
21762
- context.lineWidth = 0;
21763
- context.lineCap = "round";
21764
- context.lineJoin = "miter";
21765
- context.miterLimit = 10;
21766
- context.fillStyle = "#FFFFFF";
21767
- UtilFont.measure(context, font);
21768
- var offsetX = 7;
21769
- var offsetY = Math.round((characterSize - (font.ascent + font.descent)) * 0.5 + font.ascent);
21770
- var x = 0;
21771
- var y = 0;
21772
- for (var id in characters) {
21773
- var data = characters[id];
21774
- var advance = context.measureText(data.character).width;
21775
- var characterWidth = Math.ceil(offsetX + advance + offsetX);
21776
- var characterHeight = characterSize;
21777
- if (width <= x + characterWidth) {
21778
- x = 0;
21779
- y += characterSize;
21749
+ context_1.font = fontStyle;
21750
+ context_1.textAlign = "left";
21751
+ context_1.textBaseline = "alphabetic";
21752
+ context_1.lineWidth = 0;
21753
+ context_1.lineCap = "round";
21754
+ context_1.lineJoin = "miter";
21755
+ context_1.miterLimit = 10;
21756
+ context_1.fillStyle = "#FFFFFF";
21757
+ UtilFont.measure(context_1, font);
21758
+ var offsetX_1 = 7;
21759
+ var offsetY_1 = Math.round((fontSize_1 - (font.ascent + font.descent)) * 0.5 + font.ascent);
21760
+ var x_1 = 0;
21761
+ var y_1 = 0;
21762
+ characters.forEach(function (character) {
21763
+ var advance = context_1.measureText(character.character).width;
21764
+ var characterWidth = Math.ceil(offsetX_1 + advance + offsetX_1);
21765
+ var characterHeight = fontSize_1;
21766
+ if (width_1 <= x_1 + characterWidth) {
21767
+ x_1 = 0;
21768
+ y_1 += fontSize_1;
21780
21769
  }
21781
- data.x = x;
21782
- data.y = y;
21783
- data.width = characterWidth;
21784
- data.height = characterHeight;
21785
- data.advance = advance;
21786
- data.origin.x = x + offsetX;
21787
- data.origin.y = y + offsetY;
21788
- x += characterWidth;
21789
- }
21790
- var height = (this._height = y + characterSize);
21770
+ character.x = x_1;
21771
+ character.y = y_1;
21772
+ character.width = characterWidth;
21773
+ character.height = characterHeight;
21774
+ character.advance = advance;
21775
+ character.origin.x = x_1 + offsetX_1;
21776
+ character.origin.y = y_1 + offsetY_1;
21777
+ x_1 += characterWidth;
21778
+ });
21779
+ var height = (this._height = y_1 + fontSize_1);
21791
21780
  // Make a input canvas
21792
21781
  // Here, we need to reset the context because
21793
21782
  // context settings will be lost when we set the width/height.
21794
- canvas.width = width;
21783
+ canvas.width = width_1;
21795
21784
  canvas.height = height;
21796
- context.font = fontStyle;
21797
- context.textAlign = "left";
21798
- context.textBaseline = "alphabetic";
21799
- context.lineWidth = 0;
21800
- context.lineCap = "round";
21801
- context.lineJoin = "miter";
21802
- context.miterLimit = 10;
21803
- context.fillStyle = "#FFFFFF";
21804
- context.clearRect(0, 0, width, height);
21805
- for (var id in characters) {
21806
- var data = characters[id];
21807
- context.fillText(data.character, data.origin.x, data.origin.y);
21808
- }
21785
+ context_1.font = fontStyle;
21786
+ context_1.textAlign = "left";
21787
+ context_1.textBaseline = "alphabetic";
21788
+ context_1.lineWidth = 0;
21789
+ context_1.lineCap = "round";
21790
+ context_1.lineJoin = "miter";
21791
+ context_1.miterLimit = 10;
21792
+ context_1.fillStyle = "#FFFFFF";
21793
+ context_1.clearRect(0, 0, width_1, height);
21794
+ characters.forEach(function (character) {
21795
+ context_1.fillText(character.character, character.origin.x, character.origin.y);
21796
+ });
21809
21797
  // Convert to SDF font texture
21810
- generator.updateTexture(width, height, canvas);
21798
+ generator.updateTexture(width_1, height, canvas);
21811
21799
  generator.render();
21812
21800
  generator.read(canvas);
21813
21801
  return true;
@@ -21818,7 +21806,7 @@
21818
21806
  };
21819
21807
  Object.defineProperty(DynamicSDFFontAtlas.prototype, "length", {
21820
21808
  get: function () {
21821
- return this._length;
21809
+ return this._characters.size;
21822
21810
  },
21823
21811
  enumerable: false,
21824
21812
  configurable: true
@@ -21843,10 +21831,7 @@
21843
21831
  if (canvas != null) {
21844
21832
  this._canvas = null;
21845
21833
  }
21846
- var characters = this._characters;
21847
- for (var id in characters) {
21848
- delete characters[id];
21849
- }
21834
+ this._characters.clear();
21850
21835
  };
21851
21836
  DynamicSDFFontAtlas.prototype.toPowerOf2 = function (size) {
21852
21837
  var result = 32;
@@ -21864,52 +21849,45 @@
21864
21849
  */
21865
21850
  var DynamicSDFFontAtlases = /** @class */ (function () {
21866
21851
  function DynamicSDFFontAtlases() {
21867
- this._atlases = {};
21852
+ this._atlases = new Map();
21868
21853
  }
21869
21854
  DynamicSDFFontAtlases.prototype.begin = function () {
21870
- var atlases = this._atlases;
21871
- for (var family in atlases) {
21872
- var atlas = atlases[family];
21855
+ this._atlases.forEach(function (atlas) {
21873
21856
  atlas.begin();
21874
- }
21857
+ });
21875
21858
  };
21876
21859
  DynamicSDFFontAtlases.prototype.end = function () {
21877
21860
  var atlases = this._atlases;
21878
- for (var family in atlases) {
21879
- var atlas = atlases[family];
21880
- if (0 < atlas.length) {
21881
- atlas.addAscii();
21882
- }
21861
+ atlases.forEach(function (atlas, family) {
21883
21862
  atlas.end();
21884
21863
  if (atlas.length <= 0) {
21885
21864
  atlas.destroy();
21886
- delete atlases[family];
21865
+ atlases.delete(family);
21887
21866
  }
21888
- }
21867
+ });
21889
21868
  };
21890
- DynamicSDFFontAtlases.prototype.add = function (family, targets) {
21891
- var atlas = this._atlases[family];
21869
+ DynamicSDFFontAtlases.prototype.add = function (family, characters, nacharacters) {
21870
+ var atlases = this._atlases;
21871
+ var atlas = atlases.get(family);
21892
21872
  if (atlas != null) {
21893
- atlas.add(targets);
21873
+ atlas.add(characters, nacharacters);
21894
21874
  }
21895
21875
  else {
21896
21876
  var newAtlas = new DynamicSDFFontAtlas(family);
21897
- newAtlas.add(targets);
21898
- this._atlases[family] = newAtlas;
21877
+ newAtlas.add(characters, nacharacters);
21878
+ atlases.set(family, newAtlas);
21899
21879
  }
21900
21880
  };
21901
21881
  DynamicSDFFontAtlases.prototype.get = function (family) {
21902
- var atlas = this._atlases[family];
21882
+ var atlas = this._atlases.get(family);
21903
21883
  if (atlas != null) {
21904
21884
  return atlas;
21905
21885
  }
21906
21886
  return null;
21907
21887
  };
21908
21888
  DynamicSDFFontAtlases.prototype.update = function (baseAtlas) {
21909
- var atlases = this._atlases;
21910
21889
  var baseTexture = baseAtlas.getBaseTexture();
21911
- for (var family in atlases) {
21912
- var atlas = atlases[family];
21890
+ this._atlases.forEach(function (atlas) {
21913
21891
  if (atlas.update()) {
21914
21892
  var atlasId = atlas.id;
21915
21893
  var item = baseAtlas.get(atlasId);
@@ -21927,15 +21905,14 @@
21927
21905
  baseAtlas.set(atlasId, new DynamicAtlasItemFontAtlas(atlas, baseTexture));
21928
21906
  }
21929
21907
  }
21930
- }
21908
+ });
21931
21909
  };
21932
21910
  DynamicSDFFontAtlases.prototype.destroy = function () {
21933
21911
  var atlases = this._atlases;
21934
- for (var family in atlases) {
21935
- var atlas = atlases[family];
21912
+ atlases.forEach(function (atlas) {
21936
21913
  atlas.destroy();
21937
- }
21938
- this._atlases = {};
21914
+ });
21915
+ atlases.clear();
21939
21916
  };
21940
21917
  return DynamicSDFFontAtlases;
21941
21918
  }());
@@ -22323,9 +22300,9 @@
22323
22300
  }
22324
22301
  // Font texture atlas
22325
22302
  var text = shape.text;
22326
- var textValue = text.value;
22327
- if (0 < textValue.length) {
22328
- fontAtlases.add(text.family, textValue);
22303
+ var textCharacters = text.characters;
22304
+ if (0 < textCharacters.length) {
22305
+ fontAtlases.add(text.family, textCharacters, text.nacharacters);
22329
22306
  }
22330
22307
  };
22331
22308
  EShapeRenderer.prototype.updateAtlases = function (shapes, atlas, fontAtlases, defaultTexture, baseTexture) {
@@ -28692,6 +28669,74 @@
28692
28669
  return DDynamicTextMeasureResult;
28693
28670
  }());
28694
28671
 
28672
+ /*
28673
+ * Copyright (C) 2019 Toshiba Corporation
28674
+ * SPDX-License-Identifier: Apache-2.0
28675
+ */
28676
+ var UtilCharacterIterator = /** @class */ (function () {
28677
+ function UtilCharacterIterator() {
28678
+ this.target = "";
28679
+ this.position = 0;
28680
+ }
28681
+ UtilCharacterIterator.prototype.init = function (target) {
28682
+ this.target = target;
28683
+ this.position = 0;
28684
+ };
28685
+ UtilCharacterIterator.prototype.hasNext = function () {
28686
+ return this.position < this.target.length;
28687
+ };
28688
+ UtilCharacterIterator.prototype.findNextBreak = function (target, istart) {
28689
+ var iend = target.length;
28690
+ for (var i = istart; i < iend; ++i) {
28691
+ var code = target.charCodeAt(i);
28692
+ if (!this.isLowSurrogate(code) && !this.isVariationSelector(code)) {
28693
+ return i;
28694
+ }
28695
+ }
28696
+ return iend;
28697
+ };
28698
+ UtilCharacterIterator.prototype.isHighSurrogate = function (code) {
28699
+ return 0xd800 <= code && code <= 0xdbff;
28700
+ };
28701
+ UtilCharacterIterator.prototype.isLowSurrogate = function (code) {
28702
+ return 0xdc00 <= code && code <= 0xdfff;
28703
+ };
28704
+ UtilCharacterIterator.prototype.isVariationSelector = function (code) {
28705
+ return 0xfe00 <= code && code <= 0xfe0f;
28706
+ };
28707
+ UtilCharacterIterator.prototype.next = function () {
28708
+ var target = this.target;
28709
+ var position = this.position;
28710
+ var nextBreak = this.findNextBreak(target, position + 1);
28711
+ var result = target.substring(position, nextBreak);
28712
+ this.position = nextBreak;
28713
+ return result;
28714
+ };
28715
+ /**
28716
+ * Closes this iterator.
28717
+ *
28718
+ * @returns true if closed.
28719
+ */
28720
+ UtilCharacterIterator.prototype.close = function () {
28721
+ var length = this.target.length;
28722
+ if (this.position < length) {
28723
+ this.position = length;
28724
+ return true;
28725
+ }
28726
+ return false;
28727
+ };
28728
+ UtilCharacterIterator.from = function (target) {
28729
+ if (UtilCharacterIterator._instance == null) {
28730
+ UtilCharacterIterator._instance = new UtilCharacterIterator();
28731
+ }
28732
+ var instance = UtilCharacterIterator._instance;
28733
+ instance.init(target);
28734
+ return instance;
28735
+ };
28736
+ UtilCharacterIterator._instance = null;
28737
+ return UtilCharacterIterator;
28738
+ }());
28739
+
28695
28740
  /*
28696
28741
  * Copyright (C) 2019 Toshiba Corporation
28697
28742
  * SPDX-License-Identifier: Apache-2.0
@@ -28702,7 +28747,6 @@
28702
28747
  BREAK_ALL: 2
28703
28748
  };
28704
28749
 
28705
- var NEW_LINE = "\n";
28706
28750
  var DDynamicTextMeasure = /** @class */ (function () {
28707
28751
  function DDynamicTextMeasure() {
28708
28752
  }
@@ -28772,7 +28816,7 @@
28772
28816
  while (iterator.hasNext()) {
28773
28817
  var characterPosition = iterator.position;
28774
28818
  var character = iterator.next();
28775
- if (character === NEW_LINE) {
28819
+ if (character === Character.NEW_LINE) {
28776
28820
  if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
28777
28821
  result.newLine(lineHeight);
28778
28822
  }
@@ -28804,7 +28848,7 @@
28804
28848
  DDynamicTextMeasure.measure1b = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
28805
28849
  while (iterator.hasNext()) {
28806
28850
  var character = iterator.next();
28807
- if (character === NEW_LINE) {
28851
+ if (character === Character.NEW_LINE) {
28808
28852
  if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
28809
28853
  result.newLine(lineHeight);
28810
28854
  }
@@ -28835,7 +28879,7 @@
28835
28879
  DDynamicTextMeasure.measure1 = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
28836
28880
  while (iterator.hasNext()) {
28837
28881
  var character = iterator.next();
28838
- if (character === NEW_LINE) {
28882
+ if (character === Character.NEW_LINE) {
28839
28883
  if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
28840
28884
  result.newLine(lineHeight);
28841
28885
  }
@@ -28867,7 +28911,7 @@
28867
28911
  while (iterator.hasNext()) {
28868
28912
  var characterPosition = iterator.position;
28869
28913
  var character = iterator.next();
28870
- if (character === NEW_LINE) {
28914
+ if (character === Character.NEW_LINE) {
28871
28915
  result.newLine(lineHeight);
28872
28916
  }
28873
28917
  else {
@@ -28889,7 +28933,7 @@
28889
28933
  DDynamicTextMeasure.measure2b = function (iterator, clippingWidth, lineHeight, atlas, result) {
28890
28934
  while (iterator.hasNext()) {
28891
28935
  var character = iterator.next();
28892
- if (character === NEW_LINE) {
28936
+ if (character === Character.NEW_LINE) {
28893
28937
  result.newLine(lineHeight);
28894
28938
  }
28895
28939
  else {
@@ -28910,7 +28954,7 @@
28910
28954
  DDynamicTextMeasure.measure2 = function (iterator, clippingWidth, lineHeight, atlas, result) {
28911
28955
  while (iterator.hasNext()) {
28912
28956
  var character = iterator.next();
28913
- if (character === NEW_LINE) {
28957
+ if (character === Character.NEW_LINE) {
28914
28958
  result.newLine(lineHeight);
28915
28959
  }
28916
28960
  else {
@@ -28930,7 +28974,7 @@
28930
28974
  DDynamicTextMeasure.measure3 = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
28931
28975
  while (iterator.hasNext()) {
28932
28976
  var character = iterator.next();
28933
- if (character === NEW_LINE) {
28977
+ if (character === Character.NEW_LINE) {
28934
28978
  if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
28935
28979
  result.newLine(lineHeight);
28936
28980
  }
@@ -28954,7 +28998,7 @@
28954
28998
  DDynamicTextMeasure.measure4 = function (iterator, lineHeight, atlas, result) {
28955
28999
  while (iterator.hasNext()) {
28956
29000
  var character = iterator.next();
28957
- if (character === NEW_LINE) {
29001
+ if (character === Character.NEW_LINE) {
28958
29002
  result.newLine(lineHeight);
28959
29003
  }
28960
29004
  else {
@@ -28967,7 +29011,7 @@
28967
29011
  };
28968
29012
  DDynamicTextMeasure.measure5 = function (iterator, clippingWidth, lineHeight, atlas, result, close) {
28969
29013
  result.clipped = true;
28970
- var dots = atlas.get("...");
29014
+ var dots = atlas.get(Character.DOTS);
28971
29015
  if (dots != null) {
28972
29016
  while (!result.isPushable(clippingWidth, dots)) {
28973
29017
  if (!result.pop()) {
@@ -28983,7 +29027,7 @@
28983
29027
  }
28984
29028
  else {
28985
29029
  while (iterator.hasNext()) {
28986
- if (iterator.next() === NEW_LINE) {
29030
+ if (iterator.next() === Character.NEW_LINE) {
28987
29031
  result.newLine(lineHeight);
28988
29032
  break;
28989
29033
  }
@@ -29067,47 +29111,61 @@
29067
29111
  var DDynamicTextGeometry = /** @class */ (function (_super) {
29068
29112
  __extends(DDynamicTextGeometry, _super);
29069
29113
  function DDynamicTextGeometry() {
29070
- var _this = _super.call(this, new Float32Array(64), new Float32Array(64), new Uint16Array(48)) || this;
29114
+ var _a, _b, _c;
29115
+ var _this = _super.call(this, ((_a = DDynamicTextGeometry.VERTICES) !== null && _a !== void 0 ? _a : (DDynamicTextGeometry.VERTICES = new Float32Array(0))), ((_b = DDynamicTextGeometry.UVS) !== null && _b !== void 0 ? _b : (DDynamicTextGeometry.UVS = new Float32Array(0))), ((_c = DDynamicTextGeometry.INDICES) !== null && _c !== void 0 ? _c : (DDynamicTextGeometry.INDICES = new Uint16Array(0)))) || this;
29071
29116
  _this.width = 0;
29072
29117
  _this.height = 0;
29073
29118
  _this.scale = 1;
29074
29119
  _this.scaled = false;
29075
29120
  _this.clipped = false;
29121
+ _this.vertexBuffer = _this.getBuffer("aVertexPosition");
29122
+ _this.vertices = DDynamicTextGeometry.VERTICES;
29123
+ _this.uvBuffer = _this.getBuffer("aTextureCoord");
29124
+ _this.uvs = DDynamicTextGeometry.UVS;
29125
+ _this.indexBuffer = _this.getIndex();
29126
+ _this.indices = DDynamicTextGeometry.INDICES;
29127
+ _this.nchars = 0;
29076
29128
  return _this;
29077
29129
  }
29078
29130
  DDynamicTextGeometry.prototype.update = function (text, atlas, modifier) {
29079
- var vertexBuffer = this.getBuffer("aVertexPosition");
29080
- var uvBuffer = this.getBuffer("aTextureCoord");
29081
- var indexBuffer = this.getIndex();
29082
29131
  var result = DDynamicTextMeasure.measure(text, atlas, modifier);
29083
- var requiredTextSize = Math.ceil(result.count / 8) << 3;
29084
- var requiredVertexSize = requiredTextSize << 3;
29085
- if (vertexBuffer.data.length < requiredVertexSize) {
29086
- vertexBuffer.data = new Float32Array(requiredVertexSize);
29087
- uvBuffer.data = new Float32Array(requiredVertexSize);
29088
- }
29089
- var requiredIndexSize = requiredTextSize * 6;
29090
- if (indexBuffer.data.length < requiredIndexSize) {
29091
- indexBuffer.data = new Uint16Array(requiredIndexSize);
29092
- }
29093
- var vertices = vertexBuffer.data;
29094
- var uvs = uvBuffer.data;
29095
- var indices = indexBuffer.data;
29132
+ var resultCount = result.count;
29133
+ var nchars = ((resultCount >> 3) + (resultCount & 0x7 ? 1 : 0)) << 3;
29134
+ if (this.nchars < nchars) {
29135
+ this.nchars = nchars;
29136
+ var nvertex = nchars << 3;
29137
+ this.vertices = new Float32Array(nvertex);
29138
+ this.uvs = new Float32Array(nvertex);
29139
+ this.vertexBuffer.data = this.vertices;
29140
+ this.uvBuffer.data = this.uvs;
29141
+ var nindex = (nchars << 2) + (nchars << 1);
29142
+ this.indices = new Uint16Array(nindex);
29143
+ this.indexBuffer.data = this.indices;
29144
+ this.initIndices(this.indices);
29145
+ this.indexBuffer.update();
29146
+ }
29147
+ else {
29148
+ nchars = this.nchars;
29149
+ }
29150
+ if (nchars <= 0) {
29151
+ return;
29152
+ }
29153
+ var vertices = this.vertices;
29154
+ var uvs = this.uvs;
29096
29155
  if (atlas != null) {
29097
- var count = result.count;
29098
29156
  var characters = result.characters;
29099
29157
  var scale = result.scale;
29100
- for (var i = 0; i < count; ++i) {
29158
+ var fw = 1 / atlas.width;
29159
+ var fh = 1 / atlas.height;
29160
+ for (var i = 0; i < resultCount; ++i) {
29101
29161
  var character = characters[i];
29102
29162
  var cx = character.x;
29103
29163
  var cy = character.y;
29104
29164
  var cc = character.character;
29105
- var w = atlas.width;
29106
- var h = atlas.height;
29107
- this.writeCharacter(vertices, uvs, indices, i, cx, cy, scale, cc, w, h);
29165
+ this.fill(vertices, uvs, i, cx, cy, scale, cc, fw, fh);
29108
29166
  }
29109
- for (var i = count, imax = vertices.length >> 3; i < imax; ++i) {
29110
- this.writeCharacterEmpty(vertices, uvs, indices, i);
29167
+ for (var i = resultCount; i < nchars; ++i) {
29168
+ this.fillBlank(vertices, uvs, i);
29111
29169
  }
29112
29170
  this.width = result.width * scale;
29113
29171
  this.height = result.height * scale;
@@ -29116,8 +29174,8 @@
29116
29174
  this.clipped = result.clipped;
29117
29175
  }
29118
29176
  else {
29119
- for (var i = 0, imax = vertices.length >> 3; i < imax; ++i) {
29120
- this.writeCharacterEmpty(vertices, uvs, indices, i);
29177
+ for (var i = 0; i < nchars; ++i) {
29178
+ this.fillBlank(vertices, uvs, i);
29121
29179
  }
29122
29180
  this.width = 0;
29123
29181
  this.height = 0;
@@ -29125,11 +29183,10 @@
29125
29183
  this.scaled = false;
29126
29184
  this.clipped = false;
29127
29185
  }
29128
- vertexBuffer.update();
29129
- uvBuffer.update();
29130
- indexBuffer.update();
29186
+ this.vertexBuffer.update();
29187
+ this.uvBuffer.update();
29131
29188
  };
29132
- DDynamicTextGeometry.prototype.writeCharacter = function (vertices, uvs, indices, index, x, y, scale, character, width, height) {
29189
+ DDynamicTextGeometry.prototype.fill = function (vertices, uvs, index, x, y, scale, character, fw, fh) {
29133
29190
  var cx = character.x;
29134
29191
  var cy = character.y;
29135
29192
  var cw = character.width;
@@ -29148,10 +29205,10 @@
29148
29205
  vertices[iv + 5] = y1;
29149
29206
  vertices[iv + 6] = x0;
29150
29207
  vertices[iv + 7] = y1;
29151
- var u0 = cx / width;
29152
- var v0 = cy / height;
29153
- var u1 = (cx + cw) / width;
29154
- var v1 = (cy + ch) / height;
29208
+ var u0 = cx * fw;
29209
+ var v0 = cy * fh;
29210
+ var u1 = (cx + cw) * fw;
29211
+ var v1 = (cy + ch) * fh;
29155
29212
  uvs[iv + 0] = u0;
29156
29213
  uvs[iv + 1] = v0;
29157
29214
  uvs[iv + 2] = u1;
@@ -29160,16 +29217,8 @@
29160
29217
  uvs[iv + 5] = v1;
29161
29218
  uvs[iv + 6] = u0;
29162
29219
  uvs[iv + 7] = v1;
29163
- var ii = index * 6;
29164
- var vo = index << 2;
29165
- indices[ii + 0] = vo + 0;
29166
- indices[ii + 1] = vo + 1;
29167
- indices[ii + 2] = vo + 3;
29168
- indices[ii + 3] = vo + 1;
29169
- indices[ii + 4] = vo + 2;
29170
- indices[ii + 5] = vo + 3;
29171
- };
29172
- DDynamicTextGeometry.prototype.writeCharacterEmpty = function (vertices, uvs, indices, index) {
29220
+ };
29221
+ DDynamicTextGeometry.prototype.fillBlank = function (vertices, uvs, index) {
29173
29222
  var iv = index << 3;
29174
29223
  vertices[iv + 0] = 0;
29175
29224
  vertices[iv + 1] = 0;
@@ -29187,14 +29236,16 @@
29187
29236
  uvs[iv + 5] = 0;
29188
29237
  uvs[iv + 6] = 0;
29189
29238
  uvs[iv + 7] = 0;
29190
- var ii = index * 6;
29191
- var vo = index << 2;
29192
- indices[ii + 0] = vo + 0;
29193
- indices[ii + 1] = vo + 1;
29194
- indices[ii + 2] = vo + 3;
29195
- indices[ii + 3] = vo + 1;
29196
- indices[ii + 4] = vo + 2;
29197
- indices[ii + 5] = vo + 3;
29239
+ };
29240
+ DDynamicTextGeometry.prototype.initIndices = function (indices) {
29241
+ for (var iv = 0, ivmax = this.nchars << 2, ii = 0; iv < ivmax; iv += 4, ii += 6) {
29242
+ indices[ii] = iv;
29243
+ indices[ii + 1] = iv + 1;
29244
+ indices[ii + 2] = iv + 3;
29245
+ indices[ii + 3] = iv + 1;
29246
+ indices[ii + 4] = iv + 2;
29247
+ indices[ii + 5] = iv + 3;
29248
+ }
29198
29249
  };
29199
29250
  return DDynamicTextGeometry;
29200
29251
  }(pixi_js.MeshGeometry));
@@ -48249,26 +48300,26 @@
48249
48300
  var padding = this.toPadding(fontSize);
48250
48301
  this._padding = padding;
48251
48302
  this._font = new DynamicFontAtlasFont(fontId, fontSize, fontColor, padding);
48252
- this._characters = {};
48253
- this._length = 0;
48254
48303
  this._unrefCount = 0;
48255
48304
  this._width = 1;
48256
48305
  this._height = 1;
48257
- this._revision = 0;
48258
48306
  this._revisionUpdated = 0;
48259
48307
  this._texture = pixi_js.Texture.from(this._canvas, {
48260
48308
  mipmap: pixi_js.MIPMAP_MODES.OFF,
48261
48309
  resolution: resolution,
48262
48310
  scaleMode: pixi_js.SCALE_MODES.NEAREST
48263
48311
  });
48264
- var characters = this._characters;
48265
- this.add_(" ", " ", characters, DynamicFontAtlasCharacterType.SPACE_R);
48266
- this.add_("\t", " ", characters, DynamicFontAtlasCharacterType.SPACE_R);
48267
- this.add_("...", "...", characters, DynamicFontAtlasCharacterType.LETTER_RNB);
48268
- for (var i = 0, imax = ASCII_CHARACTERS.length; i < imax; ++i) {
48269
- var char = ASCII_CHARACTERS[i];
48270
- this.add_(char, char, characters, DynamicFontAtlasCharacterType.LETTER_RNB);
48271
- }
48312
+ var characters = new Map();
48313
+ characters.set(Character.SPACE, this.newChar(Character.SPACE, DynamicFontAtlasCharacterType.SPACE_R));
48314
+ characters.set(Character.TAB, this.newChar(Character.SOFT_TAB, DynamicFontAtlasCharacterType.SPACE_R));
48315
+ characters.set(Character.DOTS, this.newChar(Character.DOTS, DynamicFontAtlasCharacterType.LETTER_RNB));
48316
+ for (var i = 0, imax = Character.ASCII.length; i < imax; ++i) {
48317
+ var ac = Character.ASCII[i];
48318
+ characters.set(ac, this.newChar(ac, DynamicFontAtlasCharacterType.LETTER_RNB));
48319
+ }
48320
+ this._characters = characters;
48321
+ this._createds = new Map();
48322
+ this._revision = 1;
48272
48323
  }
48273
48324
  DynamicFontAtlas.prototype.toPadding = function (fontSize) {
48274
48325
  return Math.max(3, Math.ceil(fontSize * 0.2));
@@ -48322,86 +48373,106 @@
48322
48373
  enumerable: false,
48323
48374
  configurable: true
48324
48375
  });
48325
- DynamicFontAtlas.prototype.add_ = function (id, character, characters, type) {
48326
- if (!this.isIgnored(character)) {
48327
- var data = characters[id];
48328
- if (data != null) {
48329
- if (!(data.type & DynamicFontAtlasCharacterType.RESERVED)) {
48330
- if (data.ref === 0) {
48376
+ DynamicFontAtlas.prototype.newChar = function (character, type) {
48377
+ var advance = this.getAdvance(character);
48378
+ var padding = this._padding;
48379
+ var width = Math.ceil(padding + advance + padding);
48380
+ var height = this.font.height;
48381
+ return new DynamicFontAtlasCharacter(type, character, -width, // Setting X and Y to zeros leads to render the character at the UV coordinate (0, 0).
48382
+ -height, width, height, advance);
48383
+ };
48384
+ DynamicFontAtlas.prototype.add = function (characters, type) {
48385
+ var cs = this._characters;
48386
+ var cds = this._createds;
48387
+ for (var i = 0, imax = characters.length; i < imax;) {
48388
+ if (characters.charCodeAt(i) <= 0xff) {
48389
+ // Ignore ASCII characters
48390
+ i += 1;
48391
+ continue;
48392
+ }
48393
+ var j = i + 1;
48394
+ for (; j < imax; ++j) {
48395
+ var cc = characters.charCodeAt(j);
48396
+ if ((0xdc00 <= cc && cc <= 0xdfff) || (0xfe00 <= cc && cc <= 0xfe0f)) {
48397
+ // Low surrogate
48398
+ // Variation selector
48399
+ continue;
48400
+ }
48401
+ break;
48402
+ }
48403
+ // Increment the reference count or create a new one
48404
+ var nac = characters.substring(i, j);
48405
+ var c = cs.get(nac);
48406
+ if (c != null) {
48407
+ if (!(c.type & DynamicFontAtlasCharacterType.RESERVED)) {
48408
+ if (c.ref === 0) {
48331
48409
  this._unrefCount -= 1;
48332
48410
  }
48333
- data.ref += 1;
48411
+ c.ref += 1;
48334
48412
  }
48335
48413
  }
48336
48414
  else {
48337
- var advance = this.getAdvance(character);
48338
- var padding = this._padding;
48339
- var width = Math.ceil(padding + advance + padding);
48340
- var height = this.font.height;
48341
- characters[id] = new DynamicFontAtlasCharacter(type, character, -width, // Setting X and Y to zeros leads to render the letter at the UV coordinate (0, 0).
48342
- -height, width, height, advance);
48343
- this._length += 1;
48415
+ var cd = cds.get(nac);
48416
+ if (cd != null) {
48417
+ cd.ref = 1;
48418
+ cs.set(nac, cd);
48419
+ }
48420
+ else {
48421
+ var newCharacter = this.newChar(nac, type);
48422
+ cs.set(nac, newCharacter);
48423
+ cds.set(nac, newCharacter);
48424
+ }
48344
48425
  this._revision += 1;
48345
48426
  }
48427
+ // Go to the next
48428
+ i = j;
48346
48429
  }
48347
48430
  };
48348
- DynamicFontAtlas.prototype.isIgnored = function (character) {
48349
- switch (character) {
48350
- case "\n": // Line feed
48351
- return true;
48352
- case "\r": // Carriage return
48353
- return true;
48354
- case "\v": // Vertical tab
48355
- return true;
48356
- case "\f": // Form feed
48357
- return true;
48358
- case "\u0085": // Next line
48359
- return true;
48360
- }
48361
- return false;
48362
- };
48363
- DynamicFontAtlas.prototype.remove_ = function (id, characters) {
48364
- var data = characters[id];
48365
- if (data != null) {
48366
- if (!(data.type & DynamicFontAtlasCharacterType.RESERVED) && 0 < data.ref) {
48367
- data.ref -= 1;
48368
- if (data.ref === 0) {
48431
+ DynamicFontAtlas.prototype.remove = function (characters) {
48432
+ var cs = this._characters;
48433
+ for (var i = 0, imax = characters.length; i < imax;) {
48434
+ if (characters.charCodeAt(i) <= 0xff) {
48435
+ // Ignore ASCII characters
48436
+ i += 1;
48437
+ continue;
48438
+ }
48439
+ var j = i + 1;
48440
+ for (; j < imax; ++j) {
48441
+ var cc = characters.charCodeAt(j);
48442
+ if ((0xdc00 <= cc && cc <= 0xdfff) || (0xfe00 <= cc && cc <= 0xfe0f)) {
48443
+ // Low surrogate
48444
+ // Variation selector
48445
+ continue;
48446
+ }
48447
+ break;
48448
+ }
48449
+ // Decrement the reference count
48450
+ var nac = characters.substring(i, j);
48451
+ var c = cs.get(nac);
48452
+ if (c != null && 0 < c.ref && !(c.type & DynamicFontAtlasCharacterType.RESERVED)) {
48453
+ c.ref -= 1;
48454
+ if (c.ref === 0) {
48369
48455
  this._unrefCount += 1;
48370
48456
  }
48371
48457
  }
48458
+ // Go to the next
48459
+ i = j;
48372
48460
  }
48373
48461
  };
48374
- DynamicFontAtlas.prototype.cleanup_ = function () {
48375
- if (this._length >> 1 <= this._unrefCount) {
48376
- var characters = this._characters;
48377
- for (var character in characters) {
48378
- if (characters[character].ref <= 0) {
48379
- delete characters[character];
48462
+ DynamicFontAtlas.prototype.cleanup = function () {
48463
+ var characters = this._characters;
48464
+ if (characters.size >> 1 <= this._unrefCount) {
48465
+ characters.forEach(function (char, id) {
48466
+ if (char.ref <= 0) {
48467
+ characters.delete(id);
48380
48468
  }
48381
- }
48382
- this._length -= this._unrefCount;
48469
+ });
48383
48470
  this._revision += 1;
48384
48471
  this._unrefCount = 0;
48385
48472
  }
48386
48473
  };
48387
- DynamicFontAtlas.prototype.add = function (targets, type) {
48388
- if (type === void 0) { type = DynamicFontAtlasCharacterType.LETTER; }
48389
- var characters = this._characters;
48390
- var iterator = UtilCharacterIterator.from(targets);
48391
- while (iterator.hasNext()) {
48392
- var character = iterator.next();
48393
- this.add_(character, character, characters, type);
48394
- }
48395
- };
48396
- DynamicFontAtlas.prototype.remove = function (targets) {
48397
- var characters = this._characters;
48398
- var iterator = UtilCharacterIterator.from(targets);
48399
- while (iterator.hasNext()) {
48400
- this.remove_(iterator.next(), characters);
48401
- }
48402
- };
48403
48474
  DynamicFontAtlas.prototype.get = function (id) {
48404
- return this._characters[id];
48475
+ return this._characters.get(id);
48405
48476
  };
48406
48477
  DynamicFontAtlas.prototype.getAdvance = function (target) {
48407
48478
  var context = this.getContext();
@@ -48440,52 +48511,50 @@
48440
48511
  return context;
48441
48512
  };
48442
48513
  DynamicFontAtlas.prototype.update = function () {
48443
- this.cleanup_();
48514
+ this.cleanup();
48444
48515
  if (this._revisionUpdated < this._revision) {
48445
48516
  this._revisionUpdated = this._revision;
48446
48517
  var canvas = this._canvas;
48447
48518
  if (canvas != null) {
48448
48519
  var font = this._font;
48449
- var fontHeight = font.height;
48520
+ var fontHeight_1 = font.height;
48450
48521
  var characters = this._characters;
48451
- var width = (this._width = this.toPowerOf2(Math.ceil(Math.sqrt(this._length)) * fontHeight));
48452
- var offsetX = this._padding;
48453
- var x = 0;
48454
- var y = 0;
48455
- for (var key in characters) {
48456
- var character = characters[key];
48457
- if (width <= x + character.width) {
48458
- x = 0;
48459
- y += fontHeight;
48522
+ var width_1 = (this._width = this.toPowerOf2(Math.ceil(Math.sqrt(characters.size)) * fontHeight_1));
48523
+ var offsetX_1 = this._padding;
48524
+ var x_1 = 0;
48525
+ var y_1 = 0;
48526
+ characters.forEach(function (character) {
48527
+ if (width_1 <= x_1 + character.width) {
48528
+ x_1 = 0;
48529
+ y_1 += fontHeight_1;
48460
48530
  }
48461
- character.x = x;
48462
- character.y = y;
48463
- character.origin.x = x + offsetX;
48464
- x += character.width;
48465
- }
48466
- var height = (this._height = y + fontHeight);
48531
+ character.x = x_1;
48532
+ character.y = y_1;
48533
+ character.origin.x = x_1 + offsetX_1;
48534
+ x_1 += character.width;
48535
+ });
48536
+ var height = (this._height = y_1 + fontHeight_1);
48467
48537
  // Make an input canvas
48468
48538
  // Here, we need to reset the context because
48469
48539
  // context settings will be lost when we set the width/height.
48470
48540
  var baseTexture = this._texture.baseTexture;
48471
48541
  var resolution = baseTexture.resolution;
48472
- var realWidth = Math.ceil(width * resolution);
48542
+ var realWidth = Math.ceil(width_1 * resolution);
48473
48543
  var realHeight = Math.ceil(height * resolution);
48474
48544
  canvas.width = realWidth;
48475
48545
  canvas.height = realHeight;
48476
- var context = this.getContext();
48477
- if (context != null) {
48478
- UtilFont.measure(context, font);
48479
- var offsetY = Math.round((fontHeight - (font.ascent + font.descent)) * 0.5 + font.ascent);
48480
- context.save();
48481
- context.scale(resolution, resolution);
48482
- context.clearRect(0, 0, width, height);
48483
- for (var key in characters) {
48484
- var character = characters[key];
48485
- character.origin.y = character.y + offsetY;
48486
- context.fillText(key, character.origin.x, character.origin.y);
48487
- }
48488
- context.restore();
48546
+ var context_1 = this.getContext();
48547
+ if (context_1 != null) {
48548
+ UtilFont.measure(context_1, font);
48549
+ var offsetY_1 = Math.round((fontHeight_1 - (font.ascent + font.descent)) * 0.5 + font.ascent);
48550
+ context_1.save();
48551
+ context_1.scale(resolution, resolution);
48552
+ context_1.clearRect(0, 0, width_1, height);
48553
+ characters.forEach(function (character) {
48554
+ character.origin.y = character.y + offsetY_1;
48555
+ context_1.fillText(character.character, character.origin.x, character.origin.y);
48556
+ });
48557
+ context_1.restore();
48489
48558
  }
48490
48559
  baseTexture.setRealSize(realWidth, realHeight);
48491
48560
  return true;
@@ -48501,7 +48570,7 @@
48501
48570
  };
48502
48571
  Object.defineProperty(DynamicFontAtlas.prototype, "length", {
48503
48572
  get: function () {
48504
- return this._length;
48573
+ return this._characters.size;
48505
48574
  },
48506
48575
  enumerable: false,
48507
48576
  configurable: true
@@ -48511,10 +48580,9 @@
48511
48580
  if (canvas != null) {
48512
48581
  this._canvas = null;
48513
48582
  }
48514
- var characters = this._characters;
48515
- for (var character in characters) {
48516
- delete characters[character];
48517
- }
48583
+ this._characters.clear();
48584
+ this._createds.clear();
48585
+ this._unrefCount = 0;
48518
48586
  };
48519
48587
  DynamicFontAtlas.prototype.toPowerOf2 = function (size) {
48520
48588
  var result = 32;
@@ -48563,7 +48631,7 @@
48563
48631
  atlas = new DynamicFontAtlas(fontId, fontSize, fontColor, this._resolution);
48564
48632
  colorToAtlas.set(fontColor, atlas);
48565
48633
  }
48566
- atlas.add(targets);
48634
+ atlas.add(targets, DynamicFontAtlasCharacterType.LETTER);
48567
48635
  };
48568
48636
  DynamicFontAtlases.prototype.remove = function (fontId, fontColor, targets) {
48569
48637
  var colorToAtlas = this._atlases.get(fontId);
@@ -56495,22 +56563,7 @@
56495
56563
  });
56496
56564
  };
56497
56565
  DPane.prototype.onScrollBarUpdate = function (isRegionVisible) {
56498
- var overflowMask = this._overflowMask;
56499
- if (overflowMask != null) {
56500
- var content = this.content;
56501
- if (isRegionVisible) {
56502
- if (content.mask !== overflowMask) {
56503
- content.mask = overflowMask;
56504
- DApplications.update(this);
56505
- }
56506
- }
56507
- else {
56508
- if (content.mask) {
56509
- content.mask = null;
56510
- DApplications.update(this);
56511
- }
56512
- }
56513
- }
56566
+ // DO NOTHING
56514
56567
  };
56515
56568
  DPane.prototype.initScrollBar = function (scrollbar) {
56516
56569
  var _this = this;
@@ -56583,14 +56636,18 @@
56583
56636
  };
56584
56637
  DPane.prototype.getOverflowMask = function () {
56585
56638
  var result = this._overflowMask;
56586
- if (result == null) {
56587
- result = new DBaseOverflowMask(this);
56639
+ if (result === undefined) {
56640
+ result = this.newOverflowMask();
56588
56641
  this._overflowMask = result;
56589
- this.reflowable.add(result);
56590
- this.toDirty();
56591
56642
  }
56592
56643
  return result;
56593
56644
  };
56645
+ DPane.prototype.newOverflowMask = function () {
56646
+ var result = new DBaseOverflowMask(this);
56647
+ this.reflowable.add(result);
56648
+ this.toDirty();
56649
+ return result;
56650
+ };
56594
56651
  DPane.prototype.onWheel = function (e, deltas, global) {
56595
56652
  var content = this.content;
56596
56653
  var x = this.getWheelContentX(content, deltas.deltaX * deltas.lowest);
@@ -80137,6 +80194,7 @@
80137
80194
  FormatNodey: FormatNodey,
80138
80195
  FormatNodez: FormatNodez,
80139
80196
  FormatNodes: FormatNodes,
80197
+ Character: Character,
80140
80198
  DynamicAtlasItemEmpty: DynamicAtlasItemEmpty,
80141
80199
  DynamicAtlasItemFontAtlas: DynamicAtlasItemFontAtlas,
80142
80200
  DynamicAtlasItemImage: DynamicAtlasItemImage,