Bay 12 Games Forum

Dwarf Fortress => DF Modding => Topic started by: Moosey on March 21, 2011, 01:09:56 pm

Title: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Moosey on March 21, 2011, 01:09:56 pm
I'm in the process of creating a font for use with Dwarf Fortress's TrueType feature, made to fit the interface.  That is, a monospaced font whose character aspect is perfectly square, so that it matches up with DF's display grid when using a square graphic tileset like Ironhand or Mayday -- in fact, it's based directly on the letters in Mayday's tileset.  It would free up the letter spaces in the tileset for use as additional graphics, and inversely keep all graphics out of the punctuation and other rare characters in text.  The biggest drawback of a TTF font, pre-placed text appearing misaligned, would not apply to this font.

Early results are promising:
Spoiler (click to show/hide)

However, the game crashes in some modes (the "V" view units and "T" view items in buildings views, specifically).  Is this a bug in DF, or due to something missing or broken in my font?  Also, I notice that some text screens (the "thoughts and preferences" screen, for instance) are rendered with the tileset, not the TTF.  Is this going to be fixed?
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: swampwater on March 22, 2011, 01:00:02 am
I wish I had answers, but mostly I'm posting just to watch and bump since this is something I'm pretty interested in. I haven't had TTF mode crash on me in those screens so I think it must be your font- though I can't think of why other than some sort of line-overrun problem... I haven't done extensive font testing, but your project is exactly the sort of thing I was searching for, so I hope it works out. :) I have only done basic playing around with fontmakers before but if you need some help I'm willing to do what I can.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Halaster on March 25, 2011, 03:15:47 pm
Looking really good. Hope you can sort out the issues and release this.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Uristocrat on March 25, 2011, 04:28:13 pm
However, the game crashes in some modes (the "V" view units and "T" view items in buildings views, specifically).  Is this a bug in DF, or due to something missing or broken in my font?  Also, I notice that some text screens (the "thoughts and preferences" screen, for instance) are rendered with the tileset, not the TTF.  Is this going to be fixed?

I would test the same modes with the original truetype font to check that.  Also, search the bug tracker.  I haven't used TTFs because of the issues you're trying to solve, so I'm not too sure.

I do seem to remember that I might have seen a crash once, though, when I tried using TTF, but I didn't use it for very long so I don't remember any more.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: gramks2k on March 25, 2011, 04:43:59 pm
So if I am understanding this correctly this would free up 26+ tiles for use for other things without affecting any of the text in the game? Brilliant!
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Sarvesh Mossbeard on March 25, 2011, 05:07:54 pm
I approve!
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Uristocrat on March 26, 2011, 01:24:48 am
Here we go, I found the TTF bug on Mantis.  It's not marked as resolved, so I'm guessing that this still causes crashes.  Might want to compare it to your experiences (and comment on the bug if you've been getting this crash in a newer version than .18).

Bug 0003762 (http://www.bay12games.com/dwarves/mantisbt/view.php?id=3762)

Good luck with the font, though.  I really like the idea of separating letters from objects :)
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Deon on March 26, 2011, 09:51:44 am
Yeah, currently TTF mode crashes on me a lot during "v"-looking at creatures. So it's not your fault, keep your great work and we all hope that it's fixed someday. Did Baughn disappear forever? It was his work I think.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Moosey on April 10, 2011, 02:48:08 pm
Oh my!  I haven't been watching my own thread.

Anyway, my findings so far:  With some fonts (my own included), this crash happens in a repeatable fashion.  With others (the system Courier font, for example), the crash does not happen at all, even under identical circumstances.  So what's the difference?  My first thought that the game might be using an unusual code for a character somewhere, and the lack of that character in the font is causing the crash.  After filling out every reasonable (and many unreasonable) character in my font with something, even if just a scribble, the crash still happens.

But perhaps I've missed some.  The main culprit I'm looking at is the item descriptor symbols, since these generally only appear in the screens where it crashes.  There's a manual page that describes all the possible descriptors (I'm picking approximate matches from a Unicode chart for some of these):

Thing (regular)
-Thing- (well crafted)
+Thing+ (finely crafted)
¤Thing¤ (superior)
≡Thing≡ (exceptional)
*Thing* (masterpiece)
«Thing» (decorated)
‼Thing‼ (on fire)
(thing) (foreign)
{thing} (forbidden)
xThingx, XThingX, XXThingXX (damaged)
◀Thing▶ (magical) (wait, magic?  where?!)

Some of these symbols are mundane, and others are quite esoteric.  Does anybody know the exact Unicode numbers for what DF uses for these designations?  I must say I don't feel like designing characters for the full 50,000+ Unicode spectrum just in case.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Thrin on April 10, 2011, 09:03:35 pm
Well, I don't know much about ascii, unicode, or ttf's, but I think this wikipage might help you out. (http://df.magmawiki.com/index.php/Character_table)

Edit:

Looking at the page above and comparing with my current tileset, these are my best guesses:

Code: [Select]
Thing
Thing

-Thing-
2d Thing 2d

+Thing+
2b Thing 2b

*Thing*
2a Thing 2a

≡Thing≡
2261 Thing 2261

☼Thing☼
263c Thing 263c

«Thing»
ab Thing bb

‼Thing‼
203c Thing 203c

(Thing)
28 Thing 29

{Thing}
7b Thing 7d

Damage just seems to be x X and XX.

◄Thing►
25c4 Thing 25ba
Magical is, of course, a guess, as I have nothing in the game to compare to.

Also, the word "thing" has lost all meaning to me.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Spectre Incarnate on April 11, 2011, 05:14:58 am

Some of these symbols are mundane, and others are quite esoteric.  Does anybody know the exact Unicode numbers for what DF uses for these designations?  I must say I don't feel like designing characters for the full 50,000+ Unicode spectrum just in case.

Most computers come installed with a Character Map, under Accessories > System Tools.

Also, as far as I've seen, TTFonts make my game crash when looking at a creature with a long name, usually a beast or other bad guy that has made a name for him/herself in the history books. I hope that helps ya, cause it'd be awesome if you could get that working better. Thanks so much for trying!
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Jeoshua on April 11, 2011, 06:46:46 am
TTF font mode crashes when it encounters certain letters above ASCII 127, but not always.  Basically it reads/writes to an uninitialized section of code. Baughn was supposedly trying to fix it, but I haven't heard anything past "OH I know what's doing it" really
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Totaku on April 11, 2011, 07:50:17 am
Yeah, currently TTF mode crashes on me a lot during "v"-looking at creatures. So it's not your fault, keep your great work and we all hope that it's fixed someday. Did Baughn disappear forever? It was his work I think.

Well he did disappear for a while. But he came back lately. And I think he is aware of the issue since it was brought up on Ironhand's custom graphic pack, mainly due to the fact he used Truetype by default as well.

So he knows there's a problem with true type, it's just a matter of how soon the problem will be fixed, and when it'll be implmented into DF.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: KurzedMetal on June 20, 2011, 06:07:20 am
I'm kinda chanting necromantic spells here...
But the bug you guys were talking about is marked as resolved now. Did you try your font in the lastest versions?
And I was looking for a TTF font (mostly for the genre and masterwork icons), how's your project going? :)
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: kotekzot on June 20, 2011, 09:04:16 am
I believe the fix will only appear in post .25 releases.
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: KurzedMetal on June 20, 2011, 10:53:28 am
mmmm, i think you are right, i saw "product version" set to 0.31.18 and "fixed in" set to "next realease" and i guessed it would be 0.31.19, but the bug has many duplicate and some of them are from .25 (which i forgot to check).
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Sirelde on January 07, 2014, 10:42:05 am
Sorry for posting on such an old topic...
I want to know if there is a way to make every text on DF to be displayed on Truetype.
This screen, for example. Because the tileset is messing with some characters.
Thanks.


(http://i.imgur.com/efrJ7nwl.jpg)
Title: Re: Creating a custom TrueType font tailored to Dwarf Fortress
Post by: Vherid on January 07, 2014, 04:22:07 pm
I thought the whole point of TTF usage was so that the kerning wasn't just a golfbag of clubs thrown all over the place. By creating a big bulky font with wide kerning, kinda defeats the point of that. Based on what you're doing there shouldn't really be any major differences between TTF and tileset, especially if it's monospaced. I get what you're doing, but at the same time, I don't. Why not at least allow the letters to be properly kerned instead of worrying about grid alignment, as long as its the same type style.