[Pkg] The Trunk: Graphics-nice.238.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Sep 29 17:07:36 UTC 2013

Nicolas Cellier uploaded a new version of Graphics to project The Trunk:

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

Name: Graphics-nice.238
Author: nice
Time: 29 September 2013, 7:06:35.509 pm
UUID: f7a0533e-2b32-4908-8666-d26204334a6e
Ancestors: Graphics-nice.237

Take font baseKern into account when measuring a String (a small diff with defunct Multi*).
Create a specially crafted MeasuringStopConditions and use it when measuringString.
This way, initializeStringMeasurer is no longer required and deprecated.

=============== Diff against Graphics-nice.237 ===============

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 DefaultStopConditions MeasuringStopConditions PaddedSpaceCondition'
- 	classVariableNames: 'ColumnBreakStopConditions DefaultStopConditions 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') -----
  	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.
  	ColumnBreakStopConditions := a copy.
  	ColumnBreakStopConditions at: TextComposer characterForColumnBreak asciiValue + 1 put: #columnBreak.
  	PaddedSpaceCondition := a copy.
  	PaddedSpaceCondition at: Space asciiValue + 1 put: #paddedSpace.
+ 	MeasuringStopConditions := TextStopConditions new!
- !

Item was removed:
- ----- Method: CharacterScanner>>initializeStringMeasurer (in category 'initialize') -----
- initializeStringMeasurer
- 	stopConditions := TextStopConditions new
- !

Item was changed:
  ----- Method: CharacterScanner>>measureString:inFont:from:to: (in category 'scanning') -----
  measureString: aString inFont: aFont from: startIndex to: stopIndex
+ 	"Measure aString width in given font aFont.
+ 	The string shall not include line breaking, tab or other control character."
- 	"WARNING: In order to use this method the receiver has to be set up using #initializeStringMeasurer"
  	destX := destY := lastIndex := 0.
  	pendingKernX := 0.
  	font := aFont.
  	kern := 0 - font baseKern.
  	spaceWidth := font widthOf: Space.
+ 	stopConditions := MeasuringStopConditions.
+ 	self scanCharactersFrom: startIndex to: stopIndex in: aString rightX: 999999 stopConditions: stopConditions kern: kern.
- 	self scanCharactersFrom: startIndex to: stopIndex in: aString rightX: 999999 stopConditions: stopConditions kern: 0.

More information about the Packages mailing list