How to Obtain Names and Sizes of All Current Macintosh Fonts (35875)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft BASIC Compiler
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q35875

SUMMARY

The program below shows how to list the names and sizes of all the fonts that are available in the current Macintosh System file. Note that you can add, remove, or also list the fonts in the System file by using Apple's "Font/DA Mover" program. Additional fonts are provided in files on Apple Macintosh System software disks.

MORE INFORMATION

Microsoft BASIC and QuickBASIC for the Macintosh can access the fonts that are available in the System file by calling the TEXTFONT ROM routine. PRINT statements will use the font number last specified by the TEXTFONT routine as in the following example:
TEXTFONT 4 : TEXTSIZE 9 : PRINT "This is Monaco font."
				
Apple Computer, Inc., has assigned numbers to all standard Macintosh fonts. Please refer to Page I-219 of "Inside Macintosh" Volume 1 (Addison-Wesley Publishing, 1985) for a list of fonts and their assigned numbers. For a complete list of fonts, you may contact Macintosh Technical Support at the following address:

Macintosh Technical Support
Mail Stop 3-T
Apple Computer, Inc.
20520 Mariani Ave.
Cupertino, CA 95014

The following is a code example that displays the current System fonts:
' Show Fonts.
' This program indexes through all the FOND (FONT Description) resources
' which are installed in the current Macintosh System file, showing the
' name, family id, and unscaled sizes. This program runs as is in
' Macintosh QuickBASIC. To run in the earlier BASIC Compiler Version
' 1.00 or Interpreter Version 3.00, you will need to open the ToolLib
' library as follows:
' LIBRARY "BASIC TOOLBOX:TOOLLIB"
DIM c%,h,t$,real%,id%,fontn$
Countres "FOND",c%   ' Count the number of FOND resources in System.
FOR i% = 1 TO c%
  '   Get font information:
  GetIndRes "FOND",i%,h
  GetResInfo h,id%,t$,fontn$
  ReleaseRes h
  MOVETO 5,WINDOW(5)+20     'line spacing independent of font
  TEXTFONT id%
  PRINT "Font ";fontn$;" id";id%;"Size";
  '   Find all unscaled sizes of this font:
  FOR j% = 1 TO 128
    RealFont id%,j%,real%
    IF real% THEN PRINT i%;
  NEXT
NEXT
WHILE MOUSE(0)<>1:WEND    'wait for mouse click to end
				
The following QuickBASIC program also displays all the fonts, in their native (nonscaled) sizes, which are available in the current Macintosh System file. This program is not as simple as the above program, but it is provided as an example of using QuickBASIC's ToolBox routine, which is not found in the earlier BASIC Interpreter Version 3.00 or BASIC Compiler Version 1.00:
real% = 0
n$=""
FontName%=&HA8FF
ToolBox "I"
last%=0
maxSize%=24
maxFnum%=30000
WINDOW 1,"Real Fonts",,1
TEXTFONT 0:TEXTSIZE 12
PRINT USING "TEXTFONT####] ";i%;
FOR i%=0 TO maxFnum%
     FOR j%=maxSize% TO 5 STEP -1
         realFont i%,j%,real%
         IF real% THEN
              ToolBox "P",FontName%,(i%),n$
              TEXTFONT i%
              IF last%<>i% THEN
                    last%=i%
                    TEXTSIZE maxSize%
                    PRINT
                    TEXTSIZE 12 :PRINT USING "TEXTFONT####] ";i%;
              END IF
              TEXTSIZE j%
              PRINT n$;J%;
              IF WINDOW(4) > WINDOW(2)-150 THEN PRINT
         END IF
     NEXT
NEXT
WHILE MOUSE(0)<>1:WEND    ' Waits for mouse click to end.
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB35875