64 {
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 int emSize;
96
98
99 std::vector<SkGlyphID> glyphIDs;
101 glyphIDs.push_back(
SkToU16(index));
102 });
104
105
106 auto advances = std::unique_ptr<SkScalar[]>(
new SkScalar[
glyphs.size()]);
107
108
109
110
111 size_t numIntAdvances = 0;
114 if ((int32_t)currentAdvance == currentAdvance) {
115 advances[numIntAdvances++] = currentAdvance;
116 }
117 }
118 std::sort(advances.get(), advances.get() + numIntAdvances);
119 int32_t modeAdvance = (int32_t)find_mode_or_0(
SkSpan(advances.get(), numIntAdvances));
120 *defaultAdvance = modeAdvance;
121
122
123 for (
size_t i = 0;
i <
glyphs.size(); ++
i) {
125 }
126
127 for (
size_t i = 0;
i <
glyphs.size(); ++
i) {
129
130
131 if (advance == modeAdvance) {
132 continue;
133 }
134
135
136 {
138 for (; j <
glyphs.size(); ++j) {
139 SkScalar next_advance = advances[j];
140 if (advance != next_advance) {
141 break;
142 }
143 }
147 result->appendScalar(advance);
149 continue;
150 }
151 }
152
153 {
156 advanceArray->appendScalar(advance);
158 for (; j <
glyphs.size(); ++j) {
159 advance = advances[j];
160
161
162 if (advance == modeAdvance) {
163 break;
164 }
165
166 int dontCares =
glyphs[j]->getGlyphID() -
glyphs[j - 1]->getGlyphID() - 1;
167
168 if (dontCares >= 4) {
169 break;
170 }
171
173
174 if (j + 1 <
glyphs.size()) {
175 next_advance = advances[j+1];
176 int next_dontCares =
glyphs[j+1]->getGlyphID() -
glyphs[j]->getGlyphID() - 1;
177 if (advance == next_advance && dontCares + next_dontCares >= 4) {
178 break;
179 }
180 }
181
182
183 if (j + 2 <
glyphs.size() && advance == next_advance) {
184 next_advance = advances[j+2];
185 if (advance == next_advance) {
186 break;
187 }
188 }
189
190 while (dontCares --> 0) {
191 advanceArray->appendScalar(0);
192 }
193 advanceArray->appendScalar(advance);
194 }
195 result->appendObject(std::move(advanceArray));
197 }
198 }
199
201}
static std::vector< SkPDFIndirectReference > sort(const THashSet< SkPDFIndirectReference > &src)
static SkScalar from_font_units(SkScalar scaled, uint16_t emSize)
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
constexpr uint16_t SkToU16(S x)
void getSetValues(FN f) const
static SkStrikeSpec MakePDFVector(const SkTypeface &typeface, int *size)