September 15, 2019, 07:23:52 AM

Author Topic: [abandoned] Why can't Image Fonts be loaded via LoadBank()?  (Read 1072 times)

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #15 on: June 14, 2019, 10:24:20 PM »
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
  1.                        
  2. If Not data.length Then
  3.         Return Null
  4. End If
  5.  

becomes

Code: BlitzMax
  1.                        
  2. If Not data.length Then
  3.         Throw "data.length = 0"
  4.         Return Null
  5. End If
  6.  

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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #16 on: June 14, 2019, 11:00:54 PM »
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
  1.                        
  2. If Not data.length Then
  3.         Return Null
  4. End If
  5.  

becomes

Code: BlitzMax
  1.                        
  2. If Not data.length Then
  3.         Throw "data.length = 0"
  4.         Return Null
  5. End If
  6.  

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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #17 on: June 15, 2019, 06:48:26 AM »
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #18 on: June 15, 2019, 07:04:14 AM »
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.  ::)

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #19 on: June 15, 2019, 07:23:51 AM »
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

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #20 on: June 15, 2019, 07:25:28 AM »
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #21 on: June 15, 2019, 07:31:27 AM »
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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #22 on: June 15, 2019, 09:11:22 AM »
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #23 on: June 15, 2019, 09:30:43 AM »
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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #24 on: June 15, 2019, 10:36:58 AM »
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

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #25 on: June 15, 2019, 10:58:04 AM »

What happens if you replaced "FNT.FontFile" with loading a raw file into the bank?
Code: BlitzMax
  1. FNT.FontFile = LoadBank("/valid/path/to/Arial.ttf")
  2. 'FNT.FontFile = SDA.Config.Merge(11) 'Returns BANK from archive into TBANK VAR
  3. FNT.FontLoader = CreateBankStream(FNT.FontFile) 'TBankStream
  4. FNT.Font12 = LoadImageFont(FNT.FontLoader, 40, SMOOTHFONT) 'Load it
  5. SetImageFont(FNT.Font12) 'Set it
  6.  
  7. if not FNT.FontFile then Throw "FNT.FontFile not existing"
  8. if not FNT.FontLoader then Throw "FNT.FontLoader not existing"
  9. if not FNT.Font12 then Throw "FNT.Font12 not existing"
  10.  

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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #26 on: June 15, 2019, 04:49:12 PM »
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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #27 on: June 15, 2019, 09:59:20 PM »
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #28 on: June 16, 2019, 05:07:09 AM »
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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2399
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #29 on: June 16, 2019, 09:16:23 PM »
As you are surely aware (notified by github) I posted some stuff there to make Brucey aware of the situation.

bye
Ron