Nice looking imagefonts?

BlitzMax Forums/BlitzMax Programming/Nice looking imagefonts?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Interesting... do you use style=SMOOTHFONT?

have a look at this:
(requires fedprm27p.ttf from here

Graphics 600,600,0
SetBlend ALPHABLEND

Local fonts:timagefont[5]

style=SMOOTHFONT
tf:tfont=tfont.Create("fonts/FeDPrm27P.ttf",.94,.1,style)
While 1
	y#=0
	txt$="hello there, you"
	For c=1 To 10
		size#=c*(1+10.0*MouseX()/600.0)
		y:+tf.height(size)
		tf.draw txt,0,y,size
		DrawLine 0,y,tf.width(txt,size),y
	Next
	Flip
	Cls
	
	If MouseHit(1)
		style=SMOOTHFONT-style
		tf:tfont=tfont.Create("fonts/FeDPrm27P.ttf",.94,.1,style)
	EndIf
	
	If AppTerminate() Or KeyHit(KEY_ESCAPE)
		End
	EndIf
Wend
WaitKey

Function gety()
	While Not MouseHit(1)
		DrawText "hello there, you",0,0
		DrawLine 0,MouseY(),600,MouseY()
		Flip
		Cls
	Wend
	Return MouseY()
End Function

Type tfont
	Field h#
	Field jiggle#
	Field images:timagefont[5]
	Field scale#
	Field i
	
	Function Create:tfont(fname$,height#,jiggle#,style)
		tf:tfont=New tfont
		tf.h=height
		tf.jiggle=jiggle
		tf.makesizes fname,style
		Return tf
	End Function
	
	Method makesizes(fname$,style)
		For x=1 To 5
			images[x-1]=LoadImageFont(fname,2^(x+3),style)
		Next
	End Method
	
	Method setfont(size#)
		'i=(size-5)/10
		i=Int((Log(size)/Log(2))-3)
		If i>4 i=4
		If i<0 i=0
		SetImageFont images[i]
		scale#=size/(2^(i+4))
		SetScale scale,scale
	End Method
	
	Method draw(txt$,x,y,size#)
		setfont size
		DrawText txt+i+" ("+scale+") "+size,x,y-height(size)-jiggle*size
		SetScale 1,1
	End Method
	
	Method height#(size#)
		Return h*size
	End Method
	
	Method width#(txt$,size#)
		setfont size
		w#=TextWidth(txt)*scale
		SetScale 1,1
		Return w
	End Method
End Type

Left click to toggle smoothfont.

It looks like the blurriness is caused by (tri/bi)linear filtering. Is there any way to get bmax to do more complicated filtering? I suppose the text looks ok with smoothfont turned off, I'm not sure which I prefer.

I'm planning on having a good amount of text around the 20-30 pixel height mark, which is where text looks the worst with both methods, but is at least legible with smoothfont turned on.