tim Rowledge uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-tpr.226.mcz ==================== Summary ==================== Name: Graphics-tpr.226 Author: tpr Time: 23 September 2013, 12:42:11.34 pm UUID: 842c37b1-aab4-41a7-b8ff-1411a96c4590 Ancestors: Graphics-tpr.225 A first step in improvingthe characterscanner tree(s); mostly split out kerning and non-kerning scanning. Also add some guide comments for later parts of the work, so some methods are only changed in comment. =============== Diff against Graphics-tpr.225 =============== Item was added: + ----- Method: AbstractFont>>isPairKerningCapable (in category 'testing') ----- + isPairKerningCapable + "a hopefully temporary test method; better factoring of scan/measure/display should remove the need for it. + Only FreeType fonts would currently add this to return true" + ^false! Item was removed: - ----- Method: AbstractFont>>widthAndKernedWidthOfLeft:right:into: (in category 'kerning') ----- - widthAndKernedWidthOfLeft: leftCharacter right: rightCharacterOrNil into: aTwoElementArray - "Set the first element of aTwoElementArray to the width of leftCharacter and - the second element to the width of left character when kerned with - rightCharacterOrNil. Answer aTwoElementArray" - | w k | - w := self widthOf: leftCharacter. - rightCharacterOrNil isNil - ifTrue:[ - aTwoElementArray - at: 1 put: w; - at: 2 put: w] - ifFalse:[ - k := self kerningLeft: leftCharacter right: rightCharacterOrNil. - aTwoElementArray - at: 1 put: w; - at: 2 put: w+k]. - ^aTwoElementArray - ! Item was changed: ----- Method: CharacterScanner>>basicScanCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- + basicScanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + "In ancient days this would have called primitive 103 to scan a string with StrikeFont, but time moves on. See historicalScanCharactersFrom:to:in:rightX:stopConditions:kern: if you're curious. This code handles the newer shape of CharacterScanner but does *no* pair kerning. + There is a pretty deep assumption of simple ASCII strings and characters - beware" + | ascii nextDestX char | - basicScanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta - "Primitive. This is the inner loop of text display--but see - scanCharactersFrom: to:rightX: which would get the string, - stopConditions and displaying from the instance. March through source - String from startIndex to stopIndex. If any character is flagged with a - non-nil entry in stops, then return the corresponding value. Determine - width of each character from xTable, indexed by map. - If dextX would exceed rightX, then return stops at: 258. - Advance destX by the width of the character. If stopIndex has been - reached, then return stops at: 257. Optional. - See Object documentation whatIsAPrimitive." - | ascii nextDestX char floatDestX widthAndKernedWidth nextChar atEndOfRun | - <primitive: 103> lastIndex := startIndex. - floatDestX := destX. - widthAndKernedWidth := Array new: 2. - atEndOfRun := false. [lastIndex <= stopIndex] + whileTrue: [ + "get the character value" + char := sourceString at: lastIndex. - whileTrue: - [char := (sourceString at: lastIndex). ascii := char asciiValue + 1. + "if there is an entry in 'stops' for this value, return it" + (stops at: ascii) + ifNotNil: [^ stops at: ascii]. + "bump nextDestX by the width of the current character" + nextDestX := destX + (font widthOf: char). + "if the next x is past the right edge, return crossedX" + nextDestX > rightX + ifTrue: [^ stops crossedX]. + "update destX and incorporate thr kernDelta" + destX := nextDestX + kernDelta. - (stops at: ascii) == nil ifFalse: [^stops at: ascii]. - "Note: The following is querying the font about the width - since the primitive may have failed due to a non-trivial - mapping of characters to glyphs or a non-existing xTable." - nextChar := (lastIndex + 1 <= stopIndex) - ifTrue:[sourceString at: lastIndex + 1] - ifFalse:[ - atEndOfRun := true. - "if there is a next char in sourceString, then get the kern - and store it in pendingKernX" - lastIndex + 1 <= sourceString size - ifTrue:[sourceString at: lastIndex + 1] - ifFalse:[ nil]]. - font - widthAndKernedWidthOfLeft: char - right: nextChar - into: widthAndKernedWidth. - nextDestX := floatDestX + (widthAndKernedWidth at: 1). - nextDestX > rightX ifTrue: [^stops crossedX]. - floatDestX := floatDestX + kernDelta + (widthAndKernedWidth at: 2). - atEndOfRun - ifTrue:[ - pendingKernX := (widthAndKernedWidth at: 2) - (widthAndKernedWidth at: 1). - floatDestX := floatDestX - pendingKernX]. - destX := floatDestX. lastIndex := lastIndex + 1]. lastIndex := stopIndex. + ^ stops endOfRun! - ^stops endOfRun! Item was added: + ----- Method: CharacterScanner>>basicScanKernableCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- + basicScanKernableCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + "In ancient days this would have called primitive 103 to scan a string with StrikeFont, but time moves on. See historicalScanCharactersFrom:to:in:rightX:stopConditions:kern: if you're curious. This code handles the newer shape of CharacterScanner and provides some support for fonts that have pair-kerning; this may be removable with some better factoring. + There is a pretty deep assumption of simple ASCII strings and characters - beware" + | ascii nextDestX char floatDestX widthAndKernedWidth nextCharOrNil atEndOfRun | + lastIndex := startIndex. + floatDestX := destX. + widthAndKernedWidth := Array new: 2. + atEndOfRun := false. + [lastIndex <= stopIndex] + whileTrue: [ + "get the character value" + char := sourceString at: lastIndex. + ascii := char asciiValue + 1. + "if there is an entry in 'stops' for this value, return it" + (stops at: ascii) + ifNotNil: [^ stops at: ascii]. + "get the next character..." + nextCharOrNil := lastIndex + 1 <= stopIndex + ifTrue: [sourceString at: lastIndex + 1] + ifFalse: ["if we're at or past the stopIndex, see if there is anything in the full string" + atEndOfRun := true. + lastIndex + 1 <= sourceString size + ifTrue: [sourceString at: lastIndex + 1]]. + "get the font's kerning info for the pair of current character and next character" + "for almost all fonts in common use this is a waste of time since they don't support pair kerning and both values are #widthOf: char" + font + widthAndKernedWidthOfLeft: char + right: nextCharOrNil + into: widthAndKernedWidth. + "bump nextDestX by the width of the current character" + nextDestX := floatDestX + + (widthAndKernedWidth at: 1). + "if the next x is past the right edge, return crossedX" + nextDestX > rightX + ifTrue: [^ stops crossedX]. + "bump floatDestX by the *kerned* width of the current + character, which is where the *next* char will go" + floatDestX := floatDestX + kernDelta + + (widthAndKernedWidth at: 2). + "if we are at the end of this run we keep track of the + character-kern-delta for possible later use and then rather + insanely remove that character-kern-delta from floatDestX, + making it equivalent to (old floatDestX) + kernDelta + + width-of-character - no idea why" + atEndOfRun + ifTrue: [pendingKernX := (widthAndKernedWidth at: 2) + - (widthAndKernedWidth at: 1). + floatDestX := floatDestX - pendingKernX]. + "save the next x for next time around the loop" + destX := floatDestX. + lastIndex := lastIndex + 1]. + lastIndex := stopIndex. + ^ stops endOfRun! Item was added: + ----- Method: CharacterScanner>>historicalScanCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- + historicalScanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + "Primitive. This is the inner loop of text display--but see + scanCharactersFrom: to:rightX: which would get the string, + stopConditions and displaying from the instance. March through source + String from startIndex to stopIndex. If any character is flagged with a + non-nil entry in stops, then return the corresponding value. Determine + width of each character from xTable, indexed by map. + If dextX would exceed rightX, then return stops at: 258. + Advance destX by the width of the character. If stopIndex has been + reached, then return stops at: 257. Optional. + See Object documentation whatIsAPrimitive. + Historical note: this primitive has been unusable since about Squeak 2.8 when the shape of the CharracterScanner class changed. It is left here as a reminder that the actual primitive still needs supporting in the VM to keep old images such as Scratch1.4 alive - tpr" + | ascii nextDestX char | + <primitive: 103> + lastIndex _ startIndex. + [lastIndex <= stopIndex] + whileTrue: + [char _ (sourceString at: lastIndex). + ascii _ char asciiValue + 1. + (stops at: ascii) == nil ifFalse: [^stops at: ascii]. + "Note: The following is querying the font about the width + since the primitive may have failed due to a non-trivial + mapping of characters to glyphs or a non-existing xTable." + nextDestX _ destX + (font widthOf: char). + nextDestX > rightX ifTrue: [^stops at: CrossedX]. + destX _ nextDestX + kernDelta. + lastIndex _ lastIndex + 1]. + lastIndex _ stopIndex. + ^stops at: EndOfRun + ! Item was changed: ----- Method: CharacterScanner>>isBreakableAtIndex: (in category 'scanner methods') ----- isBreakableAtIndex: index + "appears t obe unused - cf MultiCharacterScanner>isBreakableAt:in:in" - ^ (EncodedCharSet at: ((text at: index) leadingChar + 1)) isBreakableAt: index in: text. ! Item was changed: ----- Method: CharacterScanner>>scanCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- + scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta - scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta - | startEncoding selector | + sourceString isByteString + ifTrue: [font isPairKerningCapable + ifTrue: [^ self + basicScanKernableCharactersFrom: startIndex + to: (stopIndex min: sourceString size) + in: sourceString + rightX: rightX + stopConditions: stops + kern: kernDelta] + ifFalse: [^ self + basicScanCharactersFrom: startIndex + to: (stopIndex min: sourceString size) + in: sourceString + rightX: rightX + stopConditions: stops + kern: kernDelta]]. + sourceString isWideString + ifTrue: [startIndex > stopIndex + ifTrue: [lastIndex := stopIndex. + ^ stops endOfRun]. + startEncoding := (sourceString at: startIndex) leadingChar. + selector := EncodedCharSet scanSelectorAt: startEncoding. + ^ self + perform: selector + withArguments: (Array + with: startIndex + with: stopIndex + with: sourceString + with: rightX + with: stops + with: kernDelta)]. + ^ stops endOfRun! - (sourceString isByteString) ifTrue: [^ self basicScanCharactersFrom: startIndex to: (stopIndex min: sourceString size) in: sourceString rightX: rightX stopConditions: stops kern: kernDelta.]. - - (sourceString isWideString) ifTrue: [ - startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun]. - startEncoding := (sourceString at: startIndex) leadingChar. - selector := EncodedCharSet scanSelectorAt: startEncoding. - ^ self perform: selector withArguments: (Array with: startIndex with: stopIndex with: sourceString with: rightX with: stops with: kernDelta). - ]. - - ^ stops endOfRun - ! Item was removed: - ----- Method: CharacterScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') ----- - scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta - "Implement a workaround for unicode composing. - a MultiCharacterScanner should better be used to handle combination." - - ^self scanMultiCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta! |
Please tim, := assignments would be much appreciated :) 2013/9/23 <[hidden email]> tim Rowledge uploaded a new version of Graphics to project The Trunk: |
On 23-09-2013, at 1:34 PM, Nicolas Cellier <[hidden email]> wrote: > Please tim, := assignments would be much appreciated :) I wasn't aware of not using them, but fortunately it's only in a virtually-dead method. Oh, I see - it was like that before I renamed it to preserve it temporarily. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Useful random insult:- Has a pulse, but that's about all. |
The update did not work for me because widthAndKernedWidthOfLeft:right:into: was removed before its senders were changed. Unfortunately some TextMorph decided to update in between...2013/9/23 tim Rowledge <[hidden email]>
SqueakDebug.log (22K) Download Attachment |
On 23-09-2013, at 2:14 PM, Nicolas Cellier <[hidden email]> wrote: > The update did not work for me because widthAndKernedWidthOfLeft:right:into: was removed before its senders were changed. > Unfortunately some TextMorph decided to update in between… Damn. And all that work that was intended to prevent order dependency goes up in smoke… So how do we rescind a change? What else do I need to know to solve this? tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim The generation of random numbers is too important to be left to chance. |
The simplest thing that could work: restart after Graphics-tpr.226, restore the removed method publish Graphics-tpr.227.mcz. browse latest update mcm, update at least Graphics to Graphics-tpr.227, publish (store) the update mcm in trunk Then remove the method again and publish Graphics-tpr.228 in trunk Or a variant: browse mcm update, update graphics package, publish mcm update Merge Graphics-tpr.226, publish Graphics-tpr.228 in trunk 2013/9/24 tim Rowledge <[hidden email]>
|
The first variant is easier, and it will also work for those who have
managed to update to tpr.226. Levente On Tue, 24 Sep 2013, Nicolas Cellier wrote: > The simplest thing that could work: > restart after Graphics-tpr.226, restore the removed method publish Graphics-tpr.227.mcz. > browse latest update mcm, update at least Graphics to Graphics-tpr.227, publish (store) the update mcm in trunk > Then remove the method again and publish Graphics-tpr.228 in trunk > > Or a variant: > restart before Graphics-tpr.226, replay all changes but the remove, publish Graphics-tpr.227.mcz. > browse mcm update, update graphics package, publish mcm update > Merge Graphics-tpr.226, publish Graphics-tpr.228 in trunk > > > 2013/9/24 tim Rowledge <[hidden email]> > > On 23-09-2013, at 2:14 PM, Nicolas Cellier <[hidden email]> wrote: > > > The update did not work for me because widthAndKernedWidthOfLeft:right:into: was removed before its senders were changed. > > Unfortunately some TextMorph decided to update in between… > > Damn. And all that work that was intended to prevent order dependency goes up in smoke… > > So how do we rescind a change? What else do I need to know to solve this? > > > tim > -- > tim Rowledge; [hidden email]; http://www.rowledge.org/tim > The generation of random numbers is too important to be left to chance. > > > > > > |
But wait a minute before touching the update map, I have to first fix update-nice.246 which broke build.squeak.org
2013/9/24 Levente Uzonyi <[hidden email]> The first variant is easier, and it will also work for those who have managed to update to tpr.226. |
Done 2013/9/24 Nicolas Cellier <[hidden email]>
|
In reply to this post by Levente Uzonyi-2
Now I'm puzzled. My image still has the widthAndKernedWidthOfLeft:right:into: method. So far as I can tell it wasn't removed at any point. I see in your debug log that a StrikeFont dNU'd when sent it but I cannot see how that would happen - all my code did was modify it.
tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Oxymorons: Silent scream |
OK, I managed to update a trunk image (from build server) and I have fixed Graphics. The method is still in use, so we must not remove it indeed. 2013/9/24 tim Rowledge <[hidden email]> Now I'm puzzled. My image still has the widthAndKernedWidthOfLeft:right:into: method. So far as I can tell it wasn't removed at any point. I see in your debug log that a StrikeFont dNU'd when sent it but I cannot see how that would happen - all my code did was modify it. |
On 23-09-2013, at 4:19 PM, Nicolas Cellier <[hidden email]> wrote: > OK, I managed to update a trunk image (from build server) and I have fixed Graphics. > The method is still in use, so we must not remove it indeed. > > Is it possible that you moved the method into another category? > Ah, I get it, you certainly loaded FreeType which is full of nasty overrides and which took the ownership of the method… D'Oh. Not entirely sure how that happened since I don't recall deliberately adding it, but that makes sense. I see you corrected the package setting, I've just brought it back up to date. Thongs *should* be better now tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim The best packed information most resembles random noise. |
Free forum by Nabble | Edit this page |