[abandoned] Why can't Image Fonts be loaded via LoadBank()?

Started by Yellownakji, June 08, 2019, 21:00:45

Previous topic - Next topic

Yellownakji

I keep all my fonts inside a personal binary..  TrueTypeFonts, anyways.

For all of my assets, i load them from my custom asset bundle via LoadBank()..  works fine for audio and graphics..   but not fonts?    Why can't i load a TTF or OTF after it's data is returned as a bank? What makes this so special?

Anyone have an idea?

wombats


Yellownakji

Quote from: wombats on June 09, 2019, 02:17:42
I haven't tested it, but does this help?

Sorry for the late reply.

No, this technique does not seem to work for me.  However, this seems to be for loading fonts from streams, instead, which isn't what i particularly need.

Maybe i'll just take this up with Brucey.

Derron

Try to import brl.bankstream and use TBankStream to connect your "bank" to the useable "stream".


bye
Ron

Derron

Uploaded a Pull Request / Change to the brl.mod/freetypefont.mod code for bmx-ng.

Either Brucey accepts it - or comes up with a way better solution than me.


bye
Ron

Yellownakji

Quote from: Derron on June 13, 2019, 22:57:28
Uploaded a Pull Request / Change to the brl.mod/freetypefont.mod code for bmx-ng.

Either Brucey accepts it - or comes up with a way better solution than me.


bye
Ron

I asked something on the Git thread but i'll post here as well:

What is "override"?   Where is it defined? - It's currently reported as undefined and is preventing me from building.

Yellownakji

Has anyone tried to INCBIN a font?  Seems to just crash for me...  invalid stream.

Really odd.

Derron

Did not try "incbin::" but am already in discussion with Brucey.

Normally it _should_ work but maybe NG altered the way incbin:: is working and it needs an overhaul too.


bye
Ron

Yellownakji

Quote from: Derron on June 14, 2019, 07:18:16
Did not try "incbin::" but am already in discussion with Brucey.

Normally it _should_ work but maybe NG altered the way incbin:: is working and it needs an overhaul too.


bye
Ron

I saw you had some very recent updates just now.  Perhaps this may be the case, but i'm happy i could bring up this topic so we could improve NG as it's an amazing language.

I just built your latest updated commit;  I'll give it a whirl.

Yellownakji


Local fontBankStream:TStream = CreateBankStream(fontBank)
Local font:TImageFont = LoadImageFont(fontBankStream, 12)
SetImageFont(font)


Works as your example did.  Of course, i still need proper TBank support so that i can use my format specifically, as it returns a bank.   I appreciate this work, however.

Looking forward to further improvements.

Yellownakji


FNT.FontFile = SDA.Config.Merge(11) 'Returns BANK from archive into TBANK VAR
FNT.FontLoader = CreateBankStream(FNT.FontFile) 'TBankStream
FNT.Font12 = LoadImageFont(FNT.FontLoader, 40, SMOOTHFONT) 'Load it
SetImageFont(FNT.Font12) 'Set it


Fails.

You said utilize TBankStream, so i tried.   Never used it before..   wanted absolute TBank support, but someone decided it should end on streams.....

I would like to know why this fails.   Is bankstream being used wrong?

Derron

First of apl: Brucey wrote an official update for the module. Use this.

Also: you can check if the bankstream is valid, the bank is valid... Also check if the bank data is the same as in the original font file (compare size...and maybe even content)..

"Fails" is no helpful answer here...what exactly happens?

Bye
Ron

Yellownakji

Quote from: Derron on June 14, 2019, 21:15:02
First of apl: Brucey wrote an official update for the module. Use this.

Also: you can check if the bankstream is valid, the bank is valid... Also check if the bank data is the same as in the original font file (compare size...and maybe even content)..

"Fails" is no helpful answer here...what exactly happens?

Bye
Ron

It's the exact same file.   Same size and same contents;  Just merged into 1 big archive.

I use this method for all of my music, graphics and bitmap glyphs, so my format isn't the problem.

Fails, not crashes, so the app runs fine but the default font is still in place.

I am using Brucey's code...

Derron

Code (Blitzmax) Select

FNT.FontFile = SDA.Config.Merge(11) 'Returns BANK from archive into TBANK VAR
FNT.FontLoader = CreateBankStream(FNT.FontFile) 'TBankStream
FNT.Font12 = LoadImageFont(FNT.FontLoader, 40, SMOOTHFONT) 'Load it
SetImageFont(FNT.Font12) 'Set it

if not FNT.FontFile then Throw "FNT.FontFile not existing"
if not FNT.FontLoader then Throw "FNT.FontLoader not existing"
if not FNT.Font12 then Throw "FNT.Font12 not existing"


If font12 is null then you might dive into freetypefont.bmx "function load" and add some throw's in the positions where it does "return null" - this way you could narrow down where it fails.


bye
Ron

Yellownakji

#14
Quote from: Derron on June 14, 2019, 22:02:28
Code (Blitzmax) Select

FNT.FontFile = SDA.Config.Merge(11) 'Returns BANK from archive into TBANK VAR
FNT.FontLoader = CreateBankStream(FNT.FontFile) 'TBankStream
FNT.Font12 = LoadImageFont(FNT.FontLoader, 40, SMOOTHFONT) 'Load it
SetImageFont(FNT.Font12) 'Set it

if not FNT.FontFile then Throw "FNT.FontFile not existing"
if not FNT.FontLoader then Throw "FNT.FontLoader not existing"
if not FNT.Font12 then Throw "FNT.Font12 not existing"


If font12 is null then you might dive into freetypefont.bmx "function load" and add some throw's in the positions where it does "return null" - this way you could narrow down where it fails.


bye
Ron

It's the font variable itself (fnt.font12);  Appears to be null.

I checked the SIZE(S) of the tbankstream and the tbank;  They match the actual TTF file.

I wish TBANK would just be implemented......................