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

commits at source.squeak.org commits at source.squeak.org
Sat Oct 5 20:43:05 UTC 2013


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

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

Name: Graphics-nice.251
Author: nice
Time: 5 October 2013, 10:42:02.017 pm
UUID: 72340e03-5929-4a5b-9514-f8feb4ccc172
Ancestors: Graphics-nice.250

Don't stop on space by default, this has no interest outside CompositionScanner except slowing down the scan loop.
Thus create a CompositionStopConditions for the case when we want stopping on space.
Revise the setting of stopConditions again (no need for setStopConditionsOrNil: intermediate)

=============== Diff against Graphics-nice.250 ===============

Item was removed:
- ----- Method: CharacterBlockScanner>>space (in category 'stop conditions') -----
- space
- 	"Account for spaceWidth"
- 
- 	spaceCount := spaceCount + 1.
- 	lastCharacterWidth := spaceWidth.
- 	(destX + lastCharacterWidth)  >= characterPoint x
- 		ifTrue:
- 			[^self crossedX].
- 	lastIndex := lastIndex + 1.
- 	destX := destX + lastCharacterWidth.
- 	^ false!

Item was changed:
  Object subclass: #CharacterScanner
  	instanceVariableNames: 'destX lastIndex destY stopConditions text textStyle alignment leftMargin rightMargin font line runStopIndex spaceCount spaceWidth emphasisCode kern indentationLevel wantsColumnBreaks pendingKernX'
+ 	classVariableNames: 'ColumnBreakStopConditions CompositionStopConditions DefaultStopConditions MeasuringStopConditions PaddedSpaceCondition'
- 	classVariableNames: 'ColumnBreakStopConditions DefaultStopConditions MeasuringStopConditions PaddedSpaceCondition'
  	poolDictionaries: 'TextConstants'
  	category: 'Graphics-Text'!
  
  !CharacterScanner commentStamp: '<historical>' prior: 0!
  My instances hold the state associated with scanning text. My subclasses scan characters for specified purposes, such as computing a CharacterBlock or placing characters into Forms.!

Item was changed:
  ----- Method: CharacterScanner class>>initialize (in category 'class initialization') -----
  initialize
  "
  	CharacterScanner initialize
  "
  	| a |
  	a := TextStopConditions new.
  	a at: 1 + 1 put: #embeddedObject.
- 	a at: Space asciiValue + 1 put: #space.
  	a at: Tab asciiValue + 1 put: #tab.
  	a at: CR asciiValue + 1 put: #cr.
  	a at: Character lf asciiValue + 1 put: #cr.
  	
  	DefaultStopConditions := a copy.
  
+ 	CompositionStopConditions := a copy.
+ 	CompositionStopConditions at: Space asciiValue + 1 put: #space.
+ 	ColumnBreakStopConditions := CompositionStopConditions copy.
- 	ColumnBreakStopConditions := a copy.
  	ColumnBreakStopConditions at: Character characterForColumnBreak asciiValue + 1 put: #columnBreak.
  
  	PaddedSpaceCondition := a copy.
  	PaddedSpaceCondition at: Space asciiValue + 1 put: #paddedSpace.
  
  	MeasuringStopConditions := TextStopConditions new!

Item was changed:
  ----- Method: CharacterScanner>>setFont (in category 'private') -----
  setFont
  	| priorFont |
  	"Set the font and other emphasis."
  	priorFont := font.
  	text == nil ifFalse:[
  		emphasisCode := 0.
  		kern := 0.
  		indentationLevel := 0.
  		alignment := textStyle alignment.
  		font := nil.
  		(text attributesAt: lastIndex forStyle: textStyle)
  			do: [:att | att emphasizeScanner: self]].
  	font == nil ifTrue:
  		[self setFont: textStyle defaultFontIndex].
  	font := font emphasized: emphasisCode.
  	priorFont 
  		ifNotNil: [
  			font = priorFont 
  				ifTrue:[
  					"font is the same, perhaps the color has changed?
  					We still want kerning between chars of the same
  					font, but of different color. So add any pending kern to destX"
  					destX := destX + (pendingKernX ifNil:[0])].
  			destX := destX + priorFont descentKern].
  	pendingKernX := 0. "clear any pending kern so there is no danger of it being added twice"
  	destX := destX - font descentKern.
  	"NOTE: next statement should be removed when clipping works"
  	leftMargin ifNotNil: [destX := destX max: leftMargin].
  	kern := kern - font baseKern.
  
  	"Install various parameters from the font."
+ 	spaceWidth := font widthOf: Space.!
- 	spaceWidth := font widthOf: Space.
- 	stopConditions := DefaultStopConditions.!

Item was changed:
+ ----- Method: CharacterScanner>>setFont: (in category 'text attributes') -----
- ----- Method: CharacterScanner>>setFont: (in category 'private') -----
  setFont: fontNumber
  	"Set the font by number from the textStyle."
  
  	self setActualFont: (textStyle fontAt: fontNumber)!

Item was changed:
  ----- Method: CharacterScanner>>setStopConditions (in category 'private') -----
  setStopConditions
  	"Set the font and the stop conditions for the current run."
  	
  	self setFont.
+ 	stopConditions := alignment = Justified
+ 		ifTrue: [PaddedSpaceCondition]
+ 		ifFalse: [DefaultStopConditions]!
- 	self setStopConditionsOrNil: (alignment = Justified ifTrue: [PaddedSpaceCondition])!

Item was removed:
- ----- Method: CharacterScanner>>setStopConditionsOrNil: (in category 'private') -----
- setStopConditionsOrNil: aStopConditionOrNil
- 
- 	aStopConditionOrNil ifNotNil: [^stopConditions := aStopConditionOrNil].
- 	^stopConditions := DefaultStopConditions!

Item was changed:
  ----- Method: CompositionScanner>>setStopConditions (in category 'stop conditions') -----
  setStopConditions
  	"Set the font and the stop conditions for the current run."
  	
  	self setFont.
+ 	stopConditions := wantsColumnBreaks == true
+ 		ifTrue: [ColumnBreakStopConditions]
+ 		ifFalse: [CompositionStopConditions]!
- 	self setStopConditionsOrNil: (wantsColumnBreaks == true ifTrue: [ColumnBreakStopConditions])!

Item was removed:
- ----- Method: DisplayScanner>>space (in category 'stop conditions') -----
- space
- 	"Don't display the space, just skip the spaceWidth."
- 
- 	spaceCount := spaceCount + 1.
- 	destX := destX + spaceWidth.
- 	lastIndex := lastIndex + 1.
- 	pendingKernX := 0.
- 	^ false!

Item was added:
+ ----- Method: SegmentScanner>>setStopConditions (in category 'private') -----
+ setStopConditions
+ 	"Set the font and the stop conditions for the current run."
+ 	
+ 	self setFont.
+ 	stopConditions := DefaultStopConditions!

Item was removed:
- ----- Method: SegmentScanner>>setStopConditionsOrNil: (in category 'private') -----
- setStopConditionsOrNil: aStopConditionOrNil
- 
- 	aStopConditionOrNil ifNotNil: [^stopConditions := aStopConditionOrNil].
- 	stopConditions := DefaultStopConditions copy.
- 	stopConditions at: Space asciiValue + 1 put: nil.
- 	^stopConditions!



More information about the Squeak-dev mailing list