loadfont confusion

Previous topic - Next topic

Andrik

Hi there,

I recently downloaded GLBASIC and right now I'm trying to get something to work but I guess I'm doing something wrong because I can't get loadfont to work properly.
I created a font with fontcreator "test.bmp" and saved in the root dir of my game.
In the game I run the following code:
LOADFONT "test.bmp", 1
SETFONT 1

PRINT "testing", 100, 100, TRUE   
SHOWSCREEN
KEYWAIT
END

When I run the code, I still see the small default font!! What am I doing wrong?

by the way, I run Glbasic on a mac via a windows xp parallels desktop virtual machine.

regards,
Andrik

mentalthink

HI Andrik the first Welcome and enjoy of GLbasic , I hope you learn a lot whit us...

I suggest you don´t use .bmp for the font´s beacuse you don´t have transparency whit a very easy mode...

Make better a .png, you can use the "pink" color for transpaency, but if you put the background of the font in pure black... 0,0,0 you don´t have touch and make nothing for have got transparency...

Be carefully, if you nottice, always when you start a new porject, you have a command that´s says something like...

Setcurrentdir("Media"), in principle it´s dissble, it´s like a comment...

Well take of the comment mode, only delete the // slash in the left corner in the same line code...

Now all you datas goes to this dir, for search the audio,l graphics, and all the things you make like stuff media, this it´s important, becuse if you develop for iPhone, you need the media folder, else on iPhone your code don´t make appears nothing in the Screen...

Another point be sure when you make the font, pres the ok, button and another verification button (i don´t rebenber the name, it´s at the side of the other, becuase if you don´t make this process the fonts don´t will created)...

And if you need more powerfull fonts, more nice, because have more colors and little but very impressive things... take around in the Dustch forum, in the first post, they are marked whit an "orange color", you can see a post called DGGUI Fonts 5.0 I think it´s called at this manner, you can donwload and try to make more complex fonts...

I hope I can help you, and again Welcome...

Darmakwolf

Heya. I had that problem at first too! Then I realized it was a simple mistake.

Use the built-in font-maker, of course. save the file as a PNG, then press OK, not cancel. CHECK the folder of your program. If the font is not in the "media" folder, the program probably just can't find the font file because by default, GLBasic uses the Media folder. so throw it in there. Then it should work!

** SAMPLE ATTACHED! **

[attachment deleted by admin]

Andrik

thanks Darmakwolf and mentalthink!!

using the media dir and setting solved my problem.

Now on with experimenting!

regards,
Andrik

Darmakwolf

Hey no problem - let me know if you get stuck again!

mentalthink

ok, Andrik, no doubt to question any thing... in the forum always you can found a good answer wht all us...

Slydog

#6
In the future when you are wondering if a file is loading properly (font, sprite, sound, etc), you can use the DOESFILEEXIST() command first, or make a library function to do this check for you, such as:

Code (glbasic) Select
FUNCTION FontLoad%: fileName$
STATIC id% = 0

IF NOT DOESFILEEXIST(fileName$)
DEBUG "Font file not found!: [" + GETCURRENTDIR$() + fileName$ + "]\n"
END // Handle missing file, or just end as your game may NEED the font to exist
ENDIF

INC id
LOADFONT fileName$, id
RETURN id
ENDFUNCTION

// Main section of code . . .
GLOBAL fontTitle%
GLOBAL fontBody%

fontTitle = FontLoad("font_title.png")
fontBody = FontLoad("font_body.png")

SETFONT fontTitle
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

erico

...and that sure helps me too Slydog, didn´t know about that command, and already got stuck a few times on that reason. Not actually stuck, but takes time if there is a lot to load and you have to get to a program part just to see if it is all ok. :good: