gay_d@elma.epfl.ch (David Gay) (08/04/89)
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 !
ruslan@ecsvax.UUCP (Robin C. LaPasha) (08/09/89)
In article <890804175711.2040019c@SIC.Epfl.CH>, gay_d@elma.epfl.ch (David Gay) writes: > cmcmanis%pepper@sun.com (Chuck McManis) writes (some time ago): > > > >[...about opening and using non-ROM fonts...] > >[code deleted to save space] > >[further OpenDiskFont discussion deleted] > > 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; > > >--Chuck McManis > >uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com > David Gay > GAY_D@ELMA.EPFL.CH, or GAY_D%ELMA.EPFL.CH@CLSEPF51.bitnet Can you folks suggest (or offer) a code example of how to manage a window or screen with proportional fonts of different sizes? How would you control vertical scrolling with a NotePad-style setup? Like, would it be easier to have the users "pre-select" the fonts and sizes they're going to use before the text is typed, so that the maximum size (and scrolling) could be calculated in advance? (Granted, a big difference in sizes could make a mixed-font text look quite strange.) (If the problem of scrolling and sizes is complex beyond belief just laugh and try to be kind in telling me so...) Any pointers to Fish Disks or other freebies are welcome. Thanks in advance. (filler) (for) (inews) -- =-=-=-=-=-=-=- Robin LaPasha |Deep-Six your ruslan@ecsvax.uncecs.edu |files with VI! ;^) ;^) ;^)