ExportFontToDoom3: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Geep (talk | contribs)
created article
 
Geep (talk | contribs)
Finish polishing
Line 5: Line 5:
=== Basic Command ===
=== Basic Command ===
To export with the common settings of 12, 24, and 48 point fonts, simply type:
To export with the common settings of 12, 24, and 48 point fonts, simply type:
  ExportFontToDoom3 <font filename>
  ExportFontToDoom3 ''font_filename''
For example (and assuming here a font "badtimes" with no legal issues):
For example (and assuming here a font "badtimes" with no legal issues):
  ExportFontToDoom3 badtimes.ttf
  ExportFontToDoom3 badtimes.ttf
Line 11: Line 11:
=== Size Option ===
=== Size Option ===
To export the font in a certain size, use the option:
To export the font in a certain size, use the option:
  -size <font point size>
  -size ''font_pointsize''
For Doom3/TDM, only the sizes 12, 24, and 48 should be chosen. More than one "-size" arguments may be specified, for example:
For Doom3/TDM, only the sizes 12, 24, and 48 should be chosen. More than one "-size" arguments may be specified, for example:
  ExportFontToDoom3 badtimes.ttf -size 12 -size 24
  ExportFontToDoom3 badtimes.ttf -size 12 -size 24
Line 17: Line 17:
=== Name Option ===
=== Name Option ===
To name the font to be exported, use the option:
To name the font to be exported, use the option:
  -name <name>
  -name ''fontname''
By default, the name is extracted from the font file. This name will be included in the TGA filename(s), which are referenced in turn in the "shaderName" fields of the DAT filename.
By default, the fontname is instead extracted from the font file. In either case, this fontname string will begin each of the TGA filename(s), which are referenced in turn in the per-character "shaderName" fields of the DAT file.
=== Other Options ===
=== Other Options ===
''In the description doc, there is a great deal of technical discussion about these next options, but of little likely relevance to TDM nowadays. Just ignore them in favor of their default values.''
In the description doc, there is a great deal of technical discussion about these next options, but of little likely relevance to TDM nowadays. Just ignore them in favor of their default values.
  -xOffsetFix <type>    ''Default is "none", which causes the font's X offset value to be exported to the "pitch" member of TDM .dat file.''
-textureFormat ''format''
where the default is .tga, which is what you want. Use another tool to convert the output from .tga to .dds, since ExportFontToDoom3 won't do it correctly.
  -xOffsetFix ''type''
where the default is "none", which causes the font's X offset value to be exported to the "pitch" member of TDM .dat file. There is also the related:
  -noXOffsetWarnings
  -noXOffsetWarnings
-textureFormat <format> ''Default is .tga, which is what you want. Use another tool to convert the output from .tga to .dds, since ExportFontToDoom3 won't do it correctly."


=== Output ===
=== Output ===
Line 45: Line 47:
== Downloads of v 1.02 ==
== Downloads of v 1.02 ==
Windows binary:
Windows binary:
* grantheant.com/products/exportfonttodoom3
* [https://grantheant.com/products/exportfonttodoom3 Grant Davie's project page]


The C++ project file with source code:
The C++ project file with source code:
* grantheant.com/products/exportfonttodoom3
* [https://grantheant.com/products/exportfonttodoom3 Grant Davie's project page]
* https://www.moddb.com/downloads/export-font-to-doom-3-v102
* [https://www.moddb.com/downloads/export-font-to-doom-3-v102 Moddb downloads page]
* also from wayback machine
* also from wayback machine.
The project makes use of the circa-2005 FreeType font library (www.freetype.org) and DevIL image library.  
The project makes use of the circa-2005 FreeType font library (www.freetype.org) and DevIL image library.  


Line 56: Line 58:
The standard version of this tool exports only the glyphs for the ASCII characters, i.e., in the range 0-127.
The standard version of this tool exports only the glyphs for the ASCII characters, i.e., in the range 0-127.


In 2009, Crispy (with input from other TDMers Hyeron, Fidcal, and greebo) developed a variant version, "ExportFontToDoom3_modified",  that could would also export characters in the range 128-256.
In 2009, Crispy (with input from other TDMers Hyeron, Fidcal, and greebo) developed a variant version, "ExportFontToDoom3_modified",  that could would also export characters in the range 128-256. (This presumably uses the character set and ordering of the Windows codepage of the generating machine. You would still have to subsequently rearrange things for the TDM-specific character mapping given in [[I18N_-_Charset]].)


Unfortunately, as of 2024, that version appears lost (see [[https://forums.thedarkmod.com/index.php?/topic/21741-subtitles-possibilities-beyond-211/&do=findComment&comment=492024 this forum post]] ).
Unfortunately, as of 2024, that version appears lost. See [https://forums.thedarkmod.com/index.php?/topic/21741-subtitles-possibilities-beyond-211/&do=findComment&comment=492024 this forum post].
=== Project Setup from Unmodified Version ===
=== Project Setup to Recreate Modified Version ===
It is possible that the modifications could be reapplied. The original modification project was https://forums.thedarkmod.com/index.php?/topic/10154-the-dark-mod-readables-ttf-fonts/&do=findComment&comment=200984 discussed here]. To summarize:
It is possible that the modifications could be reapplied. The original modification project was [https://forums.thedarkmod.com/index.php?/topic/10154-the-dark-mod-readables-ttf-fonts/&do=findComment&comment=200984 discussed here]. To summarize:
* Start with the C++ source. It uses the FreeType and DeviL DLL libraries of that era.
* Start with the unmodified C++ source. It uses the FreeType and DeviL DLL libraries of that era. (Although you probably won't need it, know that www.freetype.org has an archive of past versions.)
* Stick with the non-Unicode version of DeviL DLLs.
* Stick with the non-Unicode version of DeviL DLLs.
* The code wants il_wrap.lib, , which is an object-oriented C++ wrapper around DevIL's procedural C interface, but il_wrap.lib no longer exists.
* The code wants il_wrap.lib, , which is an object-oriented C++ wrapper around DevIL's procedural C interface, but il_wrap.lib no longer exists.
* Fortunately, the wrapper source code was available, so it could simply be added directly to the ExportFontToDoom3 project. Once the class implementation is moved out of the header, it compiles.  (The wrapper code referred to is possibly il_wrap.cpp and related .h’s from https://github.com/DentonW/DevIL/ here].)
* Fortunately, the wrapper source code was available, so it could simply be added directly to the ExportFontToDoom3 project. Once the class implementation is moved out of the header, it compiles.  (The wrapper code referred to is possibly il_wrap.cpp and related .h’s from [https://github.com/DentonW/DevIL/ here].)
* Change the loop iterating over character codes, so it goes from 0 to 255. The type of the character code index must be changed from int to unsigned long. Simply make that change in Font::getGlyphIndexForCharacterCode and the code that calls it
* Change the loop iterating over character codes, so it goes from 0 to 255. The type of the character code index must be changed from int to unsigned long. Simply make that change in Font::getGlyphIndexForCharacterCode and the code that calls it
{{tutorial}} [[Category:Fonts]]

Revision as of 17:23, 6 March 2024

This Windows command-line utility was created by Australian modder Grant Davies in 2005 to get standard Windows fonts into the Doom 3 engine. The final version, 1.02, was released as open-source and substantially used for TDM.

Using the Tool

The information here is adapted from the description doc included with the download.

Basic Command

To export with the common settings of 12, 24, and 48 point fonts, simply type:

ExportFontToDoom3 font_filename

For example (and assuming here a font "badtimes" with no legal issues):

ExportFontToDoom3 badtimes.ttf

Most standard font formats (from the 2009 timeframe) can be used for export, but TrueType is most common.

Size Option

To export the font in a certain size, use the option:

-size font_pointsize

For Doom3/TDM, only the sizes 12, 24, and 48 should be chosen. More than one "-size" arguments may be specified, for example:

ExportFontToDoom3 badtimes.ttf -size 12 -size 24

As indicated above, if no "-size" argument is specified, 12, 24, and 48 point fonts are exported.

Name Option

To name the font to be exported, use the option:

-name fontname

By default, the fontname is instead extracted from the font file. In either case, this fontname string will begin each of the TGA filename(s), which are referenced in turn in the per-character "shaderName" fields of the DAT file.

Other Options

In the description doc, there is a great deal of technical discussion about these next options, but of little likely relevance to TDM nowadays. Just ignore them in favor of their default values.

-textureFormat format

where the default is .tga, which is what you want. Use another tool to convert the output from .tga to .dds, since ExportFontToDoom3 won't do it correctly.

-xOffsetFix type

where the default is "none", which causes the font's X offset value to be exported to the "pitch" member of TDM .dat file. There is also the related:

-noXOffsetWarnings

Output

A new folder will be created and all output files will be stored there. The folder will be named according to the font being exported. The output will consist of Targa image (.tga) files and .dat files.

Afterwards, from each TGA, you should create a corresponding DDS file.

Deployment & Further Adaptions

After export, assuming you have an FM set up to test them, rename the files into standard form and move or copy them to the expected locations...

  • For DAT files: fonts/english/<your font name>/
  • For DDS files: dds/english/<your font name>/

You'll undoubtedly have to make further iterative adjustments to both the DAT files (using other methods listed in Font Conversion & Repair) and bitmap files. For instance, the "glyphScale" value will likely have to be changed.

Tutorials that Include ExportFontToDoom3

Doom3-era tutorials, once posted on www.doom3world, can still be found with the "wayback machine" links given here:

Downloads of v 1.02

Windows binary:

The C++ project file with source code:

The project makes use of the circa-2005 FreeType font library (www.freetype.org) and DevIL image library.

Modifying ExportFontToDoom3 for 256 Chars

The standard version of this tool exports only the glyphs for the ASCII characters, i.e., in the range 0-127.

In 2009, Crispy (with input from other TDMers Hyeron, Fidcal, and greebo) developed a variant version, "ExportFontToDoom3_modified", that could would also export characters in the range 128-256. (This presumably uses the character set and ordering of the Windows codepage of the generating machine. You would still have to subsequently rearrange things for the TDM-specific character mapping given in I18N_-_Charset.)

Unfortunately, as of 2024, that version appears lost. See this forum post.

Project Setup to Recreate Modified Version

It is possible that the modifications could be reapplied. The original modification project was discussed here. To summarize:

  • Start with the unmodified C++ source. It uses the FreeType and DeviL DLL libraries of that era. (Although you probably won't need it, know that www.freetype.org has an archive of past versions.)
  • Stick with the non-Unicode version of DeviL DLLs.
  • The code wants il_wrap.lib, , which is an object-oriented C++ wrapper around DevIL's procedural C interface, but il_wrap.lib no longer exists.
  • Fortunately, the wrapper source code was available, so it could simply be added directly to the ExportFontToDoom3 project. Once the class implementation is moved out of the header, it compiles. (The wrapper code referred to is possibly il_wrap.cpp and related .h’s from here.)
  • Change the loop iterating over character codes, so it goes from 0 to 255. The type of the character code index must be changed from int to unsigned long. Simply make that change in Font::getGlyphIndexForCharacterCode and the code that calls it