[BUG][FIX]character scanning primitive fails

Bob Arning arning at charm.net
Fri Jun 16 20:24:25 UTC 2000


On Fri, 16 Jun 2000 21:47:21 +0200 Hans-Martin Mosner <hm.mosner at cityweb.de> wrote:
>has anybody else noticed that Character scanning for the first line in a
>paragraph has slowed down in 2.8? Seems like the BitBltPlugin primitive
>that does it fails on the first call, but works for the others.
>Is there a solution?

Hans-Martin,

I see primitive failures in situations like:

DisplayScanner(CharacterScanner)>>primScanCharactersFrom:to:in:rightX:stopConditions:kern:
DisplayScanner>>stringWidth:
StringMorph>>fitContents
SystemWindow>>extent:
....

and

DisplayScanner(CharacterScanner)>>primScanCharactersFrom:to:in:rightX:stopConditions:kern:
DisplayScanner>>drawString:at:
FormCanvas>>text:bounds:font:color:
StringMorph>>drawOn:
....

I have included fixes for these below. Are you seeing failures elsewhere?

Cheers,
Bob


===== code follows =====
'From Squeak2.9alpha of 13 June 2000 [latest update: #2407] on 16 June 2000 at 4:16:37 pm'!
"Change Set:		lastIndexFix
Date:			16 June 2000
Author:			Bob Arning

Two methods in DisplayScanner #drawString:at: and #stringWidth: were not calling a primitive with lastIndex = nil which caused the primitive to fail and Smalltalk code to be executed in its place.

Set lastIndex to 1 in both cases and the primitive succeeds. The primitive fails if lastIndex is not an integer, but this test seems unimportant since it immediately stores the starting index into last index (i..e. it doesn't care *what* integer is there just as long as it is an integer)"!


!DisplayScanner methodsFor: 'quick print' stamp: 'RAA 6/16/2000 16:16'!
drawString: aString at: aPoint
	"Draw the given string."

	destX _ aPoint x asInteger.
	destY _ aPoint y asInteger.
	lastIndex _ 1.		"else the prim will fail"
	self primScanCharactersFrom: 1 to: aString size in: aString
		rightX: bitBlt clipX + bitBlt clipWidth + font maxWidth
		stopConditions: stopConditions kern: kern.
	font displayString: aString on: bitBlt from: 1 to: lastIndex at: aPoint kern: kern.! !

!DisplayScanner methodsFor: 'quick print' stamp: 'RAA 6/16/2000 16:16'!
stringWidth: aString
	"Answer the width of the given string."
	destX _ destY _ 0.
	aString ifNil: [^ 0].
	lastIndex _ 1.		"else the prim will fail"
	self primScanCharactersFrom: 1 to: aString size in: aString
		rightX: 99999	"virtual infinity"
		stopConditions: stopConditions
		kern: kern.
	^ destX
"
	(1 to: 10) collect: [:i | QuickPrint new stringWidth: (String new: i withAll: $A)]
"! !






More information about the Squeak-dev mailing list