Skip to content

Using custom fonts on lables #191

Answered by wx007
wx007 asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I figured it out. Here's what you do to get custom fonts on your svelte-maplibre map.

  1. Generate glyph files from your standard .otf or .ttf font. Use this site:
    https://maplibre.org/font-maker/

  2. Download and unzip the generated files. Copy the complete unzipped contents into /static/fonts

  3. 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

   const myMapStyle = {
      "version": 8,
      "glyphs": "fonts/{fontstack}/{range}.pbf",  
      "sources": {...},
      "layers": [...], 
     }
  1. I…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wx007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants