Improved TImageFonts

BlitzMax Forums/BlitzMax Module Tweaks/Improved TImageFonts

TartanTangerine (was Indiepath)(Posted 2005) [#1]
I've been having issues getting the Image Fonts to look nice at any scale... I had a root through the code and found the cause in imagefont.bmx in the Max2d.mod

First thing I noticed was Line 76 :
glyph._image=TImage.Load( pixmap.Copy(),0,0,0,_imageFlags )


Which according to the function it is calling it should be changed to:

glyph._image=TImage.Load( pixmap.Copy(),_imageFlags,0,0,0 )


I also noticed that there was no MIPMAPPEDIMAGE applied when using the SMOOTHFONT flag, so I changed Line 111 to :
If style & SMOOTHFONT font._imageFlags=FILTEREDIMAGE|MIPMAPPEDIMAGE

Oh and make sure you've got BlendMode(ALPHABLEND) set.

Now my fonts look real sexy :D


marksibly(Posted 2005) [#2]
Hi,

Well spotted - thanks!


Eric(Posted 2005) [#3]
Is this something that we should Sync Mods for?


Rambo_Bill(Posted 2005) [#4]
[edited for clarity] -- Should not post when drinking :P


Red(Posted 2005) [#5]
nice :)


Who was John Galt?(Posted 2005) [#6]
Nice one m8.


Najdorf(Posted 2005) [#7]
Hi, is this bug fix for version 1.10? I still have 1.09 and imagefont.bmx looks different (though it still does not work well).

Is this fixed in the latest modules?


Avon(Posted 2005) [#8]
Great job Tim! I would also like to know if this has been fixed for the 1.10 release?


AL(Posted 2005) [#9]
Hi Indiepath, ive applied your fix and then run the bmk makemods command, however im still seeing blurring and lines being missed off with the setimagefont and drawtext commands.

Can someone else try the following code, you need to move the text around until you get the x or y co-ordinate on a non-whole number (e.g. x=320.5). When this happens the text goes blurry and a line or two seems to get sliced from the side or top of the text:

SetGraphicsDriver GLMax2DDriver ()

bglSetSwapInterval(1)

Graphics(800,600,32)

arial_font = LoadImageFont("C:\WINDOWS\FONTS\ARIAL.TTF", 20, SMOOTHFONT)
SetImageFont(arial_font)

SetBlend(ALPHABLEND)

Local x:Float = GraphicsWidth() / 2
Local y:Float = GraphicsHeight() / 2

While Not KeyHit(KEY_ESCAPE)
  If KeyDown(KEY_UP)
    y :- 0.5
  Else If KeyDown(KEY_DOWN)
    y :+ 0.5
  End If

  If KeyDown(KEY_LEFT)
    x :- 0.5
  Else If KeyDown(KEY_RIGHT)
    x :+ 0.5
  End If

  Cls
  DrawText("SCROLLY TEXT....", x, y) 
  DrawText("More Text", x, y + 15)

  DrawText("X = " + x + "Y = " + y, 10, 10)

  Flip()
Wend



Difference(Posted 2005) [#10]
I get the line clipping too.
I have not applied the fix, but have synced modules.


Scott Shaver(Posted 2005) [#11]
The text in the above example seems fine on my windows machine. Have these changes been included in the sync mods stuff? My install is up to date with the latest.


Najdorf(Posted 2005) [#12]
Nah, this quite essential bug fix still hasn't been updated.


TartanTangerine (was Indiepath)(Posted 2005) [#13]
yey it's in the new update.


smilertoo(Posted 2005) [#14]
Is your 2d texture thing used for lighting in as well?