How can I easily change to native fonts in Smallta

2020-02-26 06:55发布

With every new Squeak/Pharo image, I immediately change the fonts to some native version. It is a lot of mouseclicks and I want to script the process.

4条回答
老娘就宠你
2楼-- · 2020-02-26 07:06

On Linux with Pharo 2.0, I added the following content to a file in a special directory that is read automatically on Image startup:

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].
}.

This special directory can be revealed with

FileDirectory preferencesVersionFolder

You should read the documentation of the StartupLoader class.

查看更多
Emotional °昔
3楼-- · 2020-02-26 07:12

This is the new way to do it in 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.  
查看更多
forever°为你锁心
4楼-- · 2020-02-26 07:19

The above answer might be outdated by now, at least it doesn't work with my 3.10 image. so, I use this:

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.
查看更多
【Aperson】
5楼-- · 2020-02-26 07:32

Found the answer, was looking for setSystemFontTo. The complete script is now:

"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.
查看更多
登录 后发表回答