Newbie questions

Previous topic - Next topic

geekpeter

ive noticed if you create your own font using the editor but keep the default name of "smallfont.png" or "smallfont.bmp" and use LOADFONT "smallfont.png",1 / USEFONT 1 your created font wont actually be loaded, but if you rename that font to something different it works, so id further assume if we call LOADFONT "smallfont.xxx" then the actual small/default font we usually see is loaded from ram or something?

definatley not advisable using the default name, i did this at first and thought glbasic was broken or was acting weird because i'm running it via WINE/PlayOnUnix in ubuntu, once i found the default name messes things up, all has been well.

CW

#16
SF, I can offer some lessons I've learned when trying to create custom fonts. GLbasic has a few quirks when it comes to fonts which we all quickly learn to deal with. After a time or two, using custom fonts will be as easy as can be.

1. In the Font Creator tool, always click on the [C:\ ...] button to set your path, THEN click on the [OK, Create] button.  If you think you have created a font, only to have it go missing, suspect that you forgot to set the path or click on the OK button.

2. When setting the path, be sure to locate and select the Media folder. (You may have to open a couple of folders from within the wizard to get there.)

3. Start each program with the following code. (Change "smalfont.png" to whatever you named your font. The name is cap sensitive.)

Code (glbasic) Select
SETSCREEN 1366,768,TRUE
GLOBAL sw%,sh%;GETSCREENSIZE sw,sh
SETCURRENTDIR(GETCURRENTDIR$()+"Media")
GLOBAL fontkey% = GENFONT()
LOADFONT "smalfont.png",fontkey
SETFONT fontkey
GLOBAL fw%,fh%;GETFONTSIZE fw,fh


4. If you use the default name, realize that there is only ONE "l" in "smalfont.png".

5. Always include the ".png" extension when you load your font. If you don't include the extension, the program may not load it. I'm not sure why, just that this has been an issue for me in the past.

6. Don't add ".png" when naming your font, or you may windup with something like "name.png.png".

7. Post if you have any trouble and someone will be very happy to help. We have a good crew here.

8. Have fun!

Cheers!
-CW

SFguy

I've just bought the full version.

Thanks a lot for the advice, geekpeter!  Incredibly, it is now working! :D Who would have thought that renaming the filename would make such a difference?

These are the bugs/features that a newbie would be challenged with. Wish there was an FAQ section for newbies that details all these bugs/features.

Thanks again.

fuzzy70

@geekpeter. Thanks for that info, I have always named my fonts in relation to their usage (along with sprites & sound etc) so have not ran into that problem but at least I am now aware of it for future reference :) .

Lee

Sent from my HTC Wildfire using Tapatalk 2

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

kanonet

I can not confirm this problem with the default name, it always worked for me.

Btw. there is a better version of the font creator that offers more options: http://www.glbasic.com/forum/index.php?topic=6421.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

geekpeter

Quote from: kanonet on 2013-May-28
I can not confirm this problem with the default name, it always worked for me.

Btw. there is a better version of the font creator that offers more options: http://www.glbasic.com/forum/index.php?topic=6421.

for such an improved font creator, is there a problem or quirk with it that has stopped it being packaged as standard?

MrTAToad

Its not written by Gernot :)

erico

#22
I have had my share of ´problems´ with fonts loading. Not something I, as people said, could not solve in a couple days ::).
Media folder, font name, extension and precise loading was my key.

You also may want to be aware of BMP as it uses the transparent color(pink), against the PNG, that pushes a self transparent color (not alpha).

Take your time understanding how it works.
GLB versions did not make a difference to me, so it is not a bug my guess?

I´m using the font appended in my projects as on screen debug display. A veeeeery small cut-off-guess-what font  =D
Somehow, the black background reads as transparent on GLB automatically, maybe related to how you save the file from the font editor? like what colors you choose to be transparent so it overides the settrasparency thing on a font level?
Maybe that could be called a quirk?

Anyways, mess with it a bit, printing fonts on screen is very important, getting the hang of how that goes is way cool! 8)

I don´t have a solve-all solution, post a code/font file if it gets to be a strong issue.
Like I said, I did spend a couple days figuring that out, and I´m not sure I did completely and in a good way  ::)

Cheers, welcome aboard! :good:

PS: I´m using the same smalfont.png without trouble on multiple platforms.

EDIT: you can see on my font, that I have a dark blue outline, that is there cause if I used a black outline, it would be called transparent on screen.

SFguy

Thanks, Erico, for the welcome.

In another language, I would usually write a subroutine/procedure myself to display proportional fonts.  It's just that in GLBasic you have it built in which I find fascinating, provided it works well! :)

erico

It does work, SFguy, it may need a little time to start and catch up.

I did build a game fully on "print" with about 5 fonts all displaying over each other similar to what a rogue like or ascii game would look like.
Fonts were done with the standard font tool.
It all worked fine.

Should you have too much trouble with it, post an example code, we will figure out. :good:


SFguy

Will do, erico.  Thanks!

I may have many questions over the next couple of weeks as I learn to get up to speed on GLBasic! :)

matchy

Quote from: geekpeter on 2013-May-28
... the default name of "smallfont.png"...

Note that the default is "smalfont.png" (not double L).

SFguy

Thanks for all the help, guys. :)

Another newbie question - is there a built-in command in GLBasic that will allow one to detect/use the accelerometer/gyroscope in an iPhone or an Android phone?

Robert

Slydog

#28
I'd still recommend rolling your own font system, using polyvectors.

Use an external bitmap font creation tool, one that saves the character positions to a definition file (and optional kerning pairs). Load this definition file to know where to extract your characters from the bitmap.

Create a new Font TYPE with commands such as: Font.Load(fontName), Font.Print("text", 100, 100), etc.

Advantages include speed, customizable, proportional fonts ("i" thinner than "w"), kerning pairs (eg: "AW" pair is squeezed together an extra two pixels), colour effects like gradients, font effects like shadowing, underlining, etc.

Not easy sure, but fun to do (if you're a little insane maybe!).
My font system was built for speed, not simplicity.  It only starts the polyvectors once per font type to keep material references / draw calls down, it caches the text string's polyvector coordinates for quick redisplaying each frame, etc.  I kinda over engineered this thing, and optimized when maybe I didn't have to, but it was fun.

I can post my code if you want, but it is pretty involved (not bad commented tho) but requires other libraries I have (such as my File, Point, etc TYPES).  Heck, I could even post my entire project (that 3d maze game you might have seen screen shots of in my earlier posts) if anybody dares wander through it, there is so many files and lines of code. 

It is basically abandoned in GLBasic, and I've since moved the project into Unity, due to the game's complexity, and proper classes and OO programming.  Here's a web player build of my latest work in progress: https://dl.dropboxusercontent.com/u/1979274/TwistedMaze/TwistedMaze.html.  I still love GLBasic and the community, and my nephew is working on a 2d platformish game in GLBasic, so I still check in here once in a while.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

geekpeter

the glbasic PRINT command is already proportional isnt it?  you just put TRUE as a final argument and the font becomes proportional?