@lightningjs/renderer
Version:
Lightning 3 Renderer
48 lines • 1.45 kB
JavaScript
import { UpdateType } from '../CoreNode.js';
import { EventEmitter } from '../../common/EventEmitter.js';
export var FontState;
(function (FontState) {
FontState[FontState["Created"] = 0] = "Created";
FontState[FontState["Loading"] = 1] = "Loading";
FontState[FontState["Loaded"] = 2] = "Loaded";
FontState[FontState["Failed"] = 3] = "Failed";
})(FontState || (FontState = {}));
/**
* EventEmiter only intended to communicated with FontManager
*/
export class CoreFont extends EventEmitter {
waitingNodes = Object.create(null);
normalizedMetrics = Object.create(null);
textRenderer;
state;
family;
metrics;
constructor(textRenderer, props) {
super();
this.family = props.family;
this.state = FontState.Created;
this.textRenderer = textRenderer;
}
onLoaded() {
const waitingNodes = this.waitingNodes;
for (let key in waitingNodes) {
waitingNodes[key].setUpdateType(UpdateType.Local);
delete waitingNodes[key];
}
this.state = FontState.Loaded;
}
waiting(node) {
this.waitingNodes[node.id] = node;
}
stopWaiting(node) {
if (this.waitingNodes[node.id]) {
delete this.waitingNodes[node.id];
}
}
destroy() {
delete this.waitingNodes;
delete this.normalizedMetrics;
delete this.metrics;
}
}
//# sourceMappingURL=CoreFont.js.map