Re: Using a new font
Posted: 01 Jan 2015, 23:38
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.
Thanks for your comments.
wuz21m wrote:Here it comes:
I zipped them because of the upload limit: (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!