API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classGlyphAtlas

@codexo/exojs / rendering / stable

A per-font-variant glyph atlas with automatic multi-page growth. In `'sdf'` mode (default) each atlas page is a single-channel R8 `DataTexture` populated by GlyphSdf. One `GlyphSdf` instance is kept per raster font size so the atlas can mix sizes efficiently. In `'color'` mode pages are RGBA canvas textures that preserve full glyph colour data for emoji and colour fonts. **Pixel ratio.** An atlas rasterizes at `pixelRatio` device pixels per logical pixel: a glyph asked for at logical size 9 in a ratio-3 atlas is rendered from a 27px font, and every raster-derived number it hands back is divided by the ratio again so the caller keeps working in logical units. The ratio is part of the atlas's identity (GlyphAtlasPool) - it has to be, because the pool is process-wide and two applications at different densities must not share one set of pages. The LOGICAL metrics layout consumes (advance, kerning) come from the ratio-independent GlyphMetrics instead, so the same string lays out identically at every ratio.

5
props
5
methods
2
events
Import
import { GlyphAtlas } from '@codexo/exojs'

A per-font-variant glyph atlas with automatic multi-page growth.

In `'sdf'` mode (default) each atlas page is a single-channel R8 `DataTexture` populated by GlyphSdf. One `GlyphSdf` instance is kept per raster font size so the atlas can mix sizes efficiently.

In `'color'` mode pages are RGBA canvas textures that preserve full glyph colour data for emoji and colour fonts.

**Pixel ratio.** An atlas rasterizes at `pixelRatio` device pixels per logical pixel: a glyph asked for at logical size 9 in a ratio-3 atlas is rendered from a 27px font, and every raster-derived number it hands back is divided by the ratio again so the caller keeps working in logical units. The ratio is part of the atlas's identity (GlyphAtlasPool) - it has to be, because the pool is process-wide and two applications at different densities must not share one set of pages. The LOGICAL metrics layout consumes (advance, kerning) come from the ratio-independent GlyphMetrics instead, so the same string lays out identically at every ratio.

Constructors1
Methods5
clear(): void
Vertical metrics of this source's font at fontSize. Optional - a caller without it falls back to fractions of the font size, which places a decoration plausibly but not typographically.
Return metrics for the given character at the given font size.
getKerning(prev: string, next: string, fontSize: number): number
Return the kerning adjustment (in pixels) between two adjacent characters. Positive values add space; negative values pull glyphs together. Optional - callers treat a missing method as zero kerning.
A solid texel decoration quads sample, or null when this source has none. A source that answers null renders no underline and no strikethrough: there is nowhere in its texture that is reliably opaque, and an offline atlas cannot be given one after the fact.
Properties5
pixelRatio: number
Device pixels per logical pixel this atlas rasterizes at. Part of its identity in the GlyphAtlasPool: a ratio-2 and a ratio-3 atlas of the same font variant are different resources holding different pages.
sdfRadius: number
SDF buffer radius in LOGICAL pixels - the outline/shadow reach this atlas can encode. Independent of pixelRatio: the raster buffer grows with the ratio so the logical reach stays put.
Events2
Dispatched after clear discards every rasterized glyph and kerning entry. A node holding GlyphInfo from this atlas has to re-layout - its UVs still address the (now-repacked) pages, but the glyph that used to sit there is gone. Text listens on the atlas it currently draws from and re-lays out in response; a caller driving GlyphAtlas directly should do the same for anything it cached from getGlyph.
Dispatched whenever a new atlas page is allocated. Listen here to detect unexpected atlas growth (e.g. many unique CJK glyphs or an oversized font size). The payload is the zero-based page index. ts const atlas = pool.getAtlas({ family: 'Roboto', fontWeight: '400' }); atlas.onPageAdded.on(idx => console.warn(Atlas page ${idx} added));
Source