Class: Font#
Font object
see online docs: https://font.tomchen.org/bdfparser_js/font
Hierarchy#
- Font
Constructors#
constructor#
+ new Font(): Font
Returns: Font
Properties#
__curline_chars#
• Private __curline_chars: null | string= null
Defined in: bdfparser.ts:196
__curline_startchar#
• Private __curline_startchar: null | string= null
Defined in: bdfparser.ts:195
__f#
• Private Optional __f: undefined | AsyncIterableIterator<string>
Defined in: bdfparser.ts:197
__glyph_count_to_check#
• Private __glyph_count_to_check: null | number= null
Defined in: bdfparser.ts:194
__headers#
• Private __headers: Partial<Headers>
Defined in: bdfparser.ts:191
glyphs#
• glyphs: Map<number, GlyphMetaInFont>
Defined in: bdfparser.ts:193
headers#
• headers: undefined | Headers
Defined in: bdfparser.ts:190
props#
• props: Props
Defined in: bdfparser.ts:192
Accessors#
length#
• length(): number
Same as .length()
Returns how many glyphs actually exist in the font.
see online docs: https://font.tomchen.org/bdfparser_js/font#length
Returns: number
Actual glyph count in the font
Defined in: bdfparser.ts:529
Methods#
__parse_glyph_count#
â–¸ Private__parse_glyph_count(): Promise<void>
Returns: Promise<void>
Defined in: bdfparser.ts:378
__parse_headers#
â–¸ Private__parse_headers(): Promise<void>
Returns: Promise<void>
Defined in: bdfparser.ts:228
__parse_headers_after#
â–¸ Private__parse_headers_after(): void
Returns: void
Defined in: bdfparser.ts:332
__parse_props#
â–¸ Private__parse_props(): Promise<void>
Returns: Promise<void>
Defined in: bdfparser.ts:339
__prepare_glyphs#
â–¸ Private__prepare_glyphs(): Promise<void>
Returns: Promise<void>
Defined in: bdfparser.ts:400
__prepare_glyphs_after#
â–¸ Private__prepare_glyphs_after(): void
Returns: void
Defined in: bdfparser.ts:508
draw#
â–¸ draw(str: string, options?: { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; missing?: undefined | null | Glyph | GlyphMeta ; mode?: undefined | null | 0 | 1 ; usecurrentglyphspacing?: undefined | null | boolean }): Bitmap
Draw (render) the glyphs of the specified words / setences / paragraphs (as a string), to a Bitmap object.
see online docs: https://font.tomchen.org/bdfparser_js/font#draw
Parameters:#
| Name | Type | Default value | Description |
|---|---|---|---|
str | string | - | String to draw |
options | { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; missing?: undefined | null | Glyph | GlyphMeta ; mode?: undefined | null | 0 | 1 ; usecurrentglyphspacing?: undefined | null | boolean } | ... | - |
Returns: Bitmap
Bitmap object
Defined in: bdfparser.ts:885
drawall#
â–¸ drawall(options?: { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; mode?: undefined | null | 0 | 1 ; order?: undefined | 0 | 1 | -1 | 2 ; r?: undefined | number | [number, number] | [number, number][] ; usecurrentglyphspacing?: undefined | null | boolean }): Bitmap
Draw all the glyphs in the font (default) or in the specified codepoint range in the font, sorted by the specified order (or by the ascending codepoint order by default), to a Bitmap object.
see online docs: https://font.tomchen.org/bdfparser_js/font#drawall
Parameters:#
| Name | Type | Default value |
|---|---|---|
options | { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; mode?: undefined | null | 0 | 1 ; order?: undefined | 0 | 1 | -1 | 2 ; r?: undefined | number | [number, number] | [number, number][] ; usecurrentglyphspacing?: undefined | null | boolean } | ... |
Returns: Bitmap
Bitmap object
Defined in: bdfparser.ts:935
drawcps#
â–¸ drawcps(cps: number[], options?: { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; missing?: undefined | null | Glyph | GlyphMeta ; mode?: undefined | null | 0 | 1 ; usecurrentglyphspacing?: undefined | null | boolean }): Bitmap
Draw the glyphs of the specified codepoints, to a Bitmap object.
see online docs: https://font.tomchen.org/bdfparser_js/font#drawcps
Parameters:#
| Name | Type | Default value | Description |
|---|---|---|---|
cps | number[] | - | Array of codepoints to draw |
options | { direction?: undefined | null | lrtb | rltb | tbrl | btrl | lr | rl | tb | bt | lrbt | rlbt | tblr | btlr ; linelimit?: undefined | null | number ; missing?: undefined | null | Glyph | GlyphMeta ; mode?: undefined | null | 0 | 1 ; usecurrentglyphspacing?: undefined | null | boolean } | ... | - |
Returns: Bitmap
Bitmap object
Defined in: bdfparser.ts:690
glyph#
â–¸ glyph(character: string): null | Glyph
Get a glyph (as Glyph object) by its character.
see online docs: https://font.tomchen.org/bdfparser_js/font#glyph
Parameters:#
| Name | Type | Description |
|---|---|---|
character | string | Character |
Returns: null | Glyph
Glyph object, or null if the glyph does not exist in the font
Defined in: bdfparser.ts:649
glyphbycp#
â–¸ glyphbycp(codepoint: number): null | Glyph
Get a glyph (as Glyph Object) by its codepoint.
see online docs: https://font.tomchen.org/bdfparser_js/font#glyphbycp
Parameters:#
| Name | Type | Description |
|---|---|---|
codepoint | number | Codepoint |
Returns: null | Glyph
Glyph object, or null if the glyph does not exist in the font
Defined in: bdfparser.ts:621
itercps#
â–¸ itercps(order?: null | 0 | 1 | -1 | 2, r?: null | number | [number, number] | [number, number][]): number[]
Similar to .iterglyphs(), except it returns an array of glyph codepoints instead of an iterator of Glyph objects.
see online docs: https://font.tomchen.org/bdfparser_js/font#itercps
Parameters:#
| Name | Type | Description |
|---|---|---|
order? | null | 0 | 1 | -1 | 2 | Order |
r? | null | number | [number, number] | [number, number][] | Codepoint range |
Returns: number[]
An iterator of the codepoints of glyphs
Defined in: bdfparser.ts:543
iterglyphs#
â–¸ iterglyphs(order?: null | 0 | 1 | -1 | 2, r?: null | number | [number, number] | [number, number][]): IterableIterator<null | Glyph>
Returns an iterator of all the glyphs (as Glyph objects) in the font (default) or in the specified codepoint range in the font, sorted by the specified order (or by the ascending codepoint order by default).
see online docs: https://font.tomchen.org/bdfparser_js/font#iterglyphs
Parameters:#
| Name | Type | Description |
|---|---|---|
order? | null | 0 | 1 | -1 | 2 | Order |
r? | null | number | [number, number] | [number, number][] | Codepoint range |
Returns: IterableIterator<null | Glyph>
An iterator of glyphs as Glyph objects. Missing glyphs are replaced by null
Defined in: bdfparser.ts:603
lacksglyphs#
â–¸ lacksglyphs(str: string): null | string[]
Check if there is any missing glyph and gets these glyphs' character.
see online docs: https://font.tomchen.org/bdfparser_js/font#lacksglyphs
Parameters:#
| Name | Type | Description |
|---|---|---|
str | string | string to check |
Returns: null | string[]
List of missing glyph(s)' characters, or null if all the glyphs in your string exist in the font
Defined in: bdfparser.ts:663
load_filelines#
â–¸ load_filelines(filelines: AsyncIterableIterator<string>): Promise<Font>
Load the BDF font file (file line async iterator).
see online docs: https://font.tomchen.org/bdfparser_js/font#load_filelines
Parameters:#
| Name | Type | Description |
|---|---|---|
filelines | AsyncIterableIterator<string> | Asynchronous iterable iterator containing each line in string text from the font file |
Returns: Promise<Font>
The current Font object
Defined in: bdfparser.ts:208