- C 74.2%
- Python 24%
- Makefile 1.8%
|
|
||
|---|---|---|
| build | Basic font reading | |
| data | [UPDATE] cleaned up the data dir and clarified the readme | |
| src | embarrassing bug fix lol | |
| work | Basic font reading | |
| .gitignore | my pawesome amendments | |
| gencharset.c | my pawesome amendments | |
| LICENSE | Licensing | |
| Makefile | my pawesome amendments | |
| openrelay-ttfhack.py | my pawesome amendments | |
| README.md | my pawesome amendments | |
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:
-
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 toyMin=-363 yMax=872, which seems to work a lot better in that regard. -
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 -
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.