I've been working on a a simple file packer which stores multiple data files in one external file. The app then extracts the required file(s) by loading them into a bank and then creating a BankStream.
Ths works fine with images & sound, but does not seem to work with fonts. To break it down to it's simplest form, try the following (replace "myfont.ttf" with any font you have available):
The first line is drawn in the correct font as expected, but the second line uses the default blitz font indicating that it did not load the front from the Stream (even though technically it is the same file).
Is this a bug/limitation of Blitz Max, or is there a way of getting this to work? (e.g. loading a font from memory) I seem to recall a while ago that a similar problem occurred with incbining fonts - incbin fonts now work but I wonder if it is a related problem?
I have tried doing it so the font is extracted to a temp file which is then loaded, however, the temp file can not be deleted (I think LoadImageFont does not release the file?). Even if I could get this method to work, I would still prefer to load directly from memory.
Ths works fine with images & sound, but does not seem to work with fonts. To break it down to it's simplest form, try the following (replace "myfont.ttf" with any font you have available):
Strict Graphics 1024, 768, 0 SetBlend ALPHABLEND Local font1:TImageFont = LoadImageFont("myfont.ttf", 20) SetImageFont font1 DrawText "Normal font load", 10, 10 Local fontStream:TStream = ReadFile("myfont.ttf") Local font2:TImageFont = LoadImageFont(fontStream, 20) SetImageFont font2 DrawText "Stream font load", 10, 40 fontStream.Close Flip WaitKey End
The first line is drawn in the correct font as expected, but the second line uses the default blitz font indicating that it did not load the front from the Stream (even though technically it is the same file).
Is this a bug/limitation of Blitz Max, or is there a way of getting this to work? (e.g. loading a font from memory) I seem to recall a while ago that a similar problem occurred with incbining fonts - incbin fonts now work but I wonder if it is a related problem?
I have tried doing it so the font is extracted to a temp file which is then loaded, however, the temp file can not be deleted (I think LoadImageFont does not release the file?). Even if I could get this method to work, I would still prefer to load directly from memory.