incbin and font in 1.06

BlitzMax Forums/BlitzMax Beginners Area/incbin and font in 1.06

Booticus(Posted 2005) [#1]
Hey guys! Im wondering if anyone can give me an example of how to use incbins with fonts. Per Marks notes in 1.06 release:

+ Modified freetype module so you can hook IO. This means you can now Incbin imagefonts.

Any examples out there? I'd appreciate it!


skidracer(Posted 2005) [#2]

Incbin "chicago.ttf"

Graphics 640,480

font=LoadImageFont("incbin::chicago.ttf",24)
SetImageFont font

Cls
DrawText "Hello World",20,20
Flip

WaitMouse
End



Booticus(Posted 2005) [#3]
Youre a gentleman and a schoolbus! Thank you very much!


Booticus(Posted 2005) [#4]
OK, I thanked you before testing it. :) It failed. The default font still shows up. Here's my code initializing the graphics when it works:

Strict
SeedRnd MilliSecs()
Const gcontinentwidth=1024
Const gheight=768

Graphics gcontinentwidth,gheight',0

Global hoog:TImageFont=LoadImageFont("Media/Fonts/hoog0553.ttf",8)'
SetImageFont hoog

SetBlend ALPHABLEND	

Incbin "Media\2d\Terrain\water.png"
Global water:TImage = LoadImage ("incbin::Media\2d\Terrain\water.png")

'etc. etc.



'#Region Initialize graphics and variables
Strict
SeedRnd MilliSecs()
Const gcontinentwidth=1024
Const gheight=768

Incbin "Media/Fonts/hoog0553.ttf"
Graphics gcontinentwidth,gheight',0

Global font:TimageFont=LoadImageFont("incbin::Media/Fonts/hoog0553.ttf",8)
SetImageFont font

SetBlend ALPHABLEND	

Incbin "Media\2d\Terrain\water.png"
Global water:TImage = LoadImage ("incbin::Media\2d\Terrain\water.png")
'etc. etc.


Just for fun, I threw the font file in the root directory of my project. No love either. Clues?


klepto2(Posted 2005) [#5]
Try to change the '/' to '\'. Sometimes this works for me. Don't know exactly why.


ziggy(Posted 2005) [#6]
IncBin uses standard path notation (not windows notation, remember cross-platform compatibility), so it has to have / instead of \


klepto2(Posted 2005) [#7]
Sorry, I have switched them wrong (blame), but then this will not solve his problem with the fonts because he uses the right slashes for the font but the wrong for the image.


Perturbatio(Posted 2005) [#8]
the slashes don't appear to make a difference with incbin for me, however case does. Ensure your path to the font is the correct case. i.e. "media/fonts/hoog0553.ttf" instead of "Media/Fonts/hoog0553.ttf"

I prefer to stick to lowercase for everything, it saves hassle.


Booticus(Posted 2005) [#9]
Nope. No love. Even changed the case of my directories, filenames, etc. Just for fun, I threw it on my root drive since folks mentioned that spaces in the DIRECTORY names can be a problem too. Its not a big deal. I thought I'd try it since it was in the release notes for 1.6. If anyone wants to zip up an example complete with a .ttf font file and throw it up for download somewhere or email it to me to show me exactly what I'm doing wrong, I'd appreciate it. Till then, like I said no big deal.


Booticus(Posted 2005) [#10]
Also remember, slashes dont make a difference if the font is contained in the root directory of the app. I've used just plain old:

Incbin "hoog0553.ttf"
Graphics gcontinentwidth,gheight',0


Global hoog=LoadImageFont("incbin::hoog0553.ttf",8)
SetImageFont hoog


per Skidracer's reply, with no luck either. As far as cross platform compatibility, all my apps compile on my Mac and my PC without incident, so I dont think it's being picky about my slashes.


Booticus(Posted 2005) [#11]
I found out what was going on. Since I'm so brilliant, I failed to update the 1.06 completely. Went ahead and reinstalled a fresh copy of BMax and it works like a charm. I am Sofa King!


LarsG(Posted 2005) [#12]
..we Todd it?


Booticus(Posted 2005) [#13]
hehehehehehe. Now say it fast with me.....

;)