[squeak-dev] The Trunk: System-fbs.576.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jul 23 19:40:22 UTC 2013


Frank Shearar uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-fbs.576.mcz

==================== Summary ====================

Name: System-fbs.576
Author: fbs
Time: 23 July 2013, 8:04:51.769 pm
UUID: 492f5125-ff20-a242-8fce-3967b4ea3c29
Ancestors: System-fbs.575

Make TrueType sit above (and extend) Graphics, thus breaking the cyclic dependency.

The decoupling is pretty rough. By all means make the division between these two packages cleaner!

Methods like #fromUser don't (in my opinion) belong in low level packages, hence their migration to System.

=============== Diff against System-fbs.575 ===============

Item was added:
+ ----- Method: StrikeFont class>>fromUser (in category '*System-Fonts') -----
+ fromUser
+ 	"StrikeFont fromUser"
+ 	^self fromUser: TextStyle defaultFont!

Item was added:
+ ----- Method: StrikeFont class>>fromUser: (in category '*System-Fonts') -----
+ fromUser: priorFont
+ 	^self fromUser: priorFont allowKeyboard: true!

Item was added:
+ ----- Method: StrikeFont class>>fromUser:allowKeyboard: (in category '*System-Fonts') -----
+ fromUser: priorFont allowKeyboard: aBoolean	"StrikeFont fromUser"
+ 	"Present a menu of available fonts, and if one is chosen, return it.
+ 	Otherwise return nil. Using ToolBuilder for added abstraction."
+ 	| fontList fontMenu font builder resultBlock widget style result item |
+ 	builder := ToolBuilder default.
+ 	fontList := StrikeFont actualFamilyNames.
+ 	fontMenu := builder pluggableMenuSpec new.
+ 	resultBlock := [:value| result := value].
+ 	fontList do: [:fontName | | active ptMenu |
+ 		style := TextStyle named: fontName.
+ 		active := priorFont familyName sameAs: fontName.
+ 		ptMenu := builder pluggableMenuSpec new.
+ 		style pointSizes do: [:pt | | label |
+ 			label := pt printString, ' pt'.
+ 			item := ptMenu add: label 
+ 				target: resultBlock
+ 				selector: #value:
+ 				argumentList: {{fontName. pt}}.
+ 			item checked: (active and:[pt = priorFont pointSize]).
+ 		].
+ 		style isTTCStyle ifTrue: [
+ 			ptMenu add: 'new size'
+ 				target: style 
+ 				selector: #addNewFontSizeDialog: 
+ 				argumentList: {{fontName. fontMenu}}.
+ 		].
+ 		item := fontMenu add: fontName action: nil.
+ 		item subMenu: ptMenu.
+ 		item checked: active.
+ 	].
+ 	TTFileDescription offerNonPortableFonts ifTrue:[
+ 		fontMenu addSeparator.
+ 		item := fontMenu add: 'More (non-portable) Fonts...' 
+ 			target: resultBlock 
+ 			selector: #value:
+ 			argumentList: #(TTFileDescription).
+ 	].
+ 	widget := builder open: fontMenu.
+ 	builder runModal: widget.
+ 	result ifNil:[^nil].
+ 	"Pick a non-portable font if requested"
+ 	result == #TTFileDescription ifTrue:[
+ 		^Smalltalk at: #TTFileDescription ifPresent:[:ttf| 
+ 			ttf fontFromUser: priorFont allowKeyboard: aBoolean]].
+ 	style := TextStyle named: result first.
+ 	style ifNil: [^ self].
+ 	font := style fonts detect: [:any | any pointSize = result last] ifNone: [nil].
+ 	^ font!

Item was added:
+ ----- Method: StrikeFont class>>newForJapaneseFromEFontBDFFile:name:overrideWith: (in category '*System-Fonts') -----
+ newForJapaneseFromEFontBDFFile: fileName name: aString overrideWith: otherFileName
+ 
+ 	| n |
+ 	n := self new.
+ 	n readEFontBDFForJapaneseFromFile: fileName name: aString overrideWith: otherFileName.
+ 	^ n.
+ !

Item was added:
+ ----- Method: StrikeFont class>>setupDefaultFallbackFont (in category '*System-Fonts') -----
+ setupDefaultFallbackFont
+ "
+ 	StrikeFont setupDefaultFallbackFont
+ "
+ 
+ 	(#(#Accuat #Accujen #Accula #Accumon #Accusf #Accushi #Accuve #Atlanta) collect: [:e | TextStyle named: e]) do: [:style |
+ 		style fontArray do: [:e |
+ 			e reset.
+ 			e setupDefaultFallbackFont.
+ 		].
+ 	].
+ 	TTCFont allSubInstances
+ 		do: [:font | font reset.
+ 			font setupDefaultFallbackFont]
+ 
+ !

Item was added:
+ ----- Method: TextStyle class>>chooseTTCFontSize: (in category '*System-Fonts') -----
+ chooseTTCFontSize: args
+ 	"Prompt for a point size and, if one is given, add a new font size to the font named by the first member of args. If args' length is three, send a message with the selector equal to the third of args, and the receiver equal to the second of args, passing the selected style as an argument."
+ 
+ 	| f n style |
+ 	f := UIManager default request: 'New Point Size' initialAnswer: '0'.
+ 	n := f asNumber.
+ 	style := (TextConstants at: args first) addNewFontSize: n.
+ 	style ifNotNil: [
+ 		args second ifNotNil: [args second perform: args third with: style].
+ 	].
+ !

Item was added:
+ ----- Method: TextStyle>>addNewFontSize: (in category '*System-Fonts') -----
+ addNewFontSize: pointSize
+ 	"Add a font in specified size to the array of fonts."
+ 	| f d newArray t isSet |
+ 	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 := fontArray first class new initialize: fontArray first.
+ 		f pointSize: pointSize.
+ 		fontArray first derivativeFonts do: [:proto |
+ 			proto ifNotNil: [
+ 				d := proto class new initialize: proto.
+ 				d pointSize: f pointSize.
+ 				f derivativeFont: d mainFont: proto.
+ 			].
+ 		].
+ 	].
+ 	newArray := (fontArray copyWith: f) asArray sort: [:a :b | a pointSize <= b pointSize].
+ 	self newFontArray: newArray.
+ 	isSet ifTrue: [
+ 		TTCFontSet register: newArray at: newArray first familyName asSymbol.
+ 	].
+ 	^ self fontOfPointSize: pointSize
+ !

Item was added:
+ ----- Method: TextStyle>>addNewFontSizeDialog: (in category '*System-Fonts') -----
+ addNewFontSizeDialog: args
+ 	"This is called from a modal menu and call back the menu with entered argument."
+ 	| f n r |
+ 	f := UIManager default request: 'Enter the point size' initialAnswer: '12'.
+ 	n := f asNumber.
+ 	r := self addNewFontSize: n.
+ 	r ifNotNil: [
+ 		args second ifNotNil: [args second modalSelection: {args first. n}].
+ 	].
+ !

Item was added:
+ ----- Method: TextStyle>>discardOtherSizes (in category '*System-Fonts') -----
+ discardOtherSizes
+ 	"This method trys to discard the fonts in non-standard size.  If the size is still in use, there will be a problem."
+ 	| newArray |
+ 	self isTTCStyle ifFalse: [^ self].
+ 	newArray := fontArray select: [:s | TTCFont pointSizes includes: s pointSize].
+ 	self newFontArray: newArray.
+ 
+ "(TextConstants at: #ComicSansMS) discardOtherSizes"!



More information about the Squeak-dev mailing list