【问题标题】:How can I easily change to native fonts in Smalltalk Squeak/Pharo如何在 Smalltalk Squeak/Pharo 中轻松更改为原生字体
【发布时间】:2010-10-09 03:51:00
【问题描述】:

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

【问题讨论】:

  • 即:改成真字体。

标签: fonts smalltalk squeak pharo


【解决方案1】:

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

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 类的文档。

【讨论】:

    【解决方案2】:

    这是在 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.  
    

    【讨论】:

      【解决方案3】:

      上面的答案现在可能已经过时了,至少它不适用于我的 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.
      

      【讨论】:

        【解决方案4】:

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

        "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.
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多