Latios-Framework icon indicating copy to clipboard operation
Latios-Framework copied to clipboard

Calligraphics: PrevCurNext MultiObject

Open Dreaming381 opened this issue 7 months ago • 0 comments

Calligraphics: PrevCurNext MultiObject

Calligraphics has a powerful character parsing engine. But currently, it assumes that every pieces of renderable text has a single Unicode attached to it. This task is to break away from this assumption.

Task is Prerequisite For

  • Combining Diacritical Marks
  • Sprites
  • Emojis

Background

In Calligraphics, there are two files named GlyphGeneration.cs and RichTextParser.cs In the former, there is a type named PrevCurNext. This contains three enumerators into the CalliString being processed. The idea is that we keep on hand the data regarding the glyph before and after the glyph we are currently processing so that we can perform kerning correctly.

The rich text parser always runs a glyph ahead. When it successfully parses a tag, it fast-forwards the “next” enumerator and exports a new configuration which will be applied after the rest of the current glyph is processed.

The main flaw with this design is that sometimes a rich text tag can itself be a glyph, or should be treated as a non-visual character for word-wrapping purposes. There are also situations where multiple Unicode characters should be combined into one object. We want a new PrevCurNext pipeline that can accommodate these use cases.

Base Requirements

Implement a new PrevCurNext that provides an enumeration specifying the type of object contained, ranges within the CalliString in the forms of bytes, Unicode runes (including tags), and visual characters. An object can be a single Unicode rune, a span of runes for emojis or combining diacritical marks, a cspace or similar tag object, or a sprite index. Tags which only affect the configuration are excluded.

Write a new lookahead parser to replace the existing rich text parser which can populate the new PrevCurNext.

Rework the remainder of GlyphGeneration to use the new PrevCurNext. Ignore emojis, combining diacritical marks, and sprites for now. The goal is purely feature-parity with the current solution, except better handling of cspace line wrapping.

Dreaming381 avatar Jul 01 '24 05:07 Dreaming381