Skip to content

Support loading json font atlas as generated by msdf-atlas-gen + fix font kerning offset to Float#1336

Open
robinp wants to merge 1 commit intoHeapsIO:masterfrom
robinp:msdf-atlas-gen
Open

Support loading json font atlas as generated by msdf-atlas-gen + fix font kerning offset to Float#1336
robinp wants to merge 1 commit intoHeapsIO:masterfrom
robinp:msdf-atlas-gen

Conversation

@robinp
Copy link

@robinp robinp commented Feb 10, 2026

Supports loading the output of Chlumsky/msdf-atlas-gen directly. This has the following benefits:

Example atlas generation (msdf):

/bin/msdf-atlas-gen -font a-font.ttf  -format png -pots -size 32 -json atlas.fnt -imageout atlas.png -yorigin top

Load it with channels=4, or specify -type sdf and use say channel 0.

Note: you might want to up the -size, depending on the font. Size=64 produced better spacings than size=32 for a random test font (arial-like, as is the sdf_font of the Text.hs example).

Edit: also, small change to take Float for glyph kerning. It was already stored as Float, but took Int (which sufficed so far). But with getting raw Float data now, it makes a real difference.

@robinp robinp changed the title Support loading json font atlas as generated by msdf-atlas-gen. Support loading json font atlas as generated by msdf-atlas-gen + fix font kerning offset to Float Feb 10, 2026
@robinp
Copy link
Author

robinp commented Feb 10, 2026

Random example - image diff on int-kern vs float-kern on a random test text, which started with "ATA...". The original A is diffed away completely since it matched, but the T and subsequent chars show a diff, due to the precision kerning. Rendered using HL target.

int-kern-vs-float-kern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant