[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XForms] True Type font pre-release

From: Jens Thoms Toerring
Subject: [XForms] True Type font pre-release
Date: Wed, 25 Jun 2014 22:33:38 +0200
User-agent: Mutt/1.5.21 (2010-09-15)


  here's a new pre-release that includes support for TTF/OTF fonts
via the use of the Xft library:


Actually, it's now two different versions of the XForms library:
when you run './configure' as you used to the new version with su-
pport for TTF/OTF fonts will be build. If you pass the '--disable-xft'
option to 'configure' a version is build that uses only the old X11
bitnap fonts (and thus should work as the previous versions).

In both versions the resulting library isn't backward compatible to
older versions (since some internal data structures had to be modi
fied), giving it a new major SO-version of 3. Thus all of your pro-
grams not rebuild will still use the already installed old version
of the library. Since this is a new SO-version you may have to
run the 'ldconfig' command after installation to make the dynamic
linker aware of its existence (a typical sign that this is required
is when you try to start fdesign and all you get is an error mes-
sage about libforms.so.3 not having been found).

With the new version there's also an updated format of the fdesign
files, so it probably will be useful to keep backups of your .fd
files around if you want to test fdesign on them.

Let's come to the actual differences and start with fdesign. You
may notice that in the "Options" meny in the main window there's
a new entry: "Use X11 fonts". This allows you to switch back and
forward between the use of the mnew TTF/OTF fonts and the old X11
bitmap fonts (as close as I was able to get it). This will also
switch between the fonts fdesign itself uses. If this option is on
when you safe a file the .fd file will contain a flag that will
make fdesign switch to the X11 fonts automatically when that .fd
file is loaded. It also will add a line to the main() function in
the C output file directly after the line with 'fl_initialize()'
to make your program switch to the use of X11 fonts. Thus, if you
find that your program doesn't look well with the new fonts you
can go back to the old ones (and then still use features like
anti-aliasing and arbitrary scaling!).

The function for switching between the default fonts used is

fl_set_default_font_type(int type);

where 'type' is either 'FL_XFT_FONT' or 'FL_X11_FONT'. The function
can also be used to "re-initialize" the settings for the default
fonts - if you have changed them and want to get back to the initial
state simply call this function.

If you like the new fonts but have an issue with their sizes you
also can set a global scaling factor for all fonts using

void fl_set_global_font_scaling(double scale);

to reduce or increase the size of all fonts at once.

If the problem is only for a certain font use instead

void fl_set_font_scaling_factor(int    index,
                                double factor);

Here 'index' is the font number (the default fonts have, as before,
the numbers 0 to 15 while the indices for additonally loaded fonts
is set by yourself.

The already existing function

int fl_set_font_name(int index, const char * name);

for loading additional fonts can only be used for X11 fonts and
with the traditional XLFD (X Logical Font Descrition) names.

If you want to load a TTF/OTF file you instead have to use

int fl_set_xft_font_name(int index, const char * name,
                         int slant, int weight);

For the name you now will use more easy to remember names like
"DejaVu Sans" or "Comic Sans MS". The slant myst be one of
and for 'weight you can use 'FL_WEIGHT_LIGHT', 'FL_WEIGHT_MEDIUM',
Of course, you should check with the 'fc-list' tool which fonts
are really available on your system;-) If you specify a font that
doesn't exist a replacement font will be picked automatoically by
the Xft library.

Note that the upper limit on the number of fonts that can be used
at once has been raised to about 1000. You can pick an arbitrary
valkue between 16 and 1000 for the index (the upper limit is actually
'FL_SHADOW_STYLE - 1'). And each of these fonts is available in any
size not less than 1.

Of course these functions can also, as previously, be used to replace
the default fonts.

Fonts can now also be unloaded when not needed anymore, use

int fl_unload_font(int index);

to unload a font given its index (this doesn't work for the default
fonts with indices 0 to 15).

If you just want to dealocate a font at a certain point size use

int fl_unload_sized_font(int index, int size);

Concerning the default fonts: as a first attempt DejaVu Sans,
DejaVu Mono and DejaVu Serif are used and a Palladino-clone,
FPL Neu. If these fonts are suitable is, of course, something
we should discuss - changing this is trivial.

Since I can't be sure these fonts are available everywhere I've
included them into the package (even though this increases its
size by more than a factor of 2).

The fonts will be installed in '/usr/local/share/fonts/XForms'
(unless you have changed the 'prefix' during 'configure') and
the fontconfigure cache will automatically be rebuild. This is
probably not the most elegant way and may change in the future,
but that was the best I could come up with at the moment.

If you ever have used the directory listing functions build into
XForms, i.e., fl_get_dirlist(), and checked if a returned entry
is of a normal file you've probably been using the 'FT_FILE'
macro. Unfortunately, this macro is already in use by the free-
type library (and its header files get automatically included
by the headers of the Xft linrary). So I had to change it to
'FT_REG' (for "regular" file). This is a bit unfortunate since
the compiler won't flag any proplems if you code uses 'FT_FILE'
since the macro is still defined, but to a different thing. Thus
you should grep your sources for use of it and replace each occu-
rence with 'FT_REG'.

What else? When you compile your programs with the new library
you need an additional compile time option,

$(pkg-config --cflags freetype2)

This is because the Xft.h file now must be included in forns.h
and this, in turn includes the freetype header files. But there
are two incompatible versions of these headers and the Xft header
can't decide on its own which one is to be used. That's what that
bit is good for, it resolves typically to '-I/usr/include/freetype2',
i.e., the correct include path for the required freetype headers.
A bit of a mess, admittedly, but there's nothing I can do about

There are a few more new things, but this email is already much too
long, so I stop here and tell you about that later. For the time
being I guess there's already enough to test;-) So, please, give it
a try and report all the problems you'll find. I'm well aware that
this is not a production-ready release yet and a few things will
change for sure. Any help in finding the weak points will be appre-
                               Best regards, Jens

PS: If you are done with testing and want to go back to the old
    version go into the directory of the new version, run "make
    uninstall", and then go into the directory of the old version
    you want to go back to and run there "make install" again.
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de

reply via email to

[Prev in Thread] Current Thread [Next in Thread]