Skip to main content
Module

x/font/mod.ts>Font

🖌 A simple deno module for font rasterization
Latest
class Font
import { Font } from "https://deno.land/x/font@0.1.3/mod.ts";

Represents a font.

Constructors

new
Font(bytes: Uint8Array, unnamed 1?: LoadOptions)

Methods

horizontalLineMetrics(px: number): LineMetrics | undefined

The new line height for the font. Only populated for fonts with vertical text layout metrics. undefined if unpopulated.

lookupGlyphIndex(character: string): number

Finds the internal glyph index for the given character. If the character is not present in the font then 0 is returned.

metrics(character: string, px: number): Metrics

Retrieves the layout metrics for the given character. If the character isn't present in the font, then the layout for the font's default character is returned instead.

metricsIndexed(index: number, px: number): Metrics

Retrieves the layout metrics at the given index. You normally want to be using metrics instead, unless your glyphs are pre-indexed.

rasterize(character: string, px: number): RasterizeResult

Retrieves the layout metrics and rasterized bitmap for the given character. If the character isn't present in the font, then the layout and bitmap for the font's default character is returned instead.

rasterizeIndexed(index: number, px: number): RasterizeResult

Retrieves the layout metrics and rasterized bitmap at the given index. You normally want to be using rasterize instead, unless your glyphs are pre-indexed.

scaleFactor(px: number): number

Calculates the glyph's outline scale factor for a given px size.

unitsPerEm(): number

Gets the font's units per em.

verticalLineMetrics(px: number): LineMetrics | undefined

The new line height for the font. Only populated for fonts with horizontal text layout metrics. undefined if unpopulated.