DescriptionSkPDF: Join Positioned Text
When N sequential positioned glyphs differ in positions by exactly the
advances of the first (N-1) glyphs, join the glyphs into a string
rather than changing the text matrix between each glyph draw.
Decreases PDF output size by about ~1.4%. Potentially more on
text-heavy pages.
A single-typeface PDF of an 27kB ASCII document shaped with harfbuzz:
before: 187743 Bytes
after: 65513 Bytes
difference: -65.1%
Before:
BT
/F0 13 Tf
1 0 0 -1 143.5 61 Tm
<0029> Tj
1 0 0 -1 150.634765 61 Tm
<004C> Tj
1 0 0 -1 154.602050 61 Tm
<0055> Tj
1 0 0 -1 160.245117 61 Tm
<0048> Tj
1 0 0 -1 167.925781 61 Tm
<004B> Tj
1 0 0 -1 176.469726 61 Tm
<0052> Tj
1 0 0 -1 184.518554 61 Tm
<0056> Tj
1 0 0 -1 190.980468 61 Tm
<0048> Tj
ET
After:
BT
/F0 13 Tf
1 0 0 -1 0 0 Tm
143.5 -61 Td <0029004C0055> Tj
16.7451171 0 Td <0048004B005200560048> Tj
ET
Also: update the Text matrix with the `Td` operator, instead of
overwriting it with the the `Tm` operator. In the worst case, when
every glyph is positioned differently than it's advance, this still
makes the command stream smaller:
Before:
...
1 0 0 -1 58.328125 660 Tm <0055> Tj
1 0 0 -1 61.609375 660 Tm <004C> Tj
1 0 0 -1 63.828125 660 Tm <0056> Tj
...
After:
...
3.140625 0 Td <0055> Tj
3.28125 0 Td <004C> Tj
2.21875 0 Td <0056> Tj
...
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2150393002
Committed: https://skia.googlesource.com/skia/+/f0c30f55665eb3555ca438855d4995baed182e97
Patch Set 1 #Patch Set 2 : 2016-07-15 (Friday) 16:11:07 EDT #
Messages
Total messages: 16 (12 generated)
|