Arsir Peta

ENID

Notes · · 1 min read

How a map app gets its fonts

A vector map does not use the fonts on the phone. It downloads its letters in blocks of 256, drawn in a way that scales.

A vector map draws its labels itself, so it cannot rely on the fonts installed on a device. In MapLibre styles, the letters come from a glyphs address in the style, a pattern with places for the font name and a range of characters. Each file holds 256 consecutive Unicode code points: the first, 0 to 255, covers the basic Latin letters, digits and punctuation.

The glyphs are stored as signed distance fields: instead of the shape of each letter at one size, each pixel records how far it is from the letter's edge. Drawn at one size, 24 pixels, a letter can be scaled up or down smoothly, and the same data draws the halo around it.

For offline packs this has a consequence. Every range that any label needs must be in the pack, or those labels simply do not appear: a place name with one accented letter outside the first range needs the file that holds it. Languages written with thousands of characters need many ranges, and the pack grows with them.

Before delivery we list every character in every label in a pack and check that its range is included. It takes seconds and prevents the most puzzling kind of fault report: a name that is on the map in the office and missing in the field.