Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!umd5!uvaarpa!mcnc!gatech!gtss!chas From: chas@gtss.UUCP (Charles Cleveland) Newsgroups: comp.sys.amiga Subject: Re: Changing fonts in the SCREEN Message-ID: <243@gtss.UUCP> Date: 17 Apr 88 20:39:10 GMT References: <428@lznh.UUCP> Reply-To: chas@gtss.UUCP (Charles Cleveland) Organization: Georgia Tech School of Physics Lines: 114 Keywords: Is this possible In article <428@lznh.UUCP> pjm@lznh.UUCP (<10000>Paul Maioriello) writes: )What I would like to do is to change the fonts used to write )into the title bar of a screen. I thought I could do this )by changing the TextAttr structure to use a font other than )topaz. It seems that I get topaz in the screen title regardless )of what fonts I set in TextAttr before calling OpenScreen. Well, you should be able to do exactly what to say, set the TextAttr in NewScreen and then call OpenScreen, but the font MUST be in memory so if its a Diskfont either another program must have opened it or you must do so yourself before calling OpenScreen. At the end of this listing is a program which opens a Screen for 5 seconds. If the first line is uncommented, it works like you want -- but if it isn't, the way it works depends on whether the font has already been loaded by another program (in which case it may be expunged if memory gets low). And you can always write directly into any RastPort. On reading the responses to this question that have arrived at this site to date, there seems to be some confusion about fonts and the various intuition structures, and who depends on what. In the following, 'font' may mean either a TextAttr or a TextFont, depending on context. 1) The Screen's RastPort's font does not determine the Screen's Title's font. Neither does the Screen's TextAttr. On the other hand, the Screen's TextAttr determines the font which new windows on the Screen would use INTERNALLY, while the Screen's RastPort's font determines the font that will be used for WINDOW Titles. Both of these fonts may be affected by Dave Haynie's SetFont program. 2) The Screen's Title's Font is determined by the Screen's BarLayer's Rastport's font. This is not affected by Dave Haynie's SetFont program, although he tells me a later version may do so. This BarLayer's Rastport's font also determines the font that String Gadgets use when they are first rendered: this is a Little Known Fact. So here's the little program: ----------------------------cut here-------------------------------- /* #define OPENFONT */ #define INTUITION_REV 33L #include #include #include #include #include #include #include #include #include #include #include struct TextFont *OpenFont(), *OpenDiskFont(); struct Library *OpenLibrary(); struct Screen *OpenScreen(); struct TextFont *font=NULL; struct TextAttr TAttr={"pearl.font",8,0,0}; struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Library *DiskfontBase; struct NewScreen NewScreen = {0,0,640,200,2,0,1,HIRES,CUSTOMSCREEN, &TAttr,"DefaultTitle",NULL,NULL}; void main() { void cleanup(); struct Screen *TempScreen; if(!(IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",INTUITION_REV)))cleanup(1); if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L))) cleanup(2); #ifdef OPENFONT if(!(font=(struct TextFont *)OpenFont(&TAttr))){ if((DiskfontBase=(struct Library *)OpenLibrary("diskfont.library",0L))){ font=(struct TextFont *)OpenDiskFont(&TAttr); CloseLibrary(DiskfontBase); } } if(!font){ puts("couldn't open font!"); cleanup(3); } #endif OPENFONT if(!(TempScreen=(struct Screen *)OpenScreen(&NewScreen)))cleanup(4); Delay(250L); CloseScreen(TempScreen); cleanup(0); return; } void cleanup(errnum) int errnum; { if(IntuitionBase)CloseLibrary(IntuitionBase); if(font)CloseFont(font); if(GfxBase)CloseLibrary(GfxBase); exit(errnum); } -- -Life would be so much easier if we could just look at the source code.- Charles Cleveland Georgia Tech School of Physics Atlanta, GA 30332 UUCP: ...!gatech!gtss!chas INTERNET: chas@ss.physics.gatech.edu