@next2d/text 1.14.20

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.
@@ -0,0 +1,250 @@
1
+ import { TextFormatAlignImpl } from "@next2d/interface";
2
+ /**
3
+ * TextFormat クラスは、文字フォーマット情報を表します。
4
+ * TextFormat クラスを使用して、テキストフィールドに特定のテキストフォーマットを作成します。
5
+ *
6
+ * The TextFormat class represents character formatting information.
7
+ * Use the TextFormat class to create specific text formatting for text fields.
8
+ *
9
+ * @class
10
+ * @memberOf next2d.text
11
+ */
12
+ export declare class TextFormat {
13
+ private _$font;
14
+ private _$size;
15
+ private _$color;
16
+ private _$bold;
17
+ private _$italic;
18
+ private _$underline;
19
+ private _$align;
20
+ private _$leftMargin;
21
+ private _$rightMargin;
22
+ private _$indent;
23
+ private _$leading;
24
+ private _$blockIndent;
25
+ private _$letterSpacing;
26
+ /**
27
+ * @param {string} [font=null]
28
+ * @param {number} [size=null]
29
+ * @param {number} [color=null]
30
+ * @param {boolean} [bold=null]
31
+ * @param {boolean} [italic=null]
32
+ * @param {boolean} [underline=null]
33
+ * @param {string} [align=null]
34
+ * @param {number} [left_margin=null]
35
+ * @param {number} [right_margin=null]
36
+ * @param {number} [indent=null]
37
+ * @param {number} [leading=null]
38
+ * @param {number} [block_indent=null]
39
+ *
40
+ * @constructor
41
+ * @public
42
+ */
43
+ constructor(font?: string | null, size?: number | null, color?: number | null, bold?: boolean | null, italic?: boolean | null, underline?: boolean | null, align?: TextFormatAlignImpl | null, left_margin?: number | null, right_margin?: number | null, indent?: number | null, leading?: number | null, block_indent?: number | null);
44
+ /**
45
+ * @description 指定されたクラスのストリングを返します。
46
+ * Returns the string representation of the specified class.
47
+ *
48
+ * @return {string}
49
+ * @default [class TextFormat]
50
+ * @method
51
+ * @static
52
+ */
53
+ static toString(): string;
54
+ /**
55
+ * @description 指定されたクラスの空間名を返します。
56
+ * Returns the space name of the specified class.
57
+ *
58
+ * @return {string}
59
+ * @default next2d.text.TextFormat
60
+ * @const
61
+ * @static
62
+ */
63
+ static get namespace(): string;
64
+ /**
65
+ * @description 指定されたオブジェクトのストリングを返します。
66
+ * Returns the string representation of the specified object.
67
+ *
68
+ * @return {string}
69
+ * @default [object TextFormat]
70
+ * @method
71
+ * @public
72
+ */
73
+ toString(): string;
74
+ /**
75
+ * @description 指定されたオブジェクトの空間名を返します。
76
+ * Returns the space name of the specified object.
77
+ *
78
+ * @return {string}
79
+ * @default next2d.text.TextFormat
80
+ * @const
81
+ * @public
82
+ */
83
+ get namespace(): string;
84
+ /**
85
+ * @description 段落の行揃えの設定を示します。
86
+ * Indicates the alignment of the paragraph.
87
+ *
88
+ * @member {string}
89
+ * @default null
90
+ * @public
91
+ */
92
+ get align(): TextFormatAlignImpl | null;
93
+ set align(align: TextFormatAlignImpl | null);
94
+ /**
95
+ * @description ブロックのインデントをピクセル単位で示します。
96
+ * Indicates the block indentation in pixels.
97
+ *
98
+ * @member {number}
99
+ * @default null
100
+ * @public
101
+ */
102
+ get blockIndent(): number | null;
103
+ set blockIndent(block_indent: number | null);
104
+ /**
105
+ * @description テキストをボールドにするかどうかを指定します。
106
+ * Specifies whether the text is boldface.
107
+ *
108
+ * @member {boolean}
109
+ * @default null
110
+ * @public
111
+ */
112
+ get bold(): boolean | null;
113
+ set bold(bold: boolean | null);
114
+ /**
115
+ * @description テキストの色を示します。
116
+ * Indicates the color of the text.
117
+ *
118
+ * @member {number}
119
+ * @default null
120
+ * @public
121
+ */
122
+ get color(): number | null;
123
+ set color(color: number | null);
124
+ /**
125
+ * @description このテキストフォーマットでのテキストフォント名を示すストリングです。
126
+ * The name of the font for text in this text format, as a string.
127
+ *
128
+ * @member {string}
129
+ * @default null
130
+ * @public
131
+ */
132
+ get font(): string | null;
133
+ set font(font: string | null);
134
+ /**
135
+ * @description 左インデントから段落の先頭文字までのインデントを示します。
136
+ * Indicates the indentation from the left margin
137
+ * to the first character in the paragraph.
138
+ *
139
+ * @member {number}
140
+ * @default null
141
+ * @public
142
+ */
143
+ get indent(): number | null;
144
+ set indent(indent: number | null);
145
+ /**
146
+ * @description このテキストフォーマットのテキストをイタリックにするかどうかを示します。
147
+ * Indicates whether text in this text format is italicized.
148
+ *
149
+ * @member {boolean}
150
+ * @default null
151
+ * @public
152
+ */
153
+ get italic(): boolean | null;
154
+ set italic(italic: boolean | null);
155
+ /**
156
+ * @description 行間の垂直の行送りを示す整数です。
157
+ * An integer representing the amount
158
+ * of vertical space (called leading) between lines.
159
+ *
160
+ * @member {number}
161
+ * @default null
162
+ * @public
163
+ */
164
+ get leading(): number | null;
165
+ set leading(leading: number | null);
166
+ /**
167
+ * @description 段落の左インデントをピクセル単位で示します。
168
+ * The left margin of the paragraph, in pixels.
169
+ *
170
+ * @member {number}
171
+ * @default null
172
+ * @public
173
+ */
174
+ get leftMargin(): number | null;
175
+ set leftMargin(left_margin: number | null);
176
+ /**
177
+ * @description すべての文字の間に均等に配分されるスペースの量を表す数値です。
178
+ * A object representing the amount
179
+ * of space that is uniformly distributed between all characters.
180
+ *
181
+ * @member {number}
182
+ * @default null
183
+ * @public
184
+ */
185
+ get letterSpacing(): number | null;
186
+ set letterSpacing(letter_spacing: number | null);
187
+ /**
188
+ * @description 段落の右インデントをピクセル単位で示します。
189
+ * The right margin of the paragraph, in pixels.
190
+ *
191
+ * @member {number}
192
+ * @default null
193
+ * @public
194
+ */
195
+ get rightMargin(): number | null;
196
+ set rightMargin(right_margin: number | null);
197
+ /**
198
+ * @description このテキストフォーマットのテキストのサイズ(ピクセル単位)です。
199
+ * The size in pixels of text in this text format.
200
+ *
201
+ * @member {number}
202
+ * @default null
203
+ * @public
204
+ */
205
+ get size(): number | null;
206
+ set size(size: number | null);
207
+ /**
208
+ * @description このテキストフォーマットを使用するテキストに
209
+ * アンダーラインを表示する(true)か、表示しない(false)かを示します。
210
+ * Indicates whether the text that uses this text format
211
+ * is underlined (true) or not (false).
212
+ *
213
+ * @member {boolean}
214
+ * @default null
215
+ * @public
216
+ */
217
+ get underline(): boolean | null;
218
+ set underline(underline: boolean | null);
219
+ /**
220
+ * @return {next2d.text.TextFormat}
221
+ * @method
222
+ * @private
223
+ */
224
+ _$clone(): TextFormat;
225
+ /**
226
+ * @return {void}
227
+ * @method
228
+ * @private
229
+ */
230
+ _$setDefault(): void;
231
+ /**
232
+ * @param {TextFormat} text_format
233
+ * @return {void}
234
+ * @method
235
+ * @private
236
+ */
237
+ _$merge(text_format: TextFormat): void;
238
+ /**
239
+ * @return {number}
240
+ * @method
241
+ * @private
242
+ */
243
+ _$widthMargin(): number;
244
+ /**
245
+ * @return {string}
246
+ * @method
247
+ * @private
248
+ */
249
+ _$generateFontStyle(): string;
250
+ }
@@ -0,0 +1,460 @@
1
+ import { $clamp, $toColorInt } from "@next2d/share";
2
+ /**
3
+ * TextFormat クラスは、文字フォーマット情報を表します。
4
+ * TextFormat クラスを使用して、テキストフィールドに特定のテキストフォーマットを作成します。
5
+ *
6
+ * The TextFormat class represents character formatting information.
7
+ * Use the TextFormat class to create specific text formatting for text fields.
8
+ *
9
+ * @class
10
+ * @memberOf next2d.text
11
+ */
12
+ export class TextFormat {
13
+ /**
14
+ * @param {string} [font=null]
15
+ * @param {number} [size=null]
16
+ * @param {number} [color=null]
17
+ * @param {boolean} [bold=null]
18
+ * @param {boolean} [italic=null]
19
+ * @param {boolean} [underline=null]
20
+ * @param {string} [align=null]
21
+ * @param {number} [left_margin=null]
22
+ * @param {number} [right_margin=null]
23
+ * @param {number} [indent=null]
24
+ * @param {number} [leading=null]
25
+ * @param {number} [block_indent=null]
26
+ *
27
+ * @constructor
28
+ * @public
29
+ */
30
+ constructor(font = null, size = null, color = null, bold = null, italic = null, underline = null, align = null, left_margin = null, right_margin = null, indent = null, leading = null, block_indent = null) {
31
+ /**
32
+ * @type {string}
33
+ * @default null
34
+ * @private
35
+ */
36
+ this._$font = font;
37
+ /**
38
+ * @type {number}
39
+ * @default null
40
+ * @private
41
+ */
42
+ this._$size = size;
43
+ /**
44
+ * @type {number}
45
+ * @default null
46
+ * @private
47
+ */
48
+ this._$color = color === null
49
+ ? null
50
+ : $clamp($toColorInt(color), 0, 0xffffff, 0);
51
+ /**
52
+ * @type {boolean}
53
+ * @default null
54
+ * @private
55
+ */
56
+ this._$bold = bold;
57
+ /**
58
+ * @type {boolean}
59
+ * @default null
60
+ * @private
61
+ */
62
+ this._$italic = italic;
63
+ /**
64
+ * @type {boolean}
65
+ * @default null
66
+ * @private
67
+ */
68
+ this._$underline = underline;
69
+ /**
70
+ * @type {string}
71
+ * @default null
72
+ * @private
73
+ */
74
+ this._$align = align;
75
+ /**
76
+ * @type {number}
77
+ * @default null
78
+ * @private
79
+ */
80
+ this._$leftMargin = left_margin;
81
+ /**
82
+ * @type {number}
83
+ * @default null
84
+ * @private
85
+ */
86
+ this._$rightMargin = right_margin;
87
+ /**
88
+ * @type {number}
89
+ * @default null
90
+ * @private
91
+ */
92
+ this._$indent = indent;
93
+ /**
94
+ * @type {number}
95
+ * @default null
96
+ * @private
97
+ */
98
+ this._$leading = leading;
99
+ /**
100
+ * @type {number}
101
+ * @default null
102
+ * @private
103
+ */
104
+ this._$blockIndent = block_indent;
105
+ /**
106
+ * @type {number}
107
+ * @default 0
108
+ * @private
109
+ */
110
+ this._$letterSpacing = 0;
111
+ }
112
+ /**
113
+ * @description 指定されたクラスのストリングを返します。
114
+ * Returns the string representation of the specified class.
115
+ *
116
+ * @return {string}
117
+ * @default [class TextFormat]
118
+ * @method
119
+ * @static
120
+ */
121
+ static toString() {
122
+ return "[class TextFormat]";
123
+ }
124
+ /**
125
+ * @description 指定されたクラスの空間名を返します。
126
+ * Returns the space name of the specified class.
127
+ *
128
+ * @return {string}
129
+ * @default next2d.text.TextFormat
130
+ * @const
131
+ * @static
132
+ */
133
+ static get namespace() {
134
+ return "next2d.text.TextFormat";
135
+ }
136
+ /**
137
+ * @description 指定されたオブジェクトのストリングを返します。
138
+ * Returns the string representation of the specified object.
139
+ *
140
+ * @return {string}
141
+ * @default [object TextFormat]
142
+ * @method
143
+ * @public
144
+ */
145
+ toString() {
146
+ return "[object TextFormat]";
147
+ }
148
+ /**
149
+ * @description 指定されたオブジェクトの空間名を返します。
150
+ * Returns the space name of the specified object.
151
+ *
152
+ * @return {string}
153
+ * @default next2d.text.TextFormat
154
+ * @const
155
+ * @public
156
+ */
157
+ get namespace() {
158
+ return "next2d.text.TextFormat";
159
+ }
160
+ /**
161
+ * @description 段落の行揃えの設定を示します。
162
+ * Indicates the alignment of the paragraph.
163
+ *
164
+ * @member {string}
165
+ * @default null
166
+ * @public
167
+ */
168
+ get align() {
169
+ return this._$align;
170
+ }
171
+ set align(align) {
172
+ this._$align = align;
173
+ }
174
+ /**
175
+ * @description ブロックのインデントをピクセル単位で示します。
176
+ * Indicates the block indentation in pixels.
177
+ *
178
+ * @member {number}
179
+ * @default null
180
+ * @public
181
+ */
182
+ get blockIndent() {
183
+ return this._$blockIndent;
184
+ }
185
+ set blockIndent(block_indent) {
186
+ this._$blockIndent = block_indent;
187
+ }
188
+ /**
189
+ * @description テキストをボールドにするかどうかを指定します。
190
+ * Specifies whether the text is boldface.
191
+ *
192
+ * @member {boolean}
193
+ * @default null
194
+ * @public
195
+ */
196
+ get bold() {
197
+ return this._$bold;
198
+ }
199
+ set bold(bold) {
200
+ this._$bold = bold !== null ? !!bold : null;
201
+ }
202
+ /**
203
+ * @description テキストの色を示します。
204
+ * Indicates the color of the text.
205
+ *
206
+ * @member {number}
207
+ * @default null
208
+ * @public
209
+ */
210
+ get color() {
211
+ return this._$color;
212
+ }
213
+ set color(color) {
214
+ this._$color = color;
215
+ if (color) {
216
+ this._$color = $clamp($toColorInt(color), 0, 0xffffff, 0);
217
+ }
218
+ }
219
+ /**
220
+ * @description このテキストフォーマットでのテキストフォント名を示すストリングです。
221
+ * The name of the font for text in this text format, as a string.
222
+ *
223
+ * @member {string}
224
+ * @default null
225
+ * @public
226
+ */
227
+ get font() {
228
+ return this._$font;
229
+ }
230
+ set font(font) {
231
+ this._$font = font !== null ? `${font}` : null;
232
+ }
233
+ /**
234
+ * @description 左インデントから段落の先頭文字までのインデントを示します。
235
+ * Indicates the indentation from the left margin
236
+ * to the first character in the paragraph.
237
+ *
238
+ * @member {number}
239
+ * @default null
240
+ * @public
241
+ */
242
+ get indent() {
243
+ return this._$indent;
244
+ }
245
+ set indent(indent) {
246
+ this._$indent = indent;
247
+ }
248
+ /**
249
+ * @description このテキストフォーマットのテキストをイタリックにするかどうかを示します。
250
+ * Indicates whether text in this text format is italicized.
251
+ *
252
+ * @member {boolean}
253
+ * @default null
254
+ * @public
255
+ */
256
+ get italic() {
257
+ return this._$italic;
258
+ }
259
+ set italic(italic) {
260
+ this._$italic = italic !== null ? !!italic : null;
261
+ }
262
+ /**
263
+ * @description 行間の垂直の行送りを示す整数です。
264
+ * An integer representing the amount
265
+ * of vertical space (called leading) between lines.
266
+ *
267
+ * @member {number}
268
+ * @default null
269
+ * @public
270
+ */
271
+ get leading() {
272
+ return this._$leading;
273
+ }
274
+ set leading(leading) {
275
+ this._$leading = leading;
276
+ }
277
+ /**
278
+ * @description 段落の左インデントをピクセル単位で示します。
279
+ * The left margin of the paragraph, in pixels.
280
+ *
281
+ * @member {number}
282
+ * @default null
283
+ * @public
284
+ */
285
+ get leftMargin() {
286
+ return this._$leftMargin;
287
+ }
288
+ set leftMargin(left_margin) {
289
+ this._$leftMargin = left_margin;
290
+ }
291
+ /**
292
+ * @description すべての文字の間に均等に配分されるスペースの量を表す数値です。
293
+ * A object representing the amount
294
+ * of space that is uniformly distributed between all characters.
295
+ *
296
+ * @member {number}
297
+ * @default null
298
+ * @public
299
+ */
300
+ get letterSpacing() {
301
+ return this._$letterSpacing;
302
+ }
303
+ set letterSpacing(letter_spacing) {
304
+ this._$letterSpacing = letter_spacing;
305
+ }
306
+ /**
307
+ * @description 段落の右インデントをピクセル単位で示します。
308
+ * The right margin of the paragraph, in pixels.
309
+ *
310
+ * @member {number}
311
+ * @default null
312
+ * @public
313
+ */
314
+ get rightMargin() {
315
+ return this._$rightMargin;
316
+ }
317
+ set rightMargin(right_margin) {
318
+ this._$rightMargin = right_margin;
319
+ }
320
+ /**
321
+ * @description このテキストフォーマットのテキストのサイズ(ピクセル単位)です。
322
+ * The size in pixels of text in this text format.
323
+ *
324
+ * @member {number}
325
+ * @default null
326
+ * @public
327
+ */
328
+ get size() {
329
+ return this._$size;
330
+ }
331
+ set size(size) {
332
+ this._$size = size ? size | 0 : null;
333
+ }
334
+ /**
335
+ * @description このテキストフォーマットを使用するテキストに
336
+ * アンダーラインを表示する(true)か、表示しない(false)かを示します。
337
+ * Indicates whether the text that uses this text format
338
+ * is underlined (true) or not (false).
339
+ *
340
+ * @member {boolean}
341
+ * @default null
342
+ * @public
343
+ */
344
+ get underline() {
345
+ return this._$underline;
346
+ }
347
+ set underline(underline) {
348
+ this._$underline = underline !== null ? !!underline : null;
349
+ }
350
+ /**
351
+ * @return {next2d.text.TextFormat}
352
+ * @method
353
+ * @private
354
+ */
355
+ _$clone() {
356
+ const textFormat = new TextFormat(this._$font, this._$size, this._$color, this._$bold, this._$italic, this._$underline, this._$align, this._$leftMargin, this._$rightMargin, this._$indent, this._$leading, this._$blockIndent);
357
+ textFormat._$letterSpacing = this._$letterSpacing;
358
+ return textFormat;
359
+ }
360
+ /**
361
+ * @return {void}
362
+ * @method
363
+ * @private
364
+ */
365
+ _$setDefault() {
366
+ this._$align = "left";
367
+ this._$blockIndent = 0;
368
+ this._$bold = false;
369
+ this._$color = 0;
370
+ this._$font = "Times New Roman";
371
+ this._$indent = 0;
372
+ this._$italic = false;
373
+ this._$leading = 0;
374
+ this._$leftMargin = 0;
375
+ this._$letterSpacing = 0;
376
+ this._$rightMargin = 0;
377
+ this._$size = 12;
378
+ this._$underline = false;
379
+ }
380
+ /**
381
+ * @param {TextFormat} text_format
382
+ * @return {void}
383
+ * @method
384
+ * @private
385
+ */
386
+ _$merge(text_format) {
387
+ if (this._$align === null) {
388
+ this._$align = text_format._$align;
389
+ }
390
+ if (this._$blockIndent === null) {
391
+ this._$blockIndent = text_format._$blockIndent;
392
+ }
393
+ if (this._$bold === null) {
394
+ this._$bold = text_format._$bold;
395
+ }
396
+ if (this._$color === null) {
397
+ this._$color = text_format._$color;
398
+ }
399
+ if (this._$font === null) {
400
+ this._$font = text_format._$font;
401
+ }
402
+ if (this._$indent === null) {
403
+ this._$indent = text_format._$indent;
404
+ }
405
+ if (this._$italic === null) {
406
+ this._$italic = text_format._$italic;
407
+ }
408
+ if (this._$leading === null) {
409
+ this._$leading = text_format._$leading;
410
+ }
411
+ if (this._$leftMargin === null) {
412
+ this._$leftMargin = text_format._$leftMargin;
413
+ }
414
+ if (this._$letterSpacing === null) {
415
+ this._$letterSpacing = text_format._$letterSpacing;
416
+ }
417
+ if (this._$rightMargin === null) {
418
+ this._$rightMargin = text_format._$rightMargin;
419
+ }
420
+ if (this._$size === null) {
421
+ this._$size = text_format._$size;
422
+ }
423
+ if (this._$underline === null) {
424
+ this._$underline = text_format._$underline;
425
+ }
426
+ }
427
+ /**
428
+ * @return {number}
429
+ * @method
430
+ * @private
431
+ */
432
+ _$widthMargin() {
433
+ let width = 0;
434
+ if (this._$indent) {
435
+ width += this._$indent;
436
+ }
437
+ if (this._$leftMargin) {
438
+ width += this._$leftMargin;
439
+ }
440
+ if (this._$rightMargin) {
441
+ width += this._$rightMargin;
442
+ }
443
+ return width;
444
+ }
445
+ /**
446
+ * @return {string}
447
+ * @method
448
+ * @private
449
+ */
450
+ _$generateFontStyle() {
451
+ let fontStyle = "";
452
+ if (this._$italic) {
453
+ fontStyle = "italic ";
454
+ }
455
+ if (this._$bold) {
456
+ fontStyle += "bold ";
457
+ }
458
+ return `${fontStyle}${this._$size}px '${this._$font}','sans-serif'`;
459
+ }
460
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./TextField";
2
+ export * from "./TextFormat";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./TextField";
2
+ export * from "./TextFormat";