'From Squeak3.7beta of ''1 April 2004'' [latest update: #5878] on 13 June 2004 at 11:47:25 pm'! "Change Set: StandardSystemFonts-bp Date: 13 June 2004 Author: Bernhard Pieber This ChangeSet fixes Preferences class>>restoreDefaultFonts. When the old Apple fonts were replaced by the Accufonts this method should have been changed as well. An additional menu item for printing the default fonts has been added. The ChangeSet also includes an SUnit TestCase."! TestCase subclass: #StandardSystemFontsTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'System-Support-Tests'! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 17:20'! chooseBalloonHelpFont BalloonMorph chooseBalloonFont! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 18:37'! fontConfigurationMenu | aMenu | aMenu := MenuMorph new defaultTarget: Preferences. aMenu addTitle: 'Standard System Fonts' translated. aMenu addStayUpIcons. aMenu add: 'default text font...' translated action: #chooseSystemFont. aMenu balloonTextForLastItem: 'Choose the default font to be used for code and in workspaces, transcripts, etc.' translated. aMenu lastItem font: Preferences standardDefaultTextFont. aMenu add: 'list font...' translated action: #chooseListFont. aMenu lastItem font: Preferences standardListFont. aMenu balloonTextForLastItem: 'Choose the font to be used in list panes' translated. aMenu add: 'flaps font...' translated action: #chooseFlapsFont. aMenu lastItem font: Preferences standardFlapFont. aMenu balloonTextForLastItem: 'Choose the font to be used on textual flap tabs' translated. aMenu add: 'eToys font...' translated action: #chooseEToysFont. aMenu lastItem font: Preferences standardEToysFont. aMenu balloonTextForLastItem: 'Choose the font to be used on eToys environment' translated. aMenu add: 'menu font...' translated action: #chooseMenuFont. aMenu lastItem font: Preferences standardMenuFont. aMenu balloonTextForLastItem: 'Choose the font to be used in menus' translated. aMenu add: 'window-title font...' translated action: #chooseWindowTitleFont. aMenu lastItem font: Preferences windowTitleFont emphasis: 1. aMenu balloonTextForLastItem: 'Choose the font to be used in window titles.' translated. aMenu add: 'balloon-help font...' translated action: #chooseBalloonHelpFont. aMenu lastItem font: Preferences standardBalloonHelpFont. aMenu balloonTextForLastItem: 'choose the font to be used when presenting balloon help.' translated. aMenu add: 'code font...' translated action: #chooseCodeFont. aMenu lastItem font: Preferences standardCodeFont. aMenu balloonTextForLastItem: 'Choose the font to be used in code panes.' translated. aMenu addLine. aMenu add: 'restore default font choices' translated action: #restoreDefaultFonts. aMenu balloonTextForLastItem: 'Use the standard system font defaults' translated. aMenu add: 'print default font choices' translated action: #printStandardSystemFonts. aMenu balloonTextForLastItem: 'Print the standard system font defaults to the Transcript' translated. ^ aMenu! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 19:13'! printStandardSystemFonts "self printStandardSystemFonts" #(standardDefaultTextFont standardListFont standardFlapFont standardEToysFont standardMenuFont windowTitleFont standardBalloonHelpFont standardCodeFont standardButtonFont) do: [:selector | | font | font _ Preferences perform: selector. Transcript cr; show: selector; space; show: font familyName; show: ' points: '; show: font pointSize printString; show: ' height: '; show: font height printString]! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 23:30'! restoreDefaultFonts "Since this is called from menus, we can take the opportunity to prompt for missing font styles." "Preferences restoreDefaultFonts" self setDefaultFonts: #( (setSystemFontTo: Accuny 10) (setListFontTo: Accuny 10) (setFlapsFontTo: ComicSansMS 9) (setEToysFontTo: Accujen 10) (setMenuFontTo: Accuny 10) (setWindowTitleFontTo: BitstreamVeraSans 11) (setBalloonHelpFontTo: Accujen 9) (setCodeFontTo: Accuny 10) (setButtonFontTo: Accujen 12) )! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 17:46'! setBalloonHelpFontTo: aFont Smalltalk at: #BalloonMorph ifPresent: [:thatClass | thatClass setBalloonFontTo: aFont]! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 23:30'! setDefaultFonts: defaultFontsSpec "Since this is called from menus, we can take the opportunity to prompt for missing font styles." | fontNames map | fontNames _ defaultFontsSpec collect: [:array | array second]. map _ IdentityDictionary new. fontNames do: [:originalName | | style response | style _ map at: originalName put: (TextStyle named: originalName). style ifNil: [ response _ TextStyle modalStyleSelectorWithTitle: 'Choose replacement for text style ', originalName. map at: originalName put: (response ifNil: [TextStyle default])]]. defaultFontsSpec do: [:triplet | self perform: triplet first with: ((map at: triplet second) fontOfPointSize: triplet third)]! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 17:19'! standardBalloonHelpFont ^BalloonMorph balloonFont! ! !Preferences class methodsFor: 'fonts' stamp: 'bp 6/13/2004 17:24'! standardDefaultTextFont ^TextStyle defaultFont! ! !StandardSystemFontsTest methodsFor: 'as yet unclassified' stamp: 'bp 6/13/2004 18:22'! assert: selector familyName: aString pointSize: anInteger | font | font _ Preferences perform: selector. self assert: font familyName = aString. self assert: font pointSize = anInteger ! ! !StandardSystemFontsTest methodsFor: 'as yet unclassified' stamp: 'bp 6/13/2004 21:51'! saveStandardSystemFontsDuring: aBlock | standardDefaultTextFont standardListFont standardEToysFont standardMenuFont windowTitleFont standardBalloonHelpFont standardCodeFont standardButtonFont | standardDefaultTextFont _ Preferences standardDefaultTextFont. standardListFont _ Preferences standardListFont. standardEToysFont _ Preferences standardEToysFont. standardMenuFont _ Preferences standardMenuFont. windowTitleFont _ Preferences windowTitleFont. standardBalloonHelpFont _ Preferences standardBalloonHelpFont. standardCodeFont _ Preferences standardCodeFont. standardButtonFont _ Preferences standardButtonFont. [aBlock value] ensure: [ Preferences setSystemFontTo: standardDefaultTextFont. Preferences setListFontTo: standardListFont. Preferences setEToysFontTo: standardEToysFont. Preferences setMenuFontTo: standardMenuFont. Preferences setWindowTitleFontTo: windowTitleFont. Preferences setBalloonHelpFontTo: standardBalloonHelpFont. Preferences setCodeFontTo: standardCodeFont. Preferences setButtonFontTo: standardButtonFont]. ! ! !StandardSystemFontsTest methodsFor: 'as yet unclassified' stamp: 'bp 6/13/2004 21:53'! testRestoreDefaultFonts self saveStandardSystemFontsDuring: [ Preferences restoreDefaultFonts. self assert: #standardDefaultTextFont familyName: 'Accuny' pointSize: 10. self assert: #standardListFont familyName: 'Accuny' pointSize: 10. self assert: #standardFlapFont familyName: 'ComicSansMS' pointSize: 9. self assert: #standardEToysFont familyName: 'Accujen' pointSize: 10. self assert: #standardMenuFont familyName: 'Accuny' pointSize: 10. self assert: #windowTitleFont familyName: 'BitstreamVeraSans' pointSize: 11. self assert: #standardBalloonHelpFont familyName: 'Accujen' pointSize: 9. self assert: #standardCodeFont familyName: 'Accuny' pointSize: 10. self assert: #standardButtonFont familyName: 'Accujen' pointSize: 12]! !