-
Hi! Can anyone tell me what I'm doing wrong in the following code? Fonts were converted to .bpf files (per maplibre docs) and stored in the SvelteKit project at "static/fonts/B612 Mono Regular/" Any suggestions are appreciated.
This is a sample of the countryLabels data:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hm I have no experience using custom fonts with MapLibre, but my first intuition would be to look at the network tab in the inspector. Then you can see if it's requesting the font at all, and if so which URL it's attempting to fetch and what is coming back from that. |
Beta Was this translation helpful? Give feedback.
-
Ok, I figured it out. Here's what you do to get custom fonts on your svelte-maplibre map.
Good luck! PS. I came across a site that mentioned the glyph path does NOT require the absolute full URL in DEV but it does in PROD. I cannot confirm this as I haven't pushed to PROD yet. The Maplibre Glyphs docs mention the absolute path is necessary but it's assuming vanilla JS. I'm not familiar enough with SK to know if it still applies or if SK does some path wrangling behind the scenes. If someone more familiar with SK deployments knows please comment. |
Beta Was this translation helpful? Give feedback.
Ok, I figured it out. Here's what you do to get custom fonts on your svelte-maplibre map.
Generate glyph files from your standard .otf or .ttf font. Use this site:
https://maplibre.org/font-maker/
Download and unzip the generated files. Copy the complete unzipped contents into /static/fonts
Add the server location of the font(s) to your map style definition.
The "glyphs" line is key. Leave it as-is.
This tells SvelteKit fonts specified by the layout's "text-font" property are located inside the SvelteKit project under static/fonts