Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for bitmap and png "fonts" #4506

Merged
merged 2 commits into from Dec 27, 2013
Merged

Conversation

@Gatleos
Copy link
Contributor

Gatleos commented Nov 19, 2013

This is basically feature-complete, but could probably use some heavy optimization to speed it up and reduce the memory footprint. I'm just throwing it out now in case anybody had suggestions for improvements.

This should allow Cataclysm to load in image files (.bmp or .png) in place of font files for curses mode. Obviously it will only work in the SDL version. It's perfectly compatible with tiles mode, and doesn't appear to have a larger memory footprint than loading a font and caching glyphs. To use an image font, just put it in the fonts folder and put its name (with file extension!) in FONTDATA. Set the font dimensions as normal.

There are a few issues that need to be worked out:

  • It's about time the FONTDATA file was made a little easier to use, now that I've complicated the way it works a bit (image files use an extension, font files don't). It should probably be converted to JSON and made more readable.
  • Currently, Cataclysm will load in an image file and remove a magenta (255,0,255) background from it. Then it makes 15 copies, one for each color of ascii character. This process could probably be optimized, since Cataclysm appears to only use the first 128 ascii characters. I need confirmation on this.
@Gatleos

This comment has been minimized.

Copy link
Contributor Author

Gatleos commented Dec 21, 2013

So does anyone have any opinions on this? I don't care if you think it's a bad idea, I just want to close this pull request if there's no desire for it.

It's much easier to use image files containing ascii characters rather than finding font files. That was the rationale behind this change.

@8bitKittyKat

This comment has been minimized.

Copy link

8bitKittyKat commented Dec 22, 2013

I haven't contributed towards the project (yet) but I'm new to the game as of last night and this is one of the first features I noticed was missing in the tiles build. I don't know about anyone else, but I definitely want this feature in the main builds.

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 24, 2013

Nope, this is a MUST HAVE.

In fact if you could make it work on the largest scale it would be great:
#4236

Hopefully it gets merged so I can test it.

But what's the actual format? I mean, how do I have to order the exact sequence so that it reads it properly?

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 24, 2013

You really can't let this slip away again. It's literally the most significant thing that can happen to this game since tile mode has no hope of ever working properly now.

I really want to test it out, please merge it.

Caveat: this needs to be done so that I can load a standard font for the text and use the png font exclusively with the map. Otherwise it's not really helpful.

@8bitKittyKat

This comment has been minimized.

Copy link

8bitKittyKat commented Dec 25, 2013

@Abalieno
I did some testing with this the other day and the bitmap font format it uses is known as Code page 437; it's basically an extended ASCII format from the days of MS-DOS. To make things easy, you can use the character sets that are compatible with Dwarf Fortress, which you can download at the link below.
http://dwarffortresswiki.org/index.php/Tileset_repository

If you drop one of the bitmap font PNGs compatible with DF in the Font folder, you can use it in FONTDATA. So if you have say, 10x10.png as a bitmap font, you'd format FONTDATA like so.

10x10.png
10
10

The dimensions must be the same as the tile size in the bitmap font or it'll crash on load.

It does indeed render the bitmap font for both the map and the text. I'm not sure how useful it would be to specify a separate fonts for either the map or the text, and it might be outside of the scope of the code in this pull request, since this simply adds an additional format for the game to use as a font.

Also just in case you weren't aware, this only works under SDL mode, aka cataclysm-tiles. Bitmap fonts are not supported in any standard console/terminal that I'm aware of. I am curious why you think tile mode will never work properly, but I think that goes a bit off-topic from this pull request.

Anyway, I hope that I managed to provide some useful information. If you can't compile it yourself I can try to package a build for you; just let me know what OS you are using.

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 25, 2013

Yes, I always use this 9x9 font that I also use in Dwarf Fortress: http://cesspit.net/misc/source.png

But the problem is that I can already use a square font. What is absolutely required is to finally be able to use two different fonts, one for text, the other for the map. This because you need a square font like 9x9 to have a decent-looking map, and you instead need a normal non-square font for the text. Otherwise a square font makes the panel on the right with the text TOO HUGE, and it's all space instead that you'd gain for the map if you instead used a normal font for the text.

Tile mode is non functional because it has plenty of bugs, performance problems and it's basically impossible to make a complete tileset for it right now. And it's dead simply because no one works on it, and the only dev who was has left the project a while ago.

So someone please at least give us the ability to load two different fonts for text and map. Otherwise the only hope is on Cataclysm 2.

@8bitKittyKat

This comment has been minimized.

Copy link

8bitKittyKat commented Dec 25, 2013

I'll look into how feasible it is to use two different fonts in tile mode. I've been using tile mode exclusively and coding in a few things to it, but I don't really know C or SDL that well. I know it's difficult to keep a tileset updated to the experimental builds but I would think that would be expected. I actually think the current format the tilesets use is pretty bad and I may attempt to clean it up a bit. But then again I haven't poked around at the current code enough so I have no idea how much work all of this will entail.

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 25, 2013

Nope. Tile mode already uses two "fonts", since it loads normal fonts for text, and tiles for map.

Tile mode isn't going to work and no one maintains it. It's a dead end, don't waste time on it. We just need a way to load a font AND a bitmap, and use the bitmap on the map.

If this commit loads ONE font bitmap, then it shouldn't be very hard to load two. And then in the output functions you just have to add a condition to check what kind of output it's doing, and use one or the other.

@kevingranade

This comment has been minimized.

Copy link
Member

kevingranade commented Dec 25, 2013

Sorry this has languished, it looks straightforward enough, my initial holdup was not having bitmapped fonts handy, I'll see about grabbing some of the DF bitmaps and trying it out with those.

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 25, 2013

We actually have already the possibility of using bitmap fonts as .ttf see for example my current configuration (with my colors):

cataascii

What we actually need is to load a separate font for the text that is more readable than the font used for the map.

And this is instead how it should look in a ideal world:

cataascii2

@dwarfkoala

This comment has been minimized.

Copy link

dwarfkoala commented Dec 25, 2013

Beautiful, Absolutely beautiful.

On Wed, Dec 25, 2013 at 3:47 PM, Abalieno notifications@github.com wrote:

We actually have already the possibility of using bitmap fonts as .ttf see
for example my current configuration (with my colors):

[image: cataascii]https://f.cloud.github.com/assets/4656436/1809216/b7525918-6dbe-11e3-95a9-35cc499ae9a5.gif

What we actually need is to load a separate font for the text that is more
readable than the font used for the map.


Reply to this email directly or view it on GitHubhttps://github.com//pull/4506#issuecomment-31207267
.

@kevingranade

This comment has been minimized.

Copy link
Member

kevingranade commented Dec 26, 2013

I have this half merged, but it breaks color handling for curses builds
since init_color() never gets called. Why did you move the init_color()
calls? Anyway, update with that fixed, or if I get around to it first I'll
sort it out. (Later tonight)

@Gatleos

This comment has been minimized.

Copy link
Contributor Author

Gatleos commented Dec 26, 2013

@kevingranade It's been a bit since I looked at the changes, but I ended up moving init_color() to fix that. Last I checked it worked in sdl and curses mode. I'll take another look and see if it's working.

@Abalieno I'm definitely planning on adding support for a separate text font, this pull request is just the foundation for that.

@kevingranade

This comment has been minimized.

Copy link
Member

kevingranade commented Dec 27, 2013

It's possible I messed up something in the merge, will take another look.

@Abalieno

This comment has been minimized.

Copy link
Contributor

Abalieno commented Dec 27, 2013

@Gathlos
If you are messing with this part of the code could you look up the thing I was asking?
Here: #4236

That would be better than all other cases (but it leaves out the little bugs in tile mode).

@kevingranade kevingranade merged commit 96f8e2b into CleverRaven:master Dec 27, 2013
1 check failed
1 check failed
default Unmergeable pull request.
@kevingranade

This comment has been minimized.

Copy link
Member

kevingranade commented Nov 30, 2019

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/using-bitmap-as-a-font/22107/1

@kevingranade

This comment has been minimized.

Copy link
Member

kevingranade commented Dec 6, 2019

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/color-generation-of-image-fonts/22165/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.