Table of Contents

Bake A Custom SDF Font!

So, you want to make a custom font atlas for the Vulkan renderer! Here's my artisanal recipe, passed down through generations.

Ingredients

Recipe

  1. Build msdf-atlas-gen
    # In the msdf-atlas-gen folder
    # On macOS/unix-like systems:
     
    mkdir build && cd build # create the build folder
    cmake -DMSDF_ATLAS_USE_VCPKG=OFF -DMSDF_ATLAS_USE_SKIA=OFF .. # generate makefile using cmake
    make & cd bin # build and go to the output folder
  2. Generate font files!
    # the magic command
    ./msdf-atlas-gen -type mtsdf -format png -csv FONTNAME.csv -imageout FONTNAME.png -font PATH_TO_FONT_FILE
  3. Copy the generated FONTNAME.csv and FONTNAME.png to the vendor/fonts folder in folk
  4. Edit line the lines that look like this line in display.folk to set it as a default
    # replace the "PTSans-Regular" with FONTNAME
    [...] {font "PTSans-Regular"} [...]
  5. To use it in programs, do so:
    # using a wish
    Wish $this is labelled "Text" with font "FONTNAME"
    # using display
    Display::text $x $y $scale $text $radians FONTNAME