🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #715

OpenFont vs OpenDiskFont

#715
From: David Gay
Date: Fri, 04 Aug 1989 16:57
70 lines
2764 bytes
cmcmanis%pepper@sun.com (Chuck McManis) writes (some time ago):
>
>>Newsgroups: comp.sys.amiga
>>Organization: Sun Microsystems, Mountain View
>
>Here is a word of warning for folks that use fonts in their programs other
>than the ROM fonts. How you open a font is _very_ important. You should
>always use the sequence :
>
>        tf = OpenFont(&font_i_want);
>        if (! tf) {
>                tf = OpenDiskFont(&font_i_want);
>                if (! tf) {
>                        WarnTheUser("Can't get your font.");
>                        optional_exit();
>                }
>        }
>
>Many programs simply call OpenDiskFont() first which does not check the
>in memory font lists and instead does just what it's name implies, opens
>the font from disk. This is arguably a bug, however since using it in the
>above manner will cause it to work correctly, if you are using non-ROM
>fonts you should note this behaviour.

Just another word of warning: if you want to open the same font in different
sizes, don't use the above approach. You'll get the font that is already
open :-( (ie, if you open helvetica 13, and then ask for helvetica 24,
you'll get helvetica 13 ...).

The following code will check the size of the returned font:

    tf1 = OpenFont(&text_attr);
    if (!tf1)
        return OpenDiskFont(&text_attr);
    else if (tf1->tf_YSize != text_attr.ta_YSize)
    {
        tf2 = OpenDiskFont(&text_attr);

        if (tf2)
        {
            CloseFont(tf1);
            return tf2;
        }
        else
            return tf2;
    }
    else
        return tf1;

This has the slight disadvantage that if you ask for a size that does not
exist, you'll get duplicate entries.


>--Chuck McManis
>uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
>These opinions are my own and no one elses, but you knew that didn't you.
>"A most excellent barbarian ... Genghis Kahn!"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Gay
  "(p.suiv :=: q.prec.suiv).prec :=: q.prec"
  You don't want to know about this language !

GAY_D@ELMA.EPFL.CH, or GAY_D%ELMA.EPFL.CH@CLSEPF51.bitnet
(not for much longer :-))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PS: VLT (v3.656 at least) suffers from this problem, if you switch to
interlace, it tries to use topaz 11, but gets topaz 9 !
Technical Details
Message-ID: <890804175711.2040019c@SIC.Epfl.CH>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!ames!purdue!decwrl!ucbvax!elma.epfl.ch!gay_d

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!ames!purdue!decwrl!ucbvax!elma.epfl.ch!gay_d
From: gay_d@elma.epfl.ch (David Gay)
Newsgroups: comp.sys.amiga.tech
Subject: OpenFont vs OpenDiskFont
Message-ID: <890804175711.2040019c@SIC.Epfl.CH>
Date: 4 Aug 89 16:57:11 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 70