@awayjs/scene
Version:
AwayJS scene classes
45 lines (44 loc) • 1.64 kB
JavaScript
import { Font } from '../text/Font';
var DeviceFontManager = /** @class */ (function () {
function DeviceFontManager() {
}
DeviceFontManager.getDeviceFont = function (fontName) {
fontName = this.getDeviceFontName(fontName);
if (this._deviceFonts[fontName])
return this._deviceFonts[fontName];
var font = new Font();
font.name = fontName;
this._deviceFonts[fontName] = font;
return this._deviceFonts[fontName];
};
DeviceFontManager.getDeviceFontName = function (fontName) {
if (!fontName) {
// console.log('default font equested - using sans');
return "sans" /* DEVICEFONT.SANS */;
}
for (var key in this.deviceFontMap) {
var idx = this.deviceFontMap[key].indexOf(fontName);
if (idx >= 0) {
return key;
}
}
console.warn("[DeviceFontManager] - no mapping exists for ".concat(fontName, "\n\t\t - falling back to ").concat("sans" /* DEVICEFONT.SANS */));
return "sans" /* DEVICEFONT.SANS */;
};
DeviceFontManager.deviceFontMap = {};
DeviceFontManager._deviceFonts = {};
return DeviceFontManager;
}());
export { DeviceFontManager };
DeviceFontManager.deviceFontMap["sans" /* DEVICEFONT.SANS */] = [
'_sans',
'Arial'
];
DeviceFontManager.deviceFontMap['Arial Narrow'] = [
'Arial Narrow'
];
DeviceFontManager.deviceFontMap['Arial Black'] = [
'Arial Black'
];
DeviceFontManager.deviceFontMap["serif" /* DEVICEFONT.SERIF */] = [];
DeviceFontManager.deviceFontMap["typewriter" /* DEVICEFONT.TYPEWRITER */] = [];