fallout2-ce icon indicating copy to clipboard operation
fallout2-ce copied to clipboard

Truetype support

Open sonilyan opened this issue 2 years ago • 7 comments

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.

example

sonilyan avatar Nov 11 '22 11:11 sonilyan

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.

sonilyan avatar Nov 11 '22 11:11 sonilyan

Tested on Arch linux and it works great. Amazing job!

JanSimek avatar Nov 13 '22 11:11 JanSimek

  • 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 avatar Apr 23 '23 16:04 klei1984

@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.

sonilyan avatar May 16 '23 15:05 sonilyan

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.

y0lo avatar Jun 02 '23 03:06 y0lo

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.

klei1984 avatar Jun 02 '23 14:06 klei1984

Will this project still be updated?

lpgneg19 avatar Dec 06 '23 06:12 lpgneg19