[squeak-dev] The Trunk: Multilingual-nice.177.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 27 00:02:03 UTC 2013


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

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

Name: Multilingual-nice.177
Author: nice
Time: 27 September 2013, 2:01:29.748 am
UUID: 47adf8ed-c629-4475-bcfd-4616b47b5cc0
Ancestors: Multilingual-nice.176

Dont refer to TrueType, just use available isFontSet.
Don't catch Exception, only Error.
Don't mess with font maxAscii, the font will have to handle display requests of charCode above that.

=============== Diff against Multilingual-nice.176 ===============

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 f nextDestX startEncoding char charValue floatDestX widthAndKernedWidth nextChar |
- 	| encoding f nextDestX maxAscii 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].
- 	((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
- 		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.
  	[lastIndex <= stopIndex] whileTrue: [
  		encoding := (sourceString at: lastIndex) leadingChar.
  		encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun].
  		char := (sourceString at: lastIndex).
  		charValue := char charCode.
- 		charValue > maxAscii ifTrue: [charValue := maxAscii].
  		(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 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].
- 	((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
- 		f := [font fontArray at: startEncoding + 1]
- 			on: Exception do: [:ex | nil].
- 		f ifNil: [ f := font fontArray at: 1].
  		spaceWidth := f widthOf: Space.
  	] ifFalse: [
  		(font isMemberOf: HostFont) ifTrue: [
  			f := font.
  			spaceWidth := f widthOf: Space.
  		].
  	].
  	[lastIndex <= stopIndex] whileTrue: [
- 		"self halt."
  		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: [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 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].
- 	((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
- 		f := [font fontArray at: startEncoding + 1]
- 			on: Exception do: [:ex | nil].
- 		f ifNil: [ f := 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 ~= 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 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].
- 	((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
- 		f := [font fontArray at: startEncoding + 1] ifError: [nil].
- 		f ifNil: [ f := 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 ~= 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: MultiDisplayScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'multilingual scanning') -----
  scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta
  
  	| 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].
- 	((font isMemberOf: StrikeFontSet) or: [font isKindOf: TTCFontSet]) ifTrue: [
- 		f := [font fontArray at: startEncoding + 1]
- 			on: Exception do: [:ex | nil].
- 		f ifNil: [ f := 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!



More information about the Squeak-dev mailing list