[comp.sys.mac.programmer] Font Menus

isle@eleazar.dartmouth.edu (Ken Hancock) (06/22/89)

Quick question, probably not so quick answer:
How does one have a Font menu show the fonts in their
own typeface?  Claris' MacWrite II does it without
any noticable delay.  Suitcase II does it, but
takes quite a long time to build it.

Any suggestions?

Ken


Ken Hancock  '90                   | BITNET/UUCP/
Personal Computing Ctr Consultant  |   INTERNET:  isle@eleazar.dartmouth.edu
-----------------------------------+----------------------------------------
DISCLAIMER?  I don't get paid enough to worry about disclaimers.

cep@apple.com (Christopher Pettus) (06/23/89)

In article <14032@dartvax.Dartmouth.EDU> isle@eleazar.dartmouth.edu (Ken 
Hancock) writes:
> Quick question, probably not so quick answer:
> How does one have a Font menu show the fonts in their
> own typeface?  Claris' MacWrite II does it without
> any noticable delay.  Suitcase II does it, but
> takes quite a long time to build it.

The basic algorithm is to write a replacement MDEF which "knows" 
that the names of the items in it are font names.  The MDEF then goes 
through drawing the font name in the font to which the name corresponds.  
The problem is that this is very, very slow, since the font manager has to 
suck in and handle each individual font; in a system with a large number 
of fonts, this can take forever.  Therefore, it makes sense to build a 
bitmap which contains the screen image for the menu, and just blit that 
onto the screen when it's time to draw.  I assume that's what MacWrite II 
does.

-- Christopher Pettus                   | "Ganesha Said: 'Done!  The very 
   Network Systems Development          | day I was born I made my first
   Apple Computer, Inc.                 | mistake, and by that path have
   cep@apple.com   {nsc, sun}!apple!cep | I sought wisdom ever since.'"
   AppleLink: PETTUS.C                  | - The Mahabharata
   (408) 974-0004                       |   I: A Mine of Jewels and Gems

tim@hoptoad.uucp (Tim Maroney) (06/23/89)

In article <14032@dartvax.Dartmouth.EDU> isle@eleazar.dartmouth.edu
(Ken Hancock) writes:
> Quick question, probably not so quick answer:
> How does one have a Font menu show the fonts in their
> own typeface?  Claris' MacWrite II does it without
> any noticable delay.  Suitcase II does it, but
> takes quite a long time to build it.

In article <2452@internal.Apple.COM> cep@apple.com (Christopher Pettus) writes:
>The problem is that this is very, very slow, since the font manager has to 
>suck in and handle each individual font; in a system with a large number 
>of fonts, this can take forever.  Therefore, it makes sense to build a 
>bitmap which contains the screen image for the menu, and just blit that 
>onto the screen when it's time to draw.  I assume that's what MacWrite II 
>does.

It's not so long since this was discussed here.  Claris software
actually builds the font menu image once and sticks it into a System
Folder file.  When the software runs again, it just checks the list of
fonts, and if it hasn't changed (which must be about 99% of the time)
it uses the stored image; otherwise, it makes a new one and stores
that.

Fortunately, it's nearly trivial to write a bitmap MDEF.  Even I have
been able to do it....

Nor should it be very hard to construct the image, though I haven't
done that.  Still, drawing into offscreen bitmaps is pretty easy if you
just follow the Tech Note (that, I have done).  And making the file in
the System Folder and storing the bitmap is a resource is trivial.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com
Postal: 424 Tehama, SF CA 94103; Phone: (415) 495-2934

A good flame strengthens its points; it does not stand in lieu of them.