Loading an image font needs more modules?

BlitzMax Forums/BlitzMax Programming/Loading an image font needs more modules?

William Drescher(Posted 2012) [#1]
I'm coding a timer and I want to load a custom font to use. My framework is as follows:

Framework brl.blitz
Import brl.d3d9max2d
Import brl.eventqueue
Import brl.font
Import brl.filesystem
Import brl.Graphics
Import brl.max2d
Import brl.pixmap
Import brl.retro
Import brl.system
Import brl.timer


This yields a Null for the TImageFont object. If I completely comment out the whole framework setup I can load the font easily with no problems. What am I missing?

Also does anyone know how to get anti-aliasing on image fonts? Is that even possible?

Last edited 2012


Zeke(Posted 2012) [#2]
yeap, youneed to import libs what you will use(if you are using frMMMWQOEK...

Last edited 2012


Brucey(Posted 2012) [#3]
brl.pngloader
brl.jpgloader

bah.freeimage
?


Bremer(Posted 2012) [#4]
LoadImageFont is part of brl.max2d, so it should be loaded since you have that in your list of imports. If you are getting a null value on load, then perhaps you are not pointing at the correct/valid font file.


William Drescher(Posted 2012) [#5]
I added brl.pngloader, brl.jpgloader, and even brl.tgaloader. It absolutely refuses to load the font unless I load every single module in the brl.mod folder and I would prefer not to have a 3 MB binary.


Floyd(Posted 2012) [#6]
Does Framework Assistant work with recent versions of BlitzMax? It might be worth a try.

http://homepage.ntlworld.com/config/fa/index.htm


William Drescher(Posted 2012) [#7]
Framework Assistant worked like a charm. I think the deciding factor was the BRL.FreeTypeFont, of which I was blissfully unaware.

Final output:
Framework BRL.GLMax2D
Import MaxGUI.Drivers
Import BRL.Timer
Import BRL.FreeTypeFont
Import BRL.EventQueue
Import BRL.Retro



Jur(Posted 2012) [#8]
TImageFont use true/free type fonts, so you should add brl.freetypefont.

Aha, you found it already :)

Last edited 2012


William Drescher(Posted 2012) [#9]
TImageFont use true/free type fonts, so you should add brl.freetypefont.


If it's required, why isn't it included in the max2d module? Better yet, why isn't it explained somewhere in the documentation that brl.freetypefont is required? I've been using BMax for years and I've never known that.

Someone higher up please make a note of this.


Arabia(Posted 2012) [#10]
I'm having the same issue. My code throws up an error "Unhandled Exception:Attempt to access field or method of Null object" on the line:

[bbcode]
SetImageFont font
[/bbcode]
Ran the code through Framework Assistant, made the suggested changes and this is what I've now got:

[bbcode]
Framework BRL.GLMax2D
Import BRL.FreeTypeFont
Import BRL.StandardIO
Import BRL.Retro

' modules which may be required:
' Import BRL.PNGLoader
' Import BRL.BMPLoader
' Import BRL.TGALoader
' Import BRL.JPGLoader


SetGraphicsDriver GLMax2DDriver()

Local fdir:String
Local font: TImagefont

Fdir="C:/Windows/fonts/"
font:TImagefont = LoadImageFont(Fdir+"arial.ttf",12, SMOOTHFONT)
If font = Null Then
Print "Font not loaded"
End
Else
SetImageFont font
EndIf
[/bbcode]

Any ideas what I'm doing wrong?

EDIT:

Problem fixed. You need to initialise the graphics before calling SetImageFont *face palm*

Ended up finding the answer by running one of Assari's examples which I remembered reading years ago.

Here

Last edited 2012


Russell(Posted 2013) [#11]
Framework Assistant is so valuable (and it's great that it still works with the latest version of BMax!). How hard would it be to incorporate its functionality into the Bmax (pre)compiler (or at least into the community edition)?

It is hugely useful for optimizing code size (and compilation speed on large projects)!

Russell