The Trunk: Multilingual-nice.175.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Multilingual-nice.175.mcz

commits-2
Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.175.mcz

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

Name: Multilingual-nice.175
Author: nice
Time: 27 September 2013, 12:55:42.866 am
UUID: 58c9e390-b2ac-4f1b-a842-81c9a43f7f86
Ancestors: Multilingual-tpr.174

Let MultiCharacterScanner properly handle #space stopCondition.
Restore DefaultStopsCondition at Space to just #space as it should.
Remove NilCondition and SpaceCondition.
Add a ColumnBreakStopConditions, this avoids any reason to copy the stopConditions.
Set stopConditions where it should be set (not in setFont, that's too weird).
Remove maxAscii handling: the font/fontSet shouldn't display charCode maxAscii when you ask maxAscii+10, should it?
Don't catch an Exception, just an Error.

=============== Diff against Multilingual-tpr.174 ===============

Item was removed:
- ----- Method: MultiCanvasCharacterScanner>>setStopConditions (in category 'stop conditions') -----
- setStopConditions
- "Set the font and the stop conditions for the current run."
-
- self setFont.
- self setConditionArray: (textStyle alignment = Justified ifTrue: [#paddedSpace]).
- !

Item was added:
+ ----- Method: MultiCanvasCharacterScanner>>space (in category 'stop conditions') -----
+ space
+ "Don't display the space, just skip the spaceWidth."
+
+ pendingKernX := 0.
+ destX := destX + spaceWidth.
+ lastIndex := lastIndex + 1.
+ ^ false!

Item was removed:
- ----- Method: MultiCharacterBlockScanner>>setStopConditions (in category 'stop conditions') -----
- setStopConditions
- "Set the font and the stop conditions for the current run."
-
- self setFont.
- self setConditionArray: (alignment = Justified ifTrue: [#paddedSpace]).
- !

Item was added:
+ ----- Method: MultiCharacterBlockScanner>>space (in category 'stop conditions') -----
+ space
+ "Account for spaceWidth"
+
+ spaceCount := spaceCount + 1.
+ lastSpaceOrTabExtent := lastCharacterExtent copy.
+ self lastSpaceOrTabExtentSetX:  spaceWidth.
+ (destX + lastSpaceOrTabExtent x)  >= characterPoint x
+ ifTrue: [lastCharacterExtent := lastSpaceOrTabExtent copy.
+ ^self crossedX].
+ lastIndex := lastIndex + 1.
+ destX := destX + lastSpaceOrTabExtent x.
+ ^ false
+ !

Item was changed:
  Object subclass: #MultiCharacterScanner
  instanceVariableNames: 'destX lastIndex destY stopConditions text textStyle alignment leftMargin rightMargin font line runStopIndex spaceCount spaceWidth emphasisCode kern indentationLevel wantsColumnBreaks pendingKernX baselineY firstDestX lastWidth'
+ classVariableNames: 'ColumnBreakStopConditions DefaultStopConditions PaddedSpaceCondition'
- classVariableNames: 'DefaultStopConditions NilCondition PaddedSpaceCondition SpaceCondition'
  poolDictionaries: 'TextConstants'
  category: 'Multilingual-Scanning'!

Item was changed:
  ----- Method: MultiCharacterScanner class>>initialize (in category 'class initialization') -----
  initialize
  "
  MultiCharacterScanner 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.
 
- NilCondition := a copy.
  DefaultStopConditions := a copy.
 
+ ColumnBreakStopConditions := a copy.
+ ColumnBreakStopConditions at: TextComposer characterForColumnBreak asciiValue + 1 put: #columnBreak.
+
  PaddedSpaceCondition := a copy.
  PaddedSpaceCondition at: Space asciiValue + 1 put: #paddedSpace.
-
- SpaceCondition := a copy.
- SpaceCondition at: Space asciiValue + 1 put: #space.
  !

Item was changed:
  ----- Method: MultiCharacterScanner>>scanMultiCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') -----
  scanMultiCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta
 
+ | ascii encoding f nextDestX startEncoding floatDestX widthAndKernedWidth nextChar atEndOfRun |
- | ascii encoding f nextDestX maxAscii startEncoding floatDestX widthAndKernedWidth nextChar atEndOfRun |
  lastIndex := startIndex.
  lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun].
  startEncoding := (sourceString at: startIndex) leadingChar.
  font ifNil: [font := (TextConstants at: #DefaultMultiStyle) fontArray at: 1].
  ((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
+ f := [font fontArray at: startEncoding + 1] ifError: [nil].
- f := [font fontArray at: startEncoding + 1]
- on: Exception do: [:ex | nil].
  f ifNil: [ f := font fontArray at: 1].
- maxAscii := f maxAscii.
  spaceWidth := f widthOf: Space.
- ] ifFalse: [
- maxAscii := font maxAscii.
  ].
  floatDestX := destX.
  widthAndKernedWidth := Array new: 2.
  atEndOfRun := false.
  [lastIndex <= stopIndex] whileTrue: [
  encoding := (sourceString at: lastIndex) leadingChar.
  encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun].
  ascii := (sourceString at: lastIndex) charCode.
+ (ascii < 256 and: [(stops at: ascii + 1) ~~ nil]) ifTrue: [^ stops at: ascii + 1].
- ascii > maxAscii ifTrue: [ascii := maxAscii].
- (encoding = 0 and: [ascii < 256 and: [(stops at: ascii + 1) ~~ nil]]) ifTrue: [^ stops at: ascii + 1].
  (self isBreakableAt: lastIndex in: sourceString in: Latin1Environment) ifTrue: [
  self registerBreakableIndex.
  ].
  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: (sourceString at: lastIndex)
  right: nextChar
  into: widthAndKernedWidth.
  nextDestX := floatDestX + (widthAndKernedWidth at: 1).
  nextDestX > rightX ifTrue: [destX ~= firstDestX 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!

Item was changed:
  ----- Method: MultiCharacterScanner>>setConditionArray: (in category 'private') -----
+ setConditionArray: aStopConditionOrNil
+ "This method is to be removed"
- setConditionArray: aSymbol
 
+ ^stopConditions := DefaultStopConditions!
- aSymbol == #paddedSpace ifTrue: [^stopConditions := PaddedSpaceCondition "copy"].
- "aSymbol == #space ifTrue: [^stopConditions := SpaceCondition copy]."
- aSymbol == nil ifTrue: [^stopConditions := NilCondition "copy"].
- self error: 'undefined stopcondition for space character'.
- !

Item was added:
+ ----- Method: MultiCharacterScanner>>setStopConditions (in category 'private') -----
+ setStopConditions
+ "Set the font and the stop conditions for the current run."
+
+ self setFont.
+ self setStopConditionsOrNil: (alignment = Justified ifTrue: [PaddedSpaceCondition]).!

Item was added:
+ ----- Method: MultiCharacterScanner>>setStopConditionsOrNil: (in category 'private') -----
+ setStopConditionsOrNil: aStopConditionOrNil
+
+ aStopConditionOrNil ifNotNil: [^stopConditions := aStopConditionOrNil].
+ ^stopConditions := DefaultStopConditions!

Item was changed:
  ----- Method: MultiCompositionScanner>>setStopConditions (in category 'stop conditions') -----
  setStopConditions
  "Set the font and the stop conditions for the current run."
 
+ self setFont.
+ self setStopConditionsOrNil: (wantsColumnBreaks == true ifTrue: [ColumnBreakStopConditions])!
- self setFont!

Item was added:
+ ----- Method: MultiCompositionScanner>>space (in category 'stop conditions') -----
+ space
+ "Record left x and character index of the space character just encounted.
+ Used for wrap-around. Answer whether the character has crossed the
+ right edge of the composition rectangle of the paragraph."
+
+ pendingKernX := 0.
+ breakAtSpace := true.
+ spaceX := destX.
+ destX := spaceX + spaceWidth.
+ spaceCount := spaceCount + 1.
+ lineHeightAtBreak := lineHeight.
+ baselineAtBreak := baseline.
+ breakableIndex := lastIndex.
+ lastIndex := lastIndex + 1.
+ destX > rightMargin ifTrue: [^self crossedX].
+ ^false
+
+ !

Item was removed:
- ----- Method: MultiDisplayScanner>>setStopConditions (in category 'stop conditions') -----
- setStopConditions
- "Set the font and the stop conditions for the current run."
-
- self setFont.
- self setConditionArray: (alignment = Justified ifTrue: [#paddedSpace]).
-
- "
- alignment = Justified ifTrue: [
- stopConditions == DefaultStopConditions
- ifTrue:[stopConditions := stopConditions copy].
- stopConditions at: Space asciiValue + 1 put: #paddedSpace]
- "!

Item was added:
+ ----- Method: MultiDisplayScanner>>space (in category 'stop conditions') -----
+ space
+ "Don't display the space, just skip the spaceWidth"
+
+ spaceCount := spaceCount + 1.
+ destX := destX + spaceWidth.
+ lastIndex := lastIndex + 1.
+ pendingKernX := 0.
+ ^ false!