1 line
24 KiB
Plaintext
1 line
24 KiB
Plaintext
|
|
{"version":3,"file":"BitmapFont.mjs","sources":["../src/BitmapFont.ts"],"sourcesContent":["import { ALPHA_MODES, BaseTexture, MIPMAP_MODES, Rectangle, settings, Texture, utils } from '@pixi/core';\nimport { TextMetrics, TextStyle } from '@pixi/text';\nimport { BitmapFontData } from './BitmapFontData';\nimport { autoDetectFormat } from './formats';\nimport { drawGlyph, extractCharCode, resolveCharacters } from './utils';\n\nimport type { IBaseTextureOptions, ICanvas, ICanvasRenderingContext2D, SCALE_MODES } from '@pixi/core';\nimport type { ITextStyle } from '@pixi/text';\n\nexport interface IBitmapFontCharacter\n{\n xOffset: number;\n yOffset: number;\n xAdvance: number;\n texture: Texture;\n page: number;\n kerning: utils.Dict<number>;\n}\n\ntype BaseOptions = Pick<IBaseTextureOptions, 'scaleMode' | 'mipmap' | 'anisotropicLevel' | 'alphaMode'>;\n\n/** @memberof PIXI */\nexport interface IBitmapFontOptions extends BaseOptions\n{\n /**\n * Characters included in the font set. You can also use ranges.\n * For example, `[['a', 'z'], ['A', 'Z'], \"!@#$%^&*()~{}[] \"]`.\n * Don't forget to include spaces ' ' in your character set!\n * @default PIXI.BitmapFont.ALPHANUMERIC\n */\n chars?: string | (string | string[])[];\n\n /**\n * Render resolution for glyphs.\n * @default 1\n */\n resolution?: number;\n\n /**\n * Padding between glyphs on texture atlas. Lower values could mean more visual artifacts\n * and bleeding from other glyphs, larger values increase the space required on the texture.\n * @default 4\n */\n padding?: number;\n\n /**\n * Optional width of atlas, smaller values to reduce memory.\n * @default 512\n */\n textureWidth?: number;\n\n /**\n * Optional height of atlas, smaller values to reduce memory.\n * @default 512\n */\n textureHeight?: number;\n\n /**\n * If mipmapping is enabled for texture. For instance, by default PixiJS only enables mipmapping\n * on Power-of-Two textures. If your textureWidth or textureHeight are not power-of-two, you\n * may consider enabling mipmapping to get better quality with lower font sizes. Note:\n * for MSDF/SDF fonts, mipmapping is not supported.\n * @default PIXI.BaseTexture.defaultOptions.mipmap\n */\n mipmap?: MIPMAP_MODES;\n\n /**\n * Anisotropic filtering level of texture.\n * @default PIXI.BaseTexture.defaultOptions.anisotropicLevel\n */\n anisotropicLevel?: number;\n\n /**\n * Default scale mode, linear, nearest. Nearest can be helpful for bitmap-style fonts.\n * @default PIXI.BaseTexture.defaultOptions.scaleMode\n */\n scaleMode?: SCALE_MODES;\n\n /**\n * Pre multiply the image alpha. Note: for MSDF/SDF fonts, alphaMode is not supported.\n * @default PIXI.BaseTexture.defaultOptions.alphaMode\n */\n alphaMode?: ALPHA_MODES;\n\n /**\n * Skip generation of kerning information for the BitmapFont.\n * If true, this could potentially increase the performance, but may impact the rendered text appearance.\n * @default false\n */\n skipKerning?: boolean;\n}\n\n/**\n * BitmapFont represents a typeface available for use with the BitmapText class. Use the `install`\n * method for adding a font to be used.\n * @memberof PIXI\n */\nexport class BitmapFont\n{\n /**\n * This character set includes all the letters in the alphabet (both lower- and upper- case).\n * @type {string[][]}\n * @example\n * BitmapFont.from('ExampleFont', style, { chars: BitmapFont.ALPHA })\n */\n public static readonly ALPHA = [['a', 'z'], ['A', 'Z'], ' '];\n\n /**\n * This character set includes all decimal digits (from 0 to 9).\n * @type {string[][]}\n * @example\n * BitmapFont.from('ExampleFont', style, { chars: BitmapFont.NUMERIC })\n */\n public static readonly NUMERIC = [['0', '9']];\n\n /**\n * This character set is the union of `BitmapFont.ALPHA` and `BitmapFont.NUMERIC`.\n * @type {string[][]}\n */\n public s
|