GetFontName
GetFontName
Obtain name of font associated with a font number short fontNum ; identifies the font
Str255 fontName ; address of buffer to receive pascal-style string Given a font number, GetFontName obtains the name of that font. fontNum identifies the font. It may be in one of the following ranges:
0 the system font (Chicago 12-pt)
1 the application font (actual font number is ApFontID)
2...127 Apple- defined fonts (see Fonts) 128...255 third-party vendor fonts
fontName is the address of a 256-byte buffer. Upon return, that buffer has
received a pascal-style length-prefixed string of the font's official
name - the same as the name displayed in a font menu (see
If font fontNum can't be located, fontName receives the empty
string (the first byte is set to 0).
Notes: This extracts the resource name of the 'FONT' resource whose ID is
fontNum * 128 (see GetResInfo); i.e., the resource ID of a nonexistent 0-pt version of the font.
The GetFNum function performs the inverse operation; it looks up a font number, given its font name. The RealFont function returns a Boolean indicating whether a particular font and size exist.
The following example prints the name of font 4.
Example
#include <Fonts.h>
if ( *theName == 0)
printf("No such font\n");
else
printf("Font name is '%s'\n", PtoCstr( theName ) );