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

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

Previous topic - Next topic

Yellownakji

Quote from: Derron on June 16, 2019, 21:16:23
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.

Derron

Best chance is to provide a sample (show it with normal banks..not your special file-bank-extract).


Bye
Ron

Yellownakji

Quote from: Derron on June 24, 2019, 06:47:55
Best chance is to provide a sample (show it with normal banks..not your special file-bank-extract).


Bye
Ron

Sample:


    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)...

Derron

Please add "superstrict" to your code

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


bye
Ron

Derron

Code (BlitzMax) Select

SuperStrict

Global Font1:TBank = LoadBank("/usr/share/fonts/truetype/msttcorefonts/arial.ttf")
Global Font2:TBank = LoadBank("/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf")
Global imgfnt1:timagefont = LoadImageFont(font1,30,smoothfont)
Global imgfnt2:timagefont = LoadImageFont(font2,50,smoothfont)


Graphics 800, 600

Repeat
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 0
Until KeyHit(KEY_ESCAPE) Or AppTerminate()





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


bye
Ron

Yellownakji

Quote from: Derron on June 24, 2019, 15:17:49
...

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.

Brucey

The following program appears to function as expected for me on Windows 10 with the latest BlitzMax code.

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:

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.

Derron

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

Brucey

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.