[squeak-dev] The Trunk: Graphics-tpr.222.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 4 00:00:52 UTC 2013


tim Rowledge uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-tpr.222.mcz

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

Name: Graphics-tpr.222
Author: tpr
Time: 3 September 2013, 4:59:59.45 pm
UUID: d3d465a1-3295-478b-bd0a-860722710e69
Ancestors: Graphics-fbs.221

Add some comments to a few important methods to, y'know, actually help readers understand WTF is going on.
Part of fixing Mantis-01781 7 years after it was reported.

=============== Diff against Graphics-fbs.221 ===============

Item was changed:
  ----- Method: FixedFaceFont>>glyphInfoOf:into: (in category 'private') -----
  glyphInfoOf: aCharacter into: glyphInfoArray
+ "since we replace every character with substitutionCharacter, get my baseFont's glyphInfo for that"
- 
  	^ baseFont glyphInfoOf: substitutionCharacter into: glyphInfoArray.
  !

Item was changed:
  ----- Method: StrikeFont>>displayMultiString:on:from:to:at:kern:baselineY: (in category 'displaying') -----
  displayMultiString: aString on: aBitBlt from: startIndex to: stopIndex at: aPoint kern: kernDelta baselineY: baselineY
+ "display a multi-byte character string"
- 
  	| leftX rightX glyphInfo char destY form gfont destX destPt |
  	destX := aPoint x.
  	glyphInfo := Array new: 5.
  	startIndex to: stopIndex do:[:charIndex|
  		char := aString at: charIndex.
  		(self hasGlyphOf: char) ifTrue: [
+ 			"I have that character ok, so display it and move on"
  			self glyphInfoOf: char into: glyphInfo.
  			form := glyphInfo at: 1.
  			leftX := glyphInfo at: 2.
  			rightX := glyphInfo at: 3.
  			destY := glyphInfo at: 4.
  			gfont := glyphInfo at: 5.
  			(gfont == aBitBlt lastFont) ifFalse: [gfont installOn: aBitBlt].
  			destY := baselineY - destY. 
  			aBitBlt displayGlyph: form at: destX @ destY left: leftX right: rightX font: self.
  			destX := destX + (rightX - leftX + kernDelta).
  		] ifFalse:[
+ 			"I'm missing that character so pass the job off to my fallback font; if one wasn't previously setup a default fixedfacefont will get used and show question-mark char(s). We pass the entire job to the font since we must not expect it to be a StrikeFont"
  			destPt := self fallbackFont displayString: aString on: aBitBlt from: charIndex to: charIndex at: destX @ aPoint y kern: kernDelta from: self baselineY: baselineY.
  			destPt x = destX ifTrue:[
  				"In some situations BitBlt doesn't return the advance width from the primitive.
  				Work around the situation"
  				destX := destX + (self widthOfString: aString from: charIndex to: charIndex) + kernDelta.
  			] ifFalse:[destX := destPt x].
  		].
  	].
  	^destX @ aPoint y
  !

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."
- glyphInfoOf: aCharacter into: glyphInfoArray
- 	"Answer the width of the argument as a character in the receiver."
- 
  	| code |
+ 	(self hasGlyphOf: aCharacter)
+ 		ifTrue: [code := aCharacter charCode]
+ 		ifFalse: [fallbackFont
+ 				ifNotNil: [^ fallbackFont glyphInfoOf: aCharacter into: glyphInfoArray].
+ 			code := 0].
- 	(self hasGlyphOf: aCharacter) ifFalse: [
- 		fallbackFont ifNotNil: [
- 			^ fallbackFont glyphInfoOf: aCharacter into: glyphInfoArray.
- 		].
- 		code := 0.
- 	] ifTrue: [
- 		code := aCharacter charCode.
- 	].
  	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!
- 		at: 5 put: self.
- 	^ glyphInfoArray.
- !



More information about the Squeak-dev mailing list