Problems with sys_font

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
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Problems with sys_font

Post 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")
Image

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:

Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Problems with sys_font

Post by Gambit37 »

UPDATE: It works fine with this font that I created:

Image

Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Problems with sys_font

Post 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...
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post 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.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Problems with sys_font

Post 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 :D
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post 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)
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post 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...
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post 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.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post by meadwarrior »

I've made a .bmp out of it, but...

Image
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post by Sophia »

That's odd. Can you send me the offending image and the log.txt? I'll try to diagnose the issue.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post by meadwarrior »

Sure! You've got a PM (well, actually two, I sent you one earlier today).

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post 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.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post 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...
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post 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?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post 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.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Problems with sys_font

Post 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://matthill.co/filesdm/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
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post by meadwarrior »

Oh yes! That worked, thank you so very much!

Now it's time to design those spell glyphs :D
Thanks again, guys!
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Problems with sys_font

Post 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
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Problems with sys_font

Post by meadwarrior »

Thanks, Gambit, really well explained!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Problems with sys_font

Post by Sophia »

Yes, thank you Gambit. The efforts of you and others to document DSB are much appreciated.
Post Reply