Path: utzoo!utgpu!water!watmath!clyde!att-cb!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!oliveb!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Changing fonts in the SCREEN Summary: It's simple when you know how :-) Keywords: Is this possible Message-ID: <49799@sun.uucp> Date: 17 Apr 88 09:58:54 GMT References: <428@lznh.UUCP> Sender: news@sun.uucp Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 56 In article <428@lznh.UUCP> pjm@lznh.UUCP (<10000>Paul Maioriello) writes: -> I am posting this in the general newsgroup because I'm sure it's -> been asked before, and the answer is readily available. -> -> 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. [Editing, running make, vt100, and the Infominder autodocs at the same time here, who was it that said Multitasking was for the birds ???? :-) ] -- Mini Font and Rastport Tutorial -- Without going into *extreme* detail, there are some things you will need to understand before this makes sense. Graphics are rendered into a 'RastPort', the RastPort defines a lot of constants for the graphics routines and the font is one of them. Now everything you can write into has a RastPort associated with it. This includes screens, windows, menu bars, etc. Each RastPort has a pointer to a BitMap structure which points to the actual data that is displayed. Fonts come in two flavors, DISK and ROM, and are accessed with OpenFont() or OpenDiskFont(). These routines take a TextAttr structure to describe what the font you would like is, they return a pointer TextFont structure which tells you what kind of font you got. IT MAY BE DIFFERENT THAN WHAT YOU REQUESTED. So be aware of that. Now with this TextFont you can make a RastPort use this font, using the call SetFont(rp,font). From then on calls to Text() will render in this font. The color of the letters will be the same as the APen, with the background being the color of the BPen if the Draw mode is JAM2. Now to change the font of the Screen, you have to go through three steps : Initialize a TextAttr structure. TextFont = OpenFont(TextAttr). SetFont(Screen->RastPort,TextFont). Now re-render the screen title and poof, new font. Remember to close the font when you exit. That way it can be expunged from memory. Now if you don't know what the font is for a particular RastPort, you can still do things safely. Critical aspects of the font are kept in the RastPort structure. Look at where it describes the fields TxHeight, TxWidth. Similarly if you want to know how much space some text is going to take on the screen but don't want to render it first you can call TextLength(RastPort,"string",strlen("string")); (why it needs the string length I don't know). This will return the width in pixels, the height is in RastPort->TxHeight, and now you have a bounding box for your text. Feed these numbers into a Border structure and you are well on your way to having a labeled button gadget. --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.