How to reorder color font as second letter behind the first one while overlapping?

Tanveer Qureshi
Posts: 18
Hello Typedrawers,
I am working on a color font and kerning them as they are overlapping. By default, the second letter always sits above the first letter, the third letter on the second, and so on. Is there any way the second letter goes behind the first one, third behind the second one and so on?
I am working on a color font and kerning them as they are overlapping. By default, the second letter always sits above the first letter, the third letter on the second, and so on. Is there any way the second letter goes behind the first one, third behind the second one and so on?
0
Comments
-
This is a limitation of the current color font specification (actual the current font rendering in general; The same happens with simple back fonts, too but there it is not a problem.)
I brought this up in various meetings and discussions over the years.4 -
Glyphs are painted in sequence. There isn’t really any way around this, and unlikely to be, as it is so basic to text rendering. It would require a major change in how text is handled in systems and applications to reverse the order in which glyphs are painted for some fonts in some situations, so it is the sort of thing that wouldn’t get traction in those places. I think probably the most direct way to do it would be in a closed environment: something like a browser-based typesetter that took care of the glyph layering and output some static graphic formats.3
-
I wonder if it would be possible (in any of the color font formats) for a glyph to act as a mask or cut-out for the next glyph to be rendered, similar to the way you can do shape math in vector graphics apps (including font editors), maybe with a special layer in the first glyph. That way, you wouldn't need to change the existing glyph-drawing order of text.0
-
>I wonder if it would be possible (in any of the color font formats) for a glyph to act as a mask or cut-out for the next glyph to be rendered...
Currently, not as such. The most that could be done currently is to provide context for a substitution of the following glyph.
(Hmmm... One could imagine an extension to COLR that has a PaintSubstGlyph table that references a glyph but allows the glyph ID to be substituted based on context of preceding or following base glyph IDs.)1 -
One could imagine an extension to COLR that has a PaintSubstGlyph table that references a glyph but allows the glyph ID to be substituted based on context of preceding or following base glyph IDs.Can you elaborate on that idea, Peter? I don’t see how substituting GIDs gets around the glyph painting order problem, or are you suggesting that the new table would enable a preceding glyph to be (re)painted based on the following context without also (re)painting that context?0
-
In principle, you could use GSUB substitution to get an alternate for a glyph that has a cut out exactly to match the immediately preceding glyph. For COLRv1 descriptions, you'd end up with a different base glyph ID and a different graph of paint tables (though some of those could be shared).
Now, Mark Simonson asked about a glyph acting like a mask for another glyph. Well, COLRv1 does support exactly that, though in a static relationship. That is, for base glyph ID (say) 1, I can have a PaintGlyph referencing GID 2 that is used for a fill, but then use PaintComposite to set up a mask where another PaintGlyph referencing GID 3 provides the shape for the mask; but that combination is static: for base glyph ID 1 the mask uses always and only GID 3. The idea occurred to me was to have an extension that allowed the mask use a new table that allow referencing a GID but also allows the choice of GID to be determined by other preceding or following glyphs in the (base glyph ID) glyph sequence. So, it would provide GSUB-like substitution capability but have that integrated into the graph of a COLR description.
Just a raw idea; haven't thought through any details, including whether it might be problematic to implement.1 -
Thanks, Peter.
I also thought about the GSUB substitution in which the contextually substituted second glyph has a cut out to accomodate the shape of the preceding glyph. But I don’t think this is really practical, because you’d need a contextual second glyph with appropriate cut-out for any preceding shape to achieve Tanveer’s desired effect.
If I understand your other idea correctly, a mask is a shape that covers a region of a glyph, but allows other objects within that region that are not part of that glyph to be displayed? Could this work in such a way that the mask matches the shape of the preceding glyph, knocking out that region of the target glyph in a way that enables the preceding glyph to ‘show through’, i.e. the mask effectively makes a region of the target glyph transparent?
The font would need a mask shape corresponding to every glyph that could precede an arbitrary target glyph—still much more efficient than the GSUB knockout hack—, and would need a mechanism to position that mask relative to the target glyph to exactly cover the same region as the preceding glyph (this would get complicated if any kerning were involved, and tracking would presmably break things).0 -
RTL?0
-
I demonstrated a way to do this at ATyPI Paris, but it depends on magic from the shaping engine. The basic approach is to draw the shadow layer for each word, then add a negative horizontal advance width the width of the whole word, then draw the letters again in the top layer.
Duplicating the word and calculating the correct advance width can't easily be done in OpenType Layout so required the use of the WASM shaper. I kind of saw this as a compelling example, but implementor interest in the WASM shaper has been almost zero, so this is not a practical approach except in very limited circumstances when you control the text stack. But here's the code anyway: https://github.com/harfbuzz/harfbuzz-wasm-examples/tree/main/shadow3 -
RTL?As a hack, one could use a right-to-left directional override character, and then type text backwards. That would achieve the look of what Tanveer is seeking, but it wouldn’t be useful text.
0 -
I demonstrated a way to do this at ATyPI Paris, but it depends on magic from the shaping engine. The basic approach is to draw the shadow layer for each word, then add a negative horizontal advance width the width of the whole word, then draw the letters again in the top layer.I don’t think that shadow mechanism is quite the same case, Simon. What Tanveer wants is a series of overlapping letter shapes where the preceding letter overlaps the following letter. So imagine it as something like letters with an outline:
2 -
John Hudson said:
If I understand your other idea correctly, a mask is a shape that covers a region of a glyph, but allows other objects within that region that are not part of that glyph to be displayed?
In this way, it's possible to use any glyph as the shape to cut out of any other glyph, without needing to define additional glyph outlines for a glyph a with some other glyph shape cut out.2 -
So, to confirm using my illustration above, the whole of the glyph L could be a shape that it is cut out of the glyph I which in turn could be a shape that it is cut out of the glyph K, and so on....
I like that very much, because it suggests that the behaviour would survive tracking or other glyph layout adjustments.0 -
>I like that very much, because it suggests that the behaviour would survive tracking or other glyph layout adjustments.
Well... not necessarily.
Consider your example, and suppose gL is the glyph for L, and gI is the glyph for I. There would be two occurrences of gL involved in the layout and rendering. First, during layout (before COLR data is processed), gL is positioned relative to gI. After the layout is finished and rendering begins, the COLR data is processed and a second instance of gL is used in the rendering of gI. At that point, the placement of that second instance of gL is entirely relative to the coordinate system of gI... unless there were some additional extension of COLR that allowed transforms that can have values that vary based on preceding or following glyph context (which is not currently supported).1 -
It seems coldtype library supports such rendering using current fonts
1
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 814 Font Technology
- 1.1K Technique and Theory
- 629 Type Business
- 449 Type Design Critiques
- 548 Type Design Software
- 30 Punchcutting
- 137 Lettering and Calligraphy
- 84 Technique and Theory
- 53 Lettering Critiques
- 495 Typography
- 307 History of Typography
- 115 Education
- 73 Resources
- 509 Announcements
- 82 Events
- 107 Job Postings
- 153 Type Releases
- 166 Miscellaneous News
- 271 About TypeDrawers
- 53 TypeDrawers Announcements
- 117 Suggestions and Bug Reports