Features/AutomaticFontInstallation

Summary
Automated installation of fonts that are required to render documents

Owner

 * Name: Behdad Esfahbod,  Richard Hughes

Current status

 * Targeted release:  Fedora 11
 * Last updated: 2008-12-01
 * Percentage of completion: 50%

The required PackageKit support is in place already. The GTK+ module is in Packagekit git upstream. The fontconfig changes are not in a fontconfig release yet. The RPM changes are not developed yet.

Detailed Description
Automatic font installation can be interpreted as three different things:


 * Show a dialog to install fonts when there are no fonts available on the system to render a given language. This is the main purpose of this feature.  Say, you try to view an Arabic website on your friend's computer, it pops up and lets you choose which Arabic font to install.


 * Show a dialog to install fonts when a requested font family is not available on the system. This is trickier, and mostly useful with Word Processors.  Say, you open a .doc file in OO.o or AbiWord and it prompts and asks to install some font.  This is not as useful as it sounds as 1) For most fonts from the other world, we don't have them in Fedora, 2) The way fontconfig works makes it hard to know when a font family is not available.  For example, when a document asks for Arial, LiberationSans is a match, but it's hard to know programatically.  Moreover, if LiberationSans is not available, it should be offered as a match to install.  This problem is not interactable, just not as automatic and easy to solve as the missing-font-for-language part is.  This may be tried in a future version (F12 perhaps).


 * Show a dialog to install fonts when there are not fonts available on the system to render a given character. This will be triggered whenever there is a Pango hexbox to be shown.  This is much harder to implement and is not in the scope of this featuree.

Automatic Font Installation for Language
Here is how it works:


 * PackageKit installs a GTK module and sets it up to be loaded by default by all GTK applications. Lets call this the missing-font module.


 * The missing-font module creates a subclass of PangoFcFontMap and installs an instance of that as default pangocairo fontmap. The said subclass simply calls into PackageKit whenever a load_fontset fails to find a font for the give language.  A fully working draft of this exists and is less than 150 lines of code.


 * The PackageKit call then causes a D-BUS call that will cause a bubble or something show up and suggest installing fonts for the language.

Note that the application does NOT need to wait for font installation to finish. We already have the pieces in place such that whenever a new font is installed all applications refresh and use it with no manual intervention. This already works in F10.

Benefit to Fedora
Improved font support without the need to include a huge amount of fonts in the default install, and user flexibility.

Scope
Requires:
 * PackageKit changes to support font installation
 * GTK+ module (shipped by PackageKit) to call PackageKit whenever Pango can't find a font for a language
 * Changes to RPM to automatically tag font packages with their language coverage information
 * [later] Modify applications (AbiWord, OO.o, Firefox, ...) to call PackageKit directly when requested font families are missing

Test Plan

 * 1) Create a number of documents in various types (html, plain text, odf, doc) that use specific fonts which are not in the default install
 * 2) Open these documents in the viewers that are mentioned above
 * 3) Verify that font installation is triggered, and the document renders correctly after the missing fonts have been installed, without needing to restart application
 * 4) Repeat the same test with fonts that are not available in Fedora repositories
 * 5) Following the use cases outlined above, on a system that doesn't have Arabic fonts installed, go to an Arabic website and check that the necessary fonts are being installed.

User Experience
User receives a document e.g. as email attachment. The user can open the document in the default viewer by clicking on the attachment in the mail client. The viewer shows a PackageKit prompt proposing to install missing fonts.



Dependencies
To be filled in.

Contingency Plan

 * Require manual font installation as usual.

Documentation
The various auto-installation features of PackageKit (codecs, fonts,...) will be explained in the gnome-PackageKit manual.

Release Notes
To be filled in.

Comments and Discussion
See Talk:Features/AutomaticFontInstallation