简体   繁体   中英

How can I easily change to native fonts in Smalltalk Squeak/Pharo

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.

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.

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.

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.  

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.

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