Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!udel!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!jl3p+ From: jl3p+@andrew.cmu.edu (James Ting Lui) Newsgroups: comp.sys.next Subject: Appkit question on fonts & text Message-ID: <8bk42oS00UhWM3B1Yx@andrew.cmu.edu> Date: 18 Feb 91 21:01:40 GMT Organization: Computer Science, Carnegie Mellon, Pittsburgh, PA Lines: 52 I am currently working on an application which requires the frequent entry of some common mathematical symbols. To facilitate this, I have created a panel which contains buttons for the symbols needed. When one of these buttons are pushed, it puts the appropriate symbol into a text object. I have noticed that any text following the symbol is also of the symbol font. Does anyone know how to insert the symbol into the text without affecting the font of the characters which are entered following it? I have tried selecting the zero-length position following the symbol and setting it to the text's font. This doesn't work, and the font method for Text returns the first font in the text in a multi-font text object anyway. I've also tried inserting the symbol with an extra space, where both the symbol and space are in the current text font, then changing the symbol character to the symbol font and then deleting the space. This does not work either. But I have noticed that if I do this but do not delete the space programmatically ( with delete: method or by a replaceSel: with "" ) but by pushing the delete key, it has the desired result. Is there a better solution then simulating a key press? Finally, I used setAutodisplay: NO/YES to make the symbol insertion look cleaner. The code goes something like this: [ theText setAutodisplay: NO ]; [ theText setSel: start : end ]; newEnd = start + theSymbolLen; [ theText replaceSel: theSymbol ]; [ theText setFontFamily: [ theSymbolFont name ] ]; [ theText setAutodisplay: YES ]; [ theText setSel: newEnd : newEnd ]; When I pushed the symbol button to insert the symbol, I get these funny white blocks on the panel next to the button I am pushing. It's as if the changes made to the text object is somehow reflected back to the panel where the button is ( the text is on a separate window all of its own ). If the setAutodisplay: YES line above is moved up to before the setSelFontFamily: method is called, then these white blocks do not show up. By the way, these blocks appear after I've pushed the button a couple of times, then they appear one-to-one for each button press thereafter. Sorry to make this all sound so complicated, but this really seems to be a big mess of a problem and I have no clue on how to solve it. I'd appreciate any help anyone can give me on it. Thanks a lot, -- Jim