o
odinpkg.dev
packages / library / serafont

serafont

7ebdbfblibrary

an odin ttf font renderer

MIT · updated 1 week ago

This is a (hopefully) simple odin font renderer.

  1. Download https://github.com/devNegative-asm/odin-cuda-bindings into shared:devnegative-asm
  2. Parse the font binary.
    font, err := ttf.parse_ttf(font_file)
  3. Get the scale factor for your monitor and font size
    scale := ttf.get_font_scale_factor_for_metrics(&font, ttf.SizeMetrics{
        size = ttf.Millimeters(620),
        resolution = 3840,
        point_size = 60
    })
  4. Pick your rendering settings. See RenderSettings. To reuse settings, set the font.default_settings = settings
  5. Call render_string_to_buffer(settings, font_file) if using default settings, otherwise call render_string(font, font_file, "string you want to render")
  6. ttf.destroy_font(font)