BreadCrumbs: True Type Fonts

True Type Fonts

From Luke Jackson

Revision as of 22:18, 25 January 2008; Ljackson (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Contents

Overview

The primary font technology used on Microsoft Windows and the Mac OS is based on the TrueType specification. TrueType fonts are scalable which means the glyphs can be displayed at any resolution and any point size (though the glyphs may not look good in extreme cases). A TrueType font is a binary file containing a number of tables. There is a directory of tables at the start of the file. The file may contain only one table of each type, and the type is indicated by a case-sensitive four letter tag. Each table and the whole font file have checksums.

The TrueType specification was developed by Apple and adopted by Microsoft. Later Microsoft and Adobe expanded the specification to support smart rendering and PostScript glyphs. The new specification, which added more tables, was called OpenType. Apple also added tables to TrueType to support a different smart rendering system producing the Apple Advanced Typography (AAT) font specification. SIL’s Graphite smart rendering system works by adding tables, too.

Data Tables

A TrueType font file consists of a sequence of concatenated tables. A table is a sequence of words. Each table must be long aligned and padded with zeros if necessary.

The first of the tables is the font directory, a special table that facilitates access to the other tables in the font. The directory is followed by a sequence of tables containing the font data. These tables can appear in any order. Certain tables are required for all fonts. Others are optional depending upon the functionality expected of a particular font.

The tables have names known as tags. Tags have the type uint32. Currently defined tag names consist of four characters. Tag names with less than four characters have trailing spaces. When tag names are shown in text they are enclosed in straight quotes.

Tables that are required must appear in any valid TrueType font file. The required tables and their tag names are shown in the table below.

Tag Table
'cmap' character to glyph mapping
'glyf' glyph data
'head' font header
'hhea' horizontal header
'hmtx' horizontal metrics
'loca' index to location
'maxp' maximum profile
'name' naming
'post' PostScript

Platform

Name

This table stores text strings which an application can use to provide information about the font. Each string in the name table has a platform and encoding id corresponding to the platform and encoding ids in the cmap table. Each string also has a language id which can be used to support strings in different languages. For Windows (platform id 3) the language id is the same as a Windows LCID. For the Mac OS (platform id 1), script manager codes are used instead.

ID Description
0 Copyright notice
1 Font Family name.
2 Font Subfamily name. Font style (italic, oblique) and weight (light, bold, black, etc.). A font with no particular differences in weight or style (e.g. medium weight, not italic) should have the string "Regular" stored in this position.
3 Unique font identifier. Usually similar to 4 but with enough additional information to be globally unique. Often includes information from Id 8 and Id 0.
4 Full font name. This should be a combination of strings 1 and 2. Exception: if the font is “Regular” as indicated in string 2, then use only the family name contained in string 1. This is the font name that Windows will expose to users.
5 Version string. Must begin with the syntax ‘Version n.nn ‘ (upper case, lower case, or mixed, with a space following the number).
6 Postscript name for the font.
7 Trademark. Used to save any trademark notice/information for this font. Such information should be based on legal advice. This is distinctly separate from the copyright.
8 Manufacturer Name.
9 Designer. Name of the designer of the typeface.
10 Description. Description of the typeface. Can contain revision information, usage recommendations, history, features, etc.
11 URL Vendor. URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font.
12 URL Designer. URL of typeface designer (with protocol, e.g., http://, ftp://).
13 License description. Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese.
14 License information URL. Where additional licensing information can be found.
15 Reserved; Set to zero.
16 Preferred Family (Windows only). In Windows, the Family name is displayed in the font menu. The Subfamily name is presented as the Style name. For historical reasons, font families have contained a maximum of four styles, but font designers may group more than four fonts to a single family. The Preferred Family and Preferred Subfamily IDs allow font designers to include the preferred family/subfamily groupings. These IDs are only present if they are different from IDs 1 and 2.
17 Preferred Subfamily (Windows only). See above.
18 Compatible Full (Mac OS only). On the Mac OS, the menu name is constructed using the FOND resource. This usually matches the Full Name. If you want the name of the font to appear differently than the Full Name, you can insert the Compatible Full Name here.
19 Sample text. This can be the font name, or any other text that the designer thinks is the best sample text to show what the font looks like.
20 PostScript CID findfont name.
21-255 Reserved for future expansion.
256-32767 Font-specific names.

Example (.SVG File)

Below is a text generated .svg file. You can match the element font-family of the text container to key id 1 (Font Family Name) in the Name table above.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xml:space="preserve">
<g>
<text x="0" y="149.62448979592" font-size="161.33333333333" font-family="Hole-HeartedRegular" text-anchor="" fill="#D31818">Adrian</text>
<text x="0" y="352.07346938776" font-size="161.33333333333" font-family="Hole-HeartedRegular" text-anchor="" fill="#D31818">was here!</text>
</g>
<font-face font-family="Hole-HeartedRegular">
<font-face-src><font-face-uri xlink:href="/local/www/us/img/fonts/ttf/hole-heartedregular.ttf" />
</font-face-src>
</font-face>
</svg>

Example (Helvetica Narrow Italic)

The Subfamily string in the name table should be used for variants of weight (ultra light to extra black) and style (oblique/italic or not). So, for example, the full font name of “Helvetica Narrow Italic” should be defined as Family name “Helvetica Narrow” and Subfamily “Italic.” This is so that Windows can group the standard four weights of a font in a reasonable fashion for non-typographically aware applications which only support combinations of “bold” and “italic.”

Linux

Overview

An easy way to install Microsoft's TrueType core fonts on linux

The original unaltered .exe files as downloaded from microsoft.com when they were available here

Install

If you don't have a rpm based distribution, you can compile the tool to extract the .ttf files from the .exe files, cabextract from source, found here How to install

Installing Microsoft's TrueType core fonts for the web on any rpm based linux box with TrueType support is now easy. The instructions below have been tested on various Red Hat and Fedora Core systems, but they are fairly generic so they should apply to any redhat-like linux distribution, such as mandrake or yellowdog. If you are running debian, please have a look here. If you are running suse, please have a look here

1.

Make sure you have the following rpm-packages installed from from your favourite distribution. Any version should do.

  • rpm-build
  • wget
  • A package that provides the ttmkfdir utility. For example

o For Fedora Core and Red Hat Enterprise Linux 4, ttmkfdir o For old redhat releases, XFree86-font-utils o For mandrake-8.2, freetype-tools 2.

Install the cabextract utility. For users of Fedora Core it is available from extras. Others may want to compile it themselves from source, or download the source rpm from fedora extras and rebuild.

3.

Download the latest msttcorefonts spec file from here

4.

If you haven't done so already, set up an rpm build environment in your home directory. You can to this by adding the line %_topdir %(echo $HOME)/rpmbuild to your $HOME/.rpmmacros and create the directories $HOME/rpmbuild/BUILD and $HOME/rpmbuild/RPMS/noarch

5.

Build the binary rpm with this command:

$ rpmbuild -bb msttcorefonts-2.0-1.spec

This will download the fonts from a Sourcforge mirror (about 8 megs) and repackage them so that they can be easily installed.

6.

Install the newly built rpm using the following command (you will need to be root):

# rpm -ivh $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

7.

You might need to reload the X font server. Normally this is done as a part of the installation process (this is done by chkfontpath). However in some situations it seems like you need to reload or restart the font server manually. I am told that the last argument needs to be restart and not reload on Mandrake 9.0

# /sbin/service xfs reload

A bug in RedHat 8.0 makes the X server lose the connection to the font server if the font server is restarted instead of reloaded. That will cause assorted strange behaviour (changed fonts in newly opened applications, applications hanging). Logging out and logging in again will solve the problems, or just use 'reload' instead of 'restart'. 8. Enjoy your new high quality fonts. To verify that the installation succeeded, please use the command 'xlsfonts | grep ^-microsoft'. You should see a whole lot of microsoft font names there. Please note that you need to restart all programs that you want to make aware of the new fonts. Note also that not all fonts have 'microsoft' in their name, some of them will be from 'monotype' instead.

Features

  • Does not distribute Microsoft's fonts in a prohibited way (to the best of my knowledge that is)
  • Doesn't bypass the rpm database like other font install scripts


Sources

Personal tools