[Pkg] The Trunk: Graphics-nice.289.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 17 22:30:48 UTC 2014


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

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

Name: Graphics-nice.289
Author: nice
Time: 17 February 2014, 11:29:40.779 pm
UUID: e809bcbf-53e1-420b-846a-9e86e0dd1f06
Ancestors: Graphics-nice.288

Fix incorrect display of underscore and caret in case of WideString displayed in DejaVu sans Strike fonts.

Those fonts map caret Character (ascii 94) and underscore Character (ascii 95) to xTable at: 128 and 129 to avoid display of up and left arrow (thanks to characterToGlypMap ivar)

But some StrikeFont methods did access directly the xTable, ignoring the indirection characterToGlypMap. This is incorrect, and lead to various layout problems because widthOf: correctly takes the indirection into account. Among those problems we can cite:
- incorrect measurement of strings,
- unconsistent placement of cursor,
- weird text selection

This fix is a serious candidate for inclusion in 4.5 release, but I let the maintainer decide...

=============== Diff against Graphics-nice.288 ===============

Item was changed:
  ----- Method: StrikeFont>>characterFormAt: (in category 'character shapes') -----
  characterFormAt: character 
  	"Answer a Form copied out of the glyphs for the argument, character."
  	| ascii leftX rightX |
+ 	ascii := self codeForCharacter: character.
- 	ascii := character charCode.
  	(ascii between: minAscii and: maxAscii) ifFalse: [ascii := maxAscii + 1].
  	leftX := xTable at: ascii + 1.
  	rightX := xTable at: ascii + 2.
  	leftX < 0 ifTrue: [^ glyphs copy: (0 at 0 corner: 0 at self height)].
  	^ glyphs copy: (leftX @ 0 corner: rightX @ self height)!

Item was removed:
- ----- Method: StrikeFont>>characterFormAtMulti: (in category 'character shapes') -----
- characterFormAtMulti: character 
- 	"Answer a Form copied out of the glyphs for the argument, character."
- 	| ascii leftX rightX |
- 	ascii := character charCode.
- 	(ascii between: minAscii and: maxAscii) ifFalse: [ascii := maxAscii + 1].
- 	leftX := xTable at: ascii + 1.
- 	rightX := xTable at: ascii + 2.
- 	^ glyphs copy: (leftX @ 0 corner: rightX @ self height)!

Item was changed:
  ----- Method: StrikeFont>>characters:in:displayAt:clippedBy:rule:fillColor:kernDelta:on: (in category 'displaying') -----
  characters: anInterval in: sourceString displayAt: aPoint clippedBy: clippingRectangle rule: ruleInteger fillColor: aForm kernDelta: kernDelta on: aBitBlt
  	"Simple, slow, primitive method for displaying a line of characters.
  	No wrap-around is provided."
  	| destPoint |
  	destPoint := aPoint.
  	anInterval do: 
  		[:i | | sourceRect leftX ascii rightX |
  		self flag: #yoDisplay.
  		"if the char is not supported, fall back to the specified fontset."
+ 		ascii := self codeForCharacter: (sourceString at: i).
- 		ascii := (sourceString at: i) charCode.
  		(ascii < minAscii or: [ascii > maxAscii])
  			ifTrue: [ascii := maxAscii].
  		leftX := xTable at: ascii + 1.
  		rightX := xTable at: ascii + 2.
  		sourceRect := leftX at 0 extent: (rightX-leftX) @ self height.
  		aBitBlt copyFrom: sourceRect in: glyphs to: destPoint.
  		destPoint := destPoint + ((rightX-leftX+kernDelta)@0).
  		"destPoint printString displayAt: 0@(i*20)"].
  	^ destPoint!

Item was added:
+ ----- Method: StrikeFont>>codeForCharacter: (in category 'private') -----
+ codeForCharacter: aCharacter
+ 	| code |
+ 	code := aCharacter charCode.
+ 	(self characterToGlyphMap isNil
+ 		or: [	characterToGlyphMap size <= code ])
+ 			ifTrue: [^code].
+ 	^characterToGlyphMap at: code + 1!

Item was changed:
  ----- Method: StrikeFont>>glyphInfoOf:into: (in category 'accessing') -----
  glyphInfoOf: aCharacter into: glyphInfoArray 
  	"return the glyph info for aCharacter; if I don't have such a character, try my fallback font, if I have one of those.
  	Unlike some other implementors, the returned info for a missing character is not given for the question-mark but rather the zero-ascii char."
  	| code |
  	(self hasGlyphOf: aCharacter)
+ 		ifTrue: [code := self codeForCharacter: aCharacter]
- 		ifTrue: [code := aCharacter charCode]
  		ifFalse: [fallbackFont
  				ifNotNil: [^ fallbackFont glyphInfoOf: aCharacter into: glyphInfoArray].
  			code := 0].
  	glyphInfoArray at: 1 put: glyphs;
  		at: 2 put: (xTable at: code + 1);
  		at: 3 put: (xTable at: code + 2);
  		at: 4 put: (self ascentOf: aCharacter);
  		 at: 5 put: self.
  	^ glyphInfoArray!

Item was changed:
  ----- Method: StrikeFont>>glyphOf: (in category 'accessing') -----
  glyphOf: aCharacter 
  	"Answer the width of the argument as a character in the receiver."
  
  	| code |
  	(self hasGlyphOf: aCharacter) ifFalse: [
  		fallbackFont ifNotNil: [
  			^ fallbackFont glyphOf: aCharacter.
  		].
  		^ (Form extent: 1 at self height) fillColor: Color white
  	].
+ 	code := self codeForCharacter: aCharacter.
- 	code := aCharacter charCode.
  	^ glyphs copy: (((xTable at: code + 1)@0) corner: (xTable at: code +2)@self height).
  !

Item was added:
+ ----- Method: StrikeFont>>hasGlyphForCode: (in category 'multibyte character methods') -----
+ hasGlyphForCode: aCharacterCode
+ 
+ 	((aCharacterCode between: self minAscii and: self maxAscii) not) ifTrue: [
+ 		^ false.
+ 	].
+ 	(xTable at: aCharacterCode + 1) < 0 ifTrue: [
+ 		^ false.
+ 	].
+ 	^ true.
+ !

Item was changed:
  ----- Method: StrikeFont>>hasGlyphOf: (in category 'multibyte character methods') -----
  hasGlyphOf: aCharacter
  
+ 	^self hasGlyphForCode: (self codeForCharacter: aCharacter)
- 	| code |
- 	code := aCharacter charCode.
- 	((code between: self minAscii and: self maxAscii) not) ifTrue: [
- 		^ false.
- 	].
- 	(xTable at: code + 1) < 0 ifTrue: [
- 		^ false.
- 	].
- 	^ true.
  !

Item was removed:
- ----- Method: StrikeFont>>leftAndRighOrNilFor: (in category 'private') -----
- leftAndRighOrNilFor: char
- 
- 	| code leftX |
- 	code := char charCode.
- 	((code between: self minAscii and: self maxAscii) not) ifTrue: [
- 		code := $? charCode.
- 	].
- 	leftX := xTable at: code + 1.
- 	leftX < 0 ifTrue: [
- 		code := $? charCode.
- 		leftX := xTable at: code + 1.
- 	].
- 	^ Array with: leftX with: (xTable at: code + 2).
- !



More information about the Packages mailing list