Font Conversion & Repair: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(update)
(move font patcher section to own article)
Line 7: Line 7:
* ExportFontToDoom
* ExportFontToDoom
* Q3Font [http://rfactory.org/q3font.html] (Runs also fine under ''Wine'')
* Q3Font [http://rfactory.org/q3font.html] (Runs also fine under ''Wine'')
* [http://www.bloodgate.com/mirrors/tdm/pub/scripts/font_patcher.pl font_patcher.pl]
* [[Font Patcher]]


My understanding is that ''ExportFontToDoom'' is more suitable than Q3Font for converting. It is what I used to convert a lot of TTF fonts. See notes with that tool as to how use it. But be aware of copyright issues if converting TTF fonts.
My understanding is that ''ExportFontToDoom'' is more suitable than Q3Font for converting. It is what I used to convert a lot of TTF fonts. See notes with that tool as to how use it. But be aware of copyright issues if converting TTF fonts.
Line 67: Line 67:
== font_patcher.pl ==
== font_patcher.pl ==


This utility allows you to "patch" a fontimage.dat file, e.g. change different characters and values without having the other characters getting affect (a common proble with q3font, f.i.).
Please see the [[Font Patcher|main article]].
 
The file reads in a fontimage.dat file, a file with commands, then executes each command and then writes out the modified fontimage.dat file. Here is an example command file:
 
<pre>
source font_source/carleton/fontimage_48.dat
target ../fonts/english/carleton/fontimage_48.dat
// the texture for this font is 256x256 pixel
dim 256 256
 
copy_char 0x43 0xac                                    // copy all fields from C to the new characte Č
move_by 0xac 74 -52                                    // (new position 174, 19 minus 100, 71
shader 0xac fonts/carleton_6_48.tga                    // set the right texture file (the .tga here is ignored by D3)
extend_top 0xac 8                                      // extend the character 8 pixel on the top
</pre>
 
=== Additional commands ===
 
dump 0x65
 
This will dump all the fields for the character 0x65 (in this case "a").
 
extend_bottom 0xac 8
 
This will extend the character by 8 pixels on the bottom.
 


== I18N (Internationalization) ==
== I18N (Internationalization) ==
Line 102: Line 77:
* [http://www.inventivedingo.com/stuff/exportfonttodoom3_modified.zip Fixed version of ExportFontToDoom] (exports special chars, too)
* [http://www.inventivedingo.com/stuff/exportfonttodoom3_modified.zip Fixed version of ExportFontToDoom] (exports special chars, too)
* [http://rfactory.org/q3font.html Q3Font]
* [http://rfactory.org/q3font.html Q3Font]
* [http://www.bloodgate.com/mirrors/tdm/pub/scripts/font_patcher.pl font_patcher.pl]
* [[I18N]]
* [[I18N]]


{{tutorial}} [[Category:Fonts]]
{{tutorial}} [[Category:Fonts]]

Revision as of 08:22, 6 November 2011

These are some rough notes about converting ttf fonts to doom3 and repairing if necessary.

There are three tools:

My understanding is that ExportFontToDoom is more suitable than Q3Font for converting. It is what I used to convert a lot of TTF fonts. See notes with that tool as to how use it. But be aware of copyright issues if converting TTF fonts.

With ExportFontToDoom there were quite a few spacing errors. Q3Font I found a bit puzzling so never did any conversions (it may be better for all I know.) BUT it can convert the dat files to readables for editing and back again so I used Q3Font to fix the errors.

Doom fonts have multiple dat files for each size, but sometimes not all of them are used:

  • fontImage_6.dat
  • fontImage_8.dat
  • fontImage_12.dat
  • fontImage_24.dat
  • fontImage_48.dat

The size 24 is used mostly by readables, while the menu uses 48 (the big headlines and the main menu) and 24 (settings and other headlines).

q3font

Copy the dat file(s) to the q3font folder and use this syntax to get a readable .fnt file:

q3font.exe -decompile fontImage_24.dat

A common problem is this:

Characters have an actual width but they also have a distance value from where they start being 'written' to the start of the next letter (xskip in the readable .fnt files.)

The true type font to doom font convertor named ExportFontToDoom3 appears to calculate this based on the character width (my guess.)

If lower case letters have descenders that curl back under the previous letter on the line, eg, f, g, j, p, y (q is OK because it curls forward) then the actual width of the character is greater than the distance from its start point to the start of the next character.

So, ExportFontToDoom3 makes xskip too big in the case of the above letters. Reducing xskip in the .fnt files and restoring them to .dat files cures the problem.

In the readable .fnt files the characters are ASCII numbers.

A to Z are 65 to 90
a to z are 97 to 122
f = 102
g = 103
j = 106
p = 112
y = 121

Search the net for an ascii code list for others, or use "ascii" on the Linux console to get a list.

They fnt file can be converted back to .dat files using...

q3font.exe fontImage_24

You will need to relaunch Doom each adjustment as there is no quick way to reload fonts.

Example: Say you want to reduce the space after letter j

  • q3font.exe -decompile fontImage_24.dat to produce a readable .fnt file
  • In the .fnt file search down for the character header, eg, char 106.
  • Within the curly brackets below the header are the various values.
  • Look for xSkip.
  • Say it has a value of 12. Try reducing it to 9 to reduce the offset.
  • Convert back to .dat format, reload Dark Mod and check in-game.

font_patcher.pl

Please see the main article.

I18N (Internationalization)

If you convert a russian font, you need to move the character 0xFF to 0xB6, otherwise it will not show in the GUI or readables. See I18N for details.

Weblinks