Scribble icon indicating copy to clipboard operation
Scribble copied to clipboard

Get Scribble working with font_add()... somehow

Open JujuAdams opened this issue 3 years ago • 8 comments

JujuAdams avatar Jul 05 '20 14:07 JujuAdams

Needs checking against font_get_info() but I don't hold much hope.

JujuAdams avatar Dec 04 '21 23:12 JujuAdams

It was a nice dream while it lasted :(

DragoniteSpam avatar Dec 05 '21 01:12 DragoniteSpam

Huh. Looks like font_get_info() does work with font_add(). Glyphs that have not been cached yet have an x/y position of -1. I am a bit concerned about how this'll pan out if glyphs are removed from the cache at any point, but the best I can do is label it as a point of failure and move on.

JujuAdams avatar Dec 10 '21 21:12 JujuAdams

From some of my testing, I haven't seen glyphs cache disappear at all. I've tried flushing the texture memory. Haven't had any issues with the texture or the glyphs at all. So we could cache the results of the glyphs after drawing the entire string, fetching the font info and storing it, and then add the texture as a sprite if there's concerns of the glyph/texture possibly being cleared at random?

tabularelf avatar Mar 16 '22 03:03 tabularelf

jesus, this has been almost two years in the making now

DragoniteSpam avatar Mar 16 '22 04:03 DragoniteSpam

That is has been indeed

tabularelf avatar Mar 16 '22 04:03 tabularelf

Adding two gists to here that I've previously dabbled with when testing with making font_add() work. The current issues that lie at hand are:

  • If you have too many characters in a font, it'll most likely break the fonts texture page itself (characters replacing eachother)
  • There's a separate variable that controls the size of the font texture page font_texture_page_size. We can probably do this on the fly with a build script, since we can access this kind of information.
  • We don't necessarily have a way to manage all of these fonts together (whether they share the same texture page or have their own.)
  • Very minor (and I don't know if we'd support it), but font families also do not work super well with Scribble (tested on Windows thus far.) Mainly Scribble is unable to pick up spacing from font families last I can recall. Font Families mostly just provide an easy way to add fonts from the system itself, rather than including a font file.
  • Some glyphs may have an offset (needs testing)

I'm considering taking some pages from Collage and adding a mini texture page builder for the purpose of Scribble being able to store multiple font textures. And then if we get a large character set, Scribble can break the charset down into multiple fonts, extract their characters and data and add to a custom texture page. Making it easier (and more optimized for vertex/texture swaps).

If we were to go down this route, I'm happy to expand upon my current gists scripts (down below) that already do showcase some of the current issues at hand, and poke in a custom texture page builder for Scribble.

https://gist.github.com/tabularelf/f493624796dd8bbba85466101ad1eabd https://gist.github.com/tabularelf/94337b30295fcba67d57e7f2bb03ff16

tabularelf avatar Aug 12 '22 11:08 tabularelf

I've realized from this comment here that the custom texture page side of things might not be as farfetched... Shouldn't hurt then to try this out.

tabularelf avatar Aug 12 '22 12:08 tabularelf

Largely complete now. Thanks everyone for your help and advice.

JujuAdams avatar Feb 07 '23 12:02 JujuAdams