Repository navigation
Draw basemap labels in their styled fonts - #519
Open
simplifaisoul wants to merge 1 commit into
Open
simplifaisoul wants to merge 1 commit into
simplifaisoul wants to merge 1 commit into
Conversation
The tile server's own font merging ignores a stack's order, so labels styled "Montserrat SemiBold, Open Sans Bold, Noto Sans Regular" were drawn in Noto Sans. /api/basemap now asks for each font on its own and merges the glyphs itself, each character from the first font that has it, as map styles expect. A stack with a font that failed to load answers 502 uncached rather than being cached incomplete.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Basemap place names were drawn in the wrong typeface. The style asks for font stacks such as
Montserrat SemiBold, Open Sans Bold, Noto Sans Regular, where each character should come from the first font that has it. The tile server's own font merging ignores that order, so labels came out in Noto Sans instead of Montserrat and looked noticeably different from CARTO's map./api/basemapnow merges font stacks itself, so place names match CARTO's lettering.Changes
src/lib/basemap/glyphs.ts: reads and writes glyph files (protobuf) and merges them in stack order. Each character comes from the first font that has it; glyph bytes are copied unchanged./api/basemap/fonts/{fontstack}/{range}requests each font of the stack from the tile server on its own and merges the result.502and uncached, so an incomplete stack is never cached for a month.Testing
npx vitest run: 180 files and 1,827 tests pass (27 skipped, as on master).npx tsc --noEmit: no errors. ESLint: no findings in changed files.next build: completes with exit code 0./api/basemap/fontsnow match CARTO's own glyph server exactly (previously they matched Noto Sans). The Arabic range still returns 253 glyphs from the Noto fallback fonts.🤖 Generated with SIMPLIFAI