Text attributes
Last updated at 5:07 am UTC on 30 March 2017
Text attributes like bold and italics are stored in several different ways in Squeak.
This is a source of some bugs and inconsistent behavior of some tools.
Class Text have two instance variables: text and runs. One collection of the characters and one collection of text attributes in a RunArray.
Examle of a RunArray:
a RunArray runs: #(14 16 1 321 2 85) values: {#() .
{a TextFontChange font: 1} . {a TextColor code: Color black} .
{a TextColor code: (Color r: 0.0 g: 0.5 b: 0.5)} .
{a TextColor code: Color black} .
{a TextColor code: (Color r: 0.0 g: 0.5 b: 0.5)}}
"#(14 16 1 321 2 85)" are the total number of characters in the text divided up in parts which will get different emphasis or font etc.
For the first 14 characters use {a TextFontChange font: 1}.
For the next 16 characters use {a TextColor code: Color black} .
Etc.
Text is displayed with a TextStyle
TextStyle does not seem to keep track of different fonts. It stores fonts in a fontArray but that seems to not be all the fonts used in the text. Rather it seems that a default font is stored in the fontArray and some tools or menus can change what is stored in the fontArray, but it's not totally clear what and why.
A RunArray {a TextFontChange font: 1} will use fontArray index 1 font.
Much of the inconsitency in the tools seem to be because TextStyle is not updated to reflect which fonts are used in a text.
Some emphasis is stored in the fonts so a font can have a derivativeFont with another style.