Selecting a partial ligature using DirectWrite

Using the HitTestPextPosition style API from IDWriteTextLayout I was not able to correctly process text positions inside "ti", "ffi" or other ligatures with fonts such as Calibri. It always returns the position after or before the ligature is not inside, like t | me or f | f | i.

What is the recommended way to move carriage inside ligatures using the DirectWrite API?

+5
source share
1 answer

There ... no inside position if you have GSUB replacement enabled?

The linearities of the Opentype GSUB are single-character substitutions for code sequences, matching, and not "multiple glyphs compressed together." They literally differ from each other, single glyphs, with only bounding rectangles and one left and right side supports for placing / aligning the cursor. If you have text A + E , and the font has a ligature replacement that turns it into Ӕ , then with ligatures turned on in this code sequence there really are only two cursor positions: and Ӕ| . You cannot place the cursor “in the middle” because there is no “middle”; it is a single, atomic, indivisible symbol.

The same goes for f. ligatures such as , , , , or : these are single glyphs once formed with GSUB enabled. This is actually what was supposed to happen if you included the GUBS replacement means that you clearly want the text to be presented - for all purposes and purposes - as having atomic characters for a one-to-one replacement, for example, turning a complete phrase "صلى الله عليه وعلى آله وسلم", as well as variations of this, in one glyph ﷺ.

If you want to work with basic codepoint sequences, so if you have text with f + f + i , it will not turn it into , you will need to download the font using the liga OpenType function disabled.

0
source

Source: https://habr.com/ru/post/1274966/


All Articles