ktx-font: GPU-ready rasterized fonts

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:


[Skip to Readme]

Properties

Versions 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson, base (>=4.11 && <5), brillo, bytestring, containers, kb-text-shape, ktx-codec, ktx-font, msdf-atlas, text, vector, zstd [details]
License BSD-3-Clause
Copyright 2025 IC Rainbow
Author IC Rainbow
Maintainer aenor.realm@gmail.com
Category Graphics
Source repo head: git clone https://gitlab.com/dpwiz/ktx-font
Uploaded by AlexanderBondarenko at 2025-12-30T22:13:53Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
executablesDisabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for ktx-font-0.1.0.0

[back to package description]

ktx-font

A KTX2 format containing a font atlas texture, enriched with:

The package also has a module to run the shaping using stacks of those font bundles.

The pipeline

Typically you'd just use your rendering engine's utilities to do this.

To implement one, you have to address the three points in the font lifecycle:

Preparing the font bundle

This part is the slowest one, as it takes care to distill and optimize the data for faster use later.

  1. Generate an atlas with msdf-atlas-gen
  2. Transcode into KTX file.
  3. Preprocess and inject the extras as texture attributes.

Loading

Since all the data are already preprocessed you only have to move it to the appropriate places on CPU/GPU.

For each font file:

For each combination of fonts (font stack:

Using

  1. Run Codec.Ktx2.Font.Shaping.shape on your text.
  2. Iterate over the result and convert the UV and world boxes to the data you use for rendering.

NB: Due to font format and design shenanigans you have to use a sane "font size" metric that is shared for all the fonts in the stack. Typically that would be "cap height", and msdf-atlas takes care of converting "em" units into that.

For more details on the problem see:

Demo

The repo has a demo of using the shaping results in a Gloss (Brillo) context.

sorry for the swearing, i was that mad making all this

The glyphs have black boxes because the atlas is transcoded as having the single channel swizzled as rrr1. This allows to see the glyph boxes against the grey background.

The msdf-atlas-gen is typically used to produce distance fields, but Gloss can't render them.