(fixed) Font load failure

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
ian_scho
High Lord
Posts: 2807
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

(fixed) Font load failure

Post by ian_scho »

Late to the party I know but...

I get a failure in this build calling the following which worked in 0.36:

Code: Select all

gfx["GAUDYMEDIEVALFONT"] = dsb_get_font("./fonts/gaudymedieval")
Error:

Code: Select all

Error: Font not found:
./ian_test/fonts/gaudymedieval (dsb_get_font)
gaudymedieval.pcx file is in a subdirectory to my main dungeon folder. Nice and tidy.
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Font load failure

Post by Sophia »

This kind of syntax is not particularly well-behaved, which is why I added the ability to specify a long name. The preferred way to do something like this, e.g. with dsb_get_bitmap is:

Code: Select all

dsb_get_bitmap("SHORTNAME", "path/to/long/filename.ext")
Unfortunately, that syntax doesn't (yet!) work with dsb_get_font.

For the time being, try moving your font into your dungeon's root directory and just doing

Code: Select all

gfx.GAUDYMEDIEVALFONT = dsb_get_font("GAUDYMEDIEVAL")
If this still doesn't work, there's probably something wrong with the font itself, like being something other than a 256 color PCX image.
User avatar
Gambit37
Should eat more pies
Posts: 13766
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Font load failure

Post by Gambit37 »

When you use a multi folder level path, don't you need the file extension too? Thought that was something I saw in the docs I've read so far...
EDIT: Ignore me, posted at the same time as Sophia... although, why PCX? Why do you programmers keep using this ancient format, lol!?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Font load failure

Post by Sophia »

Oh, it's worse than this.

Short explanation: dsb_get_font is unstable and shouldn't be used at all. I'll release a new version of DSB as soon as I can to fix this.

Long explanation: I did 99% of the work of making dsb_get_font support long names, except then I forgot that I did it. The C function in the core engine that is actually being called expects two parameters, a short name and a long name, but the function prototype only has one parameter. The Lua export functions and the font loader are in different files, so the compiler doesn't "notice" this. Basically, the reason the function doesn't work is that it's pulling random garbage off the stack and trying to use it as a filename.
Mon Ful Ir
Adept
Posts: 221
Joined: Sat Jan 07, 2006 1:54 am
Location: Britain

Re: Font load failure

Post by Mon Ful Ir »

Does the same problem apply to dsb_get_sound? I'm having similar trouble loading sound files.
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Font load failure

Post by Sophia »

Mon Ful Ir wrote:Does the same problem apply to dsb_get_sound? I'm having similar trouble loading sound files.
:oops:
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Font load failure

Post by Sophia »

Ok, new DSB version up, everything should work fine now.

The following syntax is now supported and recommended for fonts, as well:

Code: Select all

gfx.whatever_font = dsb_get_font("SHORTNAME", "path/to/long/filename.ext")
Post Reply