Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: TrueType font experiments...  (Read 4786 times)

Freddybear

  • Bay Watcher
    • View Profile
TrueType font experiments...
« on: May 06, 2011, 09:34:41 am »

First off, disclaimers.I am a complete n00b at working with truetype fonts. I'm doing this by trial and error.

I tried out the truetype font option, and found the default font provided was not terribly much to my liking, and the special characters were missing as well, so I decided to experiment with changing the font and adding the special characters myself.

First experiment, I copied the "Dejavu-sans-mono-bold" font from c:\windows\fonts to my dwarf fortress data\art folder, and renamed it to font.ttf. That worked fine, and Dwarf Fortress text uses the font. However, the special characters and other symbols in the DF alphabet are still not showing up, which is no surprise.

Second experiment, I downloaded a copy of FontForge for mingw from here: http://www.geocities.jp/meir000/fontforge/
(that page is in japanese, just look for the fontforge-mingw zip file)
If you're using linux, you may be able to install fontforge from source from sourceforge: http://sourceforge.net/projects/fontforge/

I copied the dejavu font unicode glyphs for the male and female signs to the character positions shown in the wiki page: http://df.magmawiki.com/index.php/Character_table
I then generated a new font.ttf file, and now those symbols show up in the animal lists in the embark preparation screens. So I think this is going to work out.

I'll probably spend the next couple of days to fill in the rest of the missing character glyphs and then we'll see how it works out.

One warning, I think there is a glitch when you save the font you're working on in fontforge's own file format. I had better luck using the generate font option to create a new ttf file rather than saving work in the fontforge format.
Logged

Freddybear

  • Bay Watcher
    • View Profile
Re: TrueType font experiments...
« Reply #1 on: May 06, 2011, 11:08:50 am »

Third experiment, it seems that DF's truetype text output code is translating accented characters to non-accented characters. Is that the case?
Logged

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: TrueType font experiments...
« Reply #2 on: May 06, 2011, 12:52:02 pm »

The case is that any character above 127 is causing errors.  That's why looking at creatures with long names can cause problems, because they're more likely to have some strange goblin name.

You can have all the glyphs you want in the TTF font, but only the basic ASCII compliment will be displayed.

Baughn was working on it, last I knew.  The next release might have the fixes in, but only Toady really knows.
Logged
I like fortresses because they are still underground.

Freddybear

  • Bay Watcher
    • View Profile
Re: TrueType font experiments...
« Reply #3 on: May 06, 2011, 01:21:51 pm »

I see. At least I have got the low-ascii special characters like male and female.
Logged

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: TrueType font experiments...
« Reply #4 on: May 06, 2011, 01:27:07 pm »

And that is a small miracle.  I would venture to say you could do all the low-bit control glyphs, and they would work.
Logged
I like fortresses because they are still underground.

Freddybear

  • Bay Watcher
    • View Profile
Re: TrueType font experiments...
« Reply #5 on: May 06, 2011, 02:10:46 pm »

I have entered glyphs for all of the characters in the DF alphabet, although the accented characters aren't actually showing up (yet?)
Here is the modified font file: http://www.mediafire.com/?tk6654bv6xa9xkn
Put that in your data/art directory and rename it to font.ttf...

Now for the !!fun!! part. I tried to create a new font file with just the first 256 character positions filled, but I'm obviously missing some vital information about the font glyphs that I'm copying into that new file because they aren't showing up correctly at all.
Logged

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: TrueType font experiments...
« Reply #6 on: May 06, 2011, 02:48:01 pm »

When you say "at all", do you mean even the normal letters aren't showing up?  1-127 are working correctly as of right now, anything higher than that does not.  That means accented characters won't work, and it also means that the greek characters won't show up either.
Logged
I like fortresses because they are still underground.

Freddybear

  • Bay Watcher
    • View Profile
Re: TrueType font experiments...
« Reply #7 on: May 06, 2011, 03:18:05 pm »

I meant that the low-ascii character glyphs, such as "male" and "female". They work in the (rather large) modified dejavu font file but do not work in the smaller font file which I tried to create. Oddly, though, the regular letter glyphs do work. I do not know enough about font creation to figure out what I'm doing wrong.
Logged

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: TrueType font experiments...
« Reply #8 on: May 06, 2011, 03:24:34 pm »

I use a font named Tuffy, which I found while trolling the forums here.  It's truetype, and has special characters, although the exceptional quality isn't three bars, but instead a questionmark within a circle.  Small change, I find it workable.  All other symbols work as desired, M/F and Masterwork.  I can toss it onto DFFD is needed.

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: TrueType font experiments...
« Reply #9 on: February 27, 2012, 10:46:41 pm »

I'm using fontforge, minigw version.  I'm trying to generate fonts, and they output, and I can open them in notepad, as well as swriter, but not in putty.  Any ideas?  Am I choosing the wrong options for ttf?

Update:
got it, had to check all checkboxes of scale uniformly, I was comparing to the original tocky, and without those additional checkboxes, it was spaced to far.

Update: I got it, when you are resize uniformly, or scale, or whatever, don't choose center, choose glyph origin.

By the way, I used dt2ttf, then fontforge to downscale.

Update: Resizing vher seemed to give me problems.  So it's a hit or miss I guess.  The original one based on tocky is working well with this method.
« Last Edit: February 28, 2012, 12:11:32 am by thistleknot »
Logged