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.

AppGameKit Classic Chat / How to use a truetype font in AGK2

Author
Message
David Gervais
Retired Moderator
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 17th Jul 2021 14:33 Edited at: 17th Jul 2021 14:36
Hello everyone I'm trying to use a truetype font in AGK2 but it seems to still be using the default AppGameKit bitmap font.


I compiled and ran with the LoadFont and SetTextFont active then rem'd out and get the same result.. (see attached image)



What am I doing wrong? Help Please.

Attachments

Login to view attachments
David Gervais
Retired Moderator
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 17th Jul 2021 15:33 Edited at: 17th Jul 2021 15:34
I found my mistake.. in case it helps.. you need the UseNewDefaultFonts( 1 ) command at initialization and I was a fool and didn't tell it to set the font for each 'text string' this sample code now works..



I did some digging and got my answer, I hope this helps people trying to use truetype fonts in their apps.

Cheers!

TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 17th Jul 2021 17:29
great
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Jul 2021 07:59 Edited at: 18th Jul 2021 08:17
Quote: "you need the UseNewDefaultFonts( 1 ) command"
i'm not sure about that:


to be clear:


then, i'm surprised your code didn't error on the first SetTextFont (1,1) since there wasn't a text object 1 yet.
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]

Attachments

Login to view attachments
JonEnstrom
3
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 21st Jul 2021 03:12 Edited at: 21st Jul 2021 03:15
UseNewDefaultFonts is unrelated, it's only for the Print command.

Also instead of applying your font to each string, you can SetTextDefaultFontImage to your font choice and now every string will use that font. I think you'll need an image though instead of ttf. Not to be confused with UseNewDefaultFonts.

Login to post a reply

Server time is: 2024-04-20 16:33:08
Your offset time is: 2024-04-20 16:33:08