I’ve been trying to come up with a scripting solution for designers to comfortably design Mongolian-script fonts:
https://github.com/lianghai/mongolian/tree/master/glyphs-app/scripting
Currently the rotate_to_vertical.py
and rotate_to_horizontal.py
scripts allows a user to rotate an existing font drawn in the LTR way to TTB, and rotate back to LTR. The export_instances.py
script rotates a TTB font to LTR in the background for exporting. (The following screenshot is taken in Tengis’ work-in-progress project.)
However, many architectural limitations of Glyphs make it painful and sometimes a long shot to find reliable workarounds.
Therefore here I’m writing some ideas down. I understand the improvement for Mongolian scripts won’t be a development priority (3type and Tengis already have enough contact with the Glyphs team—I’m not really here to add pressure), but I hope such analyses provide some valuable review of Glyphs (and other editors)’s architecture nonetheless.
The Edit view’s current vertical mode
- Totally designed for upright glyphs in vertical text.
- Without rotation, all the vertical metrics (ascender, cap height, x-height descender) are useless and only cause confusion. Plus there’s even the obscure vertical origin.
- I had to zero the three above-baseline vertical metrics to avoid showing them in the Edit view, and set descender to the original ascender - descender to keep the sum height intact, so glyph thumbnails and the preview panel is not messed up. The four sides of the metric square you see in the screenshot above are actually: x = 0, horizontal width, y = 0, vertical width.
- It is possible for me to write a reporter plugin that rotates glyphs to sideways in the Edit view’s vertical mode while not messing up with other functions like outline editing?
- Line-to-line progression direction is determined by heuristics on the glyphs’ script value, and script values like “mongolian” and “han” lock the direction to either LTRTTB or RTLTTB.
- This is okayish but probably not a necessary magic behavior.
- Even the constants
LTRTTB
andRTLTTB
’s names seem to suggest some architectural confusion, as the line-to-line progression actually has nothing to do with the horizontal direction LTR/RTL. Fyi, CSSwriting-mode
valuesvertical-rl
andvertical-lr
are a good example of a proper abstraction from all the mathematically possible inline direction and line-to-line progression.
Proposals
- The vertical Edit view should be built in a way that it assumes sideways glyphs by default. Treat upright CJK glyphs and emojis as special case.
- This will align with today’s mainstream layout engines’ default behavior.
-
GSGlyphInfo
should have a new property specifying how a glyph should be by default placed in a vertical Edit view.- The minimal version would be a boolean for sideways/upright, like what UAX #50’s
U
vsR
values do. - Considering that even UAX #50 is facing a potential need for extending (because certain historical RTL scripts are apparently expected to be set TTB instead of BTT, therefore their glyphs need to be rotated 90° anti-clockwise instead of the usual 90° clockwise), it’s probably better for this property to be prepared for all the four orientations.
- The default values can be derived from UAX #50’s data.
- The minimal version would be a boolean for sideways/upright, like what UAX #50’s
- The Edit view can have two toggle buttons for inline text direction (LTR vs RTL) and vertical mode (off, vertical-lr, vertical-rl).
- In a vertical mode, LTR becomes TTB, and RTL becomes BTT.
- Glyph rotation is done on a glyph-by-glyph basis, based on each glyph’s new property for its expected rotation in vertical mode.
There are some additional issues I’ve run into when dealing with GSFont
’s vertical kerning data. Will open a separate thread.