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

commits at source.squeak.org commits at source.squeak.org
Mon Mar 8 13:37:47 UTC 2010


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

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

Name: Graphics-nice.117
Author: nice
Time: 8 March 2010, 2:37:28.434 pm
UUID: ecfc0981-dfd0-7f46-9956-d4224cdbda7e
Ancestors: Graphics-ar.116

Restore TextStopConditions backward compatibility support for FreeType overrides.
Otherwise, VMMaker update cannot be loaded safely in the image.

Add a long comment to TextStopConditions.
I cannot complain about comments if I don't put some myself.
Maybe it does not belong here, but hey, that's better than nothing.

=============== Diff against Graphics-ar.116 ===============

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

Item was changed:
  ----- Method: CharacterScanner>>initializeStringMeasurer (in category 'initialize') -----
  initializeStringMeasurer
+ 
+ 	stopConditions := TextStopConditions new
- 	| stops |
- 	stops := Array new: 256.
- 	stopConditions := TextStopConditions new setStops: stops.
  !

Item was changed:
  ----- Method: TextStopConditions>>initialize (in category 'initialize-release') -----
  initialize
+ 	"Initialize the default stop conditions."
+ 	stops := Array new: 258.
+ 	self endOfRun: #endOfRun.
+ 	self crossedX: #crossedX.!
- 	stops := Array new: 256.
- 	crossedX := #crossedX.
- 	endOfRun := #endOfRun!

Item was changed:
  ----- Method: TextStopConditions>>crossedX (in category 'accessing') -----
  crossedX
+ 	"Answer the special action to be performed when crossing composition bounds."
+ 	
  	^crossedX!

Item was changed:
  ----- Method: TextStopConditions>>at: (in category 'accessing') -----
  at: anInteger
+ 	"Answer the special action associated with a character of code anInteger, or nil if none.
+ 	The character code should be betxween 1 and 256 (presumably codePoint + 1).
+ 	It can eventually be 257 for endOfRun action, or 258 for crossedX action for backward compatibility with historical squeak versions."
+ 	
  	^stops at: anInteger!

Item was changed:
  ----- Method: TextStopConditions>>crossedX: (in category 'accessing') -----
  crossedX: aSymbolOrNil
+ 	crossedX := aSymbolOrNil.
+ 	
+ 	"Backward compatibility with historical EndOfRun TextConstant handling"
+ 	stops size >= 258 ifTrue: [stops at: 258 put: crossedX]!
- 	crossedX := aSymbolOrNil!

Item was changed:
  Object subclass: #TextStopConditions
  	instanceVariableNames: 'stops crossedX endOfRun'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Graphics-Text'!
+ 
+ !TextStopConditions commentStamp: 'nice 3/8/2010 14:31' prior: 0!
+ A TextStopConditions is a private helper class for text composition (See class CharacterScanner and subclasses).
+ It maps some characters controling the text layout (like carriage return, line feeds, space and tabulation) to some selector representing the action to be performed by the CharacterScanner.
+ By default, a TextStopConditions does not map any action to control character; instances must be properly initialized by sending #at:put: messages.
+ 
+ For example, inter-word spacing can be adjusted so as to obtain "justified" paragraphs. See implementors of #paddedSpace, #cr, #space, #columnBreak for example of special character actions.
+ 
+ A TextStopConditions also store two selectors for mapping the actions to be taken when:
+ - end of run is encountered;
+ - text overflows horizontal composition bounds.
+ These actions are by default #endOfRun and #crossedX (see implementors of these messages), but can enventually be changed using #endOfRun: and #crossedX:.
+ 
+ In a text (see class Text), the "runs" are used to store text style attributes, so an "end of run" event probably means some action in the textcomposer should be taken to change the font.
+ 
+ TextStopConditions current implementation can only map 256 character codes (from 1 to 256). It is the composer responsibility to encode the character before sending #at:. Presumably, the composer will use the character codePoint + 1 (see implementors of #codePoint).
+ If this is not sufficient, then this class could be changed to use a Dictionary or a LargeTable
+ 
+ Historically, the EndOfRun and CrossedX were two TextConstant of value 257 and 258, which did occupy corresponding slots in the stops array. Since these are valid character codePoint, this usage has been deprecated. However, because any error in text composition would have catastrophic consequences (unresponsive user interface), backward compatibility with obsolete historical code is still maintained internally which is why the stops array has a sze of 258.
+ 
+ Instance Variables
+ 	crossedX:		<Symbol | nil>
+ 	endOfRun:		<Symbol | nil>
+ 	stops:		<Array of: Symbol | nil>
+ 
+ crossedX
+ 	- selector to perform when the composed text overflows X composition bound
+ 
+ endOfRun
+ 	- selector to perform at end of run
+ 
+ stops
+ 	- an array mapping character code (codePoint + 1) to special actions, or nil if character is to be rendered normally
+ !

Item was changed:
  ----- Method: TextStopConditions>>endOfRun: (in category 'accessing') -----
  endOfRun: aSymbolOrNil
+ 	endOfRun := aSymbolOrNil.
+ 	
+ 	"Backward compatibility with historical EndOfRun TextConstant handling"
+ 	stops size >= 257 ifTrue: [stops at: 257 put: endOfRun]!
- 	endOfRun := aSymbolOrNil!

Item was changed:
  ----- Method: TextStopConditions>>endOfRun (in category 'accessing') -----
  endOfRun
+ 	"Answer the special action to be performed et end of text."
+ 	
  	^endOfRun!

Item was changed:
  ----- Method: TextStopConditions>>at:put: (in category 'accessing') -----
  at: anInteger put: aSymbolOrNil
+ 	"Set the special action associated with a character of code anInteger, or nil if none.
+ 	The character code should be betxween 1 and 256 (presumably codePoint + 1).
+ 	It can eventually be 257 for endOfRun action, or 258 for crossedX action for backward compatibility with historical squeak versions."
+ 	
+ 	anInteger = 257
+ 		ifTrue: [
+ 			self endOfRun: aSymbolOrNil..
+ 			^aSymbolOrNil].
+ 	anInteger = 258
+ 		ifTrue: [
+ 			self crossedX: aSymbolOrNil..
+ 			^aSymbolOrNil].
  	^stops at: anInteger put: aSymbolOrNil!

Item was removed:
- ----- Method: TextStopConditions>>setStops: (in category 'initialize-release') -----
- setStops: stopArray
- 	stops := stopArray!




More information about the Squeak-dev mailing list