Page 1 of 1
Problems with sys_font
Posted: Fri Nov 09, 2018 11:47 am
by Gambit37
I extended the system font with some extra/missing characters. But I can't seem to use the new font successfully.
Using a graphics replacement method doesn't seem to make any difference:
Code: Select all
gfx.sys_font = dsb_get_font("font_sys_extended")
The above code does nothing, the existing font is still used.
If instead I do this, then DSB does seem to render it, but it's tiny!?
Code: Select all
sys_font = dsb_get_font("font_sys_extended")
I tried just placing a file named
sys_font.pcx in the dungeon root folder. That doesn't work, nor does a file named
fontgrid.pcx (the actual file name extracted from DSBs graphics).
Is this bugged? Am I doing something wrong? Or is it not possible to replace the system font? It used to work in my old tests with other fonts, so I'm confused why I now can't get it to work with my extended original sys font?
This is the new font image that I'm using:

Re: Problems with sys_font
Posted: Fri Nov 09, 2018 11:59 am
by Gambit37
UPDATE: It works fine with this font that I created:

Re: Problems with sys_font
Posted: Fri Nov 09, 2018 12:03 pm
by Gambit37
I'm guessing that you're going to say that DSB/Allegro doesn't support the extended ASCII set (128-255). I did consider that, so I also cut back my extended sys font to be the same size as the original (ie, I deleted the extra 8 rows I'd previously added). But DSB still rendered it tiny as in my first screenshot above.
There's something very weird about the sys_font...
Re: Problems with sys_font
Posted: Sat Nov 10, 2018 12:24 am
by Sophia
I had a post but the forum ate it, and I don't really feel like retyping, so this will be kind of short.
You need a 256 color image where index 0 is the background of each character, index 1 is the foreground, and index 255 is the spacer between each characters.
As we've noticed already, the font handling in Allegro 4 is... not the best.
Re: Problems with sys_font
Posted: Sun Nov 11, 2018 7:49 pm
by Gambit37
For my own custom fonts, I've always created them as you suggest as they work fine. But the sys_font in the DSB graphics download is not constructed that way. It's a 2 bit font, and the colour indexes for the foreground and spaces between each letter are #1 and #2 respectively. But it still works? Yet if I create the same 2 bit palette for my own version of sys_font, it doesn't work at all, I get that weird junky tiny pixel thing I showed earlier.
So custom fonts created as you just described do work, but the sys font supplied in the graphics download don't. Maybe the font in the graphics download is not the same as what's bundled in the graphics.dsb that comes with the actual DSB zip?
Anyway, I've fixed it by using a correctly indexed font, so I know all this is moot. I just can't help but be curious about the peculiar sys_font... I guess I just don't like unresolved things like this, lol

Re: Problems with sys_font
Posted: Mon Nov 12, 2018 4:18 am
by Sophia
The sys_font in the DSB graphics download is constructed that way for me when I tried to import it into Paint Shop Pro 9. My guess is that PCX is such an ancient, weird format that whatever you're using isn't importing it properly, or is perhaps trying to be too clever (reducing a 256-color image that only uses 3 colors to a 4-color image, for example) or doing something else in the importation process that, when you save it again, ends up producing a weird PCX image that Allegro can't really figure out how to use. Or something.
("Not using PCX" is on my list of things I'd do if I were starting DSB over today)
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 2:15 am
by meadwarrior
Hello!
I have problems with changing the system font as well.
Code: Select all
gfx["CHICAGO"] = dsb_get_font("CHICAGO", "gfx/gui/chicago.png")
That's what I do, however he always tells me that he can't find the font.
I replaced my fontgrid with Gambit's font example for testing, still no luck...
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 2:32 am
by Sophia
Fonts can't be png images. Convert the image to bmp (or pcx, but pcx is weird, so you probably want to use bmp) and it'll work.
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 2:44 am
by meadwarrior
I've made a .bmp out of it, but...

Re: Problems with sys_font
Posted: Wed Dec 19, 2018 2:48 am
by Sophia
That's odd. Can you send me the offending image and the log.txt? I'll try to diagnose the issue.
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 3:01 am
by meadwarrior
Sure! You've got a PM (well, actually two, I sent you one earlier today).
Thanks!
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 3:23 am
by Sophia
Somehow in the conversion process that bitmap got changed into something that Allegro doesn't like. The yellow background needs to be color index 255. I filled it in color 255 (gray in that image's palette) and tried again and the image loaded without a problem.
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 3:31 am
by meadwarrior
Hmm, I've never worked with bitmaps before, so I'm a bit stumped at finding out how to even find out the color palette of an image...
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 3:53 am
by meadwarrior
Hmm, so I found this thing here
https://jonasjacek.github.io/colors/
and used colors 0,1 and 255... Still nothing.
How did you find out what color 255 was for this image? Or are these the same values for every bitmap?
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 4:12 am
by Sophia
You'll need to check the documentation of your art program of choice for information on how to work with paletted images, because I really have no idea as to the specifics of your situation. You probably want to use some sort of "color picker" or some such tool to get access to the color palette, though if you're using Photoshop I've heard that the support for 256 color images isn't actually the best.
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 9:40 am
by Gambit37
Fonts can be 8bit (256 colours) or 24 bit (millions of colours). But stick to 8 bit if you want predictability in DSB, and want to recolour your fonts using DSBs text-writing functions.
Do you use PhotoShop? If so, you can reduce a font to 8-bit using the
Image > Mode > Indexed Colour option. From the
Palette dropdown, select
Custom... which will popup a colour table that contains the "best fit" palette for your current image. However, this may not be correct for DSB, so instead, click
Load and load in this custom palette that I created for this very purpose:
https://files.matthill.co/dm/powerpink+yellow.act
It uses yellow as the background, powerpink as the letter background, and white for the characters, and has those colours in the right indexes for DSB to work its magic. So make sure your font uses those colours!
Then click OK out of all these screens and your image will be reduced to the correct 8bit palette. Save it as a PCX or BMP then call it in your
graphics.lua as normal. (I would recommend that before doing all this, you
Select All and
Copy Merged your entire source image into a new fresh document before doing the palette conversion -- the amount of times I've gone and saved my source PSD as a converted 8bit image...!)
Or just ignore all this, and use FontEd for constructing your fonts
http://members.allegro.cc/miran/fonted.html
Re: Problems with sys_font
Posted: Wed Dec 19, 2018 2:05 pm
by meadwarrior
Oh yes! That worked, thank you so very much!
Now it's time to design those spell glyphs

Thanks again, guys!
Re: Problems with sys_font
Posted: Thu Dec 20, 2018 11:52 am
by Gambit37
I've now created a page about fonts on the DSB wiki, hopefully it's helpful:
https://dmwiki.atomas.com/wiki/DSB/Fonts
Re: Problems with sys_font
Posted: Thu Dec 20, 2018 8:28 pm
by meadwarrior
Thanks, Gambit, really well explained!
Re: Problems with sys_font
Posted: Thu Dec 20, 2018 8:44 pm
by Sophia
Yes, thank you Gambit. The efforts of you and others to document DSB are much appreciated.