Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.232.mcz ==================== Summary ==================== Name: Graphics-nice.232 Author: nice Time: 27 September 2013, 1:46:10.919 am UUID: 472d6703-6dca-4bfd-ae45-bc4924574586 Ancestors: Graphics-nice.231 Restore two methods stolen by *TrueType and one by *Morphic. While at it, use the whileFalse: loop rather than repeat. =============== Diff against Graphics-nice.231 =============== Item was added: + ----- Method: CharacterScanner>>scanJapaneseCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') ----- + scanJapaneseCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta + + | 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 isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [ + f := font fontArray at: startEncoding + 1. + 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]. + nextDestX := destX + (font widthOf: (sourceString at: lastIndex)). + nextDestX > rightX ifTrue: [^ stops crossedX]. + destX := nextDestX + kernDelta. + "destX printString displayAt: 0@(lastIndex*20)." + lastIndex := lastIndex + 1. + ]. + lastIndex := stopIndex. + ^ stops endOfRun! Item was added: + ----- Method: CharacterScanner>>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 | + 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. + 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]. + nextDestX := destX + (font widthOf: (sourceString at: lastIndex)). + nextDestX > rightX ifTrue: [^ stops crossedX]. + destX := nextDestX + kernDelta. + "destX printString displayAt: 0@(lastIndex*20)." + lastIndex := lastIndex + 1. + ]. + lastIndex := stopIndex. + ^ stops endOfRun! Item was added: + ----- Method: CompositionScanner>>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. + 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" + line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0) + rectangle: lineRectangle. + self setStopConditions. "also sets font" + runLength := text runLengthFor: startIndex. + runStopIndex := (lastIndex := startIndex) + (runLength - 1). + spaceCount := 0. + 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! |
Free forum by Nabble | Edit this page |