Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: LDEF with multiple fonts Message-ID: <9104@hoptoad.uucp> Date: 28 Nov 89 21:46:38 GMT References: <13748@eerie.acsu.Buffalo.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 47 In article <13748@eerie.acsu.Buffalo.EDU> volaski@acsu.buffalo.edu () writes: >I'm still curious as to why my TextFont doesn't work. Here's my code: > >procedure DrawList; > begin > with lhandle^^ do > begin > theChar := cells^^[lDataOffset]; > aStr := theChar; > Textfont(6); {this line is ignored; everything appears in Geneva} > with lRect do > moveTo(left, bottom); > drawstring(aStr); > end; > end; I'm curious too. Is it possible you don't have London font (font 6) installed? Also, why aren't you doing a TextSize, since London doesn't come in the default 12 point size? This omission makes me wonder, is this your real and complete code? It also makes me wonder if, on getting the bad font size, the system would use Geneva instead of scaling the font down, but I don't see why it would. Here's an example of some code in an LDEF of mine that draws in a nonstandard font. TextFont(newYork); TextSize(9); TextFace(0); GetFontInfo(&info); w1 = TextWidth(p->humanName + 1, 0, p->humanName[0]) + 2; MoveTo(r.left + 4, r.bottom - (1 + info.leading + info.descent)); DrawText(p->humanName + 1, 0, p->humanName[0]); Since it works, so should yours. One more note. You are using unsafe "with" statements. It is unsafe to use a with statement involving a relocatable handle if anything within the with statement could cause memory to be moved. TextFont can cause memory to be moved, so it could cause the previous dereference of lhandle to become invalid, and so you would be reading from invalid memory. This wouldn't cause your problem, but it could cause a problem in various conditions. You should just bite the bullet and say "lhandle^^" before every field reference. (Actually, looking at your code, it probably won't cause a problem, but it would be easy to forget and add a new statement after TextFont that uses the implicit reference to lHandle -- it's fragile code, in other words.) -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Next prefers its X and T capitalized. We'd prefer our name in lights in Vegas." -- Louis Trager, San Francisco Examiner