"use strict";
/*---------------------------------------------------------------------------------------------
* 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FontMap = exports.FontType = void 0;
/** The type of a font.
 * @public
 * @extensions
 */
var FontType;
(function (FontType) {
    FontType[FontType["TrueType"] = 1] = "TrueType";
    FontType[FontType["Rsc"] = 2] = "Rsc";
    FontType[FontType["Shx"] = 3] = "Shx";
})(FontType || (exports.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 The font map is generally established when the iModel is first created to specify the set of fonts available
 * for editors. Adding new entries requires that the schema lock be held.
 * @public
 */
class FontMap {
    constructor(props) {
        this.fonts = new Map();
        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 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 === arg)
                return font;
        return undefined;
    }
}
exports.FontMap = FontMap;
//# sourceMappingURL=Fonts.js.map