Changes between Version 3 and Version 4 of ComplexTextController


Ignore:
Timestamp:
Jan 26, 2017 8:25:03 PM (7 years ago)
Author:
mmaxfield@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ComplexTextController

    v3 v4  
    3636After creating a ComplexTextController, clients can do a couple things with it. First, they can ask for the totalWidth() which is just the vector from p to y above. Second, they can create a sort of cursor into the text, and tell the cursor to advance in string order. After you advance the cursor, you can ask for the runWidthSoFar() which represents the sum of the layout advances you have traversed. You can also pass a GlyphBuffer to advance() which records paint advances.
    3737
    38 There are some interesting properties of this, though. First, advance() happens in string order, not glyph order. Remember that glyphs are held in glyph order inside ComplexTextController, which means when you advance in the string, it can be nontrivial to find which run you are currently inside of.
     38There are some interesting properties of this, though. First, advance() happens in string order, not glyph order. Remember that glyphs are held in glyph order inside ComplexTextController, which means when you advance in the string, it can be nontrivial to find which run you are currently inside of. Also, the reported paint advances are appended in string order, so if you have an RTL string, you have to reverse() the GlyphBuffer before using it to paint.
    3939
    4040Secondly, we only report the initial paint advance when you actually traverse across the leftmost character, which means if your string is RTL you have to consume the entire string in order to get it. This is a problem if you want to know the paint advance (relative to the origin of the entire TextRun) of an arbitrary glyph in the middle of an RTL TextRun. However, you can exploit the fact that the sum of the layout advances is equal to the sum of the paint advances. If you use the totalWidth() to find the distance from p to y in the above image, you can subtract all of the paint advances from y to s, which leaves you with the advance from p to s.