简体   繁体   English

如何在Smalltalk中制作非常大的文本?

[英]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: 我正在尝试使用以下代码在Squeak Smalltalk中制作一个大文本横幅:

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? 但文字大小似乎最多约为60.我使用错误的课程吗? 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. 添加另一种字体大小: (TextStyle named: #BitstreamVeraSans) addNewFontSize: 200并像以前一样使用常规文本变形。

  2. Use a "Truetype banner" which can be arbitrarily scaled: Either get one from the object catalog, or use TTSampleStringMorph new initializeToStandAlone openInHand . 使用可以任意缩放的“Truetype banner”:从对象目录中获取一个,或者使用TTSampleStringMorph new initializeToStandAlone openInHand Look into the initializeToStandAlone method to make your own. 查看initializeToStandAlone方法来创建自己的方法。

For a large heading I probably would use the 对于大型标题,我可能会使用

I think it is because Squeak uses bitmap fonts as standard. 我认为这是因为Squeak使用位图字体作为标准。 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. 包含在Squeak图像中的BitstreamVeraSans的最大大小似乎是36.因此,虽然您可以缩放变形,但文本本身不会变得更大。

In Pharo you can use TrueType fonts in a TextMorph like this: 在Pharo中,您可以在TextMorph中使用TrueType字体,如下所示:

|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. 在Squeak中也可能有类似的东西。 There is some TrueType support included. 包含一些TrueType支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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