'From etoys2.2 of 1 October 2007 [latest update: #1715] on 22 October 2007 at 7:38:06 pm'! "Change Set: systemFont-yo Date: 22 October 2007 Author: Yoshiki Ohshima Fix the recursive fallbackfont problem."! !Locale class methodsFor: 'accessing' stamp: 'yo 10/22/2007 15:58'! switchAndInstallFontToID: localeID gently: gentlyFlag | locale | locale := Locale localeID: localeID. locale languageEnvironment isFontAvailable ifFalse: [(self confirm: 'This language needs additional fonts. Do you want to install the fonts?' translated) ifTrue: [locale languageEnvironment installFont. StrikeFont setupDefaultFallbackTextStyle] ifFalse: [^ self]]. self switchTo: locale gently: gentlyFlag ! ! !StrikeFont methodsFor: 'multibyte character methods' stamp: 'yo 10/22/2007 15:53'! setupDefaultFallbackFont self setupDefaultFallbackTextStyleTo: self class defaultFallbackTextStyle.! ! !StrikeFont methodsFor: 'multibyte character methods' stamp: 'yo 10/22/2007 15:48'! setupDefaultFallbackTextStyleTo: aTextStyle | fonts f | fonts := aTextStyle fontArray. f _ fonts first. f familyName = self familyName ifTrue: [^ self]. 1 to: fonts size do: [:i | self height > (fonts at: i) height ifTrue: [f _ fonts at: i]. ]. self fallbackFont: f. self reset. ! ! !StrikeFont class methodsFor: 'font creation' stamp: 'yo 10/22/2007 15:53'! defaultFallbackTextStyle ^ TextConstants at: #DefaultFallbackFont ifAbsent: [TextStyle named: 'Accuny']. ! ! !StrikeFont class methodsFor: 'font creation' stamp: 'yo 10/22/2007 15:58'! localeChanged self setupDefaultFallbackTextStyle! ! !StrikeFont class methodsFor: 'font creation' stamp: 'yo 10/22/2007 15:57'! setupDefaultFallbackFont self setupDefaultFallbackTextStyle ! ! !StrikeFont class methodsFor: 'font creation' stamp: 'yo 10/22/2007 16:21'! setupDefaultFallbackTextStyle | defaultStyle | defaultStyle := self defaultFallbackTextStyle. (#(Accuat Accujen Accula Accumon Accusf Accushi Accuve Atlanta) collect: [:e | TextStyle named: e]) do: [:style | style fontArray do: [:e | e reset. e setupDefaultFallbackTextStyleTo: defaultStyle. ]. ]. TTCFont allSubInstances do: [:e | e reset. e setupDefaultFallbackTextStyleTo: defaultStyle] ! ! !StrikeFont class methodsFor: 'font creation' stamp: 'yo 10/22/2007 15:29'! setupDefaultFallbackTextStyleTo: aTextStyle TextConstants at: #DefaultFallbackFont put: aTextStyle. ! ! !TextStyle methodsFor: 'fonts and font indexes' stamp: 'yo 10/22/2007 15:49'! addNewFontSize: pointSize "Add a font in specified size to the array of fonts." | f d newArray t isSet fallbackStyle | fontArray first emphasis ~= 0 ifTrue: [ t _ TextConstants at: self fontArray first familyName asSymbol. t fonts first emphasis = 0 ifTrue: [ ^ t addNewFontSize: pointSize. ]. ]. pointSize <= 0 ifTrue: [^ nil]. fontArray do: [:s | s pointSize = pointSize ifTrue: [^ s]. ]. (isSet _ fontArray first isKindOf: TTCFontSet) ifTrue:[ | fonts | fonts _ fontArray first fontArray collect: [ :font | | newFont | (font isNil) ifTrue: [newFont _ nil] ifFalse: [ newFont _ (font ttcDescription size > 256) ifTrue: [MultiTTCFont new initialize] ifFalse: [TTCFont new initialize]. newFont ttcDescription: font ttcDescription. newFont pixelSize: pointSize * 96 // 72. font derivativeFonts notEmpty ifTrue: [font derivativeFonts do: [ :proto | proto ifNotNil: [ d _ proto class new initialize. d ttcDescription: proto ttcDescription. d pixelSize: newFont pixelSize. newFont derivativeFont: d]]]. ]. newFont]. f _ TTCFontSet newFontArray: fonts] ifFalse: [ f _ TTCFont new initialize. f ttcDescription: fontArray first ttcDescription. f pointSize: pointSize. fontArray first derivativeFonts do: [:proto | proto ifNotNil: [ d _ TTCFont new initialize. d ttcDescription: proto ttcDescription. d pointSize: f pointSize. f derivativeFont: d. ]. ]. ]. isSet ifFalse: [ fallbackStyle _ TextStyle named: (fontArray first fallbackFont textStyleName). ]. newArray _ ((fontArray copyWith: f) asSortedCollection: [:a :b | a pointSize <= b pointSize]) asArray. self newFontArray: newArray. isSet ifTrue: [ TTCFontSet register: newArray at: newArray first familyName asSymbol. ]. isSet ifFalse: [ f setupDefaultFallbackTextStyleTo: fallbackStyle. f derivativeFonts do: [:g | g setupDefaultFallbackTextStyleTo: fallbackStyle]. ]. ^ self fontOfPointSize: pointSize ! ! !TTCFont methodsFor: 'friend' stamp: 'yo 10/22/2007 15:48'! setupDefaultFallbackTextStyleTo: aTextStyle | fonts f | fonts _ aTextStyle fontArray. f _ fonts first. f familyName = self familyName ifTrue: [^ self]. 1 to: fonts size do: [:i | self height > (fonts at: i) height ifTrue: [f _ fonts at: i]. ]. self fallbackFont: f. self reset. ! ! !TTCFont methodsFor: 'as yet unclassified' stamp: 'yo 10/22/2007 15:55'! setupDefaultFallbackFont self setupDefaultFallbackTextStyleTo: (StrikeFont defaultFallbackTextStyle). ! ! TTCFont removeSelector: #setupDefaultFallbackFontTo:!