Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Using a secondary PNG as pseudo "TrueType"  (Read 1880 times)

Michael

  • Bay Watcher
    • View Profile
Using a secondary PNG as pseudo "TrueType"
« on: September 30, 2012, 03:42:15 am »

I never use the TrueType font feature in DF.  At a tileset height of only 16, every pixel counts and scaled fonts are just barely usable.  My tileset looks much better.

However, the fact that modern versions of DF can indeed cope with text that not only comes from outside the 256 normal tiles but is proportionally spaced, suggests some other improvements that could be made to the graphics.

That is, allow a second PNG tileset to be used for all the text that currently may be rendered in TrueType.  This tileset would have to have the same pixel height, but could have a different width.  After all, monospace text that doesn't match the "grid" is just a trivial subset of the proportional case that is already supported.

This would allow a tall aspect ratio tileset to be used for text at the same time as a square one is used for the map.  It would also free "graphics" tileset authors to alter the accented letters without distorting dwarven names.

Finally, this would lead to more intensive testing of some of the code paths currently only used by TrueType mode.  In the long run this would lead to better quality for people who do prefer an actual scaled font.
Logged

Courtesy Arloban

  • Bay Watcher
  • This isn't a fortress... ...It's also not a map.
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #1 on: October 01, 2012, 11:36:10 am »

I think this is a good idea, but the second PNG should be based on a different codesheet with more accented letters, less graphics.

There are programs that will allow you to convert a PNG file, that you've edited yourself, to a ttf file you can rename and stick in your init folders.  However legends mode will still use the tileset for the game.
Logged
Maybe that the dwarves never died and everyone is just shunning them.
"Wait, what are you doing?  I don't want to go in there!  No, I'm still alive, you can't do this to me!  Is Anybody listening?  Hello... Can someone let me out?  Help me!  Is anyone there?  I'm running out of air!"

Michael

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #2 on: October 01, 2012, 01:17:23 pm »

I think this is a good idea, but the second PNG should be based on a different codesheet with more accented letters, less graphics.
That would not bring any benefits at present, since DF does not use any characters beyond the CP437 set in text.  Also, it would be convenient to be able to use any existing tileset PNG as the alternate font.

There are programs that will allow you to convert a PNG file, that you've edited yourself, to a ttf file you can rename and stick in your init folders.  However legends mode will still use the tileset for the game.
That legends mode doesn't make much use of the TrueType feature is an example of a bug that would be more visible, and thus more likely to be fixed, if this feature were present.
Logged

CLA

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #3 on: October 02, 2012, 11:34:29 am »

The same is true for a separate tileset for the map only. In the end it's just part of the "full graphics support" suggestion, really.

In the end it might just be simpler to handle all graphics like creatures are currently handled. If there's a raw and a graphic that assigns a symbol to something (be it a letter, a map symbol, a creature or an object), use it, if not, fall back to the CP437 tileset.
Logged
CLA - an ASCII-like Graphic Pack with simplified letter-like creature graphics. The simple and clean looks of ASCII with distinct creature graphics - best of both worlds!

http://www.bay12forums.com/smf/index.php?topic=105376.0

Michael

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #4 on: October 02, 2012, 03:01:36 pm »

The same is true for a separate tileset for the map only.
I don't get what you mean here. 

In the end it's just part of the "full graphics support" suggestion, really.

In the end it might just be simpler to handle all graphics like creatures are currently handled. If there's a raw and a graphic that assigns a symbol to something (be it a letter, a map symbol, a creature or an object), use it, if not, fall back to the CP437 tileset.
That wouldn't give you the ability to use 9x16 text alongside 16x16 map tiles.

Also, I suspect there is some sort of architectural restriction in DF that is blocking further expansion of graphics.  "Graphics" in its current, creatures-only, form has been here since the 2-D days.  An extension to override the images for stone or trees has been obvious all along, but has not appeared in six years.

Perhaps DF maintains a cache of the appearance of each Z-level, which rigidly uses two bytes per grid in VGA textmode format, but treats mobile entities as "sprites" in a separate layer overlaying the player's view. The fact that creature graphics are not used when a creature is caged, and that dyes do not transcend the 16-color limit despite the raw data suggesting they should, would appear to support this.

But the fact that TrueType works as well as it does indicates that the architectural limits regarding text have been broken.  Not only can text use images outside the base 256 tiles, it doesn't even have to respect the grid.
Logged

King Mir

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #5 on: October 02, 2012, 04:03:20 pm »

There were plans to expand to different font formats besides truetype. Baughn, who was doing the development on that doesn't have time these days, however.


I have played around with creating a 16x16 true type font that works with DF, but it was unstable and would crash DF in certain cases.

CLA

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #6 on: October 02, 2012, 04:05:46 pm »

The same is true for a separate tileset for the map only.
I don't get what you mean here. 

I meant in regards to freed up tiles.

Quote from: Michael
That wouldn't give you the ability to use 9x16 text alongside 16x16 map tiles.
In the current implementation, yes. But considering that there is a definite difference between areas that draw text and that draw the world, I don't see what's stopping us to have that at some point.

Quote from: Michael
Also, I suspect there is some sort of architectural restriction in DF that is blocking further expansion of graphics.
Well, there certainly is a lot of legacy code that has to be adapted and possibly rewritten, plenty of hardcoded things that have to be rewritten and possibly bugs.

For example a few texts still don't work with TrueType (the embark message amongst others).



In either case, did you think about making your own TT font with a program like FontForge, based on your tileset?
Personally, I use Profont with a 18x18 tileset, and I think a lot of fonts made for programming are great for DF, even when zooming.

I have played around with creating a 16x16 true type font that works with DF, but it was unstable and would crash DF in certain cases.
What did you use? I added some missing glyphs to use ProFont with DF, and had no problems. I used FontForge for windows (which itself is an instable pile of shit, on windows at least).
« Last Edit: October 02, 2012, 04:08:10 pm by CLA »
Logged
CLA - an ASCII-like Graphic Pack with simplified letter-like creature graphics. The simple and clean looks of ASCII with distinct creature graphics - best of both worlds!

http://www.bay12forums.com/smf/index.php?topic=105376.0

King Mir

  • Bay Watcher
    • View Profile
Re: Using a secondary PNG as pseudo "TrueType"
« Reply #7 on: October 02, 2012, 04:14:30 pm »

I have played around with creating a 16x16 true type font that works with DF, but it was unstable and would crash DF in certain cases.
What did you use? I added some missing glyphs to use ProFont with DF, and had no problems. I used FontForge for windows (which itself is an instable pile of shit, on windows at least).
I used FontForge on Ubuntu. I took a mono-space font and tried to widen it.

The problem I ran into was with centered font. I'm not positive of this, but this was my conclusion. When text in DF is centered, and has an odd number of characters, then the text space in not symmetrical. Since the text would not fit the space on one side, DF would crash.

I also had problems with creating a font that would scale properly-- that is it's width would constantly be equal to it's height. So if you changed the height, DF would crash, because the width was no longer thin enough.