-
Notifications
You must be signed in to change notification settings - Fork 18
/
e-shape-text.ts
103 lines (89 loc) · 2.65 KB
/
e-shape-text.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { Texture } from "pixi.js";
import { DeepPartial } from "../util/deep-partial";
import { EShapeResourceManagerDeserialization } from "./e-shape-resource-manager-deserialization";
import { EShapeResourceManagerSerialization } from "./e-shape-resource-manager-serialization";
import { EShapeTextAlign, EShapeTextAlignLike } from "./e-shape-text-align";
import { EShapeTextDirection } from "./e-shape-text-direction";
import { EShapeTextOffset, EShapeTextOffsetLike } from "./e-shape-text-offset";
import { EShapeTextOutline, EShapeTextOutlineLike } from "./e-shape-text-outline";
export const EShapeTextWeight = {
NORMAL: 0,
BOLD: 1
} as const;
export type EShapeTextWeight = (typeof EShapeTextWeight)[keyof typeof EShapeTextWeight];
export const EShapeTextStyle = {
NORMAL: 0,
ITALIC: 1
} as const;
export type EShapeTextStyle = (typeof EShapeTextStyle)[keyof typeof EShapeTextStyle];
export interface EShapeTextLike {
value: string;
color: number;
alpha: number;
family: string;
size: number;
weight: EShapeTextWeight;
align: EShapeTextAlignLike;
offset: EShapeTextOffsetLike;
style: EShapeTextStyle;
outline: EShapeTextOutlineLike;
spacing: EShapeTextOffsetLike;
direction: EShapeTextDirection;
padding: EShapeTextOffsetLike;
clipping: boolean;
fitting: boolean;
}
export interface EShapeTextAtlasCharacter {
x: number;
y: number;
width: number;
height: number;
advance: number;
origin: {
x: number;
y: number;
};
}
export type EShapeTextAtlasCharacters = Record<string, EShapeTextAtlasCharacter>;
export interface EShapeTextAtlas {
width: number;
height: number;
font: {
size: number;
};
characters: EShapeTextAtlasCharacters;
}
export interface EShapeText extends EShapeTextLike {
enable: boolean;
align: EShapeTextAlign;
offset: EShapeTextOffset;
outline: EShapeTextOutline;
spacing: EShapeTextOffset;
padding: EShapeTextOffset;
texture?: Texture; // Used for rendering and updated when rendered
atlas?: EShapeTextAtlas; // Used for rendering and updated when rendered
world?: number[]; // Updated when rendered
readonly length: number;
/** Peak length */
readonly plength: number;
copy(target?: DeepPartial<EShapeTextLike>): this;
set(
value?: string,
color?: number,
alpha?: number,
family?: string,
size?: number,
weight?: EShapeTextWeight,
style?: EShapeTextStyle,
direction?: EShapeTextDirection,
clipping?: boolean,
fitting?: boolean
): this;
toObject(): EShapeTextLike;
serialize(manager: EShapeResourceManagerSerialization): number;
deserialize(target: number, manager: EShapeResourceManagerDeserialization): void;
}