Fonts 如何轻松地在Smalltalk Squeak/Pharo中更改为本机字体

Fonts 如何轻松地在Smalltalk Squeak/Pharo中更改为本机字体,fonts,smalltalk,squeak,pharo,Fonts,Smalltalk,Squeak,Pharo,对于每一个新的Squeak/Pharo图像,我都会立即将字体更改为一些本机版本。这是很多鼠标点击,我想脚本的过程 找到了答案,正在寻找SetSystemFonto。现在,完整的脚本是: "Set fonts on Mac OS X" defaultFont := LogicalFont familyName: 'Lucida Grande' pointSize: 10 stretchValue: 5 weightValue: 400 slantValue: 0. codeFont :=

对于每一个新的Squeak/Pharo图像,我都会立即将字体更改为一些本机版本。这是很多鼠标点击,我想脚本的过程

找到了答案,正在寻找SetSystemFonto。现在,完整的脚本是:

"Set fonts on Mac OS X"
defaultFont := LogicalFont familyName: 'Lucida Grande' pointSize: 10 
   stretchValue:  5 weightValue: 400 slantValue: 0.
codeFont := LogicalFont familyName: 'Monaco' pointSize: 10 
   stretchValue:  5 weightValue: 400 slantValue: 0.
Preferences setCodeFontTo: codeFont.
Preferences setWindowTitleFontTo: defaultFont.
Preferences setButtonFontTo: defaultFont.
Preferences setListFontTo: defaultFont.
Preferences setMenuFontTo: defaultFont.
Preferences setSystemFontTo: defaultFont.

以上答案现在可能已经过时了,至少我的3.10版图片不适用。所以,我用这个:

defaultFont := LogicalFont familyName: 'Geneva' pointSize: 10 emphasis:0 .
codeFont := LogicalFont familyName: 'Monaco' pointSize: 10 emphasis:0.
Preferences setCodeFontTo: codeFont.
Preferences setWindowTitleFontTo: defaultFont.
Preferences setButtonFontTo: defaultFont.
Preferences setListFontTo: defaultFont.
Preferences setMenuFontTo: defaultFont.
Preferences setSystemFontTo: defaultFont.

这是在Pharo中使用的新方法:

|font codeFont|

font := LogicalFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.
codeFont := LogicalFont familyName: 'Bitmap DejaVu Sans' pointSize: 9.
StandardFonts listFont: codeFont.
StandardFonts menuFont: font.
StandardFonts codeFont: codeFont.
StandardFonts buttonFont: codeFont.
StandardFonts defaultFont: font.
StandardFonts windowTitleFont: font.

FreeTypeFontProvider current updateFromSystem.  

在使用Pharo 2.0的Linux上,我将以下内容添加到一个特殊目录中的文件中,该目录在映像启动时自动读取:

StartupLoader default executeAtomicItems: {
  StartupAction
    name: 'Use Free type'
    code: '(Smalltalk at: #FreeTypeSystemSettings)
    perform: #loadFt2Library: with: (true)'
    runOnce: true.
  StartupAction name: 'Setting up fonts' code: [
    |font codeFont|

    FileStream stdout lf; nextPutAll: 'Setting up fonts'; lf.

    font := LogicalFont familyName: 'DejaVu Sans' pointSize: 12.
    codeFont := LogicalFont familyName: 'DejaVu Sans Mono' pointSize: 12.
    StandardFonts listFont: codeFont.
    StandardFonts menuFont: font.
    StandardFonts codeFont: codeFont.
    StandardFonts buttonFont: codeFont.
    StandardFonts defaultFont: font.
    StandardFonts windowTitleFont: font.
    StandardFonts balloonFont: font.
    StandardFonts haloFont: font.

    FileStream stdout lf; nextPutAll: 'Finished'; lf].
}.
此特殊目录可通过以下方式显示:

FileDirectory preferencesVersionFolder

您应该阅读StartupLoader类的文档。

即:更改为true type字体。