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 DBPro Corner / Fonts not loading 95% of the time

Author
Message
Choper
13
Years of Service
User Offline
Joined: 14th Mar 2011
Location: England
Posted: 22nd Mar 2011 12:53
Hi Guys. I am pretty new here, only just put my game on WIP, Dungeon Quest V1.0. The comments I have got there are good, but that the font is rubbish. I have done searches and found the coding below (forgot who from though, sorry). This works for a very few fonts, but 95% of them dont work. I have attached a font that does'nt work for reference. Does anyone else have this problem, or is it just me. Would appreciate any help on this, as it is holding me up finishing my game.

print "Standard font"

if FontLoaded("VeniceClassic") = 0 then LoadFont("VeniceClassic.ttf")
set text font "VeniceClassic"

text 50,50,"Venice Font Loaded"

wait key
end

function LoadFont(FontFile as string)
load dll "gdi32.dll", 1
result = call dll(1, "AddFontResourceExA", FontFile, 0x10, 0)
delete dll 1
endfunction result

function UnloadFont(FontFile as string)
load dll "gdi32.dll", 1
call dll 1, "RemoveFontResourceA", FontFile
delete dll 1
endfunction

function FontLoaded(FontName as string)
local i as integer

FontName = upper$(FontName)

perform checklist for fonts
for i = 1 to checklist quantity()
if upper$( checklist string$(i) ) = FontName then exitfunction 1
next i
endfunction 0

Regards
Choper

Attachments

Login to view attachments
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Mar 2011 15:51
That looks familiar ... but then that piece of code has been written many times before, so could be anyone's.

Anyway, do you have a font file called 'VeniceClassic.ttf' in your project directory?

Even if you do, when loaded, is it known as 'VeniceClassic'? (For instance, I have a file named 'advlit.ttf' containing a font named 'Adventurer Light SF' in it, and possibly other fonts too).

Choper
13
Years of Service
User Offline
Joined: 14th Mar 2011
Location: England
Posted: 22nd Mar 2011 17:36
Hi IanM, thanks for the quick response, I do have the fonts in the game folder. I think I understand now anyway. It seems that the file name can be different from the font name, all very confusing. I got it to work like this...

if FontLoaded("Venice Classic")=0 then LoadFont("VeniceClassic.ttf")
set text font "Venice Classic"

or this...

if FontLoaded("Monofur")=0 then LoadFont("monof56.ttf")
set text font "Monofur"

Thanks again for your help.

Regards
Choper

Login to post a reply

Server time is: 2024-11-16 19:13:16
Your offset time is: 2024-11-16 19:13:16