Font standards

E16 themes have many choices when it comes to font setup.

X Font (normal/multibyte)
Fnlib
TrueType

Pango
Xft

In order for a theme to be functional on as many distributions as possible, which choice would be the most effective? Should we limit the themes here to a standard set (possibly UTF8) for the best support? If so which ones would be good candidates?

RE: Font standards

This is unfortunately all quite complicated. I'll try to elaborate.

First an easy one - Fnlib font support was removed as of 0.16.7 with the transition to imlib2. I'm not aware of any theme having used it. In any case, fnlib is and will stay dead.

The "core themes" (i.e. the ones I have been maintaining) use a "font alias" file - fonts.cfg[.something]. This feature is available as of 0.16.8. I'll get back to the font alias file later.

All other themes (afaik) use the old theme way of doing things, i.e. specifying the font in every textclass, either as a TTF one (<name>/<size>) or as an XLFD one (-*-blah-*). TTF fonts are normally shipped with the theme. XLFD fonts must be installed on the system.

A general problem with TTF fonts shipped by themes is that they only have a limited character set, which causes the suckage when rendering text with glyphs outside basically the ASCII set.

With XLFD font(set)s there are similar problems although it is possible to do a better job than with the often obscure TTF fonts.

e16 cannot figure out whether or not a font sucks and cannot generally override fonts directly specified in the themes to something less sucking. In order to do something about this the themes will have to be modified, e.g. to use font aliases.

The big problem as I see it with changing the theme font is that the "personality" of many themes partly lies in the selected fonts. So, in my opinion it should somehow be possible to select between "original style" or "unicode support". This shouldn't be too hard if the themes are modified to use font aliases.

As mentioned above it is possible to select between four font selection/rendering "types" (see also README-0.16.8).
(Note - I'm not really an expert on these matters so please correct me if you think I got something wrong).

1) TTF (via imlib2). In general themes will contain the fonts.
Pros: Self contained (no external dependencies).
Cons: Cost space on system. Generally poor unicode support. Often have "improper" license. e16/imlib2 must be able to find the absolute location of the font.

Distributions are focusing more and more on not distributing more font files than necessary and not distributing fonts with questionable/improper licenses.

This why I introduced the normal/bold "pseudo" TTF font names now used in the winter theme and the e16-docs package. In the default e16 installation normal/bold.ttf are found in /usr/share/e16/fonts and are links to Vera/VeraBd.ttf in the same directory.
The Vera ttf's are included in the default e16 installation to avoid having to figure out what to do on every possible target installation.

Distributions can now easily remove the Vera ttf's and change the normal/bold links to whatever is considered the appropriate replacement, e.g. /usr/share/fonts/dejavu/DejaVuSans[-Bold].ttf.

2) XLFD.
Pros: Always available. Installed on system.
Cons: The fonts may not be installed on the system. Special theme fonts need to be installed depending on the system. It is hard to get good unicode coverage even with the most "standard" font (-misc-*).

3) Xft/fontconfig.
Pros: Widely available, if not always. Likely to give good unicode coverage, at least for the current locale, whichever it is.
Cons: In my experience it is not possible to rely on getting "full" unicode coverage, as in being able to show russian, chinese and arabic at the same time. I'm not quite sure whether or not this is a fundamental limitation of fontconfig or it can be fixed by proper configuration. Themes can in general not rely on any particular font being installed on the system.

4) Pango.
Pros: Pretty much standard (dependency of gtk2). With a "sans" font the unicode coverage seems to be limited only by the fonts installed on the system.
Cons: Introduces a number of additional dependencies for e16 (pango, obviously, glib and related stuff), which is why it is disabled by default (I believe most distributions do enable it though). Again, themes can in general not rely on any particular font being installed.

Now, how does e16 select the font used in a theme?
Well, if the theme does not use font aliases they are simply defined in the theme text classes. It is possible to use all available font types, but it is not possible to change any theme font without changing the theme (textclasses).
If the theme does use font aliases (which just are symbolic names which are looked up in a font configuration file, see e.g. default winter theme) it is possible to change all fonts in the theme just by specifying which font configuration file to use.

The font configuration file used depends on a few settings:

theme.use_alt_font_cfg (boolean, default "1", i.e. true)
theme.font_cfg (string, default "fonts.cfg.xft")
NB! changing these will only take effect after a restart.

The search path for font configuration files (in a standard setup) is ~/.e16, <theme directory>, /usr/share/e16/config.

If theme.use_alt_font_cfg (use alternate font configuration file) is true, e16 will look for the file specified by theme.font_cfg, otherwise it will look for fonts.cfg.

Thus, by default, e16 will look for fonts.cfg.xft, which (unless you have one in ~/.e16) will be found in /usr/share/e16/config, and the theme will use Xft and select the sans font (in various sizes and boldness for different theme elements).
If theme.use_alt_font_cfg is set to 0, then e16 will look for fonts.cfg which (again, unless you have your own in ~/.e16) will be found in the theme directory. These font configuration files specify the fonts originally used in each of the core themes.

So, just to emphasise this, by default e16 uses an Xft sans font in all core themes, which normally should give good "native" unicode coverage in any particular locale.

If better unicode coverage is desired it is probably necessary to enable pango support in e16 and change the font configuration file to one specifying pango fonts, e.g. by changing theme.font_cfg to fonts.cfg.pango, which is also supplied in /usr/share/e16/config, or by using a custom fonts.cfg file in ~/.e16/.

So, how to improve font support in other (Don's :) ) themes?
I think the best way is to change all textclasses to use font aliases, basically as I have done in the core themes.
Each theme should have its own fonts.cfg specifying the original fonts.
e16 probably should have a dialog checkbox to select "Use theme font". If that is selected e16 should use fonts.cfg (hmm.. maybe that should be fonts.cfg.theme to explicitly select the theme font and not ~/.e16/fonts.cfg) which will be found in the theme directory. If not selecting the theme font maybe e16 should default to fonts.cfg.pango if compiled with that and fonts.cfg.xft if not.

The only problem I can think of (except the hassle of having to change all the textclasses :) ) with this approach is that using font aliases requires 0.16.8. An then again, I think I'll consider that a benefit rather than a problem.

I hope this has shed a bit of light on the use of fonts in e16 :)