fallout2-ce
fallout2-ce copied to clipboard
Truetype support
Hello, I added truetype font support for Fallout 2, which makes it easy to support multiple languages. Support to adjust the font size and replace different ttf fonts.
Use iconv to convert the encoding, and then read the glyphs through the freetype library.
Windows, android, ios, macos have been tested, but linux platform has not been tried.
Create a fonts folder in the root directory, then add the corresponding folders according to the language, such as chs, english, and then create an ini file with the following content:
[font0] maxHeight=10 maxWidth=10 lineSpacing=0 wordSpacing=4 letterSpacing=1 heightOffset=0 fileName=r_fallouty.ttf warpMode=0 encoding=GBK
[font1] maxHeight=12 maxWidth=12 lineSpacing=0 wordSpacing=4 letterSpacing=1 heightOffset=0 fileName=r_fallouty.ttf warpMode=0 encoding=GBK
[font2]...etc
The encoding value refers to the support for encoding in libiconv https://www.gnu.org/software/libiconv/
Then put the corresponding ttf font file in the directory.
If there is an error in this process, the font is displayed in the old way.
Tested on Arch linux and it works great. Amazing job!
-
The iconv library uses LGPL-2.1 license. Statically linking it requires fallout2-ce to provide instructions on how to relink another version of the library to the application. For the LGPL requirements to be fulfilled it is recommended to add the modified iconv library version (source code) to the fallout2-ce project before this pull request.
-
The freetype library uses its own FTL license. It is recommended to add the following disclaimer to the fallout2-ce readme:
Portions of this software are copyright © <year> The FreeType Project (www.freetype.org). All rights reserved.
-
The licenses for the 5 ttf fonts needs to be confirmed and their copyright holders mentioned in a manifest or similar.
@klei1984 Thank you for your feedback. This part of the work only shows a framework and possibilities. I hope that if @alexbatalov decides to adopt this approach, he can open a branch and then do further work on it. I’m very busy at the moment. I hope that if this part of the code can enter the main branch, then more people can help improve this part of the code.
Nice to see this. I tried different approach. I did simple python script and used FreeType to covert ttf to aaf. I even tried to resize original glyphs in runtime on load.
However I disappointed in this approach the size of glyphs is too small. Any custom font looks awful. And many menus elements doesn't support custom size of glyphs. For exmple in dialogs you cannot scroll your answers list.
I integrated the given solution into GNW in the M.A.X. Port project trying to resolve all code review findings that are noted here.
M.A.X. had a C++ wrapper on top of GNW for its basic UI elements like windows, edit controls, buttons, text boxes. The C++ layer manages various resources, including audio samples, but it does not handle automatic label formatting and resizing. Truncation of non fitting text is supported.
The implementation of the TTF GNW font manager in M.A.X. Port can be found here.
Please note that M.A.X. does not use monochromatic AAF fonts, so GNW Color's blending tables are not supported in the given implementation. Based on the review comments it can be integrated with relative ease.
Will this project still be updated?