235 // CoreText failed to shape the text we gave it, so we assume one glyph |
235 // CoreText failed to shape the text we gave it, so we assume one glyph |
236 // per character and build a list of invalid glyphs with zero advance |
236 // per character and build a list of invalid glyphs with zero advance |
237 *nglyphs = len; |
237 *nglyphs = len; |
238 for (int i = 0; i < len; ++i) { |
238 for (int i = 0; i < len; ++i) { |
239 outGlyphs[i] = 0; |
239 outGlyphs[i] = 0; |
240 logClusters[i] = i; |
240 if (logClusters) |
|
241 logClusters[i] = i; |
241 outAdvances_x[i] = QFixed(); |
242 outAdvances_x[i] = QFixed(); |
242 outAdvances_y[i] = QFixed(); |
243 outAdvances_y[i] = QFixed(); |
243 outAttributes[i].clusterStart = true; |
244 outAttributes[i].clusterStart = true; |
244 } |
245 } |
245 return true; |
246 return true; |
345 } |
346 } |
346 |
347 |
347 bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, |
348 bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, |
348 int *nglyphs, QTextEngine::ShaperFlags flags) const |
349 int *nglyphs, QTextEngine::ShaperFlags flags) const |
349 { |
350 { |
350 return stringToCMap(str, len, glyphs, nglyphs, flags, 0, 0); |
351 *nglyphs = len; |
|
352 QVarLengthArray<CGGlyph> cgGlyphs(len); |
|
353 CTFontGetGlyphsForCharacters(ctfont, (const UniChar*)str, cgGlyphs.data(), len); |
|
354 |
|
355 for (int i = 0; i < len; ++i) |
|
356 glyphs->glyphs[i] = cgGlyphs[i]; |
|
357 |
|
358 if (flags & QTextEngine::GlyphIndicesOnly) |
|
359 return true; |
|
360 |
|
361 QVarLengthArray<CGSize> advances(len); |
|
362 CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), len); |
|
363 |
|
364 for (int i = 0; i < len; ++i) { |
|
365 glyphs->advances_x[i] = QFixed::fromReal(advances[i].width); |
|
366 glyphs->advances_y[i] = QFixed::fromReal(advances[i].height); |
|
367 if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { |
|
368 glyphs->advances_x[i] = glyphs->advances_x[i].round(); |
|
369 glyphs->advances_y[i] = glyphs->advances_y[i].round(); |
|
370 } |
|
371 } |
|
372 |
|
373 return true; |
351 } |
374 } |
352 |
375 |
353 void QCoreTextFontEngineMulti::recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const |
376 void QCoreTextFontEngineMulti::recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const |
354 { |
377 { |
355 } |
378 } |