Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.202.mcz ==================== Summary ==================== Name: Graphics-nice.202 Author: nice Time: 7 March 2013, 10:08:58.015 pm UUID: a84ed987-0efb-442b-b3eb-fd3d9e29bfaf Ancestors: Graphics-nice.201 Let CharacterScanner take kerning into account when measuring a String in order to fall in agreement with CompositionScanner. Note that #measureString:inFont:from:to: is not used in image but seems to be by some Tweak code as reported by mtf in dec. 2010. Remove unused xTable (such low level responsibility has been transferred into BitBlt) =============== Diff against Graphics-nice.201 =============== 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' - instanceVariableNames: 'destX lastIndex xTable destY stopConditions text textStyle alignment leftMargin rightMargin font line runStopIndex spaceCount spaceWidth emphasisCode kern indentationLevel wantsColumnBreaks pendingKernX' classVariableNames: 'DefaultStopConditions NilCondition PaddedSpaceCondition SpaceCondition' 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>>measureString:inFont:from:to: (in category 'scanning') ----- measureString: aString inFont: aFont from: startIndex to: stopIndex "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. - xTable := aFont xTable. self scanCharactersFrom: startIndex to: stopIndex in: aString rightX: 999999 stopConditions: stopConditions kern: 0. ^destX! 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. - xTable := font xTable. stopConditions := DefaultStopConditions.! |
Free forum by Nabble | Edit this page |