Why is TextHeight so far out?

BlitzMax Forums/BlitzMax Programming/Why is TextHeight so far out?

Grey Alien(Posted 2010) [#1]
I've found that TextHeight is always way higher than the actual drawn height of text on-screen, even for the built in font that gets used when the current ImageFont is null (it reports a height of 16 even if you draw a full-stop/period).

I've love an accurate TextHeight, but obviously it can't be changed now or it would break the alignment of many people games, but how about a new function called TextHeightAccurate or something?

And yes, I'm making sure SetScale 1,1 is used.


slenkar(Posted 2010) [#2]
you could use a fonttext module and hope that is more accurate?


Bremer(Posted 2010) [#3]
It looks like the calculation was taken out and replaced with a return of just the font height.

Function TextHeight( text$ )
	Return gc.image_font.Height()
	Rem
	Local height=0
	For Local n=0 Until text.length
		Local c=text[n]-image_font.BaseChar()
		If c<0 Or c>=image_font.CountGlyphs() Continue
		Local x,y,w,h
		image_font.Glyph(c).GetRect( x,y,w,h )
		height=Max(height,h)
	Next
	Return height
	End Rem
End Function



Grey Alien(Posted 2010) [#4]
Yowzer, I wonder when that was done? Perhaps it's already broken my old games if I was to recompile them?


ziggy(Posted 2010) [#5]
I think it's been like this since 1.21 or the like. This was modified very early.


Bremer(Posted 2010) [#6]
Not really sure when it was done, since I use my own bitmap font system. Now that I seen the change I do wonder why it was changed?


Grey Alien(Posted 2010) [#7]
Ah, OK if it's a really old mod then that's probably fine. I use bitmap fonts for my most recent games but not my early ones. Guess I should check them to see if anything is screwed, not sure what version BMax was when I started using it in summer 2006.