July 21, 2019, 10:52:19 AM

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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 243
  • Whoop-de-doo-ba-dooo!
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #30 on: June 23, 2019, 09:48:40 PM »
As you are surely aware (notified by github) I posted some stuff there to make Brucey aware of the situation.

bye
Ron

Hi,  i've found a major bug with the latest version of the module.     You can only load 1 bank..

I am successfully able to load 1 font from my binary, as well as a bank from just a folder without any issues.   You cannot load multiple banks at all.

So for example, i can only load "Arial.ttf"...   i can't also load "Arial_italic.ttf" or "Tahoma.ttf"...   only 1 will successfully pass.

If i use a REAL STRING, i can load a bank and other fonts, but i want to load from my binary (tbank basically)...

Yes, i verified all the fonts are not corrupted...  saved outputs and everything..  identical.    This is a module bug.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2218
Re: [BUG FOUND] Why can't Image Fonts be loaded via LoadBank()?
« Reply #31 on: June 24, 2019, 06:47:55 AM »
Best chance is to provide a sample (show it with normal banks..not your special file-bank-extract).


Bye
Ron

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 243
  • Whoop-de-doo-ba-dooo!
Re: [BUG FOUND] Why can't Image Fonts be loaded via LoadBank()?
« Reply #32 on: June 24, 2019, 07:56:35 AM »
Best chance is to provide a sample (show it with normal banks..not your special file-bank-extract).


Bye
Ron

Sample:

Code: [Select]
    Global Font1:tbank = loadbank("Fonts\Arial.ttf")
    Global Font2:tbank = loadbank("Fonts\TimesNewRoman.ttf")
    Global imgfnt1:timagefont = loadimagefont(font1,30,smoothfont)
    Global imgfnt2:timagefont = loadimagefont(font2,50,smoothfont)

if imgfont1 then setimagefont(imgfont1)
drawtext("blah blah blah",0,0)
if imgfont2 then setimagefont(imgfont2)
drawtext("more blah blah blah!,0,22)

Only IMGFONT1 will be loaded.    imgfont2 will display as invisible (error)...

Offline Derron

  • Hero Member
  • *****
  • Posts: 2218
Re: [BUG FOUND] Why can't Image Fonts be loaded via LoadBank()?
« Reply #33 on: June 24, 2019, 03:07:17 PM »
Please add "superstrict" to your code

imgfont1 not found (you defined imgfnt1)
imgfont2 not found (you defined imgfnt2)


bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 2218
Re: [BUG FOUND] Why can't Image Fonts be loaded via LoadBank()?
« Reply #34 on: June 24, 2019, 03:17:49 PM »
Code: BlitzMax
  1. SuperStrict
  2.  
  3. Global Font1:TBank = LoadBank("/usr/share/fonts/truetype/msttcorefonts/arial.ttf")
  4. Global Font2:TBank = LoadBank("/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf")
  5. Global imgfnt1:timagefont = LoadImageFont(font1,30,smoothfont)
  6. Global imgfnt2:timagefont = LoadImageFont(font2,50,smoothfont)
  7.  
  8.  
  9. Graphics 800, 600
  10.  
  11. Repeat
  12.         Cls
  13.        
  14.         If imgfnt1 Then SetImageFont(imgfnt1)
  15.         DrawText("blah blah blah",0,0)
  16.         If imgfnt2 Then SetImageFont(imgfnt2)
  17.         DrawText("more blah blah blah",0,22)
  18.  
  19.         Flip 0
  20. Until KeyHit(KEY_ESCAPE) Or AppTerminate()
  21.  




Make sure to not copy parts of the patch but just _really_ update your brl.mod (and the likes)


bye
Ron

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 243
  • Whoop-de-doo-ba-dooo!
Re: Why can't Image Fonts be loaded via LoadBank()?
« Reply #35 on: June 26, 2019, 08:56:07 PM »
...

I'm just going to revert back to 0.99 and use my bitmap font system.  Nothing i need builds on the latest and i'm also tired of testing the font module.

I am on the latest version when i tested this; Those were my results.

I'm going back to 0.99 again, so that i can actually work on my projects.

Offline Brucey

  • Jr. Member
  • **
  • Posts: 74
Re: [abandoned] Why can't Image Fonts be loaded via LoadBank()?
« Reply #36 on: June 27, 2019, 06:53:30 AM »
The following program appears to function as expected for me on Windows 10 with the latest BlitzMax code.
Code: [Select]
SuperStrict

Framework brl.glmax2d
Import brl.freetypefont

Graphics 800, 600, 0

Global Font1:TBank = LoadBank("Fonts\Arial.ttf")
Global Font2:TBank = LoadBank("Fonts\TimesNewRoman.ttf")
Global imgfnt1:timagefont = LoadImageFont(font1,30,smoothfont)
Global imgfnt2:timagefont = LoadImageFont(font2,50,smoothfont)

While Not KeyDown(key_escape)

Cls

If imgfnt1 Then SetImageFont(imgfnt1)
DrawText("blah blah blah",0,0)
If imgfnt2 Then SetImageFont(imgfnt2)
DrawText("more blah blah blah",0,22)

Flip

Wend
Image fonts can now be loaded via LoadBank, as per your original request to have it do so.

The way it does this is as follows:
Code: [Select]
Local data:Byte Ptr = TBank(src).Lock()
buf = New Byte[TBank(src).Size()]
MemCopy(buf, data, TBank(src).Size())
TBank(src).UnLock()
It copies the the bank data into a Byte array which is then associated with the font object. The data itself is converted into font data using the freetype api.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2218
Re: [abandoned] Why can't Image Fonts be loaded via LoadBank()?
« Reply #37 on: June 27, 2019, 07:11:49 AM »
I think Yellownakji is using a mix of updated sources, manually copied (parts) of updates, ... and maybe it does not recompile the modules for him ("quick" enabled) ... or something similar.
This leads then to such issues.

More probably is that you did not try the code we posted but are thinking that you do "nearly the same" in your code (hence the "not compilable source example" of your). Please try our examples so we use the same "basement".


@ Brucey
Paths with "\" are translated to "/" internally (I think so at least) so you might write "/" in your paths. Albeit... someone had issues with paths in the past...


bye
Ron

Offline Brucey

  • Jr. Member
  • **
  • Posts: 74
Re: [abandoned] Why can't Image Fonts be loaded via LoadBank()?
« Reply #38 on: June 27, 2019, 04:33:19 PM »
I just copied the example. I usually use forward slashes in all my code, but it doesn't matter. BlitzMax is generally dir separator agnostic.