Levente Uzonyi uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-ul.34.mcz
==================== Summary ====================
Name: GraphicsTests-ul.34
Author: ul
Time: 4 September 2013, 4:22:37.151 pm
UUID: 5a880e16-3d95-4f7c-bddf-a2e7a5952efc
Ancestors: GraphicsTests-tpr.33
- added a test for JPEGReadWriter2, which checks if images with high entropy data can be written in high quality
=============== Diff against GraphicsTests-tpr.33 ===============
Item was added:
+ TestCase subclass: #JPEGReadWriter2Test
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'GraphicsTests-Files'!
Item was added:
+ ----- Method: JPEGReadWriter2Test>>testHighEntropyImageCanBeWrittenInHighQuality (in category 'tests') -----
+ testHighEntropyImageCanBeWrittenInHighQuality
+
+ self
+ shouldnt: [
+ ByteArray streamContents: [ :stream |
+ | form rng |
+ form := Form extent: 20 @ 20 depth: 32.
+ rng := Random seed: 36rSQUEAK.
+ 0 to: form height do: [ :y |
+ 0 to: form width do: [ :x |
+ form pixelValueAt: x @ y put: (rng nextInt: 16r100000000) - 1 ] ].
+ (JPEGReadWriter2 on: stream)
+ nextPutImage: form quality: 100 progressiveJPEG: true ] ]
+ raise: Error!
Levente Uzonyi uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-ul.34.mcz
==================== Summary ====================
Name: GraphicsTests-ul.34
Author: ul
Time: 4 September 2013, 4:22:37.151 pm
UUID: 5a880e16-3d95-4f7c-bddf-a2e7a5952efc
Ancestors: GraphicsTests-tpr.33
- added a test for JPEGReadWriter2, which checks if images with high entropy data can be written in high quality
=============== Diff against GraphicsTests-tpr.33 ===============
Item was added:
+ TestCase subclass: #JPEGReadWriter2Test
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'GraphicsTests-Files'!
Item was added:
+ ----- Method: JPEGReadWriter2Test>>testHighEntropyImageCanBeWrittenInHighQuality (in category 'tests') -----
+ testHighEntropyImageCanBeWrittenInHighQuality
+
+ self
+ shouldnt: [
+ ByteArray streamContents: [ :stream |
+ | form rng |
+ form := Form extent: 20 @ 20 depth: 32.
+ rng := Random seed: 36rSQUEAK.
+ 0 to: form height do: [ :y |
+ 0 to: form width do: [ :x |
+ form pixelValueAt: x @ y put: (rng nextInt: 16r100000000) - 1 ] ].
+ (JPEGReadWriter2 on: stream)
+ nextPutImage: form quality: 100 progressiveJPEG: true ] ]
+ raise: Error!
tim Rowledge uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-tpr.167.mcz
==================== Summary ====================
Name: Multilingual-tpr.167
Author: tpr
Time: 3 September 2013, 5:02:14.904 pm
UUID: 370d09db-992b-4348-9062-79cfaacf0e5e
Ancestors: Multilingual-fbs.166
Provide a sensible implementation of #characterToGlyphMap to allow the intended primitive to do what it primitively does.
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 Multilingual-fbs.166 ===============
Item was added:
+ ----- Method: StrikeFontSet>>characterToGlyphMap (in category 'accessing') -----
+ characterToGlyphMap
+ "return the mapping for my first font; this follows the general form of all the other accessing methods but since we can't specifically find a font for a particualr character her we devolve to the first font in the fontArray - just like the other non-character-specific messages (#ascent etc).
+ This is only sent by the BitBlt>primDisplayString:from:to:map:xTable: method (other than internally by StrikeFont)"
+ ^fontArray first characterToGlyphMap!
Item was changed:
----- Method: StrikeFontSet>>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 characterset string; each character may require swapping to a new strikefont as discovered by glyphInfoOf:"
-
| destPoint leftX rightX glyphInfo g destY |
destPoint := aPoint.
glyphInfo := Array new: 5.
startIndex to: stopIndex do: [:charIndex |
self glyphInfoOf: (aString at: charIndex) into: glyphInfo.
g := glyphInfo at:1.
leftX := glyphInfo at:2.
rightX := glyphInfo at:3.
((glyphInfo at:5) ~= aBitBlt lastFont) ifTrue: [
(glyphInfo at:5) installOn: aBitBlt.
].
aBitBlt sourceForm: g.
destY := baselineY - (glyphInfo at:4).
aBitBlt destX: (destPoint x) destY: destY width: (rightX - leftX) height: (self height).
aBitBlt sourceOrigin: leftX @ 0.
aBitBlt copyBits.
destPoint := destPoint x + (rightX - leftX + kernDelta) @ destPoint y.
].
^ destPoint.!
Item was changed:
----- Method: StrikeFontSet>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return glyph info for the character; it can get complicated."
-
| index f code leftX |
+ "the leadingChar gives us an encoding. if that is outside the range of fonts in my fontArray, just return the default glyphInfo for a question-mark"
index := aCharacter leadingChar + 1.
fontArray size < index ifTrue: [^ self questionGlyphInfoInto: glyphInfoArray].
(f := fontArray at: index) ifNil: [^ self questionGlyphInfoInto: glyphInfoArray].
+ "if the actual character is not in the range supported by the chosen font, return that default question-mark info "
code := aCharacter charCode.
((code between: f minAscii and: f maxAscii) not) ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "if the xTable doesn't like the character, return that question-mark default info"
leftX := f xTable at: code + 1.
leftX < 0 ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "finally, we have an ok font and character to return glyph info about"
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: leftX;
at: 3 put: (f xTable at: code + 2);
at: 4 put: (f ascentOf: aCharacter);
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: StrikeFontSet>>questionGlyphInfoInto: (in category 'private') -----
questionGlyphInfoInto: glyphInfoArray
+ "return glyph info for the question mark character in the first font of the fontArray -sort of a default set of info"
-
| f ascii |
f := fontArray at: 1.
ascii := $? asciiValue.
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: (f xTable at: ascii + 1);
at: 3 put: (f xTable at: ascii + 2);
at: 4 put: (self ascentOf: $?);
at: 5 put: self.
^ glyphInfoArray.
!
tim Rowledge uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-tpr.167.mcz
==================== Summary ====================
Name: Multilingual-tpr.167
Author: tpr
Time: 3 September 2013, 5:02:14.904 pm
UUID: 370d09db-992b-4348-9062-79cfaacf0e5e
Ancestors: Multilingual-fbs.166
Provide a sensible implementation of #characterToGlyphMap to allow the intended primitive to do what it primitively does.
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 Multilingual-fbs.166 ===============
Item was added:
+ ----- Method: StrikeFontSet>>characterToGlyphMap (in category 'accessing') -----
+ characterToGlyphMap
+ "return the mapping for my first font; this follows the general form of all the other accessing methods but since we can't specifically find a font for a particualr character her we devolve to the first font in the fontArray - just like the other non-character-specific messages (#ascent etc).
+ This is only sent by the BitBlt>primDisplayString:from:to:map:xTable: method (other than internally by StrikeFont)"
+ ^fontArray first characterToGlyphMap!
Item was changed:
----- Method: StrikeFontSet>>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 characterset string; each character may require swapping to a new strikefont as discovered by glyphInfoOf:"
-
| destPoint leftX rightX glyphInfo g destY |
destPoint := aPoint.
glyphInfo := Array new: 5.
startIndex to: stopIndex do: [:charIndex |
self glyphInfoOf: (aString at: charIndex) into: glyphInfo.
g := glyphInfo at:1.
leftX := glyphInfo at:2.
rightX := glyphInfo at:3.
((glyphInfo at:5) ~= aBitBlt lastFont) ifTrue: [
(glyphInfo at:5) installOn: aBitBlt.
].
aBitBlt sourceForm: g.
destY := baselineY - (glyphInfo at:4).
aBitBlt destX: (destPoint x) destY: destY width: (rightX - leftX) height: (self height).
aBitBlt sourceOrigin: leftX @ 0.
aBitBlt copyBits.
destPoint := destPoint x + (rightX - leftX + kernDelta) @ destPoint y.
].
^ destPoint.!
Item was changed:
----- Method: StrikeFontSet>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return glyph info for the character; it can get complicated."
-
| index f code leftX |
+ "the leadingChar gives us an encoding. if that is outside the range of fonts in my fontArray, just return the default glyphInfo for a question-mark"
index := aCharacter leadingChar + 1.
fontArray size < index ifTrue: [^ self questionGlyphInfoInto: glyphInfoArray].
(f := fontArray at: index) ifNil: [^ self questionGlyphInfoInto: glyphInfoArray].
+ "if the actual character is not in the range supported by the chosen font, return that default question-mark info "
code := aCharacter charCode.
((code between: f minAscii and: f maxAscii) not) ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "if the xTable doesn't like the character, return that question-mark default info"
leftX := f xTable at: code + 1.
leftX < 0 ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "finally, we have an ok font and character to return glyph info about"
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: leftX;
at: 3 put: (f xTable at: code + 2);
at: 4 put: (f ascentOf: aCharacter);
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: StrikeFontSet>>questionGlyphInfoInto: (in category 'private') -----
questionGlyphInfoInto: glyphInfoArray
+ "return glyph info for the question mark character in the first font of the fontArray -sort of a default set of info"
-
| f ascii |
f := fontArray at: 1.
ascii := $? asciiValue.
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: (f xTable at: ascii + 1);
at: 3 put: (f xTable at: ascii + 2);
at: 4 put: (self ascentOf: $?);
at: 5 put: self.
^ glyphInfoArray.
!
tim Rowledge uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-tpr.167.mcz
==================== Summary ====================
Name: Multilingual-tpr.167
Author: tpr
Time: 3 September 2013, 5:02:14.904 pm
UUID: 370d09db-992b-4348-9062-79cfaacf0e5e
Ancestors: Multilingual-fbs.166
Provide a sensible implementation of #characterToGlyphMap to allow the intended primitive to do what it primitively does.
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 Multilingual-fbs.166 ===============
Item was added:
+ ----- Method: StrikeFontSet>>characterToGlyphMap (in category 'accessing') -----
+ characterToGlyphMap
+ "return the mapping for my first font; this follows the general form of all the other accessing methods but since we can't specifically find a font for a particualr character her we devolve to the first font in the fontArray - just like the other non-character-specific messages (#ascent etc).
+ This is only sent by the BitBlt>primDisplayString:from:to:map:xTable: method (other than internally by StrikeFont)"
+ ^fontArray first characterToGlyphMap!
Item was changed:
----- Method: StrikeFontSet>>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 characterset string; each character may require swapping to a new strikefont as discovered by glyphInfoOf:"
-
| destPoint leftX rightX glyphInfo g destY |
destPoint := aPoint.
glyphInfo := Array new: 5.
startIndex to: stopIndex do: [:charIndex |
self glyphInfoOf: (aString at: charIndex) into: glyphInfo.
g := glyphInfo at:1.
leftX := glyphInfo at:2.
rightX := glyphInfo at:3.
((glyphInfo at:5) ~= aBitBlt lastFont) ifTrue: [
(glyphInfo at:5) installOn: aBitBlt.
].
aBitBlt sourceForm: g.
destY := baselineY - (glyphInfo at:4).
aBitBlt destX: (destPoint x) destY: destY width: (rightX - leftX) height: (self height).
aBitBlt sourceOrigin: leftX @ 0.
aBitBlt copyBits.
destPoint := destPoint x + (rightX - leftX + kernDelta) @ destPoint y.
].
^ destPoint.!
Item was changed:
----- Method: StrikeFontSet>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return glyph info for the character; it can get complicated."
-
| index f code leftX |
+ "the leadingChar gives us an encoding. if that is outside the range of fonts in my fontArray, just return the default glyphInfo for a question-mark"
index := aCharacter leadingChar + 1.
fontArray size < index ifTrue: [^ self questionGlyphInfoInto: glyphInfoArray].
(f := fontArray at: index) ifNil: [^ self questionGlyphInfoInto: glyphInfoArray].
+ "if the actual character is not in the range supported by the chosen font, return that default question-mark info "
code := aCharacter charCode.
((code between: f minAscii and: f maxAscii) not) ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "if the xTable doesn't like the character, return that question-mark default info"
leftX := f xTable at: code + 1.
leftX < 0 ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+
+ "finally, we have an ok font and character to return glyph info about"
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: leftX;
at: 3 put: (f xTable at: code + 2);
at: 4 put: (f ascentOf: aCharacter);
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: StrikeFontSet>>questionGlyphInfoInto: (in category 'private') -----
questionGlyphInfoInto: glyphInfoArray
+ "return glyph info for the question mark character in the first font of the fontArray -sort of a default set of info"
-
| f ascii |
f := fontArray at: 1.
ascii := $? asciiValue.
glyphInfoArray at: 1 put: f glyphs;
at: 2 put: (f xTable at: ascii + 1);
at: 3 put: (f xTable at: ascii + 2);
at: 4 put: (self ascentOf: $?);
at: 5 put: self.
^ glyphInfoArray.
!
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.
- !
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.
- !
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.
- !
tim Rowledge uploaded a new version of TrueType to project The Trunk:
http://source.squeak.org/trunk/TrueType-tpr.26.mcz
==================== Summary ====================
Name: TrueType-tpr.26
Author: tpr
Time: 3 September 2013, 4:59:10.251 pm
UUID: 964516e1-f994-408b-9cc1-0a5b7408ad3a
Ancestors: TrueType-fbs.25
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 TrueType-fbs.25 ===============
Item was changed:
----- Method: MultiTTCFont>>glyphInfoOf:into: (in category 'as yet unclassified') -----
glyphInfoOf: char into: glyphInfoArray
+ "return glyph info for char; I may have cached info to work from"
-
| newForm |
self hasCached: char ifTrue: [:form :index |
self access: char at: index.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: (self ascentOf: char);
at: 5 put: self.
^ glyphInfoArray.
].
newForm := self computeForm: char.
self at: char put: newForm.
glyphInfoArray at: 1 put: newForm;
at: 2 put: 0;
at: 3 put: newForm width;
at: 4 put: (self ascentOf: char);
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFont>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return the glyph info for aCharacter; if I don't have such a character, try my fallback font"
- "Answer the width of the argument as a character in the receiver."
| form |
(self hasGlyphOf: aCharacter) ifFalse: [
^ self fallbackFont glyphInfoOf: aCharacter into: glyphInfoArray.
].
form := self formOf: aCharacter.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: ascent "(self ascentOf: aCharacter)";
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFontSet>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return glyph info for the character; it can get complicated."
-
| index f code |
+ "the leadingChar gives us an encoding. if that is outside the range of fonts in my fontArray, just return the default glyphInfo for a question-mark"
index := aCharacter leadingChar + 1.
fontArray size < index ifTrue: [^ self questionGlyphInfoInto: glyphInfoArray].
(f := fontArray at: index) ifNil: [^ self questionGlyphInfoInto: glyphInfoArray].
+ "if the actual character is not in the range supported by the chosen font, return that default question-mark info "
code := aCharacter charCode.
((code between: f minAscii and: f maxAscii) not) ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+ "finally, we have an ok font and character to return glyph info about - note that the font may have other ideas. "
f glyphInfoOf: aCharacter into: glyphInfoArray.
glyphInfoArray at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFontSet>>questionGlyphInfoInto: (in category 'private') -----
questionGlyphInfoInto: glyphInfoArray
+ "return glyph info for the question mark character in the first font of the fontArray -sort of a default set of info"
-
| f form |
f := fontArray at: 1.
form := f formOf: $?.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: self.
^ glyphInfoArray.
!
tim Rowledge uploaded a new version of TrueType to project The Trunk:
http://source.squeak.org/trunk/TrueType-tpr.26.mcz
==================== Summary ====================
Name: TrueType-tpr.26
Author: tpr
Time: 3 September 2013, 4:59:10.251 pm
UUID: 964516e1-f994-408b-9cc1-0a5b7408ad3a
Ancestors: TrueType-fbs.25
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 TrueType-fbs.25 ===============
Item was changed:
----- Method: MultiTTCFont>>glyphInfoOf:into: (in category 'as yet unclassified') -----
glyphInfoOf: char into: glyphInfoArray
+ "return glyph info for char; I may have cached info to work from"
-
| newForm |
self hasCached: char ifTrue: [:form :index |
self access: char at: index.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: (self ascentOf: char);
at: 5 put: self.
^ glyphInfoArray.
].
newForm := self computeForm: char.
self at: char put: newForm.
glyphInfoArray at: 1 put: newForm;
at: 2 put: 0;
at: 3 put: newForm width;
at: 4 put: (self ascentOf: char);
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFont>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return the glyph info for aCharacter; if I don't have such a character, try my fallback font"
- "Answer the width of the argument as a character in the receiver."
| form |
(self hasGlyphOf: aCharacter) ifFalse: [
^ self fallbackFont glyphInfoOf: aCharacter into: glyphInfoArray.
].
form := self formOf: aCharacter.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: ascent "(self ascentOf: aCharacter)";
at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFontSet>>glyphInfoOf:into: (in category 'private') -----
glyphInfoOf: aCharacter into: glyphInfoArray
+ "return glyph info for the character; it can get complicated."
-
| index f code |
+ "the leadingChar gives us an encoding. if that is outside the range of fonts in my fontArray, just return the default glyphInfo for a question-mark"
index := aCharacter leadingChar + 1.
fontArray size < index ifTrue: [^ self questionGlyphInfoInto: glyphInfoArray].
(f := fontArray at: index) ifNil: [^ self questionGlyphInfoInto: glyphInfoArray].
+ "if the actual character is not in the range supported by the chosen font, return that default question-mark info "
code := aCharacter charCode.
((code between: f minAscii and: f maxAscii) not) ifTrue: [
^ self questionGlyphInfoInto: glyphInfoArray.
].
+ "finally, we have an ok font and character to return glyph info about - note that the font may have other ideas. "
f glyphInfoOf: aCharacter into: glyphInfoArray.
glyphInfoArray at: 5 put: self.
^ glyphInfoArray.
!
Item was changed:
----- Method: TTCFontSet>>questionGlyphInfoInto: (in category 'private') -----
questionGlyphInfoInto: glyphInfoArray
+ "return glyph info for the question mark character in the first font of the fontArray -sort of a default set of info"
-
| f form |
f := fontArray at: 1.
form := f formOf: $?.
glyphInfoArray at: 1 put: form;
at: 2 put: 0;
at: 3 put: form width;
at: 4 put: self.
^ glyphInfoArray.
!