[comp.sys.mac.programmer] Font loading time.

jp57+@andrew.cmu.edu (Jefferson Provost) (05/24/91)

Hi,

Has anyone out there found a way to get around the time that is taken up
when QuickDraw asks the Font Manager to give the font info needed to
draw text on the screen?  

I've discovered that sometimes it takes as much as 200 ms to draw a
single word on the screen and it seems as if the time is being taken up
by the font manager. For some fonts, the time is consistently very low,
(e.g. 10 ms for Chicago), and for others it is very high (e.g. 200 ms
for Palatino).

I'm running on a IIsi w/ system 6.0.7 and usually have some fonts in
Suitcases open with Suitcase II, but even w/o Suitcase II, it seems to
take a long time for some of the fonts.  These times are in 256 color
mode, in monochrome, the times are all very low, but I often need color.

I'm running timing critical code, and I can live with the general
overhead of about 1 tick that you seem to get with everything, but 60 or
100 ms or more is just too much.  I shudder to think what it'll be on
system 7 with truetype fonts.

I know there's a lot of work that's involved in getting the  right font,
in the right size, especially if the font needs to be scaled.  What I'd
like to do is control the time at which the fonts are loaded so that I
could, for example, load a font that I need at some particular time, and
then later display some text in that font without taking the time to
load it right then. 

I've tried calling FMSwapFont myself and locking the fontHandle and the
handle to the 'FOND' resource ahead of time.  That didn't seem to make a
difference.

I've tried patching the FMSwapFont trap so that if I want it to, it just
returns an FMOutPtr to a record that I got previously, but it seems like
QuickDraw doesn't actually call the FMSwapFont trap, but instead calls
the FMSwapFont code directly  (or is there some nuance of trap patching
that I'm missing?  That'd be nice...  but my patch seems to be there,
when I call FMSwapFont, it calls my patch, but when QuickDraw calls it,
it doesn't).  Nothing has worked so far.

What do people do who make animations with text in them?  Just suffer?

I'm contemplating drawing the text into an offscreen buffer before hand,
and then just slapping the buffer on the screen, but if I can find a
solution with out off-screen buffering, I'll use it. 

Any ideas on how to get around this problem?  I'm I missing something major?

All input will be appreciated,

Jeff


+-------------------------------------------+
|Jefferson Provost    | jp57+@andrew.cmu.edu|
| Psychology          |  (412) 268-3139     |
| Carnegie Mellon     |---------------------|
| Pittsburgh, PA 15213|-=-=-=-=-=-=-=-=-=-=-|
+-------------------------------------------+

lim@iris.ucdavis.edu (Lloyd Lim) (05/24/91)

In article <ocD3xea00Uh_440ksp@andrew.cmu.edu> jp57+@andrew.cmu.edu (Jefferson Provost) writes:
>
>Has anyone out there found a way to get around the time that is taken up
>when QuickDraw asks the Font Manager to give the font info needed to
>draw text on the screen?  
>[...]

How about SetFontLock?  When you start up, draw a sample of each font you
need and call SetFontLock after each one.  Just a quick, simple idea.
Sounds easier than using FMSwapFont.

+++
Lloyd Lim     Internet: lim@iris.eecs.ucdavis.edu
              America Online: LimUnltd
              Compuserve: 72647,660
              US Mail: 215 Lysle Leach Hall, U.C. Davis, Davis, CA 95616