UNPKG

@nmmty/lazycanvas

Version:

A simple way to interact with @napi-rs/canvas in an advanced way!

85 lines (84 loc) 2.64 kB
import { IFonts, IFontsManager } from "../../types"; import { Font } from "../helpers/Font"; export declare class FontsManager implements IFontsManager { map: Map<string, Font>; debug: boolean; constructor(debug?: boolean); /** * Replace base fonts with custom fonts by special file. * Use this method before loading fonts by `FontManager`. * The file should be generated by the following instructions: * @see https://github.com/NMMTY/LazyCanvas/blob/main/scripts/FontsGenerate.md * @param fontList {IFonts[]} - The `fonts` to set */ loadFonts(fontList: IFonts): this; /** * Add a font to the map * @param fonts {Font[]} - The `font` to add to the map */ add(...fonts: Font[]): this; /** * Remove a font from the map * @param array {Array<{ family: string, weight: string }>} - The `family` and `weight` of the font to remove */ remove(...array: Array<{ family: string; weight: string; }>): this; /** * ClearLayer all fonts from the map */ clear(): this; /** * Get a font from the map * @param family {string} - The `family` of the font to get * @param weight {string} - The `weight` of the font to get */ get(family: string, weight?: string): Font | Font[] | undefined; /** * Check if a font exists in the map * @param family {string} - The `family` of the font to check * @param weight {string} - The `weight` of the font to check */ has(family: string, weight?: string): boolean; /** * Get the size of the map */ size(): number; /** * Get the values of the map */ values(): IterableIterator<Font>; /** * Get the keys of the map */ keys(): IterableIterator<string>; /** * Get the entries of the map */ entries(): IterableIterator<[string, Font]>; /** * Iterate over the map * @param callbackfn {Function} - The function to execute on each font * @param thisArg {any} - The `this` context to use */ forEach(callbackfn: (value: Font, key: string, map: Map<string, Font>) => void, thisArg?: any): this; /** * Convert the map to a JSON object */ toJSON(): object; /** * Convert the map from a JSON object * @param json {object} - The JSON object to convert */ fromJSON(json: object): this; /** * Convert the map to an array */ toArray(): Font[]; /** * Convert an array to the map * @param array {Font[]} - The `array` to convert */ fromArray(array: Font[]): this; }