168 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
169 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
170 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
171 : m_font(font)
172 , m_characters(characters)
173 , m_stringLength(stringLength)
174 , m_indexBegin(indexBegin)
175 , m_indexEnd(indexEnd)
176 , m_stringLocation(stringLocation)
177 , m_isLTR(ltr)
178 {
179 auto runLengthInCodeUnits = m_indexEnd - m_indexBegin;
180 m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits);
181 unsigned r = m_indexBegin;
182 while (r < m_indexEnd) {
183 m_coreTextIndices.uncheckedAppend(r);
184 UChar32 character;
185 U16_NEXT(m_characters, r, m_stringLength, character);
186 }
187 m_glyphCount = m_coreTextIndices.size();
188 if (!ltr) {
189 for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
190 std::swap(m_coreTextIndices[r], m_coreTextIndices[end]);
191 }
192
193 // Synthesize a run of missing glyphs.
194 m_glyphs.fill(0, m_glyphCount);
195 m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount);
196 }
197
198
199 ComplexTextController::ComplexTextRun::ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
200 : m_baseAdvances(advances)
201 , m_glyphOrigins(origins)
202 , m_glyphs(glyphs)
203 , m_coreTextIndices(stringIndices)
204 , m_initialAdvance(initialAdvance)
205 , m_font(font)
206 , m_characters(characters)
207 , m_stringLength(stringLength)
208 , m_indexBegin(indexBegin)
209 , m_indexEnd(indexEnd)
210 , m_glyphCount(glyphs.size())
211 , m_stringLocation(stringLocation)
212 , m_isLTR(ltr)
213 {
214 }
215