🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Opening a diskfont??

#8086
From: Alain Didierjean
Date: Thu, 10 Jan 1991 07:37
98 lines
3632 bytes
In article <1991Jan8.173617.12144@msuinfo.cl.msu.edu>, Joe Porkka writes:

-> peterk@cbmger.UUCP (Peter Kittel GERMANY) writes:
->
-> >In article <faheyr.663140235@silver> faheyr@silver.ucs.indiana.edu (Bob Fahey <NECR0SIS>) writes:
-> >>I am programming a utility in C (lattice), and need to open a specific font off of a disk. (the font
-> >>is already stored in the fonts: dir of my boot disk).
-> >>
-> >>How do you go about opening that disk-based font?
->
-> >Use function OpenDiskFont() instead of OpenFont().
-> >I'm too lazy to type an example here, but look into the program
->
-> Also, in my experience, OpenDiskFont does NOT check to see
-> if the font is already loaded, and will load a duplicate.

Quite right, you have to check by yourself. Following is an old piece of code
that :
1) Finds out wether your display is PAL or NTSC
2) Tries to OpenFont(textattr), the size of the font depending on the video, so
the display looks about the same in both modes
3) If Open Font fails, tries OpenDiskFont
4) If that fails too, sends a requester telling you should copy the proper
font in FONTS:, then uses Topaz
5) adjusts margins and the same to final font size

#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/diskfont.h>


static struct TextAttr Fbub11ta = { (STRPTR)"fbubba.font",11,0,1 };
static struct TextAttr Fbub9ta =  { (STRPTR)"fbubba.font",9,0,1 };
USHORT xpos = 100;                                  /* left margin */
USHORT linespace = 11;
USHORT strophespace = 14;
USHORT topspace = 50;


main()
{
/* deleted code here, opening a screen then a backdrop, borderless window */

    if(SysBase->VBlankFrequency == 50) pal = TRUE;  /* a PAL system */
    else                                            /* a NTSC system */
    {
        pal = FALSE;
        NewScreenStructure.Height = 200;
        PNewWindowStructure1.Height = 200;
    }

    if(pal)    Fbubbatf = OpenFont(&Fbub11ta);  /* PAL */

    else       Fbubbatf = OpenFont(&Fbub9ta);   /* NTSC */

    Topaztf = OpenFont(&TOPAZ80);

    if(! Fbubbatf)
    {
        struct Library *DiskfontBase;

        if(DiskfontBase = (struct Library *)OpenLibrary("diskfont.library", 0))
        {
            if(pal)     Fbubbatf = OpenDiskFont(&Fbub11ta);
            else        Fbubbatf = OpenDiskFont(&Fbub9ta);
        }
    }
   if(! pal)
    {
        linespace = 9;
        strophespace = 10;
        topspace = 40;
    }

    if (! Fbubbatf)
    {
        BYTE result;

        SetFont(PRastPort, Topaztf);
        result = SmartReq(PWindow, &FBubbafReq);
        xpos += 40;
        linespace = 9;
        strophespace = 10;
        topspace = 40;
    }

    /* some code here , and some cleaning */

    if (Fbubbatf)           CloseFont(Fbubbatf);
    if (DiskfontBase)       CloseLibrary((struct Library *)DiskfontBase);
}

Hope this is going to help.          Alain DIDIERJEAN
         The Software Winery        ...cbmvax!cbmehq!cbmfra!swindj!didierj
Technical Details
Message-ID: <187ff6cd.ARN10d2@swindj.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!cbmehq!cbmfra!swindj!didierj
References: <faheyr.663140235@silver> <700@cbmger.UUCP> <1991Jan8.173617.12144@msuinfo.cl.msu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!cbmehq!cbmfra!swindj!didierj
From: didierj@swindj.UUCP (Alain Didierjean)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Opening a diskfont??
Message-ID: <187ff6cd.ARN10d2@swindj.UUCP>
Date: 10 Jan 91 07:37:17 GMT
References: <faheyr.663140235@silver> <700@cbmger.UUCP> <1991Jan8.173617.12144@msuinfo.cl.msu.edu>
Reply-To: didierj@cbmfra
Followup-To: comp.sys.amiga.tech
Organization: The Software Winery
Lines: 98