Page 1 of 1
[Patch]: Font settings GUI
Posted: 14 Oct 2010 12:14
by thror
Hi, this is my first patch, so I'm sure it needs to be improved a lot.
This patch enables to modify the freetype settings inside the game. I've added a button on the Game Options window that opens a new window with the settings.

- Some screen shots
- capturas.png (65.46 KiB) Viewed 5999 times
It works in Windows and Linux, but in Windows take a long time making the list of avaiable fonts.
Both attachments have the same code, in the zip file the patch is split in smaller patchs.
Latest version here
Re: [Patch]: Freetype font settings
Posted: 14 Oct 2010 12:45
by norbert79
What if you would use font-caches, like VideoLan.org's VLC does? That would speed up the selection screen to be loaded, especially where you have more, than 1000 fonts installed (which is the case for me with more, than 8000 fonts).
Re: [Patch]: Freetype font settings
Posted: 15 Oct 2010 09:16
by Timmaexx
Thank you very much for this nice patch!
Do I right understand, that the patch analyses ALL installed fonts in the OS,
Even newinstalled fonts?
Re: [Patch]: Freetype font settings
Posted: 15 Oct 2010 12:31
by thror
norbert79 wrote:What if you would use font-caches, like VideoLan.org's VLC does?
I've been thinking a little about it. The problem is that the the patch make a list with the fonts that matchs your languaje settings, if you change it, the cache has to be refresh or use a different cache for any different language. Anyway I'll think more about that.
Timmaexx wrote:Do I right understand, that the patch analyses ALL installed fonts in the OS,
Even newinstalled fonts?
The patch ask the OS about the fonts so, if the new installed fonts have been installed properly, you should see them in the list.
Re: [Patch]: Font settings GUI
Posted: 22 Oct 2010 12:11
by thror
I've made a new versión which improves the performance of the Windows patch, but the list of fonts could include some fonts that the game can´t load.
The older version shares part of the Windows callback code with the fallback font function. That code checks if a font can be used with the current settings. One of the checks is trying to load the font. The new version doesn't share that code and skip this ckeck, instead of that implements a simple check that in my computer filters the same fonts than the older check.
This version needs more testing so I'll keep the older version on the first post.
Re: [Patch]: Font settings GUI
Posted: 16 Nov 2010 13:16
by thror
New version:
- Fixed patchs to work with the latest code.
- Patch 30 is no longer needed due to changes in r21161.
- Bug Fixed: Strings width calc didn't work properly after changes until restart openttd.
Known issues:
- The list of fonts doesn't update if languaje changes after open the font settings window
Theese changes have been done over the testing version because It seems to work fine.
Anyway, I've been wondering about if fill the list of fonts on a separate thread when the aplication starts could be a better solution. What do you think?
Re: [Patch]: Font settings GUI
Posted: 16 Nov 2010 14:54
by Terkhen
It seems that the list of available fonts is not updated if the language changes. As a result, it is possible to select fonts that are not suitable for the current language if the font window is already opened before changing language. You can reproduce this by changing from English to Chinese (Simplified) for example.
Re: [Patch]: Font settings GUI
Posted: 18 Nov 2010 11:11
by thror
Terkhen wrote:It seems that the list of available fonts is not updated if the language changes. As a result, it is possible to select fonts that are not suitable for the current language if the font window is already opened before changing language. You can reproduce this by changing from English to Chinese (Simplified) for example.
I've checked it and I'm trying to fix it, but the fix adds some new problems that I'd like to solve before upload a new version.
Re: [Patch]: Font settings GUI
Posted: 26 Apr 2011 18:01
by thror
It has been a long time since my last post, but I haven't forgotten the patch.
New version:
- Bug fixed: The list of fonts doesn't update if languaje changes after opening the font settings window
- The list of fonts is filled on a separate thread when the window opens, for the first time or after change the language
- Close the fonts settings window if the settings window is closed.
- The code has been cleaned up.
Re: [Patch]: Font settings GUI
Posted: 27 Apr 2011 16:37
by Terkhen
20: _list_of_fonts is missing doxygen documentation, and the documentation of _list_of_font_status is a bit incomplete. It should also be called "_list_of_fonts_status"
On 30: Why are the functions EnumFontCallback and ListFontCallback so similar? Could it be possible to merge them into a single function?
On 30: What is the point of the stop_calc code?
Also, there are many occurences of this coding style error:
stop_calc=true --> stop_calc = true
Re: [Patch]: Font settings GUI
Posted: 27 Apr 2011 18:35
by thror
Terkhen wrote:20: _list_of_fonts is missing doxygen documentation, and the documentation of _list_of_font_status is a bit incomplete.
I know that documentation is incomplete but I'd like to get some feedback about the patch performance before.
Terkhen wrote:On 30: Why are the functions EnumFontCallback and ListFontCallback so similar? Could it be possible to merge them into a single function?
IIRC on the first version of the patch the part in common of that functions was split to a new function that both of them called, but the performance of the patch was a little bit better with the actual implementation. Probably with this multi-thread version would make more sense come back to that solution.
Terkhen wrote:On 30: What is the point of the stop_calc code?
I forgot add documentation about that part

The point of the stop_calc code is the need to stop the thread that fills the list before it ends because the language has changed. The only way that I found to do that is check that variable on every iteration of the loop that fills the list and break it if the value changes. I guess that there should be a better solution but I don't know what is.
Terkhen wrote:Also, there are many occurences of this coding style error:
stop_calc=true --> stop_calc = true
I'll try to fix all of them.