[squeak-dev] The Trunk: Graphics-nice.224.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 4 20:13:34 UTC 2013


Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.224.mcz

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

Name: Graphics-nice.224
Author: nice
Time: 4 September 2013, 10:11:17.858 pm
UUID: 9a7bbc80-ea53-4fb7-a793-274be1ed108f
Ancestors: Graphics-ul.223

1) remove #canComputDefaultLineHeight it has a brother with a e after comput which is sent.
2) avoid 'a litral string' asSymbol, #'a literal symbol' is the syntax.
3) Transform this construct into something not less understandable:
    [ doSomeLoop.
	testStopCondition ifTrue: [^something] ] repeat
=>
    [ doSomeLoop.
	testStopCondition ] whileFalse.

	^something

=============== Diff against Graphics-ul.223 ===============

Item was changed:
  ----- Method: BDFFontReader>>read (in category 'reading') -----
  read
  	| xTable strikeWidth glyphs ascent descent minAscii maxAscii maxWidth chars charsNum height form encoding bbx array width blt lastAscii pointSize ret stream |
  	form := encoding := bbx := nil.
  	self readAttributes.
  	height := Integer readFromString: ((properties at: #FONTBOUNDINGBOX) at: 2).
+ 	ascent := Integer readFromString: (properties at: #'FONT_ASCENT') first.
+ 	descent := Integer readFromString: (properties at: #'FONT_DESCENT') first.
+ 	pointSize := (Integer readFromString: (properties at: #'POINT_SIZE') first) // 10.
- 	ascent := Integer readFromString: (properties at: 'FONT_ASCENT' asSymbol) first.
- 	descent := Integer readFromString: (properties at: 'FONT_DESCENT' asSymbol) first.
- 	pointSize := (Integer readFromString: (properties at: 'POINT_SIZE' asSymbol) first) // 10.
  	
  	maxWidth := 0.
  	minAscii := 9999.
  	strikeWidth := 0.
  	maxAscii := 0.
  
  	charsNum := Integer readFromString: (properties at: #CHARS) first.
  	chars := Set new: charsNum.
  
  	1 to: charsNum do: [:i |
  		array := self readOneCharacter.
  		stream := ReadStream on: array.
  		form := stream next.
  		encoding := stream next.
  		bbx := stream next.
  		form ifNotNil: [
  			width := bbx at: 1.
  			maxWidth := maxWidth max: width.
  			minAscii := minAscii min: encoding.
  			maxAscii := maxAscii max: encoding.
  			strikeWidth := strikeWidth + width.
  			chars add: array.
  		].
  	].
  
  	chars := chars asSortedCollection: [:x :y | (x at: 2) <= (y at: 2)].
  	charsNum := chars size. "undefined encodings make this different"
  
  	charsNum > 256 ifTrue: [
  		"it should be 94x94 charset, and should be fixed width font"
  		strikeWidth := 94*94*maxWidth.
  		maxAscii := 94*94.
  		minAscii := 0.
  		xTable := XTableForFixedFont new.
  		xTable maxAscii: 94*94.
  		xTable width: maxWidth.
  	] ifFalse: [
  		xTable := (Array new: 258) atAllPut: 0.
  	].
  
  	glyphs := Form extent: strikeWidth at height.
  	blt := BitBlt toForm: glyphs.
  	lastAscii := 0.
  	
  	charsNum > 256 ifTrue: [
  		1 to: charsNum do: [:i |
  			stream := ReadStream on: (chars at: i).
  			form := stream next.
  			encoding := stream next.
  			bbx := stream next.
  			encoding := ((encoding // 256) - 33) * 94 + ((encoding \\ 256) - 33).
  			blt copy: ((encoding * maxWidth)@0 extent: maxWidth at height)
  				from: 0 at 0 in: form.
  		].
  	] ifFalse: [
  		1 to: charsNum do: [:i |
  			stream := ReadStream on: (chars at: i).
  			form := stream next.
  			encoding := stream next.
  			bbx := stream next.
  			lastAscii+1 to: encoding-1 do: [:a | xTable at: a+2 put: (xTable at: a+1)].
  			blt copy: (((xTable at: encoding+1)@(ascent - (bbx at: 2) - (bbx at: 4)))
  					extent: (bbx at: 1)@(bbx at: 2))
  				from: 0 at 0 in: form.
  			xTable at: encoding+2 put: (xTable at: encoding+1)+(bbx at: 1).
  			lastAscii := encoding.
  		]
  	].
  
  	ret := Array new: 8.
  	ret at: 1 put: xTable.
  	ret at: 2 put: glyphs.
  	ret at: 3 put: minAscii.
  	ret at: 4 put: maxAscii.
  	ret at: 5 put: maxWidth.
  	ret at: 6 put: ascent.
  	ret at: 7 put: descent.
  	ret at: 8 put: pointSize.
  	^ret.
  " ^{xTable. glyphs. minAscii. maxAscii. maxWidth. ascent. descent. pointSize}"
  !

Item was changed:
  ----- Method: BDFFontReader>>readChars (in category 'reading') -----
  readChars
  	| strikeWidth ascent descent minAscii maxAscii maxWidth chars charsNum height form encoding bbx array width pointSize stream |
  	form := encoding := bbx := nil.
  	self readAttributes.
  	height := Integer readFromString: ((properties at: #FONTBOUNDINGBOX) at: 2).
+ 	ascent := Integer readFromString: (properties at: #'FONT_ASCENT') first.
+ 	descent := Integer readFromString: (properties at: #'FONT_DESCENT') first.
+ 	pointSize := (Integer readFromString: (properties at: #'POINT_SIZE') first) // 10.
- 	ascent := Integer readFromString: (properties at: 'FONT_ASCENT' asSymbol) first.
- 	descent := Integer readFromString: (properties at: 'FONT_DESCENT' asSymbol) first.
- 	pointSize := (Integer readFromString: (properties at: 'POINT_SIZE' asSymbol) first) // 10.
  	
  	maxWidth := 0.
  	minAscii := 9999.
  	strikeWidth := 0.
  	maxAscii := 0.
  
  	charsNum := Integer readFromString: (properties at: #CHARS) first.
  	chars := Set new: charsNum.
  
  	1 to: charsNum do: [:i |
  		array := self readOneCharacter.
  		stream := ReadStream on: array.
  		form := stream next.
  		encoding := stream next.
  		bbx := stream next.
  		form ifNotNil: [
  			width := bbx at: 1.
  			maxWidth := maxWidth max: width.
  			minAscii := minAscii min: encoding.
  			maxAscii := maxAscii max: encoding.
  			strikeWidth := strikeWidth + width.
  			chars add: array.
  		].
  	].
  
  	chars := chars asSortedCollection: [:x :y | (x at: 2) <= (y at: 2)].
  
  	^ chars.
  !

Item was removed:
- ----- Method: CompositionScanner>>canComputDefaultLineHeight (in category 'testing') -----
- canComputDefaultLineHeight
- 	^ rightMargin notNil!

Item was changed:
  ----- Method: CompositionScanner>>composeLine:fromCharacterIndex:inParagraph: (in category 'scanning') -----
  composeLine: lineIndex fromCharacterIndex: startIndex inParagraph: aParagraph 
  	"Answer an instance of TextLineInterval that represents the next line in the paragraph."
  	| runLength stopCondition |
  	destX := spaceX := leftMargin := aParagraph leftMarginForCompositionForLine: lineIndex.
  	destY := 0.
  	rightMargin := aParagraph rightMarginForComposition.
  	leftMargin >= rightMargin ifTrue: [self error: 'No room between margins to compose'].
  	lastIndex := startIndex.	"scanning sets last index"
  	lineHeight := textStyle lineGrid.  "may be increased by setFont:..."
  	baseline := textStyle baseline.
  	self setStopConditions.	"also sets font"
  	self handleIndentation.
  	runLength := text runLengthFor: startIndex.
  	runStopIndex := (lastIndex := startIndex) + (runLength - 1).
  	line := TextLineInterval
  		start: lastIndex
  		stop: 0
  		internalSpaces: 0
  		paddingWidth: 0.
  	spaceCount := 0.
  	
  	[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  		in: text string rightX: rightMargin stopConditions: stopConditions
  		kern: kern.
  	"See setStopConditions for stopping conditions for composing."
+ 	self perform: stopCondition] whileFalse.
+ 
+ 	^line
+ 		lineHeight: lineHeight + textStyle leading
+ 		baseline: baseline + textStyle leading!
- 	(self perform: stopCondition)
- 		ifTrue: [^line lineHeight: lineHeight + textStyle leading
- 					baseline: baseline + textStyle leading]] repeat!

Item was changed:
  ----- Method: FontSet class>>fontCategory (in category 'private') -----
  fontCategory
+ 	^ #'Graphics-Fonts'!
- 	^ 'Graphics-Fonts' asSymbol!



More information about the Squeak-dev mailing list