[squeak-dev] Improving SqueakToolsHelp class>>#fontSizeSummary reveals problems in Text & styles

tim Rowledge tim at rowledge.org
Sun Jul 22 22:52:52 UTC 2018


I wanted to make the help page for the font summary show the actual fonts; it seems an appropriate thing to do. Some ... interesting ... issues came up whilst looking into it.

Changing TextStyle class>>#fontSizeSummaryContents wasn't too hard. It's easy enough to stick in TextFontReferences that point to a relevant font and the resulting text can be displayed easily enough. It seems a bit strange the TextStyle>>knownTextStyles returns a list of symbols rather than the actual styles, but whatever.

That's where it stopped being simple. Upon opening a help browser the fonts were all flattened out to the default font of the default style. It turns out that in the building of the pluggable text morph the text font gets overwritten, although initially in the code it might look otherwise. See MorphicToolBuilder>>#buildPluggableText: and note where it says 'aSpec font ifNotNil:[:f| widget font: f]'. Since the spec #font method (PluggableTextSpec>>#font) returns the default font unless some other has been set, we will normally get the preferences set default font - Deja Vu san 9 in my image. This font is then blasted over the text with #beAllFont: which actually does a great deal of manipulating of the text's runs and produces a rather obese collection of runs all with the same values, rather than consolidating into a single run (modulo having other types of text attribute involved of course). Looking at how the TextMorph>>#beAllFont: and Text>>#addAttribute: works is quite interesting too, since we get into a rather complex and ripe for improved implementation subsystem where I see mis-use of #isKindOf: etc. in places where some double-dispatching would be much nicer.

Changing any of this seems like more change than we really want just before a release so it will have to wait and the font summary help page can't really be improved much until then. To make things a bit more irritating it is quite possible to generate the multi-font text and paste it into a text morph and see the desired effect! 

And yet again the supposedly randomly chosen sigline summarises the entire thing rather well. "Random" my ass....

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
This is all a lot simpler and a lot more complicated than you could possibly imagine




More information about the Squeak-dev mailing list