How To build a Newton Font on MacOS X
by Paul Guyot <pguyot@kallisys.net>
16th April 2004

1Introduction

This How-To explains how to port a MacOS font to NewtonOS on MacOS X.
Porting fonts rely on old Apple font tools and therefore on Classic. We (the DCL Group) are currently
investigating a method to port fonts without relying on these tools, but some features of these old tools
we need are apparently not available in MacOS X Font Tools.
Important Note : Fonts are copyrightable and usually copyrighted. Please make sure that porting afont is compatible with the license you were granted on it.
This tutorial supposes that you have basic knowledge of MacOS X, that you know what the Terminal is,but it does not require that you have a long experience with the tools involved. We may use terms thatwould require a definition or a clarification. Most unusual terms used here are defined in the Newton
Glossary1 . Do not hesitate to send me corrections or ask me for clarifications if required.
This tutorial will guide through porting Gill Sans. The font book application shows this font:1

http://www.splorp.com/newton/glossary/1Newton Fonts How-To

2

This font actually exists in 6 forms:• Gill Sans Regular• Gill Sans Bold
• Gill Sans Italic• Gill Sans Bold Italic• Gill Sans Light• Gill Sans Light Italic
This font can be ported as two Newton font packages (Gill Sans and Gill Sans Light). The Gill Sans
package will include regular (or plain), bold, italic and bold-italic forms and the Gill Sans Light package
will include regular and italic forms.
You will need :• Newton Toolkit 1.6.4, which can be downloaded from UNNA (http://www.unna.org/)• The following Apple Font Tools (http://fonts.apple.com/)– AAT Font Tool 2.0a8

Newton Fonts How-To3– Fissioner 1.2b2– Fuser 1.2b1– TrueEdit 2.2b2• ResEdit (http://developer.apple.com/)• Apple Developer Tools for MacOS X (http://developer.apple.com/)• MacOS X Terminal

2Preparing the conversion

To prepare the conversion, create a folder called Gill Sans somewhere on your disk. Then, create afolder called Font in it.
On my disk, this folder is in:/Users/paul/Projets/Newton/NTK/Fonts/3Converting the font to a classic font suitcase

This step is necessary for Gill Sans because it is in the dfont format. The dfont format is just a resource
fork in the data fork. To perform the conversion, you can use ResMerger command line tool from theDeveloper Tools. Gill Sans is in /Library/Fonts/GillSans.dfont. You just have to write inthe terminal (on a single line) :ResMerger -fileType FFIL -fileCreator dmov -srcIs DF -dstIs RSRC/Library/Fonts/GillSans.dfont -o/Users/paul/Projets/Newton/NTK/Fonts/Gill\ Sans/Font/Gill\ Sans

Newton Fonts How-To

4Adapt the line to use the actual path of your folder. This line creates the file Gill Sans in your Fontfolder.

Newton Fonts How-To

5This step is not required if you are converting a font available as a suitcase. If it is available as a suitcase,just copy it to the Font folder.
There may be tools with a graphical interface to perform this step.

4

Checking what work will need to be performed

The next step is to open the font with TrueEdit to find what work will be required.

Newton Fonts How-To6Opening the Gill Sans font with TrueEdit reveals that this suitcase includes six fonts, the six forms
revealed by MacOS X font book. 2

If you open the first regular font, you will see its tables:
2

TrueEdit sometimes cannot display the font names properly in such lists, apparently because it relies on Resource names
and some fonts’ sfnt resources do not have any name.

Newton Fonts How-To

7

Double-clicking the name row shows the name table with the various information on this font including
the family and the subfamily names (so you can check that indeed you did open the Gill Sans Regularfont) :Newton Fonts How-To

8This font has no bdat table which means that it has no bitmap information. This is true for all the fonts
included in this suitcase, but if you’re working with another font, you may want to check.
NewtonOS requires bitmap tables in fonts. You will generate these tables using Fissioner andFuser.

5Running AAT Font Tool

The next step is to run AAT Font Tool on the font.

According to Apple documentation, running AAT Font Tool on fonts to built Newton fonts is only
useful because NewtonOS require Unicode character maps in fonts. In fact, most MacOS X fonts al-Newton Fonts How-To

9

ready have Unicode character maps. However, old Apple Font Tools are not extremely stable and myexperience is that they work better on a font pre-processed by AAT Font Tool.
Just drop the font suitcase on AAT Font Tool (make sure you closed it in TrueEdit first). Gill Sans
suitcase will go from 340 KB to 368 KB.

6Creating bitmaps

Newton Fonts are TrueType fonts with bitmaps. Gill Sans is a set of TrueType fonts with no bitmap
embedded in them. You need to generate the bitmaps for the sizes you want. In this tutorial, we willbuild fonts with 6 sizes (9, 10, 12, 14, 18 and 24). To do so, run Fissioner and tell it to open the Gill Sans
suitcase.

Then, choose one of the 6 fonts (you will have to do them all anyway). You can start with Gill Sans
Bold Italic because it’s the first in the list.

Newton Fonts How-To

10Then, enter a font size and press OK.

This will generate two files.
Iterate this process for all the the sizes. You will end up with 12 files plus the original suitcase in theFont folder.

Newton Fonts How-To
Then, you need to put the bitmaps back into the TrueType font.
To do so, run Fuser.

Choose Gill Sans :Select Gill Sans Bold Italic since it’s the one you are doing now :11Newton Fonts How-To

And then, choose a size and press OK.

You will have to do this another 5 times for the other 5 sizes.
Finally, open the font with TrueEdit to check that everything went well.
There are new tables :12Newton Fonts How-To

13

Open the bloc table. With the buttons labelled Smaller and Bigger you can navigate through thesizes (the size is in the field labelled ppemX).

Newton Fonts How-To

14Check that the six sizes are present and that for each size, the maxBeforeBL and minAfterBL fields
are not 0. If you have 0, copy what you will find in the ascender and descender fields respectively3 .
You can trash the 12 files created by Fissioner now and repeat the process with the five other fonts inthe suitcase (we only need 4 fonts to build the Gill Sans Newton package, the two others, Gill Sans
Light and Gill Sans Light Italic, are for the Gill Sans Light Newton package).
I suggest doing backups everytime bitmaps for a font have been successfully included back in the font.
Fissioner and Fuser aren’t very stable and sometimes, they may damage your font. Typically, the font
will only include 3 sizes out of six although you did include all the sizes. Or these tools may crashClassic. You probably don’t want to start all over again this boring process. Sometimes, doing bitmaps
in the descending order of sizes helps.
3The maxBeforeBL and minAfterBL fields were not used in earlier versions of MacOS, but they are used byNewtonOS.

Newton Fonts How-To

715

Cleaning the fonts

The next step is to remove every bit of the fonts NewtonOS won’t need. I suggest doing a backup
before as there is no way to recover a table you would have accidently deleted.
Open each font of the suitcase with TrueEdit and delete all tables except:• bdat• bloc• cmap• head• hhea• hmtx• maxp• nameThen open the cmap table and delete every row except the Unicode one. Open the name table anddelete every row except the English ones where the Name ID is not a number (this means keeping the8 or 9 rows that have one of the following Name IDs : Copyright, Family, Subfamily, UniqueName,FullName, Version, Postscript, Trademark, Manufacturer)4 .

4Some documentation mention that NewtonOS does not use the name table, while others mention that one must keep itfor NewtonOS

Newton Fonts How-To

16

Write the PostScript and the copyright down or copy them to a text file, you will need them whenbuilding the package.

8Getting the Macintosh Font ID and the Resource IDs

If a font is still open in TrueEdit, close it. Then open the suitcase with ResEdit.

Double-click on the FOND icon.

Newton Fonts How-To

17

There is one resource (one line) per font family, hence Gill Sans suitcase has two lines (one for Gill Sans
and one for Gill Sans Light). Gill Sans family ID is 4242 and Gill Sans Light family ID is 4243.

You need to identify the sfnt resources for NTK. Double-click on the sfnt icon. Some fonts have sfnt
resources with names. This is not the case with Gill Sans :Newton Fonts How-To

To identify the resources, open the FOND resource and scroll down to the Font entries :18

Newton Fonts How-To

19The Gill Sans FOND resource has 4 font entries. The Font Style field determines the face of the font.
0 is plain, 1 is bold, 2 is italic and 3 is bold italic (the only four styles handled in Newton fonts).
Hence, in Gill Sans, sfnt #8110 is Gill Sans Plain, sfnt #24685 is Gill Sans Bold, sfnt #15129 isGill Sans Italic and snft #4035 is Gill Sans Bold Italic.

9Building the hsty table

NewtonOS uses a specific table of type hsty (Horizontal Style) to print properly on LaserWriter printers when the font style is not available.
While the FOND resource is open in ResEdit, scroll up to see the Extra width for * fields.

Newton Fonts How-To

20

The values are all zeroes for Gill Sans and Gill Sans Light. The Horizontal Style table should containthese values scaled by the unit used in the htmx (Horizontal Metrix) table. However, I don’t know how
to scale these values exactly, unless they are zeroes.
Close the suitcase in ResEdit.
If you have zeroes, you can create the hsty table in every font with TrueEdit. Choose New Table
from the File menu and select horizontal style at the bottom of the Tag popup. The values arealready filled with zeroes.

Newton Fonts How-To

21

Note : this table is optional and is only used for printing.

10

Building the Newton Package

Start NTK. Click cancel in the Open File dialog that appears and create a new project from the Projectmenu. Call it Gill Sans and put it in the Gill Sans folder.

Newton Fonts How-To

22

Set the Project settings (from the Project menu) as follows:• in the Project Settings pane :– Uncheck Compile for debugging– Check Newton 2.0 platform only if you want to install the font on a Newton with NewtonOS
2.x.

Newton Fonts How-To• in the Output Settings pane :– Click Custom Part: and enter font in it.
– Put output in the Result field.
– Set the symbol to Gill Sans:Font.

23

Newton Fonts How-To

24• in the Package Settings pane :– Set the name to Gill Sans:Font– Check Use Compression– Uncheck Faster Compression– Set the Copyright field to the (beginning of the) Copyright string of the font that you readin the name table in TrueEdit.

Newton Fonts How-To

Create a new text file in NTK from the File menu. Write the following content:/*File:GillSansFont.f
Project:
Gill Sans
Written by: Paul Guyot
Copyright: c 2000-2004 by Paul Guyot.
All rights reserved worldwide.
*/// Customize the following lines// Set IDs to nil if there is no such resource.
DefConst(’kFontName, "Gill Sans" );DefConst(’kFontFile, "Gill Sans" );DefConst(’kFontSym, ’GillSans );DefConst(’kMacFontID, 4242 );DefConst(’kSizes, ’[9, 10, 12, 14, 18, 24] );DefConst(’kPlainResourceID, 8110 );DefConst(’kBoldResourceID, 24685 );DefConst(’kItalicResourceID, 15129 );DefConst(’kBoldItalicResourceID, 4035 );// You normally don’t need to change anything below this line.

25Newton Fonts How-To// ----------------------------------------------------------SetPartFrameSlot(’title, kFontName);constant kUnicode := 0;
constant kFix1 := 0x00010000;
refNum := OpenResFileX(HOME & "Font:" & kFontFile);
foreach style in[{id: kPlainResourceID, sym: ’plainSFNTData},{id: kBoldResourceID, sym: ’boldSFNTData},{id: kItalicResourceID, sym: ’italicSFNTData},{id: kBoldItalicResourceID, sym: ’bolditalicSFNTData}] do
begin
if style.id then
DefConst(style.sym, GetResource("sfnt", style.id, ’sfnt));
else
DefConst(style.sym, nil);
end;
CloseResFileX(refNum);
output := {};output.(kFontSym) := {name:kFontName,
encoding:
kUnicode,
macFontID:
kMacFontID,
screenSym:
kFontSym,
psName:kFontSym,
psScale:kFix1,// no scaling
plainData:
plainSFNTData,
boldData:
boldSFNTData,
italicData:
italicSFNTData,
boldItalicData: bolditalicSFNTData,userSizes:kSizes,};

Save it as GillSansFont.f

26

Newton Fonts How-To

27

Add the file to the project (with Add GillSansFont.f from the Project menu) and then build thepackage (with Build Package from the Project menu). Repeat this step for Gill Sans Light.

Newton Fonts How-To

28

Newton Fonts How-To

29

Voilà.

11Notes• A Newton font package actually can include several fonts, but this topic is not covered by thistutorial.

Newton Fonts How-To30• Due to the lack of a PostScript printer, printing was not tested (including scaling). Most fonts donot print properly from the Newton on PostScript printers because the Newton does not download PostScript fonts to the PostScript printers before printing (and therefore the Newton Fonts
do not include the Postscript fonts).
• NewtonOS only understands some formats of font tables and porting Asian fonts often fails.

12

Change History• 14/04/2004 Initial version

13

Contact

Don’t hesitate to send remarks,
mailto:pguyot@kallisys.net.

comments

andquestions

totheauthor

at