1
0
Fork
You've already forked ttf2psf
0
ttf2psf with some extra stuff i needed to make it work right
  • C 74.2%
  • Python 24%
  • Makefile 1.8%
Find a file
2026年05月05日 02:29:16 +01:00
build Basic font reading 2023年02月10日 09:29:58 -06:00
data [UPDATE] cleaned up the data dir and clarified the readme 2025年12月16日 22:39:06 +05:00
src embarrassing bug fix lol 2025年12月22日 05:39:30 -06:00
work Basic font reading 2023年02月10日 09:29:58 -06:00
.gitignore my pawesome amendments 2026年05月05日 02:29:16 +01:00
gencharset.c my pawesome amendments 2026年05月05日 02:29:16 +01:00
LICENSE Licensing 2023年02月20日 17:12:54 -06:00
Makefile my pawesome amendments 2026年05月05日 02:29:16 +01:00
openrelay-ttfhack.py my pawesome amendments 2026年05月05日 02:29:16 +01:00
README.md my pawesome amendments 2026年05月05日 02:29:16 +01:00

winter's amended version of ttf2psf

i didn't actually edit the code itself i just brought a bunch of other software in here to use with it!! plus i can write notes for myself on how to make this stuff work.

really i just wanted to get Fairfax as my linux console font cause i thought it would look nice :>

i edited ttf2psf's makefile trivially to let it use an installation prefix instead of hardcoded to /usr/bin and /usr/share. i also brought in the ttfhack script from openrelay-tools, which was necessary to convince ttf2psf of the correct dimensions of the font. (Fairfax HD comes with a pre-ttfhacked version, but plain Fairfax doesn't at time of writing). note that openrelay-tools is available under the MIT licence, contrary to the GPLv3 licence applied to ttf2psf. i hope it's okay for me to put them together like this :3

here's how i turned fairfax into a console font:

  1. run the original font file through ttfhack and set its dimensions as needed. i used Fairfax SM mostly because i figured it would probably work better. i copied the dimensions from Fairfax HD's ttfhack build steps:
    ./openrelay-ttfhack.py if=/path/to/FairfaxSM.ttf yMin=-544 yMax=1308 of=FairfaxSMBoundsHack.ttf
    however after testing i found that this ended up leaving a lot of space between lines, so i did some quick maths and changed it to yMin=-363 yMax=872, which seems to work a lot better in that regard.

  2. create a custom character set to specify the characters included in the console font. unfortunately you can't just put them all in there because linux refuses to load the font if it has more than 512. there are premade charsets in data/ but i decided to make my own so that i could specifically have basic and supplemental latin and arrows and box drawings. i wrote a tiny c program to do this because i'm lazy; you can edit it if you want to select different codepoint ranges.
    cc gencharset.c -o gencharset && ./gencharset >charset

  3. finally we can run ttf2psf to generate the final font file. i ran it like this:
    ttf2psf -g -c charset -e data/equivalence/linux.set -w 6 -r 11 FairfaxSMBoundsHack.ttf FairfaxSM.1x.psfu.gz
    i set width 6 and height 11 because fairfax is a 6x12 bitmap font. originally i used height 12 but i noticed this left 1 pixel gaps between lines and i didn't really like that cause i wanted my box drawings to join up so i just changed it to 11 and that seemed to work fine. i also made a version with width 12 and height 23 in order to have a 2x scaled font, since the 1x version was very tiny on my display. in all honesty i don't know which equivalence file i ought to be using so i just picked the linux one since i'm on linux and it seems to work fine i'm not familiar enough with this to know if that's heinous or not

original ttf2psf readme

ttf2psf - a simple psf generator

This just converts files to psf format with freetype, nothing else.

Quickstart

ttf2psf -g -c [charset file] -e [equivalence file] input.ttf output.psfu.gz

Note

When generating a psf file, you may get the following warning:

Warning: Equivalence file includes characters not in the charset!

This generally means that the equivalence file and the charset file aren't exactly compatible. This can usually be ignored, but if these files were generated with a utility like psfextract it may be a sign that something has gone wrong.

Usage

Mandatory

ttf2psf -c [char set] -e [equivalence file] [input.ttf] [output.psfu]
-c : Specify a character set from one of the following
 (see /usr/share/ttf2psf/charsets or ./data/charsets)
-e : Specify an equivalence file from one of the following
 (see /usr/share/ttf2psf/equivalence or ./data/equivalence)

Optional

-1 : Output a psf1 file
-2 : Output a psf2 file (default)
-g : Output a gzip compressed file
-h : Show this help menu
-w, -r : Sets character width and row count respectively (default: 8x16)
 increase -w to increase the size, increase -r to adjust the spacing

Licensing/inspiration

This specific utility is released under the GPL-3.0 or later license, but there are several other projects with other licenses that this one wouldn't have been possible without.

The charset and equivalence files are taken directly from Anton Zinoviev's bdf2psf utility, which is released under the GPL-2.0. These specific files are in the public domain, but I feel like I should include this message.

To write this program I've had to consult Alexey Gladkov's kbd utilities quite a bit (GPLv2 or later). I haven't copied any code from them, but I feel like they deserve some recognition.