[Patch]: Font settings GUI

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

[Patch]: Font settings GUI

Post 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
Some screen shots
capturas.png (65.46 KiB) Viewed 5991 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
Attachments
font_settings_r20920.diff
Patch for r20920
(36.5 KiB) Downloaded 287 times
patches.zip
Patch split in pieces
(12.22 KiB) Downloaded 237 times
Last edited by thror on 26 Apr 2011 18:02, edited 4 times in total.
User avatar
norbert79
Engineer
Engineer
Posts: 102
Joined: 25 Apr 2003 16:44
Location: Hungary
Contact:

Re: [Patch]: Freetype font settings

Post 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).
Üdvözlettel / Mit freundlichen Grüßen / Best regards:
Norbert


Image Image
Image Image
Timmaexx
Transport Coordinator
Transport Coordinator
Posts: 301
Joined: 03 Jan 2009 17:55

Re: [Patch]: Freetype font settings

Post by Timmaexx »

Thank you very much for this nice patch! :bow:
Do I right understand, that the patch analyses ALL installed fonts in the OS,
Even newinstalled fonts?
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Freetype font settings

Post 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.
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Font settings GUI

Post 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.
Attachments
font_settings_gui_v2_r21005.diff
New version of the patch
(35.18 KiB) Downloaded 207 times
patches.zip
The new patch split in pieces.
(11.45 KiB) Downloaded 161 times
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Font settings GUI

Post 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?
Attachments
font_settings_gui_r21201.diff
(34.62 KiB) Downloaded 198 times
patches.zip
(10.76 KiB) Downloaded 175 times
Last edited by thror on 18 Nov 2010 11:13, edited 1 time in total.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch]: Font settings GUI

Post 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.
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Font settings GUI

Post 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.
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Font settings GUI

Post 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.
Attachments
patches.zip
The patch split in pieces.
(10.75 KiB) Downloaded 341 times
font_settings_r22376.diff
New version of the patch
(33.53 KiB) Downloaded 353 times
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch]: Font settings GUI

Post 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
thror
Engineer
Engineer
Posts: 8
Joined: 16 Jul 2010 09:18
Location: Spain

Re: [Patch]: Font settings GUI

Post 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 :oops: 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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests