Feature request: font selection gui

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Feature request: font selection gui

Post by Quark »

Is it possible to make in-game menu for choosing font for freetype? Preview will be good.
Also as I unferstand it's not possible to select font style? Some fonts don't have separate bold font for example.
Image
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Re: Feature request: font selection gui

Post by DirtY iCE »

Quark wrote:Is it possible to make in-game menu for choosing font for freetype? Preview will be good.
Also as I understand it's not possible to select font style? Some fonts don't have separate bold font for example.
Well, I started to make an in-game menu for it. It'll under game options, and probably it will have preview.. I'll post a screenshot soon...

-------------------------------------------------------------

patch ChangeLog
  • 0.1.0 - Initial release - gui, dropdown, apply...
    0.2.0 - added bounding boxes
    0.3.0 - added preview to the drop-down list
    0.3.1 - updated to r10622
    0.3.2 - fixed a bug with the 32bpp blitter
    0.4.0 - option to antialias, for r10645
    0.5.0 - selectable font style, for r10654
    0.5.1 - for r???, based on the win version (forgot to release)
    0.5.2 - nothing new, just compiles with r11643
Attachments
fontselect_window_v.0.5.2.diff
The lastest version of the patch - v. 0.5.2 (for Unix and Windows)
(77.14 KiB) Downloaded 3197 times
Last edited by DirtY iCE on 16 Dec 2007 11:48, edited 7 times in total.
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
Bjarni
Tycoon
Tycoon
Posts: 2088
Joined: 08 Mar 2004 13:10

Re: Feature request: font selection gui

Post by Bjarni »

DirtY iCE wrote:Well, I started to make an in-game menu for it. It'll under game options, and probably it will have preview.. I'll post a screenshot soon...
And how do it find the fonts to put in the list?
Is it portable code or hardcoded for one OS?
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Re: Feature request: font selection gui

Post by DirtY iCE »

Bjarni wrote:And how do it find the fonts to put in the list?
Is it portable code or hardcoded for one OS?
Well, on Windows it can retrieved from registry, on Linux font-config can list the available fonts, and for other OS-es they will a custom-font option, where you can specific the font (as in openttd.cfg)...
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Screenshoot

Post by DirtY iCE »

I'm struggling with the preview, and now it's only works with FontConfig, but it's near to finished state...
Attachments
The drop-down font selector.
The drop-down font selector.
fontselect2.png (19.51 KiB) Viewed 12405 times
The config window with a normal, a custom and an invalid font.
The config window with a normal, a custom and an invalid font.
fontselect1.png (27.33 KiB) Viewed 12406 times
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7597
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

Ooh, that looks quite handy, good work!
Image
User avatar
Juhl
Engineer
Engineer
Posts: 26
Joined: 27 Jan 2007 23:20
Location: Kgs. Lyngby, Denmark

Suggestion

Post by Juhl »

Wow that looks great.

If this should be really helpful for all languages, the text shown in the preview should be defined in the language files. This would allow to preview speciel characters and charset.
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Re: Screenshoot

Post by Quark »

DirtY iCE wrote:I'm struggling with the preview, and now it's only works with FontConfig, but it's near to finished state...
Good work, but can you make font preview in drop-down list?
Image
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Re: Suggestion

Post by DirtY iCE »

Juhl wrote:If this should be really helpful for all languages, the text shown in the preview should be defined in the language files. This would allow to preview special characters and charset.
I've already done it that way.. :)
Quark wrote:Good work, but can you make font preview in drop-down list?
show preview in the drop-down list looks cool, but it eats a lot of memory and CPU to load..
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
Bjarni
Tycoon
Tycoon
Posts: 2088
Joined: 08 Mar 2004 13:10

Re: Suggestion

Post by Bjarni »

DirtY iCE wrote:show preview in the drop-down list looks cool, but it eats a lot of memory and CPU to load..
Then make an on/off button so people can decide if they want to do so. People with high end computers might wants this and people with low end computers will not. I presume that you can free the memory allocated to this when the window is closed.
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Re: Suggestion

Post by DirtY iCE »

Bjarni wrote:Then make an on/off button so people can decide if they want to do so. People with high end computers might wants this and people with low end computers will not. I presume that you can free the memory allocated to this when the window is closed.
Maybe I'll do that, but first I have to made preview work correctly :)
Attachments
The font select window with Hungarian translation.
The font select window with Hungarian translation.
fontselect_hu.png (4.05 KiB) Viewed 12287 times
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Post by DirtY iCE »

Well, it likes as a working thing :) I made the drop-down menu sorted, the preview works (I didn't know about that glyph cache), and the apply button works. But listing available fonts only works with FontConfig.. And I don't know how winapi work, so I think someone has to write that piece of code...

Just a small code cleanup and I'll upload the first patch (maybe tomorrow).. but until that I post some screenshot...

And a question: why doesn't this forum allow me to upload file, that name contain : (colon)?
Attachments
The sorted list
The sorted list
fontselect_sortedlist.png (7.03 KiB) Viewed 12140 times
The font select window with working preview
The font select window with working preview
fontselect3.png (5.6 KiB) Viewed 12151 times
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

Is it possible to make font style selection available?
Image
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Ok, ok, I post a diff file

Post by DirtY iCE »

Well, I just started to type a reply with the diff file, when I found a bug :)
But now, everything is working for me, but this piece of code are STILL EXPERIMENTAL, and it can (or may :) ) contain bugs, packed segfaults, and so on.. So use it at your OWN RISK!
If you try it, and it works, be happy! Or, if you found any bug, please send it to me (only the bug report.. I have many bugs at my home, so I don't need more) through e-mail or IM.
Attachments
My e-mail address.
My e-mail address.
email.png (416 Bytes) Viewed 12042 times
Last edited by DirtY iCE on 10 Feb 2007 19:33, edited 1 time in total.
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Ok, ok, I post a diff file

Post by belugas »

Hell of a good job :D

Congrats
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Post by DirtY iCE »

Hi,

I'm a bit happy because I can announce the v. 0.2 of my patch.

I've added a feature that I only call bounding boxes. It does the following: it adds 3 boxes under each font preview. The green box means the font size with the original font. The orange box is a little bigger, and it means a size that usable in most cases, and the red box means, the font is too big...

I've uploaded the patch to my first post.
Attachments
Fontselect dialog with boundig boxes on and off.
Fontselect dialog with boundig boxes on and off.
boundingbox.png (20.13 KiB) Viewed 11723 times
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
DarkFenX
Engineer
Engineer
Posts: 98
Joined: 16 Oct 2006 20:32
Location: Russia, Saint-Petersburg
Contact:

Post by DarkFenX »

Wow, great job :)
I've moved tahoma/tahoma bold .ttf files to my linux installation, but couldn't find a way to set bold tahoma w/o exact path to it... searched how i may do it with font-config or sth like it, but found this topic... imo without that gui freetype support for amateur users would be rather useless :)
Btw, i've compiled ottd with fontconfig support, but when i set "Tahoma Bold" as font - it doesn't find it. Only when i manually set path to "/usr/share/fonts/truetype/microsoft/Tahoma_Bold.ttf".
If someone had faced this problem, please write how you've workarounded it.
- It's hot as hell in here.
- You see it too? For me, it's always like this.
-------------------
ICQ: 302028069
Jabber: DarkFenX@jabber.org
User avatar
DirtY iCE
Engineer
Engineer
Posts: 25
Joined: 12 Aug 2006 15:29
Location: *unknown*
Contact:

Post by DirtY iCE »

Hi, I'm here again:)

I've started to made the preview in the drop-down list, I actually did it, but it looks a quite funny...

DarkFenX: well, you're lucky! I needed to copy the bold font to an another directory, because it always reverted to the normal font - even with filename... but it only did it with bold fonts.. Italic fonts works nicely..
anyway, we should add a style option for the fonts.. but I don't know, what're the developers think about that :)
Attachments
Font preview in drop-down menu.
Font preview in drop-down menu.
prev_in_drpdwn.png (7.89 KiB) Viewed 11505 times
Last edited by DirtY iCE on Boomtime, the 65th day of The Aftermath in the YOLD 3173, edited 782,469,123.3691 times in total.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

DarkFenX wrote:Btw, i've compiled ottd with fontconfig support, but when i set "Tahoma Bold" as font - it doesn't find it. Only when i manually set path to "/usr/share/fonts/truetype/microsoft/Tahoma_Bold.ttf".
If someone had faced this problem, please write how you've workarounded it.
Either Fontconfig, or the Fontconfig parser is gay; you need to type your fontname as "Tahoma, Bold" (not the comma, which seperates the font-name from the type).

I have no idea if you could actually force a style to a font if that font does not exist internally. Eg if 'System' only exists in normal style how to apply 'bold' or 'italics' to it. Not sure if FreeType2 has support for that.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
DarkFenX
Engineer
Engineer
Posts: 98
Joined: 16 Oct 2006 20:32
Location: Russia, Saint-Petersburg
Contact:

Post by DarkFenX »

Thx, "Tahoma, Bold" worked as it supposed to :)
- It's hot as hell in here.
- You see it too? For me, it's always like this.
-------------------
ICQ: 302028069
Jabber: DarkFenX@jabber.org
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest