![]() ![]() Requests to (and probably most requests to custom-hosted font servers) are ultimately served by node-fontnik. The server is responsible for providing the block of glyphs in a Protobuf-encoded format. For each missing glyph, the GlyphManager will request a 256-glyph block containing that glyph. This tells the GlyphManager where to request the fonts from ( mapbox://fonts/… will resolve to something like …). If not, it will request them.Įvery style with text has a line like this: The GlyphManager maintains an in-memory cache, and if all the requested glyphs are already cached, it will return them immediately. The GlyphManager lives on the foreground and its responsibility is responding to getGlyphs requests with an SDF bitmap and glyph metrics for every requested glyph. SymbolBucket#populate: symbol_bucket.js GlyphManager SymbolLayout constructor: symbol_layout.cpp ![]() Once all the dependencies for a tile have been gathered, we send a getGlyphs message to the foreground, and wait for a response before moving on to symbol layout (unless the worker already has all the dependencies satisfied from an earlier request). It’s worth noting here that our current code treats “glyph” and “unicode codepoint” interchangeably, although that assumption won’t always hold. "Open Sans Semibold, Arial Unicode MS Bold": , Requesting glyphs: text-field + text-font → GlyphDependencies Legible, fast, and beautiful is the name of the game.įor some history on how this took shape, check out Ansis' "label placement" blog post from 2014 (many implementation details have changed, but the goals are the same). By rolling our own text rendering, we can take advantage of the GPU to efficiently re-use/re-combine small constituent parts (glyphs) Speed: If we asked the platform to draw the text for us and then uploaded the raster results to textures for rendering on the GPU, we’d have to re-upload a large amount of texture data for every new label, every change in size, etc.Control: To make beautiful interactive maps, we’re changing properties of the text in label on every frame.Why are we rolling our own text rendering in the first place, when browsers and operating systems already provide powerful text capabilities for free? Basically: For simplicity, I focus on text, but icons are a very close analog - for many purposes, you can think of an icon as just a label with a single “glyph”. Native and JS share very similar implementations, with occasionally different naming conventions. The primary audience is new maintainers or contributors to mapbox-gl-native and mapbox-gl-js, although it may also provide useful context for power users of Mapbox GL who want to know how the sausage is made. This document is intended as a high level architectural overview of the path from a text-field entry in a style specification to pixels on a screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |