QCoreTextFontEngine: Remove calls to deprecated API on macOS
CGContextShowGlyphsWithAdvances has been deprecated since 10.9. We use instead CTFontDrawGlyphs as recommended by Apple. Change-Id: I568bf588f403228e3b695e42dfe39de807537a9d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
parent
b0abe20d4b
commit
7833f7bc06
@ -440,31 +440,25 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
|
|||||||
|
|
||||||
CGContextSetTextDrawingMode(ctx, kCGTextFill);
|
CGContextSetTextDrawingMode(ctx, kCGTextFill);
|
||||||
|
|
||||||
|
QVarLengthArray<CGPoint> cgPositions(glyphs.size());
|
||||||
QVarLengthArray<CGSize> advances(glyphs.size());
|
|
||||||
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
|
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
|
||||||
|
const qreal firstX = positions[0].x.toReal();
|
||||||
for (int i = 0; i < glyphs.size() - 1; ++i) {
|
const qreal firstY = positions[0].y.toReal();
|
||||||
advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
|
for (int i = 0; i < glyphs.size(); ++i) {
|
||||||
advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
|
cgPositions[i].x = positions[i].x.toReal() - firstX;
|
||||||
|
cgPositions[i].y = positions[i].y.toReal() - firstY;
|
||||||
cgGlyphs[i] = glyphs[i];
|
cgGlyphs[i] = glyphs[i];
|
||||||
}
|
}
|
||||||
advances[glyphs.size() - 1].width = 0;
|
|
||||||
advances[glyphs.size() - 1].height = 0;
|
|
||||||
cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
|
|
||||||
|
|
||||||
CGContextSetFont(ctx, cgFont);
|
|
||||||
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
|
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
|
||||||
|
|
||||||
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
|
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
|
||||||
|
CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
|
||||||
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
|
|
||||||
|
|
||||||
if (synthesisFlags & QFontEngine::SynthesizedBold) {
|
if (synthesisFlags & QFontEngine::SynthesizedBold) {
|
||||||
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
|
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
|
||||||
positions[0].y.toReal());
|
positions[0].y.toReal());
|
||||||
|
CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
|
||||||
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextSetTextMatrix(ctx, oldTextMatrix);
|
CGContextSetTextMatrix(ctx, oldTextMatrix);
|
||||||
@ -648,14 +642,13 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
|
|||||||
CGContextSetTextMatrix(ctx, cgMatrix);
|
CGContextSetTextMatrix(ctx, cgMatrix);
|
||||||
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
|
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
|
||||||
CGContextSetTextDrawingMode(ctx, kCGTextFill);
|
CGContextSetTextDrawingMode(ctx, kCGTextFill);
|
||||||
CGContextSetFont(ctx, cgFont);
|
|
||||||
CGContextSetTextPosition(ctx, pos_x, pos_y);
|
CGContextSetTextPosition(ctx, pos_x, pos_y);
|
||||||
|
|
||||||
CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
|
CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
|
||||||
|
|
||||||
if (synthesisFlags & QFontEngine::SynthesizedBold) {
|
if (synthesisFlags & QFontEngine::SynthesizedBold) {
|
||||||
CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
|
CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
|
||||||
CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
|
CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// CGContextSetTextMatrix does not work with color glyphs, so we use
|
// CGContextSetTextMatrix does not work with color glyphs, so we use
|
||||||
|
Loading…
x
Reference in New Issue
Block a user