Changes between Initial Version and Version 1 of Adding_font_support


Ignore:
Timestamp:
May 12, 2014, 2:55:18 PM (10 years ago)
Author:
sanderd17
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Adding_font_support

    v1 v1  
     1In this page, we're going to follow the work it took to add east-asian fonts.
     2
     3= Font rendering =
     4
     5Fonts in Pyrogenesis are prerendered by the fontbuilder tool.
     6
     7First you need to do download the right font files (ttf, otf, ...), and place them in the [source:ps/trunk/binaries/data/tools/fontbuilder/fonts fonts] directory. F.e., to support east-asian fonts, we downloaded the [http://fonts.jp/hanazono/ Hanazono fonts].
     8
     9Then you need to add the font to the [source:ps/trunk/source/tools/fontbuilder2/fontbuilder.py fontbuilder] itself. If you add the font files to the back of the list, they will be used as fallback. F.e.
     10{{{
     11Sans = (["LinBiolinum_Rah.ttf","FreeSans.ttf", "HanaMinA.ttf"], FontLoader.FT_LOAD_DEFAULT)
     12}}}
     13to use the hanazono font HanaMinA.ttf as fallback for the sans style.
     14
     15If you don't want to overwrite the current fonts, but rather distribute them as a mod, it's best to change the output directory to the mod you want in the last line of the fontbuilder.
     16
     17By running the fontbuilder with Python2,
     18{{{
     19python2 fontbuilder.py
     20}}}
     21the fonts will be prerendered, and added in the output directory you defined (by default the correct path in the public mod).
     22
     23= Font caching =
     24
     25If you want to distribute the fonts as a separate mod, it's best to cache them, else users will only see grey text on their first run. Caching should be done with the archivebuild tool available in Pyrogenesis. Note that for distribution, it's also best to enable the compression flag, because cached dds files tend to be big, and seem to compress rather well.
     26
     27F.e., for the east-asian locales mod:
     28{{{
     29binaries/system/pyrogenesis -archivebuild=binaries/data/mods/east-asian-locales -archivebuild-output=ebinaries/data/mods/east-asian-locales/ast-asian-locales.zip -archivebuild-compress
     30}}}
     31Which will result in a cached, compressed east-asian-locales.zip file, ready for distribution.
     32
     33= Testing your fonts =
     34
     35To make sure you test the final version, first (re)move all old files (s.a. the png files the fontbuilder made). Then place your zip in the same directory structure as the released public mod (so mods/east-asian-locales/east-asian-locales.zip for our test), and run pyrogenesis with the mod enabled.
     36{{{
     37./pyrogenesis -mod=east-asian-locales
     38}}}