Loading Local Font File as a GUI Font

BlitzMax Forums/MaxGUI Module/Loading Local Font File as a GUI Font

William Drescher(Posted 2010) [#1]
I am trying to load a font file named "EditFont.fon" as a text area font in MaxGUI but I keep running into a problem: The font in the file is mono spaced, but when you type in the text area, it is not.

Here's some of the code:
Global EditFont:TGuiFont = New TGuiFont
EditFont.Path = "./EditFont.fon"
EditFont.Size = 12
SetTextAreaFont editArea, EditFont


Why is the font not mono spaced in the text area?


GaryV(Posted 2010) [#2]
SetTextAreaFont is deprecated. You should be using SetGadgetFont.


William Drescher(Posted 2010) [#3]
Even so, the problem still persists.


SebHoll(Posted 2010) [#4]
MaxGUI doesn't support the specifying of a font by filename - it has to be installed onto the system (effectively copying into the Font folder), and then you can use LoadGuiFont().

Someone might have a neat way of tricking MaxGUI into using one, though.


William Drescher(Posted 2010) [#5]
After installing the font into the Windows font folder and using LoadGuiFont() the font worked perfectly. What I can't understand is why when I use my above method of loading the font, it loads the correct styled characters, but they are spaced wrong.


SebHoll(Posted 2010) [#6]
I think this is just a coincidence, i.e. if a Windows control is set a font handle that doesn't exist, it defaults to a rather retro looking one that is quite similar to the old BlitzCode font.

E.g. does the following produce the same results?

Global EditFont:TGuiFont = New TGuiFont
SetTextAreaFont editArea, EditFont



skidracer(Posted 2010) [#7]
The win32 command AddFontResource should allow you to register a font file so it can then be loaded by name.