GUI ==> Image Font Conversion
BlitzMax Forums/BlitzMax Programming/GUI ==> Image Font Conversion
Hi,
Is it possible to convert a GUI font (returned from the RequestFont() command) into a font type compatible with the Max2D Drawing commands. I've tried using guiFont.path$ to try and get the URL of the font so I can manually load it using LoadImageFont() however, it doesn't have a value even if you select a font.
Anyone any ideas?
Thanks
Seb
Could you use font.name?
Thanks for the suggestion but font.name returns the actual name of the font (e.g. Times New Roman) whereas LoadImageFont() requires the file path of the font, i.e. C:\Windows\Fonts\times.ttf [I think] . I suppose I could just use a pre-determined list but seeing as the program I'm making has to be cross-platform, it would require a lot of lines to add the standard font set and more for each OS.
font.path never seems to get populated and there doesn't seem to be a bbfontpath function.
There is
this but it probably doesn't help even with Skid's bump.
Seb, you might want to look at my fontconfig mod. It lets you use LoadImageFont without a full path. (Essentially it adds a new font-loader to Max, if you need to use it that way)
Hmmm... do I need a license for hawking ?
;-)
Thanks Brucey - I'll give it a go...
It's a shame stuff like this isn't implemented in the official mods.
tonyg: I've bumped the post anyway but I doubt it will be noticed seeing as it's in the Bug Bin.
I very much doubt anybody will see it there either. You might want a new post with a link to it.
Yeah, I'll probably do that. Regarding Brucey's mod, I've played around with it, and have made a function (which I've tested briefly) that should return an image font when a GUI font is passed to it.
<code removed> Stupidly, I didn't read the docs and you can load the font simply using its name once the module has been imported.
Thanks for the mod Brucey!
Interesting. I thought you could just call LoadImageFont and pass in the usual params for bold/italics. You certainly *don't* need the full path in LoadImageFont when the Fontconfig mod is present - it should resolve the path for you.
I might do some more testing.
Oh, and I believe it's also available via syncmods - bah.fontconfig.
Indeed... there's even a "drawtext" example included with the dist. (link via the documentation or look in the "examples" folder)
And here's a snippet:
Local font1:TImageFont = LoadImageFont( "verdana", 18, BOLDFONT | SMOOTHFONT)
Note the lack of path to the verdana font - fontconfig does all that for you - which is the whole point ;-)
The above mentioned example also shows how you can add "user" font folders which fontconfig can then include when it searches for the font you want.
HTH ;-)
Whoops - looks like I completely missed the point of it. Code has been removed. Thanks!
No worries ;-)
I had a function very similar to yours before I came up with the idea of adding a new image font loader..