Fonts - where are they?

BlitzMax Forums/BlitzMax Beginners Area/Fonts - where are they?

Brucey(Posted 2004) [#1]
It's nice to be back in the world of Blitz (having last played with it on my Amiga many moons ago), and thought I'd jump straight in and have a go with Fonts...

But I'm a bit stuck at the moment :-(

I thought... FreeType fonts... cool !.... then I tried it... not so cool...

I found that I have to have the .ttf file in my project folder to be able load the font. (from my experience with FreeType, I thought it would know the locations of my fonts for my particular OS - but I've had no joy so far...)

screenFont = TFreeTypeFont.Load("Tahoma.ttf",12,0)

And then... how to put them on screen?

The Glyphs are stored as pixmaps, and so I came up with...

sprint("The Quick Brown Fox Jumped Over The Lazy Dog", 10, 10)

Function sprint(s, x, y)
Local i, advance, char
For i = 1 To s.length
char = s[i-1] - 32
If (char > 0) Then
DrawPixmap screenFont.Glyph(char).pixels(), x + advance, y
advance:+ screenFont.Glyph(char).advance() + 1
Else
advance:+ 8
End If
Next
End Function

It's rather messy... has anyone a better method?
Or perhaps I'm missing something else that's un-documented?


:-/

Brucey


skidracer(Posted 2004) [#2]
There will be some extensions for locating system fonts in the future, at the moment yes, as you found (and for the purposes of enforcing cross platform programming techniques), you are restricted to loading fonts from known locations. Also freetype is used by default by the ImageFont commands so the following is all that is required:

Graphics 640,480
SetBlend ALPHABLEND
chicago=LoadImageFont("chicago.ttf",24)
SetImageFont chicago
DrawText "Hello World",0,0
Flip
WaitMouse



Brucey(Posted 2004) [#3]
Thanks :-)

I had previously an error trying to use LoadImageFont, which led me to believe I had to take the scenic route.


btw, are there any docs on forum posting? I like the quote boxes and things everyone uses, but can't find anything for it?

:o)


simonh(Posted 2004) [#4]
What are the forum codes?


BODYPRINT(Posted 2004) [#5]
[code][/code]
[codebox][/codebox]
[quote][/quote]


gburgess(Posted 2004) [#6]
There doesn't seem to be a fontheight command, and the textheight(string) command seems to give a smaller result than it should. Anyone else had that fault?


Ed(Posted 2005) [#7]
I've noticed this too, Glenny-boy. Bumping this thread to see if there's an answer...