Skip to content

[Proposal] Optimal custom fonts using machine learning #20

Description

@cdluminate

The fonts used by us day to day are not specifically designed for printing images. In order to improve the result of character art, custom font is a doable solution, as proved by BE256 and BE512 fonts.

The highest resolution that chafa supports is 8x8 according to the bitmap. There are 2^64 possible combinations, but the whole Unicode table is not enough for that. However, my bold assumption is that most solutions in the space formed of 2^64 combinations are useless.

To find out the most useful N patterns in this space, we can take advantage from machine learning.

The proposed procedure for creating such custom font looks like this:

  1. sample M random crops (in ratio w=1:h=2) from an image dataset

  2. turn the M crops into binarized bitmaps using histogram and downsample to 8x8

  3. find N cluster centers in the space by leveraging Kmeans algorithm, with the M (64x1) binaryzed vectors as the dataset.

  4. convert the N vectors into C bitmap header and SVG plots.

Highlight:

  1. Best resolution.

  2. Easy to code. Automatic font and C code generation.

  3. I don't know what glyph is good for printing character art, but the algorithm can figure it out.

Assignee: myself

Metadata

Metadata

Assignees

Labels

featureNew feature or requestsymbolsFonts and symbols

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions