RichTextKit icon indicating copy to clipboard operation
RichTextKit copied to clipboard

Font Fallback breaks text alignment

Open Clancey opened this issue 6 years ago • 2 comments

Right now the current logic, is spaces uses the last Font found during the fallback. When you take into a string like Ride the Comet! ☄️ with even spaces on each side, the spacing is being used to help with padding. It should still properly center, however Emoji character spaces are a lot larger than say Helvetica.

I propose the line should be changed to RunFace = typeface;

Clancey avatar Nov 18 '19 21:11 Clancey

The logic should just find a matching typeface for missing character to glyph mappings. Everything else should use the original typeface.

Gillibald avatar Nov 18 '19 22:11 Gillibald

There are a couple of issues here that are affected by this logic.

In general I agree with @Gillibald however this was specifically was trying to prevent breaking a sequence of words that all require font replacement into separate font runs and thereby introducing a (probably redundant) font switch at each word boundary.

I'm not sure about replacing the spaces around emojis - seems their should be some more heuristics here but not sure what they should be.

Also, this may also affect alignment of font replacements in a fixed pitch base font. eg: see this example.

toptensoftware avatar Nov 19 '19 02:11 toptensoftware