CoreText: Remove handling of the AppleAntiAliasingThreshold user default
The setting is not relevant for modern macOS applications, and none of the applications shipped with macOS today are affected by it. The only code path in macOS that picks it up is +[NSFont initialize] in the UIFoundation framework, storing it for later so that -[NSFont screenFont] and -[NSFont screenFontWithRenderingMode:] can use it, but these APIs are deprecated and we don't use them in Qt. Other NSFont code paths will not hit these APIs unless screen font substitution is enabled, something it hasn't been since OSX 10.7. https://preview.tinyurl.com/yctpfnqp Removing handling of this setting allows us to simplify the reasoning for whether or not antialiasing and font smoothing is enabled for a given engine. Change-Id: Ie2809052a1a0815d9bddedd4a6236eb6c898f993 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
2e86b652b7
commit
3944f45c4d
@ -614,20 +614,6 @@ glyph_metrics_t QCoreTextFontEngine::alphaMapBoundingBox(glyph_t glyph, QFixed s
|
|||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QCoreTextFontEngine::antialiasingThreshold()
|
|
||||||
{
|
|
||||||
static const int antialiasingThreshold = [] {
|
|
||||||
auto defaults = [NSUserDefaults standardUserDefaults];
|
|
||||||
int threshold = [defaults integerForKey:@"AppleAntiAliasingThreshold"];
|
|
||||||
qCDebug(lcQpaFonts) << "Resolved antialiasing threshold. Defaults ="
|
|
||||||
<< [[defaults dictionaryRepresentation] dictionaryWithValuesForKeys:@[
|
|
||||||
@"AppleAntiAliasingThreshold"
|
|
||||||
]] << "Result =" << threshold;
|
|
||||||
return threshold;
|
|
||||||
}();
|
|
||||||
return antialiasingThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Apple has gone through many iterations of its font smoothing algorithms,
|
Apple has gone through many iterations of its font smoothing algorithms,
|
||||||
and there are many ways to enable or disable certain aspects of it. As
|
and there are many ways to enable or disable certain aspects of it. As
|
||||||
@ -732,8 +718,7 @@ bool QCoreTextFontEngine::expectsGammaCorrectedBlending() const
|
|||||||
return (glyphFormat == Format_A32) && !(fontDef.styleStrategy & (QFont::NoAntialias | QFont::NoSubpixelAntialias));
|
return (glyphFormat == Format_A32) && !(fontDef.styleStrategy & (QFont::NoAntialias | QFont::NoSubpixelAntialias));
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition,
|
QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &matrix)
|
||||||
bool overrideAntialiasingThreshold, const QTransform &matrix)
|
|
||||||
{
|
{
|
||||||
glyph_metrics_t br = alphaMapBoundingBox(glyph, subPixelPosition, matrix, glyphFormat);
|
glyph_metrics_t br = alphaMapBoundingBox(glyph, subPixelPosition, matrix, glyphFormat);
|
||||||
|
|
||||||
@ -770,8 +755,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
|
|||||||
qt_mac_bitmapInfoForImage(im));
|
qt_mac_bitmapInfoForImage(im));
|
||||||
Q_ASSERT(ctx);
|
Q_ASSERT(ctx);
|
||||||
CGContextSetFontSize(ctx, fontDef.pixelSize);
|
CGContextSetFontSize(ctx, fontDef.pixelSize);
|
||||||
const bool antialias = (overrideAntialiasingThreshold || fontDef.pointSize > antialiasingThreshold())
|
const bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
|
||||||
&& !(fontDef.styleStrategy & QFont::NoAntialias);
|
|
||||||
CGContextSetShouldAntialias(ctx, antialias);
|
CGContextSetShouldAntialias(ctx, antialias);
|
||||||
const bool smoothing = antialias && !(fontDef.styleStrategy & QFont::NoSubpixelAntialias);
|
const bool smoothing = antialias && !(fontDef.styleStrategy & QFont::NoSubpixelAntialias);
|
||||||
CGContextSetShouldSmoothFonts(ctx, smoothing);
|
CGContextSetShouldSmoothFonts(ctx, smoothing);
|
||||||
@ -837,7 +821,7 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosit
|
|||||||
if (x.type() > QTransform::TxScale)
|
if (x.type() > QTransform::TxScale)
|
||||||
return QFontEngine::alphaMapForGlyph(glyph, subPixelPosition, x);
|
return QFontEngine::alphaMapForGlyph(glyph, subPixelPosition, x);
|
||||||
|
|
||||||
QImage im = imageForGlyph(glyph, subPixelPosition, false, x);
|
QImage im = imageForGlyph(glyph, subPixelPosition, x);
|
||||||
|
|
||||||
QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
|
QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
|
||||||
|
|
||||||
@ -859,7 +843,7 @@ QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPo
|
|||||||
if (x.type() > QTransform::TxScale)
|
if (x.type() > QTransform::TxScale)
|
||||||
return QFontEngine::alphaRGBMapForGlyph(glyph, subPixelPosition, x);
|
return QFontEngine::alphaRGBMapForGlyph(glyph, subPixelPosition, x);
|
||||||
|
|
||||||
QImage im = imageForGlyph(glyph, subPixelPosition, true, x);
|
QImage im = imageForGlyph(glyph, subPixelPosition, x);
|
||||||
qGamma_correct_back_to_linear_cs(&im);
|
qGamma_correct_back_to_linear_cs(&im);
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
@ -869,7 +853,7 @@ QImage QCoreTextFontEngine::bitmapForGlyph(glyph_t glyph, QFixed subPixelPositio
|
|||||||
if (t.type() > QTransform::TxScale)
|
if (t.type() > QTransform::TxScale)
|
||||||
return QFontEngine::bitmapForGlyph(glyph, subPixelPosition, t);
|
return QFontEngine::bitmapForGlyph(glyph, subPixelPosition, t);
|
||||||
|
|
||||||
return imageForGlyph(glyph, subPixelPosition, true, t);
|
return imageForGlyph(glyph, subPixelPosition, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||||
|
@ -127,7 +127,6 @@ public:
|
|||||||
Q_ENUM(FontSmoothing);
|
Q_ENUM(FontSmoothing);
|
||||||
|
|
||||||
static FontSmoothing fontSmoothing();
|
static FontSmoothing fontSmoothing();
|
||||||
static int antialiasingThreshold();
|
|
||||||
|
|
||||||
static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length);
|
static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length);
|
||||||
static QFont::Weight qtWeightFromCFWeight(float value);
|
static QFont::Weight qtWeightFromCFWeight(float value);
|
||||||
@ -137,7 +136,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
QCoreTextFontEngine(const QFontDef &def);
|
QCoreTextFontEngine(const QFontDef &def);
|
||||||
void init();
|
void init();
|
||||||
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, bool colorful, const QTransform &m);
|
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &m);
|
||||||
void loadAdvancesForGlyphs(QVarLengthArray<CGGlyph> &cgGlyphs, QGlyphLayout *glyphs) const;
|
void loadAdvancesForGlyphs(QVarLengthArray<CGGlyph> &cgGlyphs, QGlyphLayout *glyphs) const;
|
||||||
bool hasColorGlyphs() const;
|
bool hasColorGlyphs() const;
|
||||||
|
|
||||||
|
@ -914,7 +914,6 @@ void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem
|
|||||||
QFontEngine *fe = ti.fontEngine;
|
QFontEngine *fe = ti.fontEngine;
|
||||||
|
|
||||||
const bool textAA = ((state->renderHints() & QPainter::TextAntialiasing)
|
const bool textAA = ((state->renderHints() & QPainter::TextAntialiasing)
|
||||||
&& (fe->fontDef.pointSize > QCoreTextFontEngine::antialiasingThreshold())
|
|
||||||
&& !(fe->fontDef.styleStrategy & QFont::NoAntialias));
|
&& !(fe->fontDef.styleStrategy & QFont::NoAntialias));
|
||||||
const bool lineAA = state->renderHints() & QPainter::Antialiasing;
|
const bool lineAA = state->renderHints() & QPainter::Antialiasing;
|
||||||
if (textAA != lineAA)
|
if (textAA != lineAA)
|
||||||
|
Loading…
Reference in New Issue
Block a user