A foray into fonts.

Original A foray into fonts. Editable
version 1 of 1

This app converts Dwarf Fortress tilesets into TrueType Fonts. The current TTFs are made by with a closed source and slow (on the order of 30 minutes per font) AutoHotKey script for an $80 windows-only app. If the last sentence made you cringe a few times, this is the app for you. (No offense, Elvang.)

Works with BMPs or PNGs, square or rectangle. Has a handful of settings to help with making one-bit fonts (which fbterm desperately needs). Usually takes less than 30 seconds.

Requires Python, Python Imaging Library and Fontforge so it should be cross platform.

kk (2015-07-14-09-25-48-040)

Unless you really know what you are doing, don't bother trying to use it on Windows. While all of these technologies run on Windows, the script does not work well there. (I suspect it is related to how fontforge is called or how the temp files are saved, patches welcome.)



Source is GPL and contains some goodies like the unicode mapping for a DF font and a homebrew bitmap-to-svg converter (optimized for pixel art). Though I think the vectorizer could be a lot better, it works fine at the single native resolution.

Jim Hill (2011-03-14-02-21-01-366)

Hey, I found a bug in your table: you have 9762 for the female sign, it should be 9792.



Kyle (2011-03-15-08-12-05-928)

Fixed. Thanks!



Alistair Buxton (2011-09-14-14-55-40-684)

Hello,

I used this code as a basis for a tool to convert pcf bitmap fonts into ttf fonts.

I added an improved vectorizer to that the fonts are much more efficient, and split up the code so that you just pass in a dict of bitmaps keyed by the character unicode values.

The code is on my github:

https://github.com/ali1234/bitmap2ttf

Thanks for making this possible :)



download: df2ttf.py

Romaq (2011-11-18-16-12-54-343)

Sorry, I'm a noob. :(

I have several 'flavors' of Python installed for GIMP, Blender, and 'just-in-case'. Subversion is also installed with its own version of Python, which this appears to be defaulting to. Anyway, just in this case, I can drop to a command prompt, type "df2ttf.py" and it attempts to run... then barfs out the following:

C:UsersasmithDocumentsDwarf Fortress ProjectsSoftwaredf2tty>df2ttf.py 'import site' failed; use -v for traceback Traceback (most recent call last): File "C:UsersasmithDocumentsDwarf Fortress ProjectsSoftwaredf2ttydf2ttf .py", line 6, in [HTML_REMOVED] import tempfile, os, subprocess, shutil, optparse File "C:csvnPython25\libtempfile.py", line 32, in [HTML_REMOVED] import os as _os File "C:csvnPython25\libos.py", line 398, in [HTML_REMOVED] import UserDict File "C:csvnPython25\libUserDict.py", line 84, in [HTML_REMOVED] _abcoll.MutableMapping.register(IterableUserDict) File "C:csvnPython25\libabc.py", line 109, in register if issubclass(subclass, cls): File "C:csvnPython25\libabc.py", line 151, in subclasscheck if subclass in cls._abc_cache: File "C:csvnPython25\lib_weakrefset.py", line 69, in contains return ref(item) in self.data TypeError: cannot create weak reference to 'classobj' object

Do I need to force a particular Python version? I have 2.6, 2.7, 3.2 in both 32 and 64 bit flavors.



--help docs

Usage: df2ttf.py [options] tileset.png/bmp

Convert a Dwarf Fortress PNG/BMP tileset to a TrueType Font.  See
http://kmkeen.com/df2ttf/ for more.

Options:
  -h, --help        show this help message and exit
  -g, --gamma       Enable gamma correction.
  -d, --dither      Enable dithering, implies -b.
  -b, --blackwhite  Create 1 bit font.