[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need font code info.
- To: D1830@AppleLink.Apple.COM (Jack Swisher & Assoc, M Wimble,PRT)
- Subject: Re: Need font code info.
- From: bill (Bill St. Clair)
- Date: Wed, 25 Sep 91 18:14:41 EST
- Cc: INFO-MCL@CAMBRIDGE.APPLE.COM
> Subject: Need font code info.
> To: INFO-MCL@CAMBRIDGE.APPLE.COM
> From: D1830@AppleLink.Apple.COM (Jack Swisher & Assoc, M Wimble,PRT)
> Date: 25 Sep 91 06:39 GMT
>
>
> Regarding font codes:
>
> p55 of the manual says,
> "They can be translated into font specs explicitly"
>
> Oh? How? Also, if I want font-info, do I somehow construct a font spec to
> feed to font-info or can I somehow use the font code value directly?
>
> Finally, what is the format of the font code numbers? Oh, I can make a guess,
> but I'd rather know explicitly what I'm looking at - what is guaranteed to work
> in the future? For instance, given a font code, how would I enable bold and
> italic and change the mode to :notpatxor?
>
> What haven't I asked about font codes that I should have?
>
Font codes are MCL's language for the 4 numbers used by the Mac ROM to
represent fonts. These numbers are stored in GrafPort, CGrafPort, and
TERec records:
(defrecord grafport
...
(txFont integer)
(txFace unsigned-byte)
(txMode integer)
(txSize integer)
...)
MCL encodes this 64 bits of information as two fixnums: The font/face
code (ff) and the mode/size code (ms) (txFace is only 8 bits, but an
alignment byte follows it in the record). You can find more about the
meaning of these codes in Inside Mac, volume 1, the QuickDraw chapter,
p. 1-151.
The layout looks like:
----------------------------------
ff: | txFont | txFace | unused |
----------------------------------
31 16 15 8 7 0
---------------------------------
ms: | txMode | txSize |
---------------------------------
31 16 15 0
Note that since MCL fixnums are only 29 bits, you get only 13 bits of the
16 bit txFont & txMode fields.
Fortunately, you don't really need to know this to manipulate font codes
with MCL. There are functions to do everything, though some of them didn't
make it into the b1 documentation.
---------------------------------------------------------------------------
FONT-CODES font-spec
returns four values: ff, ms, ff-mask, ms-mask
FF & MS are the font/face & mode/size codes. ff-mask & ms-mask are masks
which tell which bits were specified in ff & ms respectively
? (setq *print-base* 16)
10
? (font-codes '("Geneva" 9 :plain))
30000
10009
-100
FFFF
txFont for "Geneva" is 3
txFace for :plain is 0
txSize is 9
txMode was not specified, hence ms-mask is #xFFFF
Note that it defaulted to 1, however, which means :srcor
---------------------------------------------------------------------------
FONT-SPEC ff ms
Returns a font-spec for the given font/face & mode/size codes
? (font-spec #x30000 #x10009)
("Geneva" 9 :SRCOR :PLAIN)
?
---------------------------------------------------------------------------
MERGE-FONT-CODES old-ff old-ms ff ms &optional ff-mask ms-mask
Merges the font specified by FF & MS into the font specified by old-ff &
old-ms, changing only the bits in ff-mask & ms-mask.
? (font-codes '("Geneva" 9 :plain))
30000
10009
-100
FFFF
? (font-codes '(:bold :italic :notpatxor))
300
E0000
300
-10000
? (merge-font-codes #x30000 #x10009 #x300 #xe0000 #x300 #x-10000)
30300
E0009
? (font-spec #x30300 #xe0009)
("Geneva" 9 :NOTPATXOR :ITALIC :BOLD)
?
or, to make it a little clearer:
? (multiple-value-bind (ff ms) (font-codes '("Geneva" 9 :plain))
(multiple-value-bind (bin-ff bin-ms ff-mask ms-mask)
(font-codes '(:bold :italic :notpatxor))
(multiple-value-bind (merged-ff merged-ms)
(merge-font-codes ff ms bin-ff bin-ms
ff-mask ms-mask)
(font-spec merged-ff merged-ms))))
("Geneva" 9 :NOTPATXOR :ITALIC :BOLD)
?
---------------------------------------------------------------------------
FONT-CODES-INFO ff ms
Returns four values: the ascent, descent, maximum width, and leading for
the font specified by ff & ms.
? (setq *print-base* 10.)
10
? (multiple-value-bind (ff ms) (font-codes '("Geneva" 9))
(font-codes-info ff ms))
10
2
10
0
? (font-info '("Geneva" 9))
10
2
10
0
?
---------------------------------------------------------------------------