Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / LoadFont problems with Tier2

Author
Message
Kilian
7
Years of Service
User Offline
Joined: 12th Jan 2017
Location:
Posted: 12th Jan 2017 14:40
Hi!

I am having problems with LoadFont, Windows with Tier2. Whatever I do, I always get the same basic font. Checking with GetSystemFontExists gives an OK with for example Arial, checking afterwards with GetFontExists also gives an OK, but using SetTextFont on a text with loaded font gives me always the default font. Is there a bug?

Artur
damothegreat
User Banned
Posted: 12th Jan 2017 15:30
Try this



Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
Kilian
7
Years of Service
User Offline
Joined: 12th Jan 2017
Location:
Posted: 12th Jan 2017 15:54
Nope.




I always get 0 for 'font', regardless what font I use. Arial etc. exist, I get no errors, but always the default font is being used. The example is Tier 1, but it is the same with Tier 2.

Artur
damothegreat
User Banned
Posted: 12th Jan 2017 15:59
I got it working in Tier 2 by using a font in the system fonts folder, or copying to Media folder in the project root of your Final

This is basic template, but you may only need certain lines here



Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
Kilian
7
Years of Service
User Offline
Joined: 12th Jan 2017
Location:
Posted: 12th Jan 2017 16:19
Thanks! This works. The only problem is that I have in my project about 200 text boxes. If I have to do it this way with each of that boxes, won't it hit my performance or memory usage?

Artur
damothegreat
User Banned
Posted: 12th Jan 2017 16:44
I think you get 0 cause you loading it with

loadfont(font, "\media\JOKERMAN.ttf")

if you did

font = loadfont("\media\JOKERMAN.ttf")

then think that would work - cause its creating a memory reference properly INTO variable font

----

Tier 2

What command did you finally use?

agk::SetTextFont(t, agk::LoadFont("Media\\font.ttf")); ???

If so then I'm yes this works because again AppGameKit loads the font as a memory reference, so putting it directly into the text "t", will work ok
if you do it on separate lines, like

font = agk::LoadFont("Media\\font.ttf");
agk::SetTextFont(t, font);

Then the memory allocation from AppGameKit to C gets lost into the wilderness, so therefore returns 0 or uses what ever default font is instead of what
you defined in LoadFont.

This also applies to LoadImages too

Hope this makes sense and hope I'm guiding you correctly on this

Damo


Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
Kilian
7
Years of Service
User Offline
Joined: 12th Jan 2017
Location:
Posted: 12th Jan 2017 17:04
I was using the second method in Tier2:

font = agk::LoadFont("Media\\font.ttf");
agk::SetTextFont(t, font);

I am doing also this way with images and no problems at all with it, so I was wondering why it won't work with fonts. Even more, I am using one variable to load multpile images and assign them to sprites, which works also with no problems.

Another thing I just discovered: When I use Unicode national characters in Tier 1, they are being displayed correctly, where in Tier 2 different characters appear. Why?

Really appreciate Your help.
Artur
damothegreat
User Banned
Posted: 12th Jan 2017 22:54
Cause you been a noobie on posting here - its taken a while for your posts to be posted. Shall come back to you soon with something to your query, sleep time
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)

Login to post a reply

Server time is: 2024-11-22 03:22:36
Your offset time is: 2024-11-22 03:22:36