Font issues v0.1

Disclaimer

I am by no means an expert on the following subjects I am talking about: Fonts, GNUstep and the english language. So bear this in mind before pointing me in the right direction:-)

Contents

  1. Introduction
  2. How it works now
    1. Very short overview
    2. GUI side
    3. Backend
    4. Connection between backend and frontend
    5. Font naming
  3. Requirements
    1. Configuration
      1. Installation/configuration
      2. running system configuration
    2. Daily usage
  4. Proposal for new implementation
  5. Questions
    1. non-technical questions
    2. screen vs. printer fonts

1. Introduction

First a short overview of how the current font system works in GNUstep is given. Someone who know how the current font system works can skip this part. (But comments are welcome because I am new to this.)

The second part consists of the short list of what I expect from the font system. This part should be extended and be made more detailed.

The next part describes a suggestion of how the font system could be implemented. This is very high level and in the process of being written.

2. How it works now

2.1 Very short overview

The font system divided over two components:
  1. The gui (AppKit) component
  2. The graphical backend.

2.2 GUI side

The responsibility of the GUI side of the Font system is more of an administrative kind. It provides applications with roughly the following API So the lowlevel functionality of this API is delegated to the backend. The API is provided by the classes NSFont, NSFontManager and NSFontPanel. These classes are described in the OpenStep API specification. The GUI component also contains the private classes GSFontInfo and GSFontEnumerator. Those private classes do two things:
  1. They provide the link between the GUI and the backend.
  2. They implement functionality that is shared between the different backends.

2.3 Backend

The responsibilities can be divided into two parts

2.4 Connection between backend and frontend

Care has been taken to minimize the dependency of the frontend on the backend. All the functionality that the frontend need is declared in the two private classes GSFontInfo and GSFontEnumerator. The backend will subclass these two classes and implement the methods that the GSFont[Info|Enumerator] classes need. The initializers of the GSFont[Font|Enumerator] classes will upon initialization return instances of the subclasses provided by the backend. The GSFont* classes know what the subclasses are because the backend initialization routine provides the GSFont* classes with this information.

A pictorial representation of this for the NSFont class is

                                              \
+--------+             +-------------+         |
| NSFont |   --------> | GSFontInfo  |         |
+--------+-+           +-------------+         |
| fontname |           | fontname    |         |
| matrix   |           | familyname  |          >  GUI
+----------+           | matrix      |         |
                       | fontmetrics |         |
		       | fntDict (*) |         |
                       +-------------+         |
                             |                /   (*) not used at
                             |                        the moment
                            / \
                            --- 
			     |                \
			+------------+         |
			| XGFontInfo |         |
			+------------+         |
			| implements |          >  backend
			| all almost |         |
                        | logic      |         |
                        +------------+         |
                                              /

A similar picture can be drawn for the GSFontEnumerator class.

2.5 Font naming

The backend knows what fonts are available and provides the frontend, by means of GSFontEnumerator, with the names of the font it knows.

3. Requirements

Before thinking of how to reorganize the font system we should have some idea of how the `user' want the system to behave. For user we should not necessary read a human user. When this distinction is important it will be explicitly stated. The requirements of the font system can be roughly divided into two categories: daily usage, installation/configuration.

3.1 Configuration

3.1.1 installation/configuration

The installation of GNUstep should be as easy as possible. A consequence of this is that on a normal computer system no configuration is required. In order to achieve this starting the GNUstep system should be able to:
  1. Detect all fonts suitable for the different backends that are installed. This includes but is not limited to:
    1. For the xgps backend all Xlib fonts.
    2. All T1 fonts installed on the system in the default place for the underlying operating system.
    3. When a backend provides support for TrueType or Opentype fonts it should detect these.
  2. Use font mappings that can be found on the the underlying operating systems. An example of such a mapping is the FontMap file provided by ghostscript.
  3. Provide a minimum set of standard fonts, at least:
    1. The Helvetica family consisting of the regular, bold, italic, bold-italic variety.
    2. The Courier family consisting of the regular, bold, italic, bold-italic variety
    This could be done by either including these default fonts in GNUstep, or automatically map the default fonts to fonts found on the system.

3.1.2 running system configuration

After the initial installation the user should be able to add fonts. When these fonts are added to the underlying operating system, GNUstep will pick them up after restarting GNUstep. It should also be possible to install fonts in a running GNUstep system, but for this a special tool will be needed. (GNUstep can not guess that the operating system acquired a new font.) Configuration should not be necessary. But for the advanced user configuration should be possible to a high degree. Examples of what should be customized includes
  1. Mapping GNUstep font names, as the user sees them in the font panel, to fonts that the fontsystem has detected. For example, my system does not include a Helvetica font. But ghostscript maps the Helvetica fonts to the NimbusSanL fonts. These kind of mappings should be configurable.
  2. Disabling some fonts in order to remove unwanted fonts.
  3. Provide a way to influence the way that a font is displayed on the screen. This means that the connection between a NSFont and its corresponding screen font can be customized. The customization depends not only on the font but also on the point size and on the current transformation matrix. The customization includes per (font,size/matrix) combination
    • Using a specific screenfont
    • Using the Xlib mechanism, or any other specific font renderer.
    • Using antialiasing, and which form of it.
    • Or some other parameters I did not think of.
    This includes quite a bit of backend configuration. And these changes should be relativily easy to make. That means that if you decide to turn antialiasing on for fonts sizes greater than 16points it should not be necessary to change every individual pointsize bigger than 16point.
  4. Provide a way to configure the printerfonts. This is a subject that I do not understand.

3.2 daily usage

When using the fonts the user should not see anything from the configuration process. Also the user should not be restricted by what GNUstep has found. That means that

4. Proposal for new implementation

I propose the seperation of the font system into three layers. From the bottom up these are

GUI      |   NSFont                 GSFontInfo     
         |   -----                  ---------- 
         |   Object the             Provides common
	 |   GUI lib sees           logic, mostly derived
         |                          from the AFM file info.
	 |	 	           The AFM file info is
	 |			   derived from the backend.
         | 
	 |
	 |
Backend  |  General                 GSFontInfoChild           
	 |  -------                 ---------------
	 |  Reads data from         Specializes GSFontInfo
	 |  font installer          provide mapping between
	 |                          printer <--> screen font
         | 
         |
Font     |   Finds all fonts on the system.
Installer|   Parses configuration.  Creates AFM
         |   info from fonts.  precomputes
         |   stores it in a dictionary.

5. Questions

5.1 Non-technical questions

5.2 Screen vs. printer fonts