简体   繁体   中英

How do I make really large text in Smalltalk?

I'm trying to make a large text banner in Squeak Smalltalk, with the following code:

t := TextMorph new.
t string: 'You win!' fontName: 'BitstreamVeraSans' size: 400.
t extent: 600@100.
t center: Display center.
t openInWorld.

But the text size seems to max out at about 60. Am I using the wrong class? I don't need the text to be editable.

Two ways:

  1. Add another font size: (TextStyle named: #BitstreamVeraSans) addNewFontSize: 200 and use a regular text morph as before.

  2. Use a "Truetype banner" which can be arbitrarily scaled: Either get one from the object catalog, or use TTSampleStringMorph new initializeToStandAlone openInHand . Look into the initializeToStandAlone method to make your own.

For a large heading I probably would use the

I think it is because Squeak uses bitmap fonts as standard. The maximal size for BitstreamVeraSans included in the Squeak image seems to be 36. So while you can scale the Morph, the text itself does not get any bigger.

In Pharo you can use TrueType fonts in a TextMorph like this:

|font textMorph text|
font := (TextFontReference toFont: (LogicalFont familyName: 'Cochin' pointSize: 99)).
text := 'You win!' asText addAttribute: font.
textMorph := TextMorph new.
textMorph contents: text.
textMorph openInWorld

Something similar might be possible in Squeak too. There is some TrueType support included.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM