Bug? Scaled text jiggles badly.

BlitzMax Forums/BlitzMax Programming/Bug? Scaled text jiggles badly.

Grey Alien(Posted 2006) [#1]
Please try this code:

Strict
Graphics 800,600,0
Global Counter# = 0
Global Length# = 60*4
Global MainFont:TImageFont = LoadImageFont("C:\windows\fonts\arial.ttf",40,SMOOTHFONT)
SetImageFont MainFont	
While KeyHit(Key_Escape)=0
	'manage counter
	Counter:+1
	If Counter>Length Then
		Counter:-Length
	EndIf
	
	'draw the text
	Cls
	'set the scale
	Local scale# = 1 + Counter/Length
	SetScale scale,scale
	SetBlend Alphablend
	DrawText("Big line of Text",100,100)
	Flip
Wend

You should see a line of text in Arial font (on Windows systems) that grows larger over a few seconds. If you were to view any single frame on it's own, it would probably look fine, but as an animation it looks horrible because all the letters jiggle up and down as it scales. They appear to be jiggling as if an integer, not floating point y coord is being used for each letter (and they appear to be jiggling independently of each other - not all in sync). I'm not sure if it's doing it in the horizontal direction too, it's hard to tell.

Is this a 3D card/Texture artifact/issue to do with scaling or something that can be improved in the blitz max text handling code? Like a while ago when Skidracer improved the text code so it can draw at floating point coords without distortion.

Note that I've already used SMOOTHFONT and floating point coords throughout my code.

If I was to replace the text with an image, it scales perfectly without any integer jiggling, making me think this is something to do with the way that the text is drawn in BlitzMax when scaled.

Any ideas BRL? Thanks in advance for any feedback.


Yan(Posted 2006) [#2]
It would have taken you all of two minutes to fix this yourself!

I'll leave it to you to discover whereabouts in 'imagefonts.bmx' this has to go...
Method Draw( text$,x#,y#,ix#,iy#,jx#,jy# )

	For Local i=0 Until text.length
	
		Local n=CharToGlyph( text[i] )
		If n<0 Continue
		
		Local glyph:TImageGlyph=LoadGlyph(n)
		Local image:TImage=glyph._image
		
		Local tx#=glyph._x*ix+glyph._y*iy ' Changed tx to float
		Local ty#=glyph._x*jx+glyph._y*jy ' Changed ty to float			
		
		If image image.Frame(0).Draw 0,0,image.width,image.height,x+tx,y+ty
		
		x:+glyph._advance*ix
		y:+glyph._advance*jx
	Next
	
End Method
You should at least do some work, ya lazy git. ;op

[edit]
Updated to be less cryptic
[/edit]


Grey Alien(Posted 2006) [#3]

You should at least do some work, ya lazy git. ;op


:-O (;-)) Actually I don't tend to fiddle in the modules myself a) because I want my framework to work on "standard" unmodified modules and b) cos they are complicated and I don't want to break anything, wimper... oh and c) I've been coding all day (after staying up to 3am), haven't had lunch yet, and just want it to work nicely, sob. btw, thanks for the fix.

****
Anyway, I'd like to make a request that BRL make Yan's fix standard as there is no reason not to have it and scaled text will look a whole load better. Thanks.
****


Brucey(Posted 2006) [#4]
[edit]
...okay...

I'll check for posts before I post...

Go Yan! :-)


SculptureOfSoul(Posted 2006) [#5]
Tossing a Delay(50) in there helped clarify what I think the issue is.

It looks like the X,Y coordinate is not being determined for a bounding rectangle or for the string as a whole, but instead is being calculated for each individual letter. If you toss a Delay(50) in there, you'll see quite clearly that the capital B, capital T, the i's, etc - all of which are equally tall, all move at the same time. The lowercase g, o, e, x all move at the same time (and all share the same upper height value). The lowercase 't' is the oddbal and moves during it's own interval.

So, unfortunately, it looks like it's just a side effect of the nature of the DrawText function.


SculptureOfSoul(Posted 2006) [#6]
Haha, looks like I was late to the bus today too.


Grey Alien(Posted 2006) [#7]
Brucey: Saw you code, was the same, cool. Anyway the fix workds great, just want BRL to fix it now :-0 ...


Brucey(Posted 2006) [#8]
Raise a bug report, link to this post for the fix.

..might get it fixed quicker that way ;-)


Yan(Posted 2006) [#9]
GA - As I can't stand seeing a grown man cry, I'll let you off...Just this once, mind. ;o)

It'd probably be a good idea to make a bug report too.



Brucey and SOC - Hehe, I do that *all* the time. ;o)

[edit]
Just like that. ;o)
[/edit]


Grey Alien(Posted 2006) [#10]
raised in bug forum.
http://www.blitzbasic.com/Community/posts.php?topic=64711