IncBin and LoadImageFont

BlitzMax Forums/BlitzMax Beginners Area/IncBin and LoadImageFont

Mirko(Posted 2005) [#1]
Does LoadImageFont not work with IncBin ?

WithLoadImage it works fine, but i can't get LoadImageFont to use a fontfile included with incbin.


Perturbatio(Posted 2005) [#2]
no, it doesn't work with fonts.

I had considered writing an ImageToImageFont routine which would allow you to use incbin but I'm lazy :)


LeisureSuitLurie(Posted 2005) [#3]
It definitely doesn't...which sucks


marksibly(Posted 2005) [#4]
Hi,

Just had a look through freetype, and *think* this is doable.

Will keep hacking...


N(Posted 2005) [#5]
Er.. Why doesn't it work with IncBin? 0_o


marksibly(Posted 2005) [#6]
Hi,


Er.. Why doesn't it work with IncBin? 0_o



Because the FreeType library doesn't provide any IO 'hooks', the way the jpeg, png, ogg etc libraries do. Instead, it just uses the standard 'C' IO commands, which Max doesn't/can't intercept.

By hooks I mean callback functions that allow the calling app to provide IO mechanisms. With such hooks, the IO 'read' code can be Max code, which can then just use the standard Max stream system. Have a look at PNGLoader in brl.mod to see how the png lib is hooked.

However, trawling through the code it looks like FreeType does in fact localize it's IO to a single object-like struct which includes callbacks, and it will hopefully be possible to intercept things at this level.

This will mean messing with FreeType source code, which I'm not 100% happy about, but I think is worth it in this case.


N(Posted 2005) [#7]
Ah, I see.


marksibly(Posted 2005) [#8]
Well, I've successfully hooked it, but it's a little messy!

Something in freetype appears to be validating the filepath and rejecting Max's '::' 'stream protocol' prefix.

I've worked around it by stripping off the prefix before calling freetype, and reattaching it in the 'Open' callback. Ugly, but good enough for now!


Mirko(Posted 2005) [#9]
Whow, great news.
If the memory exception bug (reported here http://blitzbasic.com/Community/posts.php?topic=44935 )
will once be fixed too, BlitzMax will be 'the one and only' for my PC in my car ;-)

bye,
Mirko

[My car-pc-project, started a few years ago http://www.barchetta.info/ArtikelNr283 (text is german only)]