Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.180.mcz ==================== Summary ==================== Name: Multilingual-nice.180 Author: nice Time: 28 September 2013, 3:03:15.862 pm UUID: d6b37780-f157-4e5c-b555-e33e4d8d7e2c Ancestors: Multilingual-nice.179 More cleanups: 1) the scan* should not devise if font isNil isFontSet or whatever. Tell don't ask... They can legitimately assume that the font was correctly set, and should mind their own business. 2) remove accesses to inst. var. firstDestX. It can be replaced with leftMargin, they should in no case differ. There is one last inst. var. difference with CharacterScanner: lastWidth (just for Combining unicode) =============== Diff against Multilingual-nice.179 =============== Item was changed: ----- Method: MultiCharacterBlockScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + | encoding nextDestX startEncoding char charValue floatDestX widthAndKernedWidth nextChar | - | encoding f nextDestX startEncoding char charValue floatDestX widthAndKernedWidth nextChar | lastIndex := startIndex. lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun]. startEncoding := (sourceString at: startIndex) leadingChar. - font ifNil: [font := (TextConstants at: #DefaultMultiStyle) fontArray at: 1]. - font isFontSet ifTrue: [ - f := [font fontArray at: startEncoding + 1] ifError: [font fontArray at: 1]. - spaceWidth := f widthOf: Space. - ]. floatDestX := destX. widthAndKernedWidth := Array new: 2. [lastIndex <= stopIndex] whileTrue: [ encoding := (sourceString at: lastIndex) leadingChar. encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun]. char := (sourceString at: lastIndex). charValue := char charCode. (encoding = 0 and: [charValue < 256 and: [(stops at: charValue + 1) ~~ nil]]) ifTrue: [ ^ stops at: charValue + 1 ]. nextChar := (lastIndex + 1 <= stopIndex) ifTrue:[sourceString at: lastIndex + 1] ifFalse:[nil]. font widthAndKernedWidthOfLeft: ((char isMemberOf: CombinedChar) ifTrue:[char base] ifFalse:[char]) right: nextChar into: widthAndKernedWidth. nextDestX := floatDestX + (widthAndKernedWidth at: 1). nextDestX > rightX ifTrue: [^ stops crossedX]. floatDestX := floatDestX + kernDelta + (widthAndKernedWidth at: 2). destX := floatDestX. lastIndex := lastIndex + 1. ]. lastIndex := stopIndex. ^ stops endOfRun! Item was changed: ----- Method: MultiCharacterScanner>>scanJapaneseCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') ----- scanJapaneseCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + | ascii encoding nextDestX startEncoding | - | ascii encoding f nextDestX startEncoding | lastIndex := startIndex. lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun]. startEncoding := (sourceString at: startIndex) leadingChar. - font ifNil: [font := (TextConstants at: #DefaultMultiStyle) fontArray at: 1]. - font isFontSet ifTrue: [ - f := [font fontArray at: startEncoding + 1] ifError: [font fontArray at: 1]. - spaceWidth := f widthOf: Space. - ] ifFalse: [ - (font isMemberOf: HostFont) ifTrue: [ - f := font. - spaceWidth := f widthOf: Space. - ]. - ]. [lastIndex <= stopIndex] whileTrue: [ encoding := (sourceString at: lastIndex) leadingChar. encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun]. ascii := (sourceString at: lastIndex) charCode. (encoding = 0 and: [ascii < 256 and:[(stops at: ascii + 1) notNil]]) ifTrue: [^ stops at: ascii + 1]. (self isBreakableAt: lastIndex in: sourceString in: (EncodedCharSet charsetAt: encoding)) ifTrue: [ self registerBreakableIndex. ]. nextDestX := destX + (font widthOf: (sourceString at: lastIndex)). + nextDestX > rightX ifTrue: [leftMargin ~= destX ifTrue: [^ stops crossedX]]. - nextDestX > rightX ifTrue: [firstDestX ~= destX ifTrue: [^ stops crossedX]]. destX := nextDestX + kernDelta. lastIndex := lastIndex + 1. ]. lastIndex := stopIndex. ^ stops endOfRun! Item was changed: ----- Method: MultiCharacterScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') ----- scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta "appears to be unused" + | charCode encoding startEncoding combining combined combiningIndex c | - | charCode encoding f startEncoding combining combined combiningIndex c | lastIndex := startIndex. lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun]. startEncoding := (sourceString at: startIndex) leadingChar. - font ifNil: [font := (TextConstants at: #DefaultMultiStyle) fontArray at: 1]. - font isFontSet ifTrue: [ - f := [font fontArray at: startEncoding + 1] ifError: [font fontArray at: 1]. - ]. - - spaceWidth := font widthOf: Space. combining := nil. [lastIndex <= stopIndex] whileTrue: [ charCode := (sourceString at: lastIndex) charCode. c := (sourceString at: lastIndex). combining ifNil: [ combining := CombinedChar new. combining add: c. combiningIndex := lastIndex. lastIndex := lastIndex + 1. ] ifNotNil: [ (combining add: c) ifFalse: [ self addCharToPresentation: (combined := combining combined). combining := CombinedChar new. combining add: c. charCode := combined charCode. encoding := combined leadingChar. encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. (encoding = 0 and: [charCode < 256 and:[(stops at: charCode + 1) notNil]]) ifTrue: [ ^ stops at: charCode + 1 ] ifFalse: [ ^ stops endOfRun ]. ]. (encoding = 0 and: [charCode < 256 and:[(stops at: charCode + 1) notNil]]) ifTrue: [ combining ifNotNil: [ self addCharToPresentation: (combining combined). ]. ^ stops at: charCode + 1 ]. destX > rightX ifTrue: [ + destX ~= leftMargin ifTrue: [ - destX ~= firstDestX ifTrue: [ lastIndex := combiningIndex. self removeLastCharFromPresentation. ^ stops crossedX]]. combiningIndex := lastIndex. lastIndex := lastIndex + 1. ] ifTrue: [ lastIndex := lastIndex + 1. ]. ]. ]. lastIndex := stopIndex. combining ifNotNil: [ combined := combining combined. self addCharToPresentation: combined. ]. ^ stops endOfRun! 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 nextDestX startEncoding floatDestX widthAndKernedWidth nextChar atEndOfRun | - | ascii encoding f nextDestX 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 isFontSet ifTrue: [ - f := [font fontArray at: startEncoding + 1] ifError: [font fontArray at: 1]. - spaceWidth := f widthOf: Space. - ]. 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]. 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 ~= leftMargin ifTrue: [^stops crossedX]]. - 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: MultiCompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide: (in category 'scanning') ----- composeFrom: startIndex inRectangle: lineRectangle firstLine: firstLine leftSide: leftSide rightSide: rightSide "Answer an instance of TextLineInterval that represents the next line in the paragraph." | runLength stopCondition | "Set up margins" leftMargin := lineRectangle left. leftSide ifTrue: [leftMargin := leftMargin + (firstLine ifTrue: [textStyle firstIndent] ifFalse: [textStyle restIndent])]. destX := spaceX := leftMargin. - firstDestX := destX. rightMargin := lineRectangle right. rightSide ifTrue: [rightMargin := rightMargin - textStyle rightIndent]. lastIndex := startIndex. "scanning sets last index" destY := lineRectangle top. lineHeight := baseline := 0. "Will be increased by setFont" self setStopConditions. "also sets font" runLength := text runLengthFor: startIndex. runStopIndex := (lastIndex := startIndex) + (runLength - 1). line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0) rectangle: lineRectangle. spaceCount := 0. breakAtSpace := false. self handleIndentation. leftMargin := destX. line leftMargin: leftMargin. [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex in: text string rightX: rightMargin stopConditions: stopConditions kern: kern. "See setStopConditions for stopping conditions for composing." self perform: stopCondition] whileFalse. ^ line lineHeight: lineHeight + textStyle leading baseline: baseline + textStyle leading! Item was changed: ----- Method: MultiDisplayScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'multilingual scanning') ----- scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + | encoding nextDestX startEncoding char charValue | - | encoding f nextDestX startEncoding char charValue | lastIndex := startIndex. lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun]. startEncoding := (sourceString at: startIndex) leadingChar. - font ifNil: [font := (TextConstants at: #DefaultMultiStyle) fontArray at: 1]. - font isFontSet ifTrue: [ - f := [font fontArray at: startEncoding + 1] ifError: [font fontArray at: 1]. - spaceWidth := f widthOf: Space. - ]. - [lastIndex <= stopIndex] whileTrue: [ encoding := (sourceString at: lastIndex) leadingChar. encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun]. char := (sourceString at: lastIndex). charValue := char charCode. (encoding = 0 and: [charValue < 256 and:[(stops at: charValue + 1) notNil]]) ifTrue: [^stops at: charValue + 1]. nextDestX := destX + (font widthOf: char). nextDestX > rightX ifTrue: [^ stops crossedX]. destX := nextDestX + kernDelta. lastIndex := lastIndex + 1. ]. lastIndex := stopIndex. ^ stops endOfRun! |
Free forum by Nabble | Edit this page |