Font Rules
Font Rules
Ever since the introduction of the Macintosh II and its ability to describe
multi-bit pixels, applications have been able to draw fonts both in color and in
shades of gray. Pixels can be 1, 2, 4 or 8 bits deep, which is well to
remember since matching font depth to screen depth will considerably speed
drawing. Mac II ROMs store both 4- and 8-bit versions of the system font,
plus a 4-bit Geneva font as 'NFNT' resources.
It is possible, but unlikely that your applications need speed so much that you
want to create a separate resource for each possible screen depth for every font
family. However, you may want to rely on a creation called a synthetic font.
This is something Font Manager manufactures from the 1-bit version of any
font when it can't find a 'FONT' or 'NFNT' resource version with a depth that
corresponds to the current screen depth.
A synthetic font list, accessed by the global variable SynListHandle, contains
the synthetic font's resource ID, and the values of its foreground and
background colors.
The SynListHandle resides in low memory, the same as a fontHandle. Instead
of communicating directly with font records in the application heap the way a
fontHandle does, however, SynListHandle communicates with the the synthetic
font list on the system heap.
Synthetic font records on the system heap then communicate with font records
in the application heap and everything else in the relationship between
Font Manager data structures goes on as before.
Color Tables for Text
The 'NFNT' resource type lets your application specify color through a color
table of the type 'fctb' . Both 'NFNT' and 'fctb' have the same ID and the color
table has the same structure as the ColorTable record in Color QuickDraw.
Based on such factors as the font's depth, and the current port's foreground
and background colors, Font Manager will let your application use the color
table to assign colors to the text. If the table isn't filled out,
Font Manager assigns entries as follows: if one entry is missing it gets the
background color; if two are missing, the higher index value gets the
foreground color and the lower one gets the background color; if three or more
color entries need to be filled in they're assigned values ranging between the
foreground and background colors.
In cases where no color table at all has been created, the highest possible
index value is assigned to the foreground color, the lowest possible index value
is assigned to the background color and everything else is given a value in
between. A gray-scale font in this situation would have black as the
foreground, white as the background and as many shades of gray in between as
the remaining table entries--for a 4-bit screen, in other words, you'd get
black, white, and 14 shades of gray while a 2-bit screen would yield black,
white and 6 gray shades--all without a color table.
Filling Out Font Type
Previously reserved bits in the FontRec 's fontType field have been put to use
when dealing with color and gray-scale text on the Mac II family of machines.
They include:
bits 2 and 3 are set for font depth value 0 = a depth of 1 bit,
value 1 = a depth of 2 bits;
value 2 = a depth of 4 bits;
value 3 = a depth of 8 bits;
bits 2 and 3 are only set to 1, 2 or 3 if bit 7 is also set-indicating that the font is
an 'NFNT' resource and that an 'fctb' resource with the same ID as the font can be
used to apply color to the text.
bit 7 is set if the font has an 'fctb' resource, 0 if there is no 'fctb' ;
bit 8 is set if the font is synthetic, 0 if it is not; synthetic fonts are created
dynamically from available fonts to match specific screen color/ depth
combinations.
bit 9 is set if the font contains colors, 0 if the font is black;
bit 14 is set if the font should not be expanded, 0 if it can be expanded
Kanji, for example, is too large for synthetic fonts to be of much use and
shouldn't be expanded to match the screen depth.
The owTLoc field is now a long and the nDescent field is a high-order word
(but is ignored if negative to provide backward compatibility). See FontRec
for the format of the font record.
On the Mac II, type size can now go as high as 255 points, regardless of font
depth.
Mac II Font Families
The font family record FamRec (and therefore the 'FOND' resource type) have
new fields and new assignments for bits in old fields. Specifically, bits 8 and 9
in the ffAssoc (font association table) field must be set to the same value as
bits 2 and 3 in FontRec's fontType field. Otherwise, if a bit is un defined, it is
0.
New fields include ones for version number, number of offsets minus one,
bounding box table offset, and the bounding box table itself. See FamRec for a
layout of the family record and 'FOND' resource structure.