The Inbox: Tests-mtf.105.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Tests-mtf.105.mcz

commits-2
Matthew Fulmer uploaded a new version of Tests to project The Inbox:
http://source.squeak.org/inbox/Tests-mtf.105.mcz

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

Name: Tests-mtf.105
Author: mtf
Time: 21 December 2010, 6:43:08.673 pm
UUID: b77276f4-22c1-dd41-8749-ba8361445cc1
Ancestors: Tests-mtf.104

Illustrates a bug in antialiased strikefonts; the character scanner disagrees with the text composer on how wide paragraphs made of them are.

=============== Diff against Tests-mtf.104 ===============

Item was added:
+ TestCase subclass: #TextComposerScannerDiscrepency
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Tests-Bugs'!

Item was added:
+ ----- Method: TextComposerScannerDiscrepency>>testTextComposerAgreesWithScanner (in category 'as yet unclassified') -----
+ testTextComposerAgreesWithScanner
+ "Illustrates a bug in antialiased strikefonts; the character scanner disagrees with the text composer on how wide paragraphs made of them are. This was causing non-word-wrapped paragraphs in Tweak to have their last character chopped off. However I changed CTextParagraph >> adjustRightXBy: to behave like NewParagraph >> adjustRightX, and the visual effect of this bug went away. Nevertheless, it seems like it still should be fixed
+
+ The visual test duplicates the relevant bits of displaying non-word-wrapped text in an anti-aliased strikefont. See the following methods:
+
+ Morphic:
+ TextMorph >> paragraph
+ TextMorph >> drawOn:
+
+ Tweak:
+ CCostumeTextHolder >> updateParagraphExtent
+ CCostumeTextHolder >> drawOn:in:
+
+ and especially the core text drawing method:
+ MultiDisplayScanner >> displayLine:offset:leftInRun:
+ "
+
+ | container paragraph style scanner line scannerWidth text composerWidth |
+ text := 'Cancel' asText.
+ style := TextStyle named: 'Bitmap DejaVu Sans'. "AA StrikeFont. Test fails"
+ "style := TextStyle named: #Accuny." "Normal StrikeFont. Test passes"
+ "style := TextStyle named: #BitstreamVeraSans." "TTCFont. Test passes"
+
+ container := 0@0 extent: 999999999@999999999.
+ paragraph := NewParagraph new compose: text style: style from: 1 in: container.
+ composerWidth := paragraph composeAll.
+
+ "To see the results of the bug visually, do this (need Tweak before Tweak-Costume-mtf.116):
+ | canvas |
+ paragraph := CTextParagraph new compose: text style: style from: 1 in: container.
+ paragraph adjustRightXBy: 999999999 - paragraph width.
+ canvas := CTransformCanvas on: Display.
+ canvas transformBy: 20@20.
+ canvas paragraph: paragraph bounds: container color: Color black.
+
+ Then do this when you are done:
+ World clearTurtleTrails
+ "
+
+ self assert: (paragraph lines size = 1).
+ line := paragraph lines first.
+
+ scanner := MultiDisplayScanner new text: text textStyle: style
+ foreground: Color black background: Color transparent
+ fillBlt: nil ignoreColorChanges: false.
+ scanner initializeStringMeasurer.
+ scannerWidth := scanner measureString: text asString inFont: style defaultFont from: line first to: line last.
+
+ self assert: composerWidth = scannerWidth!