@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.
- package/dist/types/wcardinal/ui/d-dynamic-text-geometry.d.ts +14 -3
- package/dist/types/wcardinal/ui/d-pane.d.ts +4 -4
- package/dist/types/wcardinal/ui/shape/e-shape-text.d.ts +3 -1
- package/dist/types/wcardinal/ui/shape/variant/build-text.d.ts +1 -1
- package/dist/types/wcardinal/ui/shape/variant/e-shape-text-impl.d.ts +6 -1
- package/dist/types/wcardinal/ui/util/character.d.ts +8 -0
- package/dist/types/wcardinal/ui/util/dynamic-font-atlas-character.d.ts +1 -0
- package/dist/types/wcardinal/ui/util/dynamic-font-atlas-characters.d.ts +1 -1
- package/dist/types/wcardinal/ui/util/dynamic-font-atlas.d.ts +5 -7
- package/dist/types/wcardinal/ui/util/dynamic-sdf-font-atlas.d.ts +4 -5
- package/dist/types/wcardinal/ui/util/dynamic-sdf-font-atlases.d.ts +2 -2
- package/dist/types/wcardinal/ui/util/index.d.ts +1 -0
- package/dist/types/wcardinal/ui/util/util-character-iterator.d.ts +0 -8
- package/dist/wcardinal/ui/d-dynamic-text-geometry.js +56 -49
- package/dist/wcardinal/ui/d-dynamic-text-geometry.js.map +1 -1
- package/dist/wcardinal/ui/d-dynamic-text-measure.js +11 -11
- package/dist/wcardinal/ui/d-dynamic-text-measure.js.map +1 -1
- package/dist/wcardinal/ui/d-pane.js +9 -21
- package/dist/wcardinal/ui/d-pane.js.map +1 -1
- package/dist/wcardinal/ui/shape/e-shape-renderer.js +3 -3
- package/dist/wcardinal/ui/shape/e-shape-renderer.js.map +1 -1
- package/dist/wcardinal/ui/shape/e-shape-text.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/build-text.js +13 -14
- package/dist/wcardinal/ui/shape/variant/build-text.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-text.js +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-text.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-text-impl.js +88 -13
- package/dist/wcardinal/ui/shape/variant/e-shape-text-impl.js.map +1 -1
- package/dist/wcardinal/ui/util/character.js +13 -0
- package/dist/wcardinal/ui/util/character.js.map +1 -0
- package/dist/wcardinal/ui/util/dynamic-font-atlas-character.js +2 -1
- package/dist/wcardinal/ui/util/dynamic-font-atlas-character.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-font-atlas-characters.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-font-atlas.js +124 -108
- package/dist/wcardinal/ui/util/dynamic-font-atlas.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-font-atlases.js +2 -1
- package/dist/wcardinal/ui/util/dynamic-font-atlases.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-sdf-font-atlas.js +99 -112
- package/dist/wcardinal/ui/util/dynamic-sdf-font-atlas.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-sdf-font-atlases.js +18 -26
- package/dist/wcardinal/ui/util/dynamic-sdf-font-atlases.js.map +1 -1
- package/dist/wcardinal/ui/util/index.js +1 -0
- package/dist/wcardinal/ui/util/index.js.map +1 -1
- package/dist/wcardinal/ui/util/util-character-iterator.js +0 -17
- package/dist/wcardinal/ui/util/util-character-iterator.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +508 -450
- package/dist/wcardinal-ui.js +508 -450
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/wcardinal/ui/util/ascii.d.ts +0 -1
- package/dist/wcardinal/ui/util/ascii.js +0 -6
- package/dist/wcardinal/ui/util/ascii.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MeshGeometry } from "pixi.js";
|
|
1
|
+
import { Buffer, MeshGeometry } from "pixi.js";
|
|
2
2
|
import { DDynamicTextStyleWordWrap } from "./d-dynamic-text-style-word-wrap";
|
|
3
3
|
import { DynamicFontAtlas } from "./util/dynamic-font-atlas";
|
|
4
4
|
import { DynamicFontAtlasCharacter } from "./util/dynamic-font-atlas-character";
|
|
@@ -11,13 +11,24 @@ export interface DDynamicTextGeometryModifier {
|
|
|
11
11
|
lineHeight: number;
|
|
12
12
|
}
|
|
13
13
|
export declare class DDynamicTextGeometry extends MeshGeometry {
|
|
14
|
+
protected static VERTICES?: Float32Array;
|
|
15
|
+
protected static UVS?: Float32Array;
|
|
16
|
+
protected static INDICES?: Uint16Array;
|
|
14
17
|
width: number;
|
|
15
18
|
height: number;
|
|
16
19
|
scale: number;
|
|
17
20
|
scaled: boolean;
|
|
18
21
|
clipped: boolean;
|
|
22
|
+
nchars: number;
|
|
23
|
+
vertexBuffer: Buffer;
|
|
24
|
+
vertices: Float32Array;
|
|
25
|
+
uvBuffer: Buffer;
|
|
26
|
+
uvs: Float32Array;
|
|
27
|
+
indexBuffer: Buffer;
|
|
28
|
+
indices: Uint16Array;
|
|
19
29
|
constructor();
|
|
20
30
|
update(text: string, atlas: DynamicFontAtlas | null, modifier: DDynamicTextGeometryModifier): void;
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
31
|
+
protected fill(vertices: Float32Array, uvs: Float32Array, index: number, x: number, y: number, scale: number, character: DynamicFontAtlasCharacter, fw: number, fh: number): void;
|
|
32
|
+
protected fillBlank(vertices: Float32Array, uvs: Float32Array, index: number): void;
|
|
33
|
+
protected initIndices(indices: Uint16Array): void;
|
|
23
34
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { InteractionEvent, Point, Rectangle } from "pixi.js";
|
|
1
|
+
import { Graphics, InteractionEvent, Point, Rectangle } from "pixi.js";
|
|
2
2
|
import { DBase, DBaseOptions, DThemeBase } from "./d-base";
|
|
3
|
-
import { DBaseOverflowMask } from "./d-base-overflow-mask";
|
|
4
3
|
import { DContentOptions } from "./d-content";
|
|
5
4
|
import { UtilGestureMode } from "./util/util-gesture-mode";
|
|
6
5
|
import { UtilGesture } from "./util/util-gesture";
|
|
@@ -42,7 +41,7 @@ export declare class DPane<THEME extends DThemePane = DThemePane, CONTENT_OPTION
|
|
|
42
41
|
protected static WORK_POINT?: Point;
|
|
43
42
|
protected static WORK_RECTANGLE?: Rectangle;
|
|
44
43
|
protected _content?: DBase;
|
|
45
|
-
protected _overflowMask?:
|
|
44
|
+
protected _overflowMask?: Graphics | null;
|
|
46
45
|
protected _scrollbar?: DPaneScrollBar;
|
|
47
46
|
protected _gestureUtil?: UtilGesture<DPane>;
|
|
48
47
|
constructor(options?: OPTIONS);
|
|
@@ -59,7 +58,8 @@ export declare class DPane<THEME extends DThemePane = DThemePane, CONTENT_OPTION
|
|
|
59
58
|
protected toContent(options?: OPTIONS): DBase;
|
|
60
59
|
protected newContent(options?: CONTENT_OPTIONS): DBase;
|
|
61
60
|
protected initContent(content: DBase): void;
|
|
62
|
-
protected getOverflowMask():
|
|
61
|
+
protected getOverflowMask(): Graphics | null;
|
|
62
|
+
protected newOverflowMask(): Graphics | null;
|
|
63
63
|
protected onWheel(e: WheelEvent, deltas: UtilWheelEventDeltas, global: Point): boolean;
|
|
64
64
|
protected getWheelContentX(content: DBase, delta: number): number;
|
|
65
65
|
protected getWheelContentY(content: DBase, delta: number): number;
|
|
@@ -44,7 +44,7 @@ export interface EShapeTextAtlasCharacter {
|
|
|
44
44
|
y: number;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
export type EShapeTextAtlasCharacters =
|
|
47
|
+
export type EShapeTextAtlasCharacters = Map<string, EShapeTextAtlasCharacter>;
|
|
48
48
|
export interface EShapeTextAtlas {
|
|
49
49
|
width: number;
|
|
50
50
|
height: number;
|
|
@@ -62,6 +62,8 @@ export interface EShapeText extends EShapeTextLike {
|
|
|
62
62
|
padding: EShapeTextOffset;
|
|
63
63
|
texture?: Texture;
|
|
64
64
|
atlas?: EShapeTextAtlas;
|
|
65
|
+
characters: string[];
|
|
66
|
+
nacharacters: string[];
|
|
65
67
|
world?: number[];
|
|
66
68
|
readonly length: number;
|
|
67
69
|
/** Peak length */
|
|
@@ -12,4 +12,4 @@ export declare const TEXT_FMIN: number;
|
|
|
12
12
|
export declare const toTextBufferCount: (shape: EShape) => number;
|
|
13
13
|
export declare const buildTextIndex: (indices: Uint16Array | Uint32Array, voffset: number, ioffset: number, icount: number) => void;
|
|
14
14
|
export declare const buildTextStep: (steps: Float32Array, voffset: number, vcount: number, textAtlas: EShapeTextAtlas | undefined, textSize: number, textOutlineWidth: number, textWeight: EShapeTextWeight, scaleX: number, scaleY: number) => void;
|
|
15
|
-
export declare const buildTextVertex: (vertices: Float32Array, uvs: Float32Array, voffset: number, vcount: number, originX: number, originY: number, sizeX: number, sizeY: number, textAtlas: EShapeTextAtlas, textSize: number,
|
|
15
|
+
export declare const buildTextVertex: (vertices: Float32Array, uvs: Float32Array, voffset: number, vcount: number, originX: number, originY: number, sizeX: number, sizeY: number, textAtlas: EShapeTextAtlas, textSize: number, textCharacters: string[], textStyle: EShapeTextStyle, textAlignHorizontal: EShapeTextAlignHorizontal, textAlignVertical: EShapeTextAlignVertical, textOffsetHorizontal: number, textOffsetVertical: number, textSpacingHorizontal: number, textSpacingVertical: number, textDirection: EShapeTextDirection, textPaddingHorizontal: number, textPaddingVertical: number, textClipping: boolean, textFitting: boolean, textWorld: number[], textureUvs: TextureUvs, internalTransform: Matrix) => void;
|
|
@@ -30,13 +30,18 @@ export declare class EShapeTextImpl implements EShapeText {
|
|
|
30
30
|
protected _fitting: boolean;
|
|
31
31
|
texture?: Texture;
|
|
32
32
|
atlas?: EShapeTextAtlas;
|
|
33
|
+
protected _characters: string[];
|
|
34
|
+
protected _nacharacters: string[];
|
|
33
35
|
world?: number[];
|
|
34
36
|
constructor(parent: EShapeTextImplParent, value: string, color: number, alpha: number, family: string, size: number);
|
|
35
37
|
get enable(): boolean;
|
|
36
38
|
set enable(enable: boolean);
|
|
37
39
|
get value(): string;
|
|
38
40
|
set value(value: string);
|
|
39
|
-
|
|
41
|
+
get characters(): string[];
|
|
42
|
+
get nacharacters(): string[];
|
|
43
|
+
protected updateCharacters(value: string): void;
|
|
44
|
+
protected isCompatible(): boolean;
|
|
40
45
|
get length(): number;
|
|
41
46
|
get plength(): number;
|
|
42
47
|
get family(): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const Character: {
|
|
2
|
+
readonly ASCII: "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
3
|
+
readonly SPACE: " ";
|
|
4
|
+
readonly TAB: "\t";
|
|
5
|
+
readonly SOFT_TAB: " ";
|
|
6
|
+
readonly DOTS: "...";
|
|
7
|
+
readonly NEW_LINE: "\n";
|
|
8
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DynamicFontAtlasCharacterOrigin } from "./dynamic-font-atlas-chaaracter-origin";
|
|
2
2
|
import { DynamicFontAtlasCharacterType } from "./dynamic-font-atlas-character-type";
|
|
3
3
|
export declare class DynamicFontAtlasCharacter {
|
|
4
|
+
static LIFE: number;
|
|
4
5
|
ref: number;
|
|
5
6
|
life: number;
|
|
6
7
|
character: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DynamicFontAtlasCharacter } from "./dynamic-font-atlas-character";
|
|
2
|
-
export type DynamicFontAtlasCharacters =
|
|
2
|
+
export type DynamicFontAtlasCharacters = Map<string, DynamicFontAtlasCharacter>;
|
|
@@ -9,7 +9,7 @@ export declare class DynamicFontAtlas {
|
|
|
9
9
|
protected _context: CanvasRenderingContext2D | null;
|
|
10
10
|
protected _font: DynamicFontAtlasFont;
|
|
11
11
|
protected _characters: DynamicFontAtlasCharacters;
|
|
12
|
-
protected
|
|
12
|
+
protected _createds: DynamicFontAtlasCharacters;
|
|
13
13
|
protected _unrefCount: number;
|
|
14
14
|
protected _width: number;
|
|
15
15
|
protected _height: number;
|
|
@@ -26,12 +26,10 @@ export declare class DynamicFontAtlas {
|
|
|
26
26
|
get canvas(): HTMLCanvasElement | null;
|
|
27
27
|
get characters(): DynamicFontAtlasCharacters;
|
|
28
28
|
get texture(): Texture;
|
|
29
|
-
protected
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
protected
|
|
33
|
-
add(targets: string, type?: DynamicFontAtlasCharacterType): void;
|
|
34
|
-
remove(targets: string): void;
|
|
29
|
+
protected newChar(character: string, type: DynamicFontAtlasCharacterType): DynamicFontAtlasCharacter;
|
|
30
|
+
add(characters: string, type: DynamicFontAtlasCharacterType): void;
|
|
31
|
+
remove(characters: string): void;
|
|
32
|
+
protected cleanup(): void;
|
|
35
33
|
get(id: string): DynamicFontAtlasCharacter | undefined;
|
|
36
34
|
getAdvance(target: string): number;
|
|
37
35
|
getContext(): CanvasRenderingContext2D | null;
|
|
@@ -15,10 +15,11 @@ export declare class DynamicSDFFontAtlas {
|
|
|
15
15
|
protected _canvas: HTMLCanvasElement | null;
|
|
16
16
|
protected _font: DynamicSDFFontAtlasFont;
|
|
17
17
|
protected _characters: DynamicFontAtlasCharacters;
|
|
18
|
-
protected _length: number;
|
|
19
18
|
protected _width: number;
|
|
20
19
|
protected _height: number;
|
|
21
20
|
protected _isDirty: boolean;
|
|
21
|
+
protected _isTouched: boolean;
|
|
22
|
+
protected _life: number;
|
|
22
23
|
constructor(fontFamily: string);
|
|
23
24
|
get id(): string;
|
|
24
25
|
get font(): DynamicSDFFontAtlasFont;
|
|
@@ -30,10 +31,8 @@ export declare class DynamicSDFFontAtlas {
|
|
|
30
31
|
get characters(): DynamicFontAtlasCharacters;
|
|
31
32
|
begin(): void;
|
|
32
33
|
end(): void;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
protected isIgnored(character: string): boolean;
|
|
36
|
-
add(characters: string, type?: DynamicFontAtlasCharacterType): void;
|
|
34
|
+
protected newChar(character: string, type: DynamicFontAtlasCharacterType): DynamicFontAtlasCharacter;
|
|
35
|
+
add(characters: string[], nacharacters: string[]): void;
|
|
37
36
|
get(id: string): DynamicFontAtlasCharacter | undefined;
|
|
38
37
|
update(): boolean;
|
|
39
38
|
get length(): number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DynamicAtlas } from "./dynamic-atlas";
|
|
2
2
|
import { DynamicSDFFontAtlas } from "./dynamic-sdf-font-atlas";
|
|
3
3
|
export declare class DynamicSDFFontAtlases {
|
|
4
|
-
protected _atlases:
|
|
4
|
+
protected _atlases: Map<string, DynamicSDFFontAtlas>;
|
|
5
5
|
constructor();
|
|
6
6
|
begin(): void;
|
|
7
7
|
end(): void;
|
|
8
|
-
add(family: string,
|
|
8
|
+
add(family: string, characters: string[], nacharacters: string[]): void;
|
|
9
9
|
get(family: string): DynamicSDFFontAtlas | null;
|
|
10
10
|
update(baseAtlas: DynamicAtlas): void;
|
|
11
11
|
destroy(): void;
|
|
@@ -10,14 +10,6 @@ export declare class UtilCharacterIterator {
|
|
|
10
10
|
protected isLowSurrogate(code: number): boolean;
|
|
11
11
|
protected isVariationSelector(code: number): boolean;
|
|
12
12
|
next(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Advances the position if the next character is not equal to
|
|
15
|
-
* the given `except`.
|
|
16
|
-
*
|
|
17
|
-
* @param except
|
|
18
|
-
* @return true if the position is advanced
|
|
19
|
-
*/
|
|
20
|
-
advance(except?: string): boolean;
|
|
21
13
|
/**
|
|
22
14
|
* Closes this iterator.
|
|
23
15
|
*
|
|
@@ -8,47 +8,61 @@ import { DDynamicTextMeasure } from "./d-dynamic-text-measure";
|
|
|
8
8
|
var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
9
9
|
__extends(DDynamicTextGeometry, _super);
|
|
10
10
|
function DDynamicTextGeometry() {
|
|
11
|
-
var
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
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;
|
|
12
13
|
_this.width = 0;
|
|
13
14
|
_this.height = 0;
|
|
14
15
|
_this.scale = 1;
|
|
15
16
|
_this.scaled = false;
|
|
16
17
|
_this.clipped = false;
|
|
18
|
+
_this.vertexBuffer = _this.getBuffer("aVertexPosition");
|
|
19
|
+
_this.vertices = DDynamicTextGeometry.VERTICES;
|
|
20
|
+
_this.uvBuffer = _this.getBuffer("aTextureCoord");
|
|
21
|
+
_this.uvs = DDynamicTextGeometry.UVS;
|
|
22
|
+
_this.indexBuffer = _this.getIndex();
|
|
23
|
+
_this.indices = DDynamicTextGeometry.INDICES;
|
|
24
|
+
_this.nchars = 0;
|
|
17
25
|
return _this;
|
|
18
26
|
}
|
|
19
27
|
DDynamicTextGeometry.prototype.update = function (text, atlas, modifier) {
|
|
20
|
-
var vertexBuffer = this.getBuffer("aVertexPosition");
|
|
21
|
-
var uvBuffer = this.getBuffer("aTextureCoord");
|
|
22
|
-
var indexBuffer = this.getIndex();
|
|
23
28
|
var result = DDynamicTextMeasure.measure(text, atlas, modifier);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
var resultCount = result.count;
|
|
30
|
+
var nchars = ((resultCount >> 3) + (resultCount & 0x7 ? 1 : 0)) << 3;
|
|
31
|
+
if (this.nchars < nchars) {
|
|
32
|
+
this.nchars = nchars;
|
|
33
|
+
var nvertex = nchars << 3;
|
|
34
|
+
this.vertices = new Float32Array(nvertex);
|
|
35
|
+
this.uvs = new Float32Array(nvertex);
|
|
36
|
+
this.vertexBuffer.data = this.vertices;
|
|
37
|
+
this.uvBuffer.data = this.uvs;
|
|
38
|
+
var nindex = (nchars << 2) + (nchars << 1);
|
|
39
|
+
this.indices = new Uint16Array(nindex);
|
|
40
|
+
this.indexBuffer.data = this.indices;
|
|
41
|
+
this.initIndices(this.indices);
|
|
42
|
+
this.indexBuffer.update();
|
|
29
43
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
else {
|
|
45
|
+
nchars = this.nchars;
|
|
46
|
+
}
|
|
47
|
+
if (nchars <= 0) {
|
|
48
|
+
return;
|
|
33
49
|
}
|
|
34
|
-
var vertices =
|
|
35
|
-
var uvs =
|
|
36
|
-
var indices = indexBuffer.data;
|
|
50
|
+
var vertices = this.vertices;
|
|
51
|
+
var uvs = this.uvs;
|
|
37
52
|
if (atlas != null) {
|
|
38
|
-
var count = result.count;
|
|
39
53
|
var characters = result.characters;
|
|
40
54
|
var scale = result.scale;
|
|
41
|
-
|
|
55
|
+
var fw = 1 / atlas.width;
|
|
56
|
+
var fh = 1 / atlas.height;
|
|
57
|
+
for (var i = 0; i < resultCount; ++i) {
|
|
42
58
|
var character = characters[i];
|
|
43
59
|
var cx = character.x;
|
|
44
60
|
var cy = character.y;
|
|
45
61
|
var cc = character.character;
|
|
46
|
-
|
|
47
|
-
var h = atlas.height;
|
|
48
|
-
this.writeCharacter(vertices, uvs, indices, i, cx, cy, scale, cc, w, h);
|
|
62
|
+
this.fill(vertices, uvs, i, cx, cy, scale, cc, fw, fh);
|
|
49
63
|
}
|
|
50
|
-
for (var i =
|
|
51
|
-
this.
|
|
64
|
+
for (var i = resultCount; i < nchars; ++i) {
|
|
65
|
+
this.fillBlank(vertices, uvs, i);
|
|
52
66
|
}
|
|
53
67
|
this.width = result.width * scale;
|
|
54
68
|
this.height = result.height * scale;
|
|
@@ -57,8 +71,8 @@ var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
|
57
71
|
this.clipped = result.clipped;
|
|
58
72
|
}
|
|
59
73
|
else {
|
|
60
|
-
for (var i = 0
|
|
61
|
-
this.
|
|
74
|
+
for (var i = 0; i < nchars; ++i) {
|
|
75
|
+
this.fillBlank(vertices, uvs, i);
|
|
62
76
|
}
|
|
63
77
|
this.width = 0;
|
|
64
78
|
this.height = 0;
|
|
@@ -66,11 +80,10 @@ var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
|
66
80
|
this.scaled = false;
|
|
67
81
|
this.clipped = false;
|
|
68
82
|
}
|
|
69
|
-
vertexBuffer.update();
|
|
70
|
-
uvBuffer.update();
|
|
71
|
-
indexBuffer.update();
|
|
83
|
+
this.vertexBuffer.update();
|
|
84
|
+
this.uvBuffer.update();
|
|
72
85
|
};
|
|
73
|
-
DDynamicTextGeometry.prototype.
|
|
86
|
+
DDynamicTextGeometry.prototype.fill = function (vertices, uvs, index, x, y, scale, character, fw, fh) {
|
|
74
87
|
var cx = character.x;
|
|
75
88
|
var cy = character.y;
|
|
76
89
|
var cw = character.width;
|
|
@@ -89,10 +102,10 @@ var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
|
89
102
|
vertices[iv + 5] = y1;
|
|
90
103
|
vertices[iv + 6] = x0;
|
|
91
104
|
vertices[iv + 7] = y1;
|
|
92
|
-
var u0 = cx
|
|
93
|
-
var v0 = cy
|
|
94
|
-
var u1 = (cx + cw)
|
|
95
|
-
var v1 = (cy + ch)
|
|
105
|
+
var u0 = cx * fw;
|
|
106
|
+
var v0 = cy * fh;
|
|
107
|
+
var u1 = (cx + cw) * fw;
|
|
108
|
+
var v1 = (cy + ch) * fh;
|
|
96
109
|
uvs[iv + 0] = u0;
|
|
97
110
|
uvs[iv + 1] = v0;
|
|
98
111
|
uvs[iv + 2] = u1;
|
|
@@ -101,16 +114,8 @@ var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
|
101
114
|
uvs[iv + 5] = v1;
|
|
102
115
|
uvs[iv + 6] = u0;
|
|
103
116
|
uvs[iv + 7] = v1;
|
|
104
|
-
var ii = index * 6;
|
|
105
|
-
var vo = index << 2;
|
|
106
|
-
indices[ii + 0] = vo + 0;
|
|
107
|
-
indices[ii + 1] = vo + 1;
|
|
108
|
-
indices[ii + 2] = vo + 3;
|
|
109
|
-
indices[ii + 3] = vo + 1;
|
|
110
|
-
indices[ii + 4] = vo + 2;
|
|
111
|
-
indices[ii + 5] = vo + 3;
|
|
112
117
|
};
|
|
113
|
-
DDynamicTextGeometry.prototype.
|
|
118
|
+
DDynamicTextGeometry.prototype.fillBlank = function (vertices, uvs, index) {
|
|
114
119
|
var iv = index << 3;
|
|
115
120
|
vertices[iv + 0] = 0;
|
|
116
121
|
vertices[iv + 1] = 0;
|
|
@@ -128,14 +133,16 @@ var DDynamicTextGeometry = /** @class */ (function (_super) {
|
|
|
128
133
|
uvs[iv + 5] = 0;
|
|
129
134
|
uvs[iv + 6] = 0;
|
|
130
135
|
uvs[iv + 7] = 0;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
};
|
|
137
|
+
DDynamicTextGeometry.prototype.initIndices = function (indices) {
|
|
138
|
+
for (var iv = 0, ivmax = this.nchars << 2, ii = 0; iv < ivmax; iv += 4, ii += 6) {
|
|
139
|
+
indices[ii] = iv;
|
|
140
|
+
indices[ii + 1] = iv + 1;
|
|
141
|
+
indices[ii + 2] = iv + 3;
|
|
142
|
+
indices[ii + 3] = iv + 1;
|
|
143
|
+
indices[ii + 4] = iv + 2;
|
|
144
|
+
indices[ii + 5] = iv + 3;
|
|
145
|
+
}
|
|
139
146
|
};
|
|
140
147
|
return DDynamicTextGeometry;
|
|
141
148
|
}(MeshGeometry));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-dynamic-text-geometry.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dynamic-text-geometry.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAc/D;IAA0C,wCAAY;IAOrD;QAAA,YACC,kBAAM,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC,SAMtE;QALA,KAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,KAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,KAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,KAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAI,CAAC,OAAO,GAAG,KAAK,CAAC;;IACtB,CAAC;IAED,qCAAM,GAAN,UACC,IAAY,EACZ,KAA8B,EAC9B,QAAsC;QAEtC,IAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACvD,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACjD,IAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEpC,IAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClE,IAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,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AE,GAAG,CAAC,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACF,2BAAC;AAAD,CAAC,AAxKD,CAA0C,YAAY,GAwKrD","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { MeshGeometry } from \"pixi.js\";\nimport { DDynamicTextMeasure } from \"./d-dynamic-text-measure\";\nimport { DDynamicTextStyleWordWrap } from \"./d-dynamic-text-style-word-wrap\";\nimport { DynamicFontAtlas } from \"./util/dynamic-font-atlas\";\nimport { DynamicFontAtlasCharacter } from \"./util/dynamic-font-atlas-character\";\n\nexport interface DDynamicTextGeometryModifier {\n\tclipping: boolean;\n\tfitting: boolean;\n\twordWrap: DDynamicTextStyleWordWrap;\n\twidth: number;\n\theight: number;\n\tlineHeight: number;\n}\n\nexport class DDynamicTextGeometry extends MeshGeometry {\n\twidth: number;\n\theight: number;\n\tscale: number;\n\tscaled: boolean;\n\tclipped: boolean;\n\n\tconstructor() {\n\t\tsuper(new Float32Array(64), new Float32Array(64), new Uint16Array(48));\n\t\tthis.width = 0;\n\t\tthis.height = 0;\n\t\tthis.scale = 1;\n\t\tthis.scaled = false;\n\t\tthis.clipped = false;\n\t}\n\n\tupdate(\n\t\ttext: string,\n\t\tatlas: DynamicFontAtlas | null,\n\t\tmodifier: DDynamicTextGeometryModifier\n\t): void {\n\t\tconst vertexBuffer = this.getBuffer(\"aVertexPosition\");\n\t\tconst uvBuffer = this.getBuffer(\"aTextureCoord\");\n\t\tconst indexBuffer = this.getIndex();\n\n\t\tconst result = DDynamicTextMeasure.measure(text, atlas, modifier);\n\t\tconst requiredTextSize = Math.ceil(result.count / 8) << 3;\n\t\tconst requiredVertexSize = requiredTextSize << 3;\n\t\tif ((vertexBuffer.data as Float32Array).length < requiredVertexSize) {\n\t\t\tvertexBuffer.data = new Float32Array(requiredVertexSize);\n\t\t\tuvBuffer.data = new Float32Array(requiredVertexSize);\n\t\t}\n\t\tconst requiredIndexSize = requiredTextSize * 6;\n\t\tif ((indexBuffer.data as Uint16Array).length < requiredIndexSize) {\n\t\t\tindexBuffer.data = new Uint16Array(requiredIndexSize);\n\t\t}\n\n\t\tconst vertices = vertexBuffer.data as Float32Array;\n\t\tconst uvs = uvBuffer.data as Float32Array;\n\t\tconst indices = indexBuffer.data as Uint16Array;\n\n\t\tif (atlas != null) {\n\t\t\tconst count = result.count;\n\t\t\tconst characters = result.characters;\n\t\t\tconst scale = result.scale;\n\t\t\tfor (let i = 0; i < count; ++i) {\n\t\t\t\tconst character = characters[i];\n\t\t\t\tconst cx = character.x;\n\t\t\t\tconst cy = character.y;\n\t\t\t\tconst cc = character.character;\n\t\t\t\tconst w = atlas.width;\n\t\t\t\tconst h = atlas.height;\n\t\t\t\tthis.writeCharacter(vertices, uvs, indices, i, cx, cy, scale, cc, w, h);\n\t\t\t}\n\t\t\tfor (let i = count, imax = vertices.length >> 3; i < imax; ++i) {\n\t\t\t\tthis.writeCharacterEmpty(vertices, uvs, indices, i);\n\t\t\t}\n\t\t\tthis.width = result.width * scale;\n\t\t\tthis.height = result.height * scale;\n\t\t\tthis.scale = scale;\n\t\t\tthis.scaled = result.scaled;\n\t\t\tthis.clipped = result.clipped;\n\t\t} else {\n\t\t\tfor (let i = 0, imax = vertices.length >> 3; i < imax; ++i) {\n\t\t\t\tthis.writeCharacterEmpty(vertices, uvs, indices, i);\n\t\t\t}\n\t\t\tthis.width = 0;\n\t\t\tthis.height = 0;\n\t\t\tthis.scale = 1;\n\t\t\tthis.scaled = false;\n\t\t\tthis.clipped = false;\n\t\t}\n\n\t\tvertexBuffer.update();\n\t\tuvBuffer.update();\n\t\tindexBuffer.update();\n\t}\n\n\tprotected writeCharacter(\n\t\tvertices: Float32Array,\n\t\tuvs: Float32Array,\n\t\tindices: Uint16Array,\n\t\tindex: number,\n\t\tx: number,\n\t\ty: number,\n\t\tscale: number,\n\t\tcharacter: DynamicFontAtlasCharacter,\n\t\twidth: number,\n\t\theight: number\n\t): void {\n\t\tconst cx = character.x;\n\t\tconst cy = character.y;\n\t\tconst cw = character.width;\n\t\tconst ch = character.height;\n\t\tconst cox = character.origin.x;\n\n\t\tconst x0 = (x + (cx - cox)) * scale;\n\t\tconst y0 = y * scale;\n\t\tconst x1 = x0 + cw * scale;\n\t\tconst y1 = y0 + ch * scale;\n\n\t\tconst iv = index << 3;\n\t\tvertices[iv + 0] = x0;\n\t\tvertices[iv + 1] = y0;\n\t\tvertices[iv + 2] = x1;\n\t\tvertices[iv + 3] = y0;\n\t\tvertices[iv + 4] = x1;\n\t\tvertices[iv + 5] = y1;\n\t\tvertices[iv + 6] = x0;\n\t\tvertices[iv + 7] = y1;\n\n\t\tconst u0 = cx / width;\n\t\tconst v0 = cy / height;\n\t\tconst u1 = (cx + cw) / width;\n\t\tconst v1 = (cy + ch) / height;\n\t\tuvs[iv + 0] = u0;\n\t\tuvs[iv + 1] = v0;\n\t\tuvs[iv + 2] = u1;\n\t\tuvs[iv + 3] = v0;\n\t\tuvs[iv + 4] = u1;\n\t\tuvs[iv + 5] = v1;\n\t\tuvs[iv + 6] = u0;\n\t\tuvs[iv + 7] = v1;\n\n\t\tconst ii = index * 6;\n\t\tconst vo = index << 2;\n\t\tindices[ii + 0] = vo + 0;\n\t\tindices[ii + 1] = vo + 1;\n\t\tindices[ii + 2] = vo + 3;\n\t\tindices[ii + 3] = vo + 1;\n\t\tindices[ii + 4] = vo + 2;\n\t\tindices[ii + 5] = vo + 3;\n\t}\n\n\tprotected writeCharacterEmpty(\n\t\tvertices: Float32Array,\n\t\tuvs: Float32Array,\n\t\tindices: Uint16Array,\n\t\tindex: number\n\t): void {\n\t\tconst iv = index << 3;\n\t\tvertices[iv + 0] = 0;\n\t\tvertices[iv + 1] = 0;\n\t\tvertices[iv + 2] = 0;\n\t\tvertices[iv + 3] = 0;\n\t\tvertices[iv + 4] = 0;\n\t\tvertices[iv + 5] = 0;\n\t\tvertices[iv + 6] = 0;\n\t\tvertices[iv + 7] = 0;\n\n\t\tuvs[iv + 0] = 0;\n\t\tuvs[iv + 1] = 0;\n\t\tuvs[iv + 2] = 0;\n\t\tuvs[iv + 3] = 0;\n\t\tuvs[iv + 4] = 0;\n\t\tuvs[iv + 5] = 0;\n\t\tuvs[iv + 6] = 0;\n\t\tuvs[iv + 7] = 0;\n\n\t\tconst ii = index * 6;\n\t\tconst vo = index << 2;\n\t\tindices[ii + 0] = vo + 0;\n\t\tindices[ii + 1] = vo + 1;\n\t\tindices[ii + 2] = vo + 3;\n\t\tindices[ii + 3] = vo + 1;\n\t\tindices[ii + 4] = vo + 2;\n\t\tindices[ii + 5] = vo + 3;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-dynamic-text-geometry.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dynamic-text-geometry.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAU,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAc/D;IAA0C,wCAAY;IAmBrD;;QAAA,YACC,kBACC,OAAC,oBAAoB,CAAC,QAAQ,oCAA7B,oBAAoB,CAAC,QAAQ,GAAK,IAAI,YAAY,CAAC,CAAC,CAAC,EAAC,EACvD,OAAC,oBAAoB,CAAC,GAAG,oCAAxB,oBAAoB,CAAC,GAAG,GAAK,IAAI,YAAY,CAAC,CAAC,CAAC,EAAC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AAC;IACF,2BAAC;AAAD,CAAC,AAxLD,CAA0C,YAAY,GAwLrD","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Buffer, MeshGeometry } from \"pixi.js\";\nimport { DDynamicTextMeasure } from \"./d-dynamic-text-measure\";\nimport { DDynamicTextStyleWordWrap } from \"./d-dynamic-text-style-word-wrap\";\nimport { DynamicFontAtlas } from \"./util/dynamic-font-atlas\";\nimport { DynamicFontAtlasCharacter } from \"./util/dynamic-font-atlas-character\";\n\nexport interface DDynamicTextGeometryModifier {\n\tclipping: boolean;\n\tfitting: boolean;\n\twordWrap: DDynamicTextStyleWordWrap;\n\twidth: number;\n\theight: number;\n\tlineHeight: number;\n}\n\nexport class DDynamicTextGeometry extends MeshGeometry {\n\tprotected static VERTICES?: Float32Array;\n\tprotected static UVS?: Float32Array;\n\tprotected static INDICES?: Uint16Array;\n\n\twidth: number;\n\theight: number;\n\tscale: number;\n\tscaled: boolean;\n\tclipped: boolean;\n\n\tnchars: number;\n\tvertexBuffer: Buffer;\n\tvertices: Float32Array;\n\tuvBuffer: Buffer;\n\tuvs: Float32Array;\n\tindexBuffer: Buffer;\n\tindices: Uint16Array;\n\n\tconstructor() {\n\t\tsuper(\n\t\t\t(DDynamicTextGeometry.VERTICES ??= new Float32Array(0)),\n\t\t\t(DDynamicTextGeometry.UVS ??= new Float32Array(0)),\n\t\t\t(DDynamicTextGeometry.INDICES ??= new Uint16Array(0))\n\t\t);\n\t\tthis.width = 0;\n\t\tthis.height = 0;\n\t\tthis.scale = 1;\n\t\tthis.scaled = false;\n\t\tthis.clipped = false;\n\n\t\tthis.vertexBuffer = this.getBuffer(\"aVertexPosition\");\n\t\tthis.vertices = DDynamicTextGeometry.VERTICES;\n\t\tthis.uvBuffer = this.getBuffer(\"aTextureCoord\");\n\t\tthis.uvs = DDynamicTextGeometry.UVS;\n\t\tthis.indexBuffer = this.getIndex();\n\t\tthis.indices = DDynamicTextGeometry.INDICES;\n\n\t\tthis.nchars = 0;\n\t}\n\n\tupdate(\n\t\ttext: string,\n\t\tatlas: DynamicFontAtlas | null,\n\t\tmodifier: DDynamicTextGeometryModifier\n\t): void {\n\t\tconst result = DDynamicTextMeasure.measure(text, atlas, modifier);\n\t\tconst resultCount = result.count;\n\t\tlet nchars = ((resultCount >> 3) + (resultCount & 0x7 ? 1 : 0)) << 3;\n\t\tif (this.nchars < nchars) {\n\t\t\tthis.nchars = nchars;\n\n\t\t\tconst nvertex = nchars << 3;\n\t\t\tthis.vertices = new Float32Array(nvertex);\n\t\t\tthis.uvs = new Float32Array(nvertex);\n\t\t\tthis.vertexBuffer.data = this.vertices;\n\t\t\tthis.uvBuffer.data = this.uvs;\n\n\t\t\tconst nindex = (nchars << 2) + (nchars << 1);\n\t\t\tthis.indices = new Uint16Array(nindex);\n\t\t\tthis.indexBuffer.data = this.indices;\n\t\t\tthis.initIndices(this.indices);\n\t\t\tthis.indexBuffer.update();\n\t\t} else {\n\t\t\tnchars = this.nchars;\n\t\t}\n\t\tif (nchars <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst vertices = this.vertices;\n\t\tconst uvs = this.uvs;\n\t\tif (atlas != null) {\n\t\t\tconst characters = result.characters;\n\t\t\tconst scale = result.scale;\n\t\t\tconst fw = 1 / atlas.width;\n\t\t\tconst fh = 1 / atlas.height;\n\t\t\tfor (let i = 0; i < resultCount; ++i) {\n\t\t\t\tconst character = characters[i];\n\t\t\t\tconst cx = character.x;\n\t\t\t\tconst cy = character.y;\n\t\t\t\tconst cc = character.character;\n\t\t\t\tthis.fill(vertices, uvs, i, cx, cy, scale, cc, fw, fh);\n\t\t\t}\n\t\t\tfor (let i = resultCount; i < nchars; ++i) {\n\t\t\t\tthis.fillBlank(vertices, uvs, i);\n\t\t\t}\n\t\t\tthis.width = result.width * scale;\n\t\t\tthis.height = result.height * scale;\n\t\t\tthis.scale = scale;\n\t\t\tthis.scaled = result.scaled;\n\t\t\tthis.clipped = result.clipped;\n\t\t} else {\n\t\t\tfor (let i = 0; i < nchars; ++i) {\n\t\t\t\tthis.fillBlank(vertices, uvs, i);\n\t\t\t}\n\t\t\tthis.width = 0;\n\t\t\tthis.height = 0;\n\t\t\tthis.scale = 1;\n\t\t\tthis.scaled = false;\n\t\t\tthis.clipped = false;\n\t\t}\n\t\tthis.vertexBuffer.update();\n\t\tthis.uvBuffer.update();\n\t}\n\n\tprotected fill(\n\t\tvertices: Float32Array,\n\t\tuvs: Float32Array,\n\t\tindex: number,\n\t\tx: number,\n\t\ty: number,\n\t\tscale: number,\n\t\tcharacter: DynamicFontAtlasCharacter,\n\t\tfw: number,\n\t\tfh: number\n\t): void {\n\t\tconst cx = character.x;\n\t\tconst cy = character.y;\n\t\tconst cw = character.width;\n\t\tconst ch = character.height;\n\t\tconst cox = character.origin.x;\n\n\t\tconst x0 = (x + (cx - cox)) * scale;\n\t\tconst y0 = y * scale;\n\t\tconst x1 = x0 + cw * scale;\n\t\tconst y1 = y0 + ch * scale;\n\n\t\tconst iv = index << 3;\n\t\tvertices[iv + 0] = x0;\n\t\tvertices[iv + 1] = y0;\n\t\tvertices[iv + 2] = x1;\n\t\tvertices[iv + 3] = y0;\n\t\tvertices[iv + 4] = x1;\n\t\tvertices[iv + 5] = y1;\n\t\tvertices[iv + 6] = x0;\n\t\tvertices[iv + 7] = y1;\n\n\t\tconst u0 = cx * fw;\n\t\tconst v0 = cy * fh;\n\t\tconst u1 = (cx + cw) * fw;\n\t\tconst v1 = (cy + ch) * fh;\n\n\t\tuvs[iv + 0] = u0;\n\t\tuvs[iv + 1] = v0;\n\t\tuvs[iv + 2] = u1;\n\t\tuvs[iv + 3] = v0;\n\t\tuvs[iv + 4] = u1;\n\t\tuvs[iv + 5] = v1;\n\t\tuvs[iv + 6] = u0;\n\t\tuvs[iv + 7] = v1;\n\t}\n\n\tprotected fillBlank(vertices: Float32Array, uvs: Float32Array, index: number): void {\n\t\tconst iv = index << 3;\n\t\tvertices[iv + 0] = 0;\n\t\tvertices[iv + 1] = 0;\n\t\tvertices[iv + 2] = 0;\n\t\tvertices[iv + 3] = 0;\n\t\tvertices[iv + 4] = 0;\n\t\tvertices[iv + 5] = 0;\n\t\tvertices[iv + 6] = 0;\n\t\tvertices[iv + 7] = 0;\n\n\t\tuvs[iv + 0] = 0;\n\t\tuvs[iv + 1] = 0;\n\t\tuvs[iv + 2] = 0;\n\t\tuvs[iv + 3] = 0;\n\t\tuvs[iv + 4] = 0;\n\t\tuvs[iv + 5] = 0;\n\t\tuvs[iv + 6] = 0;\n\t\tuvs[iv + 7] = 0;\n\t}\n\n\tprotected initIndices(indices: Uint16Array): void {\n\t\tfor (let iv = 0, ivmax = this.nchars << 2, ii = 0; iv < ivmax; iv += 4, ii += 6) {\n\t\t\tindices[ii] = iv;\n\t\t\tindices[ii + 1] = iv + 1;\n\t\t\tindices[ii + 2] = iv + 3;\n\t\t\tindices[ii + 3] = iv + 1;\n\t\t\tindices[ii + 4] = iv + 2;\n\t\t\tindices[ii + 5] = iv + 3;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { DDynamicTextMeasureResult } from "./d-dynamic-text-measure-result";
|
|
|
2
2
|
import { UtilCharacterIterator } from "./util/util-character-iterator";
|
|
3
3
|
import { DDynamicTextStyleWordWrap } from "./d-dynamic-text-style-word-wrap";
|
|
4
4
|
import { DynamicFontAtlasCharacterType } from "./util/dynamic-font-atlas-character-type";
|
|
5
|
-
|
|
5
|
+
import { Character } from "./util/character";
|
|
6
6
|
var DDynamicTextMeasure = /** @class */ (function () {
|
|
7
7
|
function DDynamicTextMeasure() {
|
|
8
8
|
}
|
|
@@ -72,7 +72,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
72
72
|
while (iterator.hasNext()) {
|
|
73
73
|
var characterPosition = iterator.position;
|
|
74
74
|
var character = iterator.next();
|
|
75
|
-
if (character === NEW_LINE) {
|
|
75
|
+
if (character === Character.NEW_LINE) {
|
|
76
76
|
if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
|
|
77
77
|
result.newLine(lineHeight);
|
|
78
78
|
}
|
|
@@ -104,7 +104,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
104
104
|
DDynamicTextMeasure.measure1b = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
|
|
105
105
|
while (iterator.hasNext()) {
|
|
106
106
|
var character = iterator.next();
|
|
107
|
-
if (character === NEW_LINE) {
|
|
107
|
+
if (character === Character.NEW_LINE) {
|
|
108
108
|
if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
|
|
109
109
|
result.newLine(lineHeight);
|
|
110
110
|
}
|
|
@@ -135,7 +135,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
135
135
|
DDynamicTextMeasure.measure1 = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
|
|
136
136
|
while (iterator.hasNext()) {
|
|
137
137
|
var character = iterator.next();
|
|
138
|
-
if (character === NEW_LINE) {
|
|
138
|
+
if (character === Character.NEW_LINE) {
|
|
139
139
|
if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
|
|
140
140
|
result.newLine(lineHeight);
|
|
141
141
|
}
|
|
@@ -167,7 +167,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
167
167
|
while (iterator.hasNext()) {
|
|
168
168
|
var characterPosition = iterator.position;
|
|
169
169
|
var character = iterator.next();
|
|
170
|
-
if (character === NEW_LINE) {
|
|
170
|
+
if (character === Character.NEW_LINE) {
|
|
171
171
|
result.newLine(lineHeight);
|
|
172
172
|
}
|
|
173
173
|
else {
|
|
@@ -189,7 +189,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
189
189
|
DDynamicTextMeasure.measure2b = function (iterator, clippingWidth, lineHeight, atlas, result) {
|
|
190
190
|
while (iterator.hasNext()) {
|
|
191
191
|
var character = iterator.next();
|
|
192
|
-
if (character === NEW_LINE) {
|
|
192
|
+
if (character === Character.NEW_LINE) {
|
|
193
193
|
result.newLine(lineHeight);
|
|
194
194
|
}
|
|
195
195
|
else {
|
|
@@ -210,7 +210,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
210
210
|
DDynamicTextMeasure.measure2 = function (iterator, clippingWidth, lineHeight, atlas, result) {
|
|
211
211
|
while (iterator.hasNext()) {
|
|
212
212
|
var character = iterator.next();
|
|
213
|
-
if (character === NEW_LINE) {
|
|
213
|
+
if (character === Character.NEW_LINE) {
|
|
214
214
|
result.newLine(lineHeight);
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
@@ -230,7 +230,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
230
230
|
DDynamicTextMeasure.measure3 = function (iterator, clippingWidth, clippingHeight, fontHeight, lineHeight, atlas, result) {
|
|
231
231
|
while (iterator.hasNext()) {
|
|
232
232
|
var character = iterator.next();
|
|
233
|
-
if (character === NEW_LINE) {
|
|
233
|
+
if (character === Character.NEW_LINE) {
|
|
234
234
|
if (result.isPushableAtNewLine(clippingHeight, lineHeight, fontHeight)) {
|
|
235
235
|
result.newLine(lineHeight);
|
|
236
236
|
}
|
|
@@ -254,7 +254,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
254
254
|
DDynamicTextMeasure.measure4 = function (iterator, lineHeight, atlas, result) {
|
|
255
255
|
while (iterator.hasNext()) {
|
|
256
256
|
var character = iterator.next();
|
|
257
|
-
if (character === NEW_LINE) {
|
|
257
|
+
if (character === Character.NEW_LINE) {
|
|
258
258
|
result.newLine(lineHeight);
|
|
259
259
|
}
|
|
260
260
|
else {
|
|
@@ -267,7 +267,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
267
267
|
};
|
|
268
268
|
DDynamicTextMeasure.measure5 = function (iterator, clippingWidth, lineHeight, atlas, result, close) {
|
|
269
269
|
result.clipped = true;
|
|
270
|
-
var dots = atlas.get(
|
|
270
|
+
var dots = atlas.get(Character.DOTS);
|
|
271
271
|
if (dots != null) {
|
|
272
272
|
while (!result.isPushable(clippingWidth, dots)) {
|
|
273
273
|
if (!result.pop()) {
|
|
@@ -283,7 +283,7 @@ var DDynamicTextMeasure = /** @class */ (function () {
|
|
|
283
283
|
}
|
|
284
284
|
else {
|
|
285
285
|
while (iterator.hasNext()) {
|
|
286
|
-
if (iterator.next() === NEW_LINE) {
|
|
286
|
+
if (iterator.next() === Character.NEW_LINE) {
|
|
287
287
|
result.newLine(lineHeight);
|
|
288
288
|
break;
|
|
289
289
|
}
|