How hard would it be to make a Bitmap Text Tool?

Bitmap fonts have been broken for a while now. This is a problem, as they’re incredibly useful for pixel art.

It sounds like the text tool is fundamentally built around vector fonts, the libraries it uses for text rendering don’t even try to support bitmap fonts, and the fact that it worked at all in the past was more or less an accident.

But bitmap fonts are simple!! They’re basically a grid of pixels with none of the layout complexity of vector fonts! So how hard would it be to make a dedicated Bitmap Text Tool?

I’m vaguely considering diving into the code and trying to build this. It might be easier than trying to fix the existing Text Tool, but I don’t know if it’s the way to go or if anyone else would even appreciate the work anyway.

– Frost

Actually, bitmap fonts should work again, Alvin and me tried to make sure it worked, at the least, and this was done with an eye on both emoji as well as font-hinting necessary for CJK fonts. Though, the default fontconfig on many systems will hide the bitmap formats and only show vector formats.

Text tool is currently being rewritten, as it happens, I am currently fighting fonts, though right now I’m getting myself kicked by the UI code, so that’s been slow. You can try to play with the latest nightly to see bitmap fonts working.

3 Likes

Oh, sweet!! I looked in stable a few months ago, but didn’t think to look in the recent nightlies. Definitely gonna have to try that out, thanks!

…Hm, couple years later on Krita 5.3.2.1 (from Debian) and it seems like bitmap fonts still don’t work. They show up in the list, but don’t actually render as themselves, it’s just the fallback font. Still antialiased, too. Turning off the vector layer antialiasing setting does remove the antialiasing, but makes it look awful because it’s not actually caring about the pixel grid when it does the font layout.

It’d be nice to fix the text tool. I worry it’ll just get broken in another year though when people forget that un-antialiased bitmap fonts exist and “improve” the text tool again. But yeah.

I explicitely did implement support for it, so there must be something else going on on your system. Try using text-rendering property instead of vector layer anti-aliasing. You will also want to make sure that the text is moved so it aligns with the pixel grid, you can use snapping->pixel for this, and then move it with the text tool.

1 Like

Oh!! text-rendering=“optimizeSpeed” helps a TON. Thanks!

Now I just gotta figure out why it won’t load bitmap fonts. Maybe a reboot’d help.

(Also, is there a reason why it nukes and reformats and re-adds all the junk properties to the SVG source after you close the source editor? That’s a little unexpected.)

– Frost

That’s because it reloads the whole shape back into the source editor, and certain properties are always going to be set (fill and stroke, for example).

If you’ve only been using the svg source editor for your editing, what might be going on is that fontconfig is blocking those bitmap fonts from loading. The fonts should be visible in the font-family dropdown in the text properties docker if font config can find them.

Yeah, I’ve only been using the SVG source editor. I did poke the font dropdown, and it saw the font, but the preview just had the fallback font. So I’m wondering if it’s some kind of caching thing or “needs something to be restarted” thing, since I only removed the “no-bitmaps-except-emoji” config file while figuring all this out (and then restarted krita after, but not the whole session).

Does the SVG source editor… not edit the source? Like, why is it re-adding those? Would it still re-add those (and remove the spaces after the semicolons in style=, and stuff) if I unzipped the .kra file, dug into the real layer source, and fixed it to not have the junk (stroke stuff, etc.) and have proper formatting there?

(which is an extremely clunky solution to not being able to properly edit the source, but. y’know)

Maybe I should file an issue about that bit, heh.

(at least I’m assuming it’s stored as SVG internally, IIRC the old text tool’s text was when I had to mess with it to get proper text sizing)

Neither the old or the new text tool are stored as SVG internally. They’re stored as a programmed object that gets converted to SVG when editing with the source editor. Many of the data structures are the same as the structure of SVG, it’s just that fill and stroke are an exception to this.

Oh, huh! Neat.

I rebooted and it didn’t help, unfortunately. Bitmap fonts still don’t… wait, Spleen works… wait, that’s because it’s an OTF. Spleen bitmap shows up but doesn’t work either.

I poked Libreoffice and it didn’t want to pick up bitmap fonts, but Konsole does, and renders them just fine. Hmmm.

– Frost