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

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

Previous topic - Next topic

Derron

Open up "freetypefont.bmx" (in its mod folder) and look for "Function Load:TFreeTypeFont( src:Object,size:Int,style:Int )"

In there you can add some checks and "throw" if they fail:

Code (BlitzMax) Select

If Not data.length Then
Return Null
End If


becomes

Code (BlitzMax) Select

If Not data.length Then
Throw "data.length = 0"
Return Null
End If


and so on.
You might even add a "debugstop" right at the top and then execute a debug build - then go through it "step by step" and check at which position it runs into "return null".


bye
Ron

Yellownakji

Quote from: Derron on June 14, 2019, 22:24:20
Open up "freetypefont.bmx" (in its mod folder) and look for "Function Load:TFreeTypeFont( src:Object,size:Int,style:Int )"

In there you can add some checks and "throw" if they fail:

Code (BlitzMax) Select

If Not data.length Then
Return Null
End If


becomes

Code (BlitzMax) Select

If Not data.length Then
Throw "data.length = 0"
Return Null
End If


and so on.
You might even add a "debugstop" right at the top and then execute a debug build - then go through it "step by step" and check at which position it runs into "return null".


bye
Ron


Well, for your specific check (data length), nothing is thrown.   So, there is data.

Font12 isn't getting loaded, so obviously something isn't passing.

Derron

As said ("and so on") you should add more lines of "throw" to check where it returns "null" or go through it step by step in debug mode.


Bye
Ron

Yellownakji

Quote from: Derron on June 15, 2019, 06:48:26
As said ("and so on") you should add more lines of "throw" to check where it returns "null" or go through it step by step in debug mode.


Bye
Ron


My previous example was incorrect.   I forgot to initialize my binary before loading it, which explains why length was zero.

With everything properly set up, nothing get's thrown and the font still does not pass through.  Default is still being used.

At this point, i give up.  I'm just going to use a bitmap font.  ::)

Derron

You might consider handing in a (non-working) example to brucey or me ...or for all. So to see the whole thing with the font asset and so on.

Did you run it through the debugger with a debugstop at the begin of load()?


Bye
Ron

Derron

Once you returned your font as bank...you could save this bank as "test.ttf" ...then compare this font to your original one (bytewise) if they differ then you found the culprit.

If they are the same then we can look further.


Bye
Ron

Yellownakji

I have saved what was loaded into a "file";  I compared them and the output(s) were identical, so i didn't say anything.

but yes, What's being loaded is 100% identical to the raw ARIAL.TTF font.

--

I did build the module with debug stop already.   Nothing was thrown.

I put a throw in every statement that reports null.

It does not want to set my font via the tbankstream nor loadbank(tbank) - Only default is used.

Derron

Debugstop is not to see something thrown... It is there to have the possibility to observe values/variables in each executed step. Also you see if the last command (return font) is to get executed (and if the font is a valid object in that step).


As said... Hand in a complete non working example and chances to get a fix/solution will increase.


Bye
Ron

Yellownakji

Quote from: Derron on June 15, 2019, 09:11:22
Debugstop is not to see something thrown... It is there to have the possibility to observe values/variables in each executed step. Also you see if the last command (return font) is to get executed (and if the font is a valid object in that step).


As said... Hand in a complete non working example and chances to get a fix/solution will increase.


Bye
Ron

My archive format isn't public.   A proper example would require it to be included, which won't happen.

I'm simply wanting to load a TBank.    I would like a TBank version (or with support) of LoadImageFont, not with TBankStream, as it's still not solving the issue nor were streams what i made an issue for in the first place.   Streams are great and all, but i would like proper TBank support.   Brucey should not have closed the issue.

Derron

I too would have closed the issue.

You do not want to expose the format - you do not have to, either trust Brucey/me/...someone who fixes the issue for you - or try stuff on your own. your decision.



Banks are managed memory blocks. A Bankstream wraps this memory block into a standard interface (read, write, seek, ...). That way LoadImageFont (or whatever) just needs to take care of a single type: streams. This allows to have http-streams (load your font from the web) or whatever you want (eg a serial-stream from an attached protection dongle?!).

Adding "TBank" as requirement leads to a new dependency and something more to take care of.


As I wrote earlier (here or in the issue) it is no biggy to add TBank support at all - as it is a buffer too (and the new code of Brucey uses a buffer too). Feel free to extend / override the code to use your buffer too.

If it was possible to pass "byte ptr" as object then this would even be possible then ("LoadImagefont(bank.Buf(), ...)").


bye
Ron

Derron


What happens if you replaced "FNT.FontFile" with loading a raw file into the bank?
Code (BlitzMax) Select

FNT.FontFile = LoadBank("/valid/path/to/Arial.ttf")
'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"


As you told before that my sample code works, it should work flawless.
If it now works flawless, you need where to look at - and to find out why you wrote that the saved files are identical (maybe something is changing memory or whatever happens there).

If it still does not work - but my sample code above works, then you are doing something wrong elsewhere.


bye
Ron

Yellownakji

#26
Yes Derron.   I did report your example works; YOUR version of the module commit.

I'm using Brucey's personal "accepted" version.    I cannot a TBANK from a path, just tested. (Font12 not exist thrown)

I checked with filetype() and it exists.  Using the exact code example you just used.


Also on my end,  INCBIN with fonts still does not work.   Yes, i have included ramstream.

I can include audio and graphics fine, not that i want to however.

Derron

So you are saying:
- using my code works
- using brucey's code does not work
?

If so that might help narrowing down the issue (without having access to the code).


bye
Ron

Yellownakji

Quote from: Derron on June 15, 2019, 21:59:20
So you are saying:
- using my code works
- using brucey's code does not work
?

If so that might help narrowing down the issue (without having access to the code).


bye
Ron

Yes, this what i am saying.  You code can do streams and incbin.

Derron

As you are surely aware (notified by github) I posted some stuff there to make Brucey aware of the situation.

bye
Ron