<div dir="ltr"><div><div>NOTE: I could have added baselineY: baselineY parameter to font displayString:... like it is in MultiDispalyScanner<br></div>BUT: there is currently a workaround in StrikeFont which is found only in the version without baselineY:<br>
</div>All this stuff is really getting funny...<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/29  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nicolas Cellier uploaded a new version of Graphics to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Graphics-nice.236.mcz" target="_blank">http://source.squeak.org/trunk/Graphics-nice.236.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Graphics-nice.236<br>
Author: nice<br>
Time: 29 September 2013, 3:37:33.253 am<br>
UUID: 38c2e6a3-d9fa-4a5b-b5e1-91a85e4afae6<br>
Ancestors: Graphics-nice.235<br>
<br>
Don&#39;t setStopConditions twice in CharacterBlockScanner and DisplayScanner in MVC compatibility methods.<br>
SharedPools are inherited in Squeak, so don&#39;t declare TextConstants in CompositionScanner.<br>
<br>
=============== Diff against Graphics-nice.235 ===============<br>
<br>
Item was changed:<br>
  ----- Method: CharacterBlockScanner&gt;&gt;buildCharacterBlockIn: (in category &#39;private&#39;) -----<br>
  buildCharacterBlockIn: para<br>
+       &quot;This method is used by the MVC version only.&quot;<br>
+<br>
+       | lineIndex runLength lineStop stopCondition |<br>
-       | lineIndex runLength lineStop done stopCondition |<br>
        &quot;handle nullText&quot;<br>
        (para numberOfLines = 0 or: [text size = 0])<br>
                ifTrue: [^ CharacterBlock new stringIndex: 1  &quot;like being off end of string&quot;<br>
                                        text: para text<br>
                                        topLeft: (para leftMarginForDisplayForLine: 1 alignment: (alignment ifNil:[textStyle alignment]))<br>
                                                                @ para compositionRectangle top<br>
                                        extent: 0 @ textStyle lineGrid].<br>
        &quot;find the line&quot;<br>
        lineIndex := para lineIndexOfTop: characterPoint y.<br>
        destY := para topAtLineIndex: lineIndex.<br>
        line := para lines at: lineIndex.<br>
        lastIndex := line first.<br>
-<br>
        rightMargin := para rightMarginForDisplay.<br>
+       self setStopConditions.  &quot; also loads the font, alignment and all emphasis attributes &quot;<br>
-      self setStopConditions.  &quot; also loads the font and loads all emphasis attributes &quot;<br>
<br>
-<br>
        (lineIndex = para numberOfLines and:<br>
                [(destY + line lineHeight) &lt; characterPoint y])<br>
                        ifTrue: [&quot;if beyond lastLine, force search to last character&quot;<br>
                                        self characterPointSetX: rightMargin]<br>
                        ifFalse:        [characterPoint y &lt; (para compositionRectangle) top<br>
                                                ifTrue: [&quot;force search to first line&quot;<br>
                                                                characterPoint := (para compositionRectangle) topLeft].<br>
                                        characterPoint x &gt; rightMargin<br>
                                                ifTrue: [self characterPointSetX: rightMargin]].<br>
+       destX := leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: alignment.<br>
+       nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: alignment.<br>
+       runLength := text runLengthFor: line first.<br>
+       lineStop := characterIndex      &quot;scanning for index&quot;<br>
+               ifNil: [ line last ].                   &quot;scanning for point&quot;<br>
+       runStopIndex := lastIndex + (runLength - 1) min: lineStop.<br>
-       destX := (leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment])).<br>
-       nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: (alignment ifNil:[textStyle alignment]).<br>
-       lastIndex := line first.<br>
-<br>
-       self setStopConditions.         &quot;also sets font&quot;<br>
-       runLength := (text runLengthFor: line first).<br>
-       characterIndex == nil<br>
-               ifTrue: [lineStop := line last  &quot;characterBlockAtPoint&quot;]<br>
-               ifFalse:        [lineStop := characterIndex  &quot;characterBlockForIndex&quot;].<br>
-       (runStopIndex := lastIndex + (runLength - 1)) &gt; lineStop<br>
-               ifTrue: [runStopIndex := lineStop].<br>
        lastCharacterExtent := 0 @ line lineHeight.<br>
+       spaceCount := 0.<br>
-       spaceCount := 0. done  := false.<br>
        self handleIndentation.<br>
<br>
-       [done]<br>
-       whileFalse:<br>
        [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex<br>
                        in: text string rightX: characterPoint x<br>
                        stopConditions: stopConditions kern: kern.<br>
+       &quot;see setStopConditions for stopping conditions for character block operations.&quot;<br>
-<br>
-       &quot;see setStopConditions for stopping conditions for character block      operations.&quot;<br>
        self lastCharacterExtentSetX: (font widthOf: (text at: lastIndex)).<br>
+       self perform: stopCondition] whileFalse.<br>
+<br>
+       ^characterIndex == nil<br>
-       (self perform: stopCondition) ifTrue:<br>
-               [characterIndex == nil<br>
                        ifTrue: [&quot;characterBlockAtPoint&quot;<br>
                                        ^ CharacterBlock new stringIndex: lastIndex text: text<br>
                                                topLeft: characterPoint + (font descentKern @ 0)<br>
                                                extent: lastCharacterExtent]<br>
                        ifFalse: [&quot;characterBlockForIndex&quot;<br>
                                        ^ CharacterBlock new stringIndex: lastIndex text: text<br>
                                                topLeft: characterPoint + ((font descentKern) - kern @ 0)<br>
+                                               extent: lastCharacterExtent]!<br>
-                                               extent: lastCharacterExtent]]]!<br>
<br>
Item was changed:<br>
  CharacterScanner subclass: #CompositionScanner<br>
        instanceVariableNames: &#39;spaceX spaceIndex lineHeight baseline lineHeightAtSpace baselineAtSpace&#39;<br>
        classVariableNames: &#39;&#39;<br>
+       poolDictionaries: &#39;&#39;<br>
-       poolDictionaries: &#39;TextConstants&#39;<br>
        category: &#39;Graphics-Text&#39;!<br>
<br>
  !CompositionScanner commentStamp: &#39;&lt;historical&gt;&#39; prior: 0!<br>
  CompositionScanners are used to measure text and determine where line breaks and space padding should occur.!<br>
<br>
Item was changed:<br>
  ----- Method: DisplayScanner&gt;&gt;displayLines:in:clippedBy: (in category &#39;MVC-compatibility&#39;) -----<br>
  displayLines: linesInterval in: aParagraph clippedBy: visibleRectangle<br>
        &quot;The central display routine. The call on the primitive<br>
        (scanCharactersFrom:to:in:rightX:) will be interrupted according to an<br>
        array of stop conditions passed to the scanner at which time the code to<br>
        handle the stop condition is run and the call on the primitive continued<br>
        until a stop condition returns true (which means the line has<br>
        terminated).&quot;<br>
        | leftInRun |<br>
        &quot;leftInRun is the # of characters left to scan in the current run;<br>
                when 0, it is time to call &#39;self setStopConditions&#39;&quot;<br>
        morphicOffset := 0@0.<br>
        leftInRun := 0.<br>
        self initializeFromParagraph: aParagraph clippedBy: visibleRectangle.<br>
        ignoreColorChanges := false.<br>
        foregroundColor := paragraphColor := aParagraph foregroundColor.<br>
        backgroundColor := aParagraph backgroundColor.<br>
        aParagraph backgroundColor isTransparent<br>
                ifTrue: [fillBlt := nil]<br>
                ifFalse: [fillBlt := bitBlt copy.  &quot;Blt to fill spaces, tabs, margins&quot;<br>
                                fillBlt sourceForm: nil; sourceOrigin: 0@0.<br>
                                fillBlt fillColor: aParagraph backgroundColor].<br>
        rightMargin := aParagraph rightMarginForDisplay.<br>
        lineY := aParagraph topAtLineIndex: linesInterval first.<br>
        bitBlt destForm deferUpdatesIn: visibleRectangle while: [<br>
                linesInterval do:<br>
                        [:lineIndex |<br>
+                       | string startIndex lastPos runLength stopCondition baselineY |<br>
-                       | string startIndex lastPos runLength stopCondition |<br>
                        line := aParagraph lines at: lineIndex.<br>
                        lastIndex := line first.<br>
+                       leftInRun &lt;= 0<br>
+                               ifTrue: [self setStopConditions.  &quot;also sets the font, alignment and emphasisCode&quot;<br>
+                                               leftInRun := text runLengthFor: line first].<br>
+                       leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: alignment.<br>
+                       destX := runX := leftMargin.<br>
-                self setStopConditions. &quot; causes an assignment to inst var.  alignment &quot;<br>
-<br>
-                       leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment]).<br>
-                       destX := (runX := leftMargin).<br>
-                       line := aParagraph lines at: lineIndex.<br>
                        lineHeight := line lineHeight.<br>
                        fillBlt == nil ifFalse:<br>
                                [fillBlt destX: visibleRectangle left destY: lineY<br>
                                        width: visibleRectangle width height: lineHeight; copyBits].<br>
+                       baselineY := lineY + line baseline.<br>
+                       destY := baselineY - font ascent.  &quot;Should have happened in setFont&quot;<br>
-                       lastIndex := line first.<br>
-                       leftInRun &lt;= 0<br>
-                               ifTrue: [self setStopConditions.  &quot;also sets the font&quot;<br>
-                                               leftInRun := text runLengthFor: line first].<br>
-                       destY := lineY + line baseline - font ascent.  &quot;Should have happened in setFont&quot;<br>
                        runLength := leftInRun.<br>
                        runStopIndex := lastIndex + (runLength - 1) min: line last.<br>
                        leftInRun := leftInRun - (runStopIndex - lastIndex + 1).<br>
                        spaceCount := 0.<br>
                        string := text string.<br>
                        self handleIndentation.<br>
                        [<br>
                                startIndex := lastIndex.<br>
                                lastPos := destX@destY.<br>
                                stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex<br>
                                                        in: string rightX: rightMargin stopConditions: stopConditions<br>
                                                        kern: kern.<br>
                                lastIndex &gt;= startIndex ifTrue:[<br>
                                        font displayString: string on: bitBlt<br>
                                                from: startIndex to: lastIndex at: lastPos kern: kern].<br>
                                &quot;see setStopConditions for stopping conditions for displaying.&quot;<br>
                                self perform: stopCondition<br>
                        ] whileFalse.<br>
                        fillBlt == nil ifFalse:<br>
                                [fillBlt destX: destX destY: lineY width: visibleRectangle right-destX height: lineHeight; copyBits].<br>
                        lineY := lineY + lineHeight]]!<br>
<br>
<br>
</blockquote></div><br></div>