yeslogic / allsorts-tools

Various font tools built using Allsorts
Apache License 2.0
79 stars 12 forks source link

[feature-request]: "view" options for common text illustrations #27

Open n8willis opened 1 year ago

n8willis commented 1 year ago

Having worked with the view tool for a bit, this is a short wishlist for additional flags or switches that I would find specifically useful for generating "illustration" images of the type I use in the opentype-shaping-documents repo. For text-specific stuff; not considering emoji for the time being.

So I'm aware it's a narrow use case, and also aware that not all of them are strictly doable. But I figure I'd might as well keep them together, both for clarity and in case seeing them prompts comments about workarounds.

Obviously hb-view has developed quite a lot of options over the years. The ones I believe are most directly useful are:

Of secondary importance are:

...

Diverging from "steal the best switches from hb-view" somewhat, hb-view does have an --annotate flag that places a red spot on each glyph origin. That's helpful for debugging; for the "make informative illustrations" use case, I would prefer a different marker, such as a black-and-white crosshairs. Mostly due to the introduction of color, but also for size.

It is also possible to request old/deprecated shaping models in hb-view (i.e., Indic1), but the syntax for doing that is via private --script/--language tags, which is not ideal. Seeing (and showing) how deprecated OTL shaping models work is clearly low-priority, but not entirely zero.

...

Last, but not least, the biggest one is actually feature deactivation. And, more generally, some additional options for controlling feature behavior.

Deactivating a specific GSUB feature is the main use case, to show "before"" states; same with deactivating GPOS features (although those are easier to fake by setting codepoints in isolation, etc). IIRC, there are architectural reasons why this isn't in the current feature set, but I'm including it for completeness. The "faking it" approach isn't ideal, since the result doesn't show you what the default behavior/positioning of the font is, and sometimes seeing the default/feature-less result is the piece of information that you need.

wezm commented 1 year ago

--preserve-default-ignorables is useful for showing ZWJ/ZWNJ/VS/CGJ etc glyphs when they font has them, which is a common want when trying to illustrate the shaping process in a step-by-step fashion. I think it would also be useful for other debugging operations, e.g. when running tests on a text rather than entering the codepoints explicitly.

For this one, would shaping still be performed? Or is it mostly a way to generate an SVG from the input glyphs?

n8willis commented 1 year ago

For this one, would shaping still be performed? Or is it mostly a way to generate an SVG from the input glyphs?

So, generically, it would still be doing shaping. I think the HarfBuzz version is not doing any special treatment (but I could be wrong about that; I'll have a look).

My reasoning is that I believe the general case is that the input sequence would be "Codepoint, ZWJ, Codepoint2" and the sequence would match a GSUB ligation that removes the ZWJ and one or both of the default Codepoint glyphs. So, in correct shaping, it's actually getting removed. Therefore if you can see the ZWJ glyph in the output, it's told you that the GSUB lookup didn't happen (or didn't work as expected).

Using it for making illustrations is the less-common utility for sure. The font engineering debugging folks surely expect that the sequence gets processed identically to how it would without the --preserve switch ... I think. But I'll peek and see if any special casing happens.