From Mageia wiki
Jump to: navigation, search

This policy governs the packaging and installation of fonts in the Mageia distribution. All packages containing fonts should follow it.

Tools to be used

fc-cache (fontconfig)

The fc-cache tool scans the font directories on the system and builds font information cache files, which are then usable by applications using fontconfig for their font handling.

fc-cache be run in %post and %postun, after adding/removing the font directory to the configuration with chkfontpath (see below), to update the system's font cache.

chkfontpath

chkfontpath is mainly used by rpm in its %post and %postun sections to add and remove new directories to the server's config file at installation and uninstall time of packages containing fonts.

freetype-tools (ttmkfdir)

ttmkfdir is an alternative to mkfontdir, for Truetype fonts only.

mkfontscale

Should be used to generate fonts.scale, at build time.

mkfontdir

Should be used to generate fonts.dir and encodings.dir, at build time, from fonts plus fonts.scale and fonts.alias.

Example %post and %postun

  • In %post:
%{_sbindir}/chkfontpath -q -a %{_datadir}/fonts/%{name}
%{_bin}/fc-cache
  • In %postun:
%{_sbindir}/chkfontpath -q -r %{_datadir}/fonts/%{name}
%{_bin}/fc-cache

Packaging guideline

Naming

Package name should be like: fonts-$type-$name.

Where:

  • $type would be one of:
    • ttf: TrueType fonts (*.ttf)
    • otf: OpenType fonts (*.otf)
    • type1: Postscript Type1 fonts (*.pfb, *.pfa, *.afm, *.pfm)
    • bitmap: fixed size, bitmapped, fonts (*.pcf, *.bdf)
  • $name would be either:
    • the font name: fonts-type1-hebrew
    • $foundryname-$fontname: fonts-ttf-bitstream-vera

Fonts subpackages of non-fonts main packages should follow these naming rules too, where $foundryname can be the main package name. See also the Location section below.

File compression

Type1 and bitmap font files should be compressed by gzip. TrueType fonts should not.

Location

Each font package should put its fonts in its own subdirectory under /usr/share/fonts/$type/, where $type is the type of font it is;

* /usr/share/fonts/TTF/*fontname*/ - for TrueType fonts
* /usr/share/fonts/OTF/*fontname*/ - for OpenType fonts
* /usr/share/fonts/Type1/*fontname*/ - for Type1 fonts
* /usr/share/fonts/bitmap/*fontname*/ - for bitmap fonts

Programs providing their own fonts should package them in subpackage(s), following the naming rules in this policy, and without requiring the main package as far as possible. The subpackage(s) should install the fonts in its own subdirectory under '/usr/share/fonts/$type/', named after the main package. For example '/usr/share/fonts/Type1/fonts-type1-lilypond', or '/usr/share/fonts/bitmap/fonts-bitmap-fluxbox-artwiz/'.

For a fonts only package (i.e. not a subpackage of a non-fonts package), referring to the font directory by %_datadir/fonts/$type/%name should be valid.

Special files

These files are created by the font management tools and should be packaged to:

  • avoiding unpackaged and/or %ghost files lost in the system
  • reducing run time dependencies (on the tools that generate them)
  • they (at least some of them) may be hand edited for fixing/tuning (see mkfontscale(1) and mkfontdir(1) manpages)

Files to package:

  • fonts.scale: used by mkfontdir, created by mkfontscale, may be edited by hand.
  • fonts.alias: created by hand, used by mkfontdir.
  • fonts.dir: created by mkfontdir.
  • encodings.dir: created by mkfontdir.

Misc

Configuration files

  • /etc/fonts/: fontconfig configuration directory.
  • /etc/X11/fs/config: prog|xfs configuration file, handled by chkfontpath.

Notes

  • fonts coming from Xorg are being named x11-font-$name-$type
    • fonts sharing directory must run 'mkfontscale' and 'mkfontdir' (or alikes) at '%post' and '%postun'.

Some extra references