Using a new font

Discuss the future of Warzone 2100 with us.
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

I'm a little busy at the moment. I will work on both chats (I saw your comment on my other patch)

Thanks for your comments.
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

First of all, the font size changes were a mistake. They have been restored and they don't look much different. However, Exo 2 is more dense than DejaVu Sans Book (See below).

Here is a side-by-side comparison of Xolonium 21p Bold,Exo 2 Medium 16p vs DejaVu Sans Book 16p, DejaVu Sans Bold 21p. Resolution was set to 640x480.

Main Menu:
main_menu_comp.jpg
Briefing:
briefing_comp.jpg
Skirmish Menu:
skirmish_comp.jpg
Edit: I think it is clear that Exo 2 has less spacing than Deja Vu Sans. What does everyone else think? As for the dual font usage, if we keep the original sizes, do you think it is still much of an issue?
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

http://developer.wz2100.net/ticket/4267#comment:5

As vexed correctly asserted. Trying to change font sizes or fonts is pretty cumbersome with the current system.

I went ahead and wrote a large patch. This patch, does the following:
A font configuration file is added. It resides at fonts/font.cfg and is in the JSON format. In this configuration file, a pair of fonts (Regular and Bold) along with sizes for small,regular,medium and bold can be supplied. The configurations are per-locale. For example, Xolonium 21p is the Bold font and Exo 2 is used for everything else (at the original sizes).
If the current language is not assigned a font in the config file, an error message is logged and a "Default" configuration (the current font used for Warzone 2100, aka, DejaVu Sans Book and Bold) is used.
The font subsystem can switch fonts on the fly now. In other words, if the language is changed in the "config" menu, the font is immediately reconfigured preventing garbled fonts from being shown.

This means that now people can write mods to change the fonts as well.

I will be very happy to get any feedback.
cybersphinx
Inactive
Inactive
Posts: 1695
Joined: 01 Sep 2006, 19:17

Re: Using a new font

Post by cybersphinx »

Sounds good, but if you could split it up into a series of smaller changes it's probably easier to review.
We want information... information... information.
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

Here it comes:

I zipped them because of the upload limit:
big_font_patch.zip
(5.95 KiB) Downloaded 405 times
This is a survey:

i18n.patch -> Changes to the internationalization package
Addition of function getLocale(). The difference this function has of getLanguage (on which it is based is that)
-It always returns a language (even if default is picked) if the language is unsupported, it returns en
-It returns en instead of en_GB, en_US and so on

wrf.patch -> additions to the wrf file and respective changes in data.cpp
Added file font.cfg to wrf. This allows moddable fonts from what I understand of WZ2100
Added a new format (FONTCFG) and handling function dataFontCfgLoad.

text_interface.patch -> Changes to how textdraw is configured from outside
No calls to iV_font from outside. It is called internally by textdraw.cpp
Instead iV_loadFontConfig is called from data.cpp (in wrf.patch)
To initialize text, previously. iV_TextInit was called only once before any wrf files were loaded. This had to change. Now iV_TextInit is called whenever a wrf is loaded. Duplicate calls are blocked internally by textdraw.cpp to enhance performance

textdraw.patch -> the real deal, changes to textdraw.cpp
This contains these major code changes:
font_family[128] is replaced by font_family_regular and font_family_bold, this allows separate fonts to be used for Bold (used in menu) vs the rest of places.
font_regular_size, font_medium_size, font_bold_size and font_small_size are now variables. They used to be hard-coded to 12, 16, 21 and 9 respectively. They are configured based on font.cfg.
FontProperties is a data structure filled by font.cfg
fontMap stores all the loaded data front font.cfg. As a result, we will load font.cfg only once.
iV_font has a different interface now. It configures fontfaces as well as font sizes.
iV_chooseFont selects font based on the current locale (getLocale in i18n.patch)
iV_loadFontConfig given the font.cfg file, it fills the fontMap (called from data.cpp)
iV_initializeGLC used to block second calls. Now it will clean-up and start anew.
iV_TextInit calls chooseFont. If the font indeed changed (checked by mustUpdateFont) it will call re initialized the fonts.

I think that's all!
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

wuz21m wrote:Here it comes:

I zipped them because of the upload limit:
big_font_patch.zip
(I also uploaded the files, split into individual patches to the bug tracker along with this explanation)

This is a survey:

i18n.patch -> Changes to the internationalization package
Addition of function getLocale(). The difference this function has of getLanguage (on which it is based is that)
-It always returns a language (even if default is picked) if the language is unsupported, it returns en
-It returns en instead of en_GB, en_US and so on

wrf.patch -> additions to the wrf file and respective changes in data.cpp
Added file font.cfg to wrf. This allows moddable fonts from what I understand of WZ2100
Added a new format (FONTCFG) and handling function dataFontCfgLoad.

text_interface.patch -> Changes to how textdraw is configured from outside
No calls to iV_font from outside. It is called internally by textdraw.cpp
Instead iV_loadFontConfig is called from data.cpp (in wrf.patch)
To initialize text, previously. iV_TextInit was called only once before any wrf files were loaded. This had to change. Now iV_TextInit is called whenever a wrf is loaded. Duplicate calls are blocked internally by textdraw.cpp to enhance performance

textdraw.patch -> the real deal, changes to textdraw.cpp
This contains these major code changes:
font_family[128] is replaced by font_family_regular and font_family_bold, this allows separate fonts to be used for Bold (used in menu) vs the rest of places.
font_regular_size, font_medium_size, font_bold_size and font_small_size are now variables. They used to be hard-coded to 12, 16, 21 and 9 respectively. They are configured based on font.cfg.
FontProperties is a data structure filled by font.cfg
fontMap stores all the loaded data front font.cfg. As a result, we will load font.cfg only once.
iV_font has a different interface now. It configures fontfaces as well as font sizes.
iV_chooseFont selects font based on the current locale (getLocale in i18n.patch)
iV_loadFontConfig given the font.cfg file, it fills the fontMap (called from data.cpp)
iV_initializeGLC used to block second calls. Now it will clean-up and start anew.
iV_TextInit calls chooseFont. If the font indeed changed (checked by mustUpdateFont) it will call re initialized the fonts.

I think that's all!
User avatar
rayfxrazorz
Greenhorn
Posts: 11
Joined: 18 Jan 2015, 04:21

Re: Using a new font

Post by rayfxrazorz »

Try wz with the Batman Forever font !
http://www.dafont.com/batman-forever.font

Image
images hosting
Image
wuz21m
Trained
Trained
Posts: 36
Joined: 18 Dec 2014, 20:57

Re: Using a new font

Post by wuz21m »

I appreciate the effort. But this font is shareware. We wish to distribute the font with free, GPL software :)
Sadly, I don't think we can do such as thing with this font.

Of course, should this patch go through, adding a mod with this font is extremely easy for users and requires no code modifications.
Post Reply