Odd glitch with font rendering?

BlitzMax Forums/BlitzMax Programming/Odd glitch with font rendering?

Robert(Posted 2005) [#1]
It seems that fonts are rendered in a very ugly way if you specify their position using a non-whole number:

Graphics 800,600,0


SetBlend ALPHABLEND


Local displayText:TImageFont=LoadImageFont("C:\Windows\Fonts\ariblk.ttf",16,SMOOTHFONT)
SetImageFont displayText



Repeat
	
	DrawText "This Text Looks Wrong (Position with decimal)",50.5,50.5
	
	
	DrawText "This Text Looks Fine (Using integers to set position)",55,95
	
	Flip
	Cls
Until KeyHit(KEY_ESCAPE)


In addition, what exactly does it mean if you specify the position of something with a non-whole number? Since the smallest unit of display is the pixel. Does it colour nearby pixels (ie. if you were to draw a red pixel at 0.5,0.5 how would that be shown)


skidracer(Posted 2005) [#2]
Like scaling and rotation, subpixel positioning will use bi-linear filtering to determine target pixel color. The result is OK for moving text but yes, stationery text should be positioned on pixel boundaries for best effect.


Mirko(Posted 2005) [#3]
There is another strage thing. Try it with fontsize of 120 or higher and the program crashes. use a fontsize lower then 120 an it will render the text.

Tried it with another font and there the 'crashing-border' is only 30. Very strange.

Greetings
Mirko


Robert(Posted 2005) [#4]
Confirmed.

I get an 'Unhandled Memory Exception Error' in a call to FT_Render_Glyph inside the TFreeTypeFont.Load function. [freetypefont.bmx - Line 163]


Daz(Posted 2005) [#5]
Robert, I have a problem with displaying fonts too, but the problem is slightly different. When running a slightly modified version of your original code:
Graphics 800,600,0


SetBlend ALPHABLEND


Local displayText:TImageFont=LoadImageFont("C:\Windows\Fonts\ariblk.ttf",16,SMOOTHFONT)
Local displayText2:TImageFont=LoadImageFont("c:\windows\Fonts\times.ttf", 16, SMOOTHFONT)
Local displayText3:TImageFont=LoadImageFont("c:\windows\Fonts\tahoma.ttf", 16, SMOOTHFONT)

Repeat
	SetImageFont displayText
	DrawText "ARIBLK.TTF - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10, 10
	SetImageFont displayText2
	DrawText "TIMES.TTF - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10, 50
	SetImageFont displayText3
	DrawText "TAHOMA.TTF - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10, 100
	Flip
	Cls
Until KeyHit(KEY_ESCAPE)


When I run this on my main PC (ATI radeon 9600 graphics card) everything is fine. When I run it on my laptop (integrated 64meg VIA/S3G Unichrome IGP) I find that, for all three fonts, the characters I, i and l (lower case L) are displayed corrupted; they are displayed at half the height they should be. All the other characters are displayed correctly.

I also find this behaviour happening when I am running Filax's IGlass gui.

Mark - if you would like a screen dump showing this problem let me know and I will email it to you.

Regards,
Darryl.