Help with textmorph

Boris Gaertner Boris.Gaertner at gmx.net
Fri Feb 20 22:59:37 UTC 2004


 Stephane Ducasse" <ducasse at iam.unibe.ch> wrote:

>>I would like to have a textMorph (if you have soemthing
>>better please  say it)
>>that contains different fonts.

>>the way the interfaces and realtionships between strikeFont and
>>TextStyle are really not well defined.
>>It would be good that somebody understanding that propose some cleans.
Yes, but this requires some preparations.

To see all fonts, evaluate this statement:


  | fontFamilies textStream string
   currentFont fontSizes selectedFont |

  fontFamilies := (StrikeFont familyNames
                     reject: [:symbol |
                              symbol == #DefaultTextStyle
                             | (symbol == #DefaultFixedTextStyle)
                             | (TextStyle named: symbol) fontArray first
isStrikeFont not]).

  string := 'The quick brown fox jumps over the lazy sleeping dog'.
  textStream := TextStream on: (Text new: 5000).

  fontFamilies do:
    [:symbol |  | fa |
   currentFont := TextStyle named: symbol.
       fa := currentFont fontArray.
       fontSizes := fa collect: [:fnt | fnt height].
       fontSizes  do:
         [:s |
        selectedFont := StrikeFont familyName: symbol
                                     size: s.
            textStream withAttribute: (TextFontReference toFont:
selectedFont)
                    do: [textStream nextPutAll: string; cr].
     ].
      textStream cr.
    ].
   Workspace new
    contents: textStream contents;
    openLabel: 'Font survey:'




More information about the Squeak-dev mailing list