Documentation
    Preparing search index...

    Function buildGlyphAtlas

    • Packs font into one RGBA8 atlas (§56 MVP tier).

      const atlas = buildGlyphAtlas();                       // the built-in face
      atlas.width; // 128
      atlas.glyphs.get("A"); // { u0, v0, u1, v1, … }
      const texture = new Texture(atlas); // @fourjs/render

      A monospace font's cells are all one size, so the packer is a grid, not a bin packer: rectangle packing exists to fit differently sized boxes, and running one over 96 identical rectangles would trade an exact answer for a heuristic. Glyphs are placed left to right, bottom row of cells first, in ascending code-point order, with the fallback box last. Column count is whatever makes the atlas roughly square and then rounds the width up to a power of two, which the height gets too.

      Powers of two because a §77-tier texture with LINEAR filtering and CLAMP_TO_EDGE is safest at POT sizes across the WebGL 2 / WebGL 1 boundary, and because a POT atlas can grow mipmaps later without being repacked. The unused remainder is transparent and costs one quarter of a 128² atlas — 16 kB of the built-in font's 64 kB — which is a good trade against a repack.

      Nothing here reads a clock, a random number, or the environment: the same font and the same padding produce a byte-identical buffer and an identically ordered glyph map on every machine and in every process.

      Parameters

      Returns GlyphAtlas