@awayjs/scene 0.13.244 → 0.13.245
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/bundle/awayjs-scene.umd.js +42 -75
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/managers/DefaultFontManager.d.ts.map +1 -1
- package/dist/lib/managers/DefaultFontManager.js +3 -4
- package/dist/lib/text/HTMLTextProcessor.js +1 -1
- package/dist/lib/text/TextFormat.d.ts +3 -3
- package/dist/lib/text/TextFormat.d.ts.map +1 -1
- package/dist/lib/text/TextFormat.js +37 -69
- package/index.ts +1 -1
- package/lib/managers/DefaultFontManager.ts +3 -6
- package/lib/text/HTMLTextProcessor.ts +1 -1
- package/lib/text/TextFormat.ts +43 -75
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
console.debug('AwayJS - Scene - 0.13.
|
|
1
|
+
console.debug('AwayJS - Scene - 0.13.245');
|
|
2
2
|
export { Timeline } from './lib/base/Timeline';
|
|
3
3
|
export { ControllerBase } from './lib/controllers/ControllerBase';
|
|
4
4
|
export { FirstPersonController } from './lib/controllers/FirstPersonController';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultFontManager.d.ts","sourceRoot":"","sources":["../../../lib/managers/DefaultFontManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,qBAAa,kBAAkB;IAG9B,OAAc,kBAAkB,EAAE,OAAO,CAAS;IAElD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAW;IAC3C,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAW;IACxD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAgB;IAE1C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAW;WAE5B,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,MAAoC;WAgBzE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAoC;WAyB7E,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,MAAoC;WA6BrE,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;WAItD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAkB,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"DefaultFontManager.d.ts","sourceRoot":"","sources":["../../../lib/managers/DefaultFontManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,qBAAa,kBAAkB;IAG9B,OAAc,kBAAkB,EAAE,OAAO,CAAS;IAElD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAW;IAC3C,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAW;IACxD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAgB;IAE1C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAW;WAE5B,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,MAAoC;WAgBzE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAoC;WAyB7E,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,MAAoC;WA6BrE,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;WAItD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAkB,GAAG,IAAI;WA8B9D,QAAQ;CAKtB"}
|
|
@@ -60,11 +60,10 @@ var DefaultFontManager = /** @class */ (function () {
|
|
|
60
60
|
this._registered_fonts_by_className[className] = font;
|
|
61
61
|
};
|
|
62
62
|
DefaultFontManager.getFont = function (fontName, namespace) {
|
|
63
|
-
//console.log('[DefaultFontManager] - getFont', fontName);
|
|
64
63
|
if (namespace === void 0) { namespace = undefined; }
|
|
65
|
-
if
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
// return null if no fontName supplied
|
|
65
|
+
if (!fontName)
|
|
66
|
+
return null;
|
|
68
67
|
// hack for dynamic fonts: first check if reguested font-name is a classname that was registered
|
|
69
68
|
if (this._registered_fonts_by_className[fontName]) {
|
|
70
69
|
return this._registered_fonts_by_className[fontName];
|
|
@@ -327,7 +327,7 @@ var HTMLTextProcessor = /** @class */ (function () {
|
|
|
327
327
|
var value = myChild.attributes.face ?
|
|
328
328
|
myChild.attributes.face : myChild.attributes.FACE;
|
|
329
329
|
newProps_values[newProps_values.length] = value;
|
|
330
|
-
newProps_names[newProps_names.length] = '
|
|
330
|
+
newProps_names[newProps_names.length] = 'font_name';
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
// step2: collect the textformat-properties provided by this child.tagName
|
|
@@ -8,7 +8,7 @@ export declare class TextFormat extends AssetBase {
|
|
|
8
8
|
fontLookUpMode: FontLookUpMode;
|
|
9
9
|
_updateID: number;
|
|
10
10
|
get updateID(): number;
|
|
11
|
-
private
|
|
11
|
+
private _fontTableDirty;
|
|
12
12
|
/**
|
|
13
13
|
* return true if a certain property was set for this format.
|
|
14
14
|
*
|
|
@@ -175,6 +175,7 @@ export declare class TextFormat extends AssetBase {
|
|
|
175
175
|
*/
|
|
176
176
|
private _font;
|
|
177
177
|
get font_name(): string;
|
|
178
|
+
set font_name(value: string);
|
|
178
179
|
update_font_table(): void;
|
|
179
180
|
get font(): Font;
|
|
180
181
|
set font(value: Font);
|
|
@@ -253,8 +254,7 @@ export declare class TextFormat extends AssetBase {
|
|
|
253
254
|
* @param leading A number that indicates the amount of leading vertical
|
|
254
255
|
* space between lines.
|
|
255
256
|
*/
|
|
256
|
-
constructor(font?: string, size?: number, color?: number, bold?: boolean, italic?: boolean, underline?: boolean, url?: string, link_target?: string, align?: string, leftMargin?: number, rightMargin?: number, indent?: number, leading?: number);
|
|
257
|
-
private _setFontFromString;
|
|
257
|
+
constructor(font?: Font | string, size?: number, color?: number, bold?: boolean, italic?: boolean, underline?: boolean, url?: string, link_target?: string, align?: string, leftMargin?: number, rightMargin?: number, indent?: number, leading?: number);
|
|
258
258
|
clone(): TextFormat;
|
|
259
259
|
equal(format: TextFormat): boolean;
|
|
260
260
|
applyToFormat(format: TextFormat): TextFormat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFormat.d.ts","sourceRoot":"","sources":["../../../lib/text/TextFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuClD,qBAAa,UAAW,SAAQ,SAAS;IACxC,OAAc,SAAS,EAAE,MAAM,CAAwB;IAEhD,cAAc,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"TextFormat.d.ts","sourceRoot":"","sources":["../../../lib/text/TextFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuClD,qBAAa,UAAW,SAAQ,SAAS;IACxC,OAAc,SAAS,EAAE,MAAM,CAAwB;IAEhD,cAAc,EAAE,cAAc,CAA0B;IAG/D,SAAS,EAAE,MAAM,CAAK;IACtB,IAAW,QAAQ,WA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AAW,EAAE,MAAM,CAAC;IAE3B;;;;;;;;OAQG;IAEI,GAAG,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;gBAEF,IAAI,GAAE,IAAI,GAAG,MAAa,EAAE,IAAI,GAAE,MAAa,EAAE,KAAK,GAAE,MAAa,EAAE,IAAI,GAAE,OAAc,EAC3F,MAAM,GAAE,OAAc,EAAE,SAAS,GAAE,OAAc,EAAE,GAAG,GAAE,MAAa,EACrE,WAAW,GAAE,MAAa,EAAE,KAAK,GAAE,MAAa,EAChD,UAAU,GAAE,MAAa,EAAE,WAAW,GAAE,MAAa,EAAE,MAAM,GAAE,MAAa,EAAE,OAAO,GAAE,MAAa;IAuB9F,KAAK,IAAI,UAAU;IASnB,KAAK,CAAC,MAAM,EAAE,UAAU;IAUxB,aAAa,CAAC,MAAM,EAAE,UAAU;IAUvC;;;;;;OAMG;IACI,WAAW,CAAC,MAAM,EAAE,UAAU;IAQrC;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;CACD"}
|
|
@@ -39,7 +39,7 @@ var PUBLIC_FIELDS = [
|
|
|
39
39
|
'size', 'color',
|
|
40
40
|
'bold', 'italic',
|
|
41
41
|
'underline', 'leading',
|
|
42
|
-
'letterSpacing'
|
|
42
|
+
'letterSpacing'
|
|
43
43
|
];
|
|
44
44
|
var TextFormat = /** @class */ (function (_super) {
|
|
45
45
|
__extends(TextFormat, _super);
|
|
@@ -97,9 +97,10 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
97
97
|
if (indent === void 0) { indent = null; }
|
|
98
98
|
if (leading === void 0) { leading = null; }
|
|
99
99
|
var _this = _super.call(this) || this;
|
|
100
|
+
_this.fontLookUpMode = FontLookUpMode.DEFAULT;
|
|
100
101
|
// flag marked that format is changed.
|
|
101
102
|
_this._updateID = 0;
|
|
102
|
-
_this.
|
|
103
|
+
_this._fontTableDirty = true;
|
|
103
104
|
/**
|
|
104
105
|
* Specifies custom tab stops as an array of non-negative integers. Each tab
|
|
105
106
|
* stop is specified in pixels. If custom tab stops are not specified
|
|
@@ -107,7 +108,6 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
107
108
|
*/
|
|
108
109
|
//todo: not used with in tesselated-font-table yet
|
|
109
110
|
_this.tabStops = [];
|
|
110
|
-
_this.fontLookUpMode = FontLookUpMode.DEFAULT;
|
|
111
111
|
_this._size = size;
|
|
112
112
|
_this._color = color;
|
|
113
113
|
_this._bold = bold;
|
|
@@ -120,15 +120,11 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
120
120
|
_this._rightMargin = rightMargin;
|
|
121
121
|
_this._indent = indent;
|
|
122
122
|
_this._leading = leading;
|
|
123
|
-
_this._letterSpacing = null;
|
|
124
|
-
_this._font_table = null;
|
|
125
123
|
if (typeof font === 'string') {
|
|
126
|
-
_this.
|
|
127
|
-
return _this;
|
|
124
|
+
_this.font_name = font;
|
|
128
125
|
}
|
|
129
|
-
else
|
|
130
|
-
_this.
|
|
131
|
-
_this._textFormatDirty = true;
|
|
126
|
+
else {
|
|
127
|
+
_this.font = font;
|
|
132
128
|
}
|
|
133
129
|
return _this;
|
|
134
130
|
}
|
|
@@ -286,7 +282,7 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
286
282
|
this._updateID++;
|
|
287
283
|
}
|
|
288
284
|
this._bold = value;
|
|
289
|
-
this.
|
|
285
|
+
this._fontTableDirty = true;
|
|
290
286
|
},
|
|
291
287
|
enumerable: true,
|
|
292
288
|
configurable: true
|
|
@@ -300,7 +296,7 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
300
296
|
this._updateID++;
|
|
301
297
|
}
|
|
302
298
|
this._italic = value;
|
|
303
|
-
this.
|
|
299
|
+
this._fontTableDirty = true;
|
|
304
300
|
},
|
|
305
301
|
enumerable: true,
|
|
306
302
|
configurable: true
|
|
@@ -320,10 +316,8 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
320
316
|
});
|
|
321
317
|
Object.defineProperty(TextFormat.prototype, "font_table", {
|
|
322
318
|
get: function () {
|
|
323
|
-
if (!this._font_table || this.
|
|
324
|
-
this.font; // getter makes sure a font exists !
|
|
319
|
+
if (!this._font_table || this._fontTableDirty)
|
|
325
320
|
this.update_font_table();
|
|
326
|
-
}
|
|
327
321
|
return this._font_table;
|
|
328
322
|
},
|
|
329
323
|
set: function (value) {
|
|
@@ -331,7 +325,7 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
331
325
|
// font_table is only ever set in parser or when using label-data
|
|
332
326
|
// after using "bold" or "itaic" font_table should never be set directly
|
|
333
327
|
this._font_table = value;
|
|
334
|
-
this.
|
|
328
|
+
this._fontTableDirty = false;
|
|
335
329
|
},
|
|
336
330
|
enumerable: true,
|
|
337
331
|
configurable: true
|
|
@@ -341,11 +335,27 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
341
335
|
var _a;
|
|
342
336
|
return (_a = this.font) === null || _a === void 0 ? void 0 : _a.name;
|
|
343
337
|
},
|
|
338
|
+
set: function (value) {
|
|
339
|
+
var _a;
|
|
340
|
+
if (((_a = this.font) === null || _a === void 0 ? void 0 : _a.name) == value)
|
|
341
|
+
return;
|
|
342
|
+
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
343
|
+
this._font = DefaultFontManager.getFont(value);
|
|
344
|
+
}
|
|
345
|
+
else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
346
|
+
this._font = DeviceFontManager.getDeviceFont(value);
|
|
347
|
+
}
|
|
348
|
+
else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
349
|
+
this._font = DefaultFontManager.getFont_CFF(value);
|
|
350
|
+
}
|
|
351
|
+
this._fontTableDirty = true;
|
|
352
|
+
this._updateID++;
|
|
353
|
+
},
|
|
344
354
|
enumerable: true,
|
|
345
355
|
configurable: true
|
|
346
356
|
});
|
|
347
357
|
TextFormat.prototype.update_font_table = function () {
|
|
348
|
-
this.
|
|
358
|
+
this._fontTableDirty = false;
|
|
349
359
|
var stylename = FontStyleName.STANDART;
|
|
350
360
|
if (this._italic && !this._bold)
|
|
351
361
|
stylename = FontStyleName.ITALIC;
|
|
@@ -354,73 +364,31 @@ var TextFormat = /** @class */ (function (_super) {
|
|
|
354
364
|
else if (this._italic && this._bold)
|
|
355
365
|
stylename = FontStyleName.BOLDITALIC;
|
|
356
366
|
if (this._font) {
|
|
357
|
-
var
|
|
358
|
-
if
|
|
359
|
-
|
|
360
|
-
|
|
367
|
+
var font_table = this._font.get_font_table(stylename, TesselatedFontTable.assetType, null, true);
|
|
368
|
+
// if we have a font-table, and we switch to invalid style,
|
|
369
|
+
// we just keep the existing font-table
|
|
370
|
+
if (this._font_table && !font_table)
|
|
361
371
|
return;
|
|
362
|
-
|
|
363
|
-
this._font_table = newFontTable ? newFontTable : Font.emptyFontTable;
|
|
364
|
-
return;
|
|
372
|
+
this._font_table = font_table ? font_table : Font.emptyFontTable;
|
|
365
373
|
}
|
|
366
374
|
};
|
|
367
375
|
Object.defineProperty(TextFormat.prototype, "font", {
|
|
368
376
|
get: function () {
|
|
369
|
-
if (this._font) {
|
|
370
|
-
return this._font;
|
|
371
|
-
}
|
|
372
|
-
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
373
|
-
this._font = DefaultFontManager.getFont(null);
|
|
374
|
-
}
|
|
375
|
-
else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
376
|
-
this._font = DeviceFontManager.getDeviceFont(null);
|
|
377
|
-
}
|
|
378
|
-
else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
379
|
-
this._font = DefaultFontManager.getFont_CFF(null);
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
console.warn('[TextFormat] - unsupported FontLookUpMode', this.fontLookUpMode);
|
|
383
|
-
}
|
|
384
|
-
this._font_table = null;
|
|
385
|
-
this._textFormatDirty = true;
|
|
386
377
|
return this._font;
|
|
387
378
|
},
|
|
388
379
|
set: function (value) {
|
|
389
|
-
this.
|
|
390
|
-
if (typeof value === 'string') {
|
|
391
|
-
this._setFontFromString(value);
|
|
380
|
+
if (this._font == value)
|
|
392
381
|
return;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
if (value) {
|
|
398
|
-
this._font = value;
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
this._font = null;
|
|
402
|
-
this._font_table = null;
|
|
382
|
+
this._font = value;
|
|
383
|
+
this._fontTableDirty = true;
|
|
384
|
+
this._updateID++;
|
|
403
385
|
},
|
|
404
386
|
enumerable: true,
|
|
405
387
|
configurable: true
|
|
406
388
|
});
|
|
407
|
-
TextFormat.prototype._setFontFromString = function (font_name) {
|
|
408
|
-
var asset;
|
|
409
|
-
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
410
|
-
asset = DefaultFontManager.getFont(font_name);
|
|
411
|
-
}
|
|
412
|
-
else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
413
|
-
asset = DeviceFontManager.getDeviceFont(font_name);
|
|
414
|
-
}
|
|
415
|
-
else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
416
|
-
asset = DefaultFontManager.getFont_CFF(font_name);
|
|
417
|
-
}
|
|
418
|
-
this.font = asset;
|
|
419
|
-
this._textFormatDirty = true;
|
|
420
|
-
};
|
|
421
389
|
TextFormat.prototype.clone = function () {
|
|
422
390
|
var clonedFormat = new TextFormat(this._font, this._size, this._color, this._bold, this._italic, this._underline, this.url, this.link_target, this._align, this._leftMargin, this._rightMargin, this._indent, this._leading);
|
|
423
|
-
clonedFormat.font_table = this._font_table;
|
|
391
|
+
clonedFormat.font_table = this._font_table; //investigate why this needs to be copied
|
|
424
392
|
return clonedFormat;
|
|
425
393
|
};
|
|
426
394
|
TextFormat.prototype.equal = function (format) {
|
package/index.ts
CHANGED
|
@@ -88,12 +88,9 @@ export class DefaultFontManager {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
public static getFont(fontName: string, namespace: string = undefined): Font {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (!fontName) {
|
|
95
|
-
return DeviceFontManager.getDeviceFont(fontName);
|
|
96
|
-
}
|
|
91
|
+
// return null if no fontName supplied
|
|
92
|
+
if (!fontName)
|
|
93
|
+
return null;
|
|
97
94
|
|
|
98
95
|
// hack for dynamic fonts: first check if reguested font-name is a classname that was registered
|
|
99
96
|
if (this._registered_fonts_by_className[fontName]) {
|
|
@@ -325,7 +325,7 @@ export class HTMLTextProcessor {
|
|
|
325
325
|
const value = (<any>myChild.attributes).face ?
|
|
326
326
|
(<any>myChild.attributes).face : (<any>myChild.attributes).FACE;
|
|
327
327
|
newProps_values[newProps_values.length] = value;
|
|
328
|
-
newProps_names[newProps_names.length] = '
|
|
328
|
+
newProps_names[newProps_names.length] = 'font_name';
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
|
package/lib/text/TextFormat.ts
CHANGED
|
@@ -42,13 +42,13 @@ const PUBLIC_FIELDS = [
|
|
|
42
42
|
'size', 'color',
|
|
43
43
|
'bold', 'italic',
|
|
44
44
|
'underline', 'leading',
|
|
45
|
-
'letterSpacing'
|
|
45
|
+
'letterSpacing'
|
|
46
46
|
];
|
|
47
47
|
|
|
48
48
|
export class TextFormat extends AssetBase {
|
|
49
49
|
public static assetType: string = '[asset TextFormat]';
|
|
50
50
|
|
|
51
|
-
public fontLookUpMode: FontLookUpMode;
|
|
51
|
+
public fontLookUpMode: FontLookUpMode = FontLookUpMode.DEFAULT;
|
|
52
52
|
|
|
53
53
|
// flag marked that format is changed.
|
|
54
54
|
_updateID: number = 0;
|
|
@@ -56,7 +56,7 @@ export class TextFormat extends AssetBase {
|
|
|
56
56
|
return this._updateID;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
private
|
|
59
|
+
private _fontTableDirty: boolean = true;
|
|
60
60
|
/**
|
|
61
61
|
* return true if a certain property was set for this format.
|
|
62
62
|
*
|
|
@@ -294,7 +294,7 @@ export class TextFormat extends AssetBase {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
this._bold = value;
|
|
297
|
-
this.
|
|
297
|
+
this._fontTableDirty = true;
|
|
298
298
|
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -313,7 +313,7 @@ export class TextFormat extends AssetBase {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
this._italic = value;
|
|
316
|
-
this.
|
|
316
|
+
this._fontTableDirty = true;
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/**
|
|
@@ -347,10 +347,10 @@ export class TextFormat extends AssetBase {
|
|
|
347
347
|
*/
|
|
348
348
|
private _font_table: IFontTable;
|
|
349
349
|
public get font_table(): IFontTable {
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
|
|
351
|
+
if (!this._font_table || this._fontTableDirty)
|
|
352
352
|
this.update_font_table();
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
return this._font_table;
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -359,7 +359,7 @@ export class TextFormat extends AssetBase {
|
|
|
359
359
|
// font_table is only ever set in parser or when using label-data
|
|
360
360
|
// after using "bold" or "itaic" font_table should never be set directly
|
|
361
361
|
this._font_table = value;
|
|
362
|
-
this.
|
|
362
|
+
this._fontTableDirty = false;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
/**
|
|
@@ -386,9 +386,25 @@ export class TextFormat extends AssetBase {
|
|
|
386
386
|
return this.font?.name;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
+
public set font_name(value: string) {
|
|
390
|
+
if (this.font?.name == value)
|
|
391
|
+
return;
|
|
392
|
+
|
|
393
|
+
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
394
|
+
this._font = DefaultFontManager.getFont(value);
|
|
395
|
+
} else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
396
|
+
this._font = DeviceFontManager.getDeviceFont(value);
|
|
397
|
+
} else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
398
|
+
this._font = DefaultFontManager.getFont_CFF(value);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
this._fontTableDirty = true;
|
|
402
|
+
this._updateID++;
|
|
403
|
+
}
|
|
404
|
+
|
|
389
405
|
public update_font_table() {
|
|
390
406
|
|
|
391
|
-
this.
|
|
407
|
+
this._fontTableDirty = false;
|
|
392
408
|
let stylename = FontStyleName.STANDART;
|
|
393
409
|
if (this._italic && !this._bold)
|
|
394
410
|
stylename = FontStyleName.ITALIC;
|
|
@@ -398,53 +414,29 @@ export class TextFormat extends AssetBase {
|
|
|
398
414
|
stylename = FontStyleName.BOLDITALIC;
|
|
399
415
|
|
|
400
416
|
if (this._font) {
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
417
|
+
const font_table = this._font.get_font_table(stylename, TesselatedFontTable.assetType, null, true);
|
|
418
|
+
|
|
419
|
+
// if we have a font-table, and we switch to invalid style,
|
|
420
|
+
// we just keep the existing font-table
|
|
421
|
+
if (this._font_table && !font_table)
|
|
405
422
|
return;
|
|
406
|
-
|
|
407
|
-
this._font_table =
|
|
408
|
-
return;
|
|
423
|
+
|
|
424
|
+
this._font_table = font_table ? font_table : Font.emptyFontTable;
|
|
409
425
|
}
|
|
410
426
|
}
|
|
411
427
|
|
|
412
428
|
public get font(): Font {
|
|
413
|
-
if (this._font) {
|
|
414
|
-
return this._font;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
418
|
-
this._font = DefaultFontManager.getFont(null);
|
|
419
|
-
} else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
420
|
-
this._font = DeviceFontManager.getDeviceFont(null);
|
|
421
|
-
} else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
422
|
-
this._font = DefaultFontManager.getFont_CFF(null);
|
|
423
|
-
} else {
|
|
424
|
-
console.warn('[TextFormat] - unsupported FontLookUpMode', this.fontLookUpMode);
|
|
425
|
-
}
|
|
426
|
-
this._font_table = null;
|
|
427
|
-
this._textFormatDirty = true;
|
|
428
429
|
return this._font;
|
|
429
430
|
}
|
|
430
431
|
|
|
431
432
|
public set font(value: Font) {
|
|
432
|
-
this.
|
|
433
|
-
if (typeof value === 'string') {
|
|
434
|
-
this._setFontFromString(value);
|
|
433
|
+
if (this._font == value)
|
|
435
434
|
return;
|
|
436
|
-
}
|
|
437
435
|
|
|
438
|
-
|
|
439
|
-
this._updateID++;
|
|
440
|
-
}
|
|
436
|
+
this._font = value;
|
|
441
437
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
this._font = null;
|
|
447
|
-
this._font_table = null;
|
|
438
|
+
this._fontTableDirty = true;
|
|
439
|
+
this._updateID++;
|
|
448
440
|
}
|
|
449
441
|
|
|
450
442
|
/**
|
|
@@ -531,13 +523,12 @@ export class TextFormat extends AssetBase {
|
|
|
531
523
|
* space between lines.
|
|
532
524
|
*/
|
|
533
525
|
constructor(
|
|
534
|
-
font: string = null, size: number = null, color: number = null, bold: boolean = null,
|
|
526
|
+
font: Font | string = null, size: number = null, color: number = null, bold: boolean = null,
|
|
535
527
|
italic: boolean = null, underline: boolean = null, url: string = null,
|
|
536
528
|
link_target: string = null, align: string = null,
|
|
537
529
|
leftMargin: number = null, rightMargin: number = null, indent: number = null, leading: number = null) {
|
|
538
530
|
super();
|
|
539
531
|
|
|
540
|
-
this.fontLookUpMode = FontLookUpMode.DEFAULT;
|
|
541
532
|
this._size = size;
|
|
542
533
|
this._color = color;
|
|
543
534
|
this._bold = bold;
|
|
@@ -551,42 +542,19 @@ export class TextFormat extends AssetBase {
|
|
|
551
542
|
this._indent = indent;
|
|
552
543
|
this._leading = leading;
|
|
553
544
|
|
|
554
|
-
this._letterSpacing = null;
|
|
555
|
-
|
|
556
|
-
this._font_table = null;
|
|
557
|
-
|
|
558
545
|
if (typeof font === 'string') {
|
|
559
|
-
this.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this._font = font;
|
|
563
|
-
this._textFormatDirty = true;
|
|
546
|
+
this.font_name = font;
|
|
547
|
+
} else {
|
|
548
|
+
this.font = font;
|
|
564
549
|
}
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
private _setFontFromString(font_name: string) {
|
|
569
|
-
|
|
570
|
-
let asset;
|
|
571
|
-
|
|
572
|
-
if (this.fontLookUpMode == FontLookUpMode.DEFAULT) {
|
|
573
|
-
asset = DefaultFontManager.getFont(font_name);
|
|
574
|
-
} else if (this.fontLookUpMode == FontLookUpMode.DEVICE) {
|
|
575
|
-
asset = DeviceFontManager.getDeviceFont(font_name);
|
|
576
|
-
} else if (this.fontLookUpMode == FontLookUpMode.EMBED_CFF) {
|
|
577
|
-
asset = DefaultFontManager.getFont_CFF(font_name);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
this.font = asset;
|
|
581
|
-
this._textFormatDirty = true;
|
|
582
550
|
}
|
|
583
551
|
|
|
584
552
|
public clone(): TextFormat {
|
|
585
553
|
const clonedFormat: TextFormat = new TextFormat(
|
|
586
|
-
|
|
554
|
+
this._font, this._size, this._color, this._bold,
|
|
587
555
|
this._italic, this._underline,this.url, this.link_target,
|
|
588
556
|
this._align, this._leftMargin, this._rightMargin, this._indent, this._leading);
|
|
589
|
-
clonedFormat.font_table = this._font_table;
|
|
557
|
+
clonedFormat.font_table = this._font_table; //investigate why this needs to be copied
|
|
590
558
|
return clonedFormat;
|
|
591
559
|
}
|
|
592
560
|
|