Page 1 of 1

(fixed) Font load failure

Posted: Mon Dec 06, 2010 4:34 pm
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.

Re: Font load failure

Posted: Mon Dec 06, 2010 7:45 pm
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.

Re: Font load failure

Posted: Mon Dec 06, 2010 7:47 pm
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!?

Re: Font load failure

Posted: Mon Dec 06, 2010 7:54 pm
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.

Re: Font load failure

Posted: Mon Dec 06, 2010 8:04 pm
by Mon Ful Ir
Does the same problem apply to dsb_get_sound? I'm having similar trouble loading sound files.

Re: Font load failure

Posted: Mon Dec 06, 2010 8:18 pm
by Sophia
Mon Ful Ir wrote:Does the same problem apply to dsb_get_sound? I'm having similar trouble loading sound files.
:oops:

Re: Font load failure

Posted: Mon Dec 06, 2010 10:11 pm
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")