Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!sunybcs!acsu.buffalo.edu!volaski From: volaski@acsu.buffalo.edu Newsgroups: comp.sys.mac.programmer Subject: RE:LDEF with multiple fonts Message-ID: <13915@eerie.acsu.Buffalo.EDU> Date: 29 Nov 89 15:21:06 GMT Sender: nobody@acsu.buffalo.edu Reply-To: volaski@acsu.buffalo.edu () Organization: Suny at Buffalo Lines: 96 From: volaski@acsu.buffalo.edu () Path: acsu.buffalo.edu!volaski Newsgroups: comp.sys.mac.programmers Subject: LDEF with styled textedit Expires: References: Sender: Reply-To: volaski@acsu.buffalo.edu () Followup-To: Distribution: y Organization: Suny at Buffalo Keywords: From: volaski@acsu.buffalo.edu () Path: acsu.buffalo.edu!volaski Newsgroups: comp.sys.mac.programmer Subject: LDEF with multiple fonts-more Expires: References: Sender: Reply-To: volaski@acsu.buffalo.edu () Followup-To: Distribution: world Organization: Suny at Buffalo Keywords: Newsgroups: comp.sys.mac.programmer Subject: Re: LDEF with multiple fonts Summary: Expires: References: <13748@eerie.acsu.Buffalo.EDU> <9104@hoptoad.uucp> Sender: Reply-To: volaski@autarch.acsu.buffalo.edu (maurice volaski) Followup-To: Distribution: Organization: Suny at Buffalo Keywords: In article <9104@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >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. I'll definitely have to try it with other fonts. I know I don't have London installed. I wanted to get it to work, so I put in 6 as an arbitrary number. Obviously, 6 isn't a good idea. I'll add a TextSize to make it more complete. The code has changed somewhat since I first started with it. It may or may not have been the code I originally had. I did over again for the posting. >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.) Now that you mention this, how does one know if a handle is relocatable, and how does one know when to lock handles down? For example, can the list handle be locked down, and if not, then why? For example, I believe I once tried locking down a pichandle and this resulted in a crash. Maurice Volaski Dept. of Physiology University at Buffalo