UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

65 lines 3.39 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Symbology */ /** The [FontFile]($backend) encodings understood by iTwin.js. * @see [this article]($docs/learning/backend/Fonts.md) to learn more about fonts in iModels. * @public * @extensions */ export var FontType; (function (FontType) { /** [OpenType](https://en.wikipedia.org/wiki/OpenType) format, derived from and compatible with the earlier [TrueType](https://en.wikipedia.org/wiki/TrueType) format. * The vast majority of modern, scalable, aesthetically-pleasing fonts are delivered in this format. * OpenType files typically use one of the following suffixes: .ttf, .ttc, .otf, and .otc. * @see [FontFile.createFromTrueTypeFileName]($backend) to work with font files in this format. */ FontType[FontType["TrueType"] = 1] = "TrueType"; /** [RSC](https://docs.bentley.com/LiveContent/web/MicroStation%20Help-v27/en/GUID-FC78484C-E42F-30BF-BF68-2B2C025AE040.html) is a simple font format * originating in [MicroStation](https://en.wikipedia.org/wiki/MicroStation). In MicroStation, they are defined in "resource files" with a ".rsc" suffix. * In iModels, they are encoded in a binary format. Currently, no APIs exist to convert to this binary format, but some [connectors]($docs/learning/imodel-connectors.md) can * perform the conversion. */ FontType[FontType["Rsc"] = 2] = "Rsc"; /** [SHX](https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-DE941DB5-7044-433C-AA68-2A9AE98A5713) is a simple font format originating in * [AutoCAD](https://en.wikipedia.org/wiki/AutoCAD). SHX fonts are generally distributed as files with a ".shx" suffix. * @see [FontFile.createFromShxFontBlob]($backend) to work with font files in this format. */ FontType[FontType["Shx"] = 3] = "Shx"; })(FontType || (FontType = {})); /** * A FontMap holds the set of font names available in an iModel. * Within the GeometryStream of an Element, a specific font is referenced by its FontId that is local to the iModel. * This class maps FontIds to FontProps. * @note This API has never worked properly. Don't use it. Use [IModelDb.fonts]($backend) instead. * @public * @deprecated in 5.0.0 - will not be removed until after 2026-06-13. Use [IModelDb.fonts]($backend) instead. */ export class FontMap { fonts = new Map(); constructor(props) { if (undefined !== props) this.addFonts(props.fonts); } addFonts(fonts) { fonts.forEach((font) => this.fonts.set(font.id, font)); } toJSON() { const fonts = []; this.fonts.forEach((font) => fonts.push(font)); return { fonts }; } /** look up a font by case insensitive name or number and return its FontProps */ getFont(arg) { if (typeof arg === "number") return this.fonts.get(arg); for (const font of this.fonts.values()) if (font.name.toLowerCase() === arg.toLowerCase()) return font; return undefined; } } //# sourceMappingURL=Fonts.js.map