I am using Squeak 3.10.2 on Ubuntu 9.04 (Linux).
By making minor changes to Squeak I was able to have certain of my objects (trees) display themselves as text rather than as strings when they are the result of a message sent on a Workspace. E.g. evaluating 'MyTree randomTreeOfSize: 10' on a workspace would do it. Objects which don't support this feature are displayed using the normal printOn: method. The text that my trees generate for self display have color attributes and the colors are displayed correctly. I have also overwritten displays of some characters between 128 and 225. For example if I evaluate '225 asCharacter' I will see one of my special characters rather than the normal accented character. If I have a tree displayed as text then sometimes my special characters are printed correctly but other times they are not (Either all special characters are printed correctly or all are not). When my special characters are not printed correctly then the ones that would normally be displayed in Squeak are displayed instead. For example, even though I see '225 asCharacter' as one of my special characters, if I use this character in a tree text it may be displayed as an accented character. If I convert the text representation of one of my trees to a string then all the special characters are displayed correctly (but of course the color is lost). I don't know the circumstance that determines which is displayed but I guessed, that since in my tree text there is not a specification of a font, somewhere a different font was being used and that I should specify which font I want to be used for my tree text. At this point I became confused. I was expecting to be able to do something like: 'aText useFont: aFont'. But I could not figure out how I am supposed to set the font I want to use for my text. Can anyone explain? Is there good documentation anywhere? One final point of confusion. Since I have modified my image to display arrows for the _ character and the ^ character, I put the _ character in my tree's text as a test. It displays as an arrow even when my special characters do not display correctly. This is confusing because my code to set the display of my special characters mirrors the code I used to change the display of the _ and ^ characters. I picked up the code for displaying the arrows from the Internet. It goes through the fonts in the fontArray variable of the TextStyle default object and sets the arrows for the fonts of type StrikeFont or StrikeFontSet. Any help to lessen my confusion much appreciated. Ralph Boland |
Ralph Boland wrote:
> At this point I became confused. I was expecting to be able to do something > like: 'aText useFont: aFont'. But I could not figure out how I am > supposed to set the font I want to use for my text. Just use a TextFontReference, e.g., aFont := (TextStyle named: 'Atlanta') defaultFont. "or any other" text := 'Hello World' asText. text addAttribute: (TextFontReference toFont: aFont). text asTextMorph openInHand. This will do it. The magic is using the right text attribute (check the TextAttribute hierarchy for inspiration). Cheers, - Andres |
Free forum by Nabble | Edit this page |