Bug 1671963 - Always use CTFontDrawGlyphs. r=lsalzman

CTFontDrawGlyphs has been around since 10.7

Differential Revision: https://phabricator.services.mozilla.com/D94029
This commit is contained in:
Jeff Muizelaar 2020-10-19 15:59:02 +00:00
parent 678f696c20
commit 0440c26f3d
3 changed files with 6 additions and 39 deletions

View File

@ -1237,16 +1237,9 @@ bool DrawTargetSkia::FillGlyphsWithCG(ScaledFont* aFont,
macFont->FontSmoothingBackgroundColor());
SetFontColor(cgContext, mColorSpace, aPattern);
if (ScaledFontMac::CTFontDrawGlyphsPtr != nullptr) {
ScaledFontMac::CTFontDrawGlyphsPtr(macFont->mCTFont, glyphs.begin(),
positions.begin(), aBuffer.mNumGlyphs,
cgContext);
} else {
CGContextSetFont(cgContext, macFont->mFont);
CGContextSetFontSize(cgContext, macFont->mSize);
CGContextShowGlyphsAtPositions(cgContext, glyphs.begin(), positions.begin(),
aBuffer.mNumGlyphs);
}
CTFontDrawGlyphs(macFont->mCTFont, glyphs.begin(),
positions.begin(), aBuffer.mNumGlyphs,
cgContext);
// Calculate the area of the text we just drew
auto* bboxes = new CGRect[aBuffer.mNumGlyphs];

View File

@ -62,10 +62,6 @@ class AutoRelease final {
T mObject;
};
ScaledFontMac::CTFontDrawGlyphsFuncT* ScaledFontMac::CTFontDrawGlyphsPtr =
nullptr;
bool ScaledFontMac::sSymbolLookupDone = false;
// Helper to create a CTFont from a CGFont, copying any variations that were
// set on the original CGFont.
static CTFontRef CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont,
@ -132,25 +128,14 @@ ScaledFontMac::ScaledFontMac(CGFontRef aFont,
mFontSmoothingBackgroundColor(aFontSmoothingBackgroundColor),
mUseFontSmoothing(aUseFontSmoothing),
mApplySyntheticBold(aApplySyntheticBold) {
if (!sSymbolLookupDone) {
CTFontDrawGlyphsPtr =
(CTFontDrawGlyphsFuncT*)dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs");
sSymbolLookupDone = true;
}
if (!aOwnsFont) {
// XXX: should we be taking a reference
CGFontRetain(aFont);
}
if (CTFontDrawGlyphsPtr != nullptr) {
// only create mCTFont if we're going to be using the CTFontDrawGlyphs API
auto unscaledMac = static_cast<UnscaledFontMac*>(aUnscaledFont.get());
bool dataFont = unscaledMac->IsDataFont();
mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont);
} else {
mCTFont = nullptr;
}
auto unscaledMac = static_cast<UnscaledFontMac*>(aUnscaledFont.get());
bool dataFont = unscaledMac->IsDataFont();
mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont);
}
ScaledFontMac::~ScaledFontMac() {

View File

@ -78,17 +78,6 @@ class ScaledFontMac : public ScaledFontBase {
bool mUseFontSmoothing;
bool mApplySyntheticBold;
};
typedef void(CTFontDrawGlyphsFuncT)(CTFontRef, const CGGlyph[], const CGPoint[], size_t,
CGContextRef);
static bool sSymbolLookupDone;
public:
// function pointer for CTFontDrawGlyphs, if available;
// initialized the first time a ScaledFontMac is created,
// so it will be valid by the time DrawTargetCG wants to use it
static CTFontDrawGlyphsFuncT* CTFontDrawGlyphsPtr;
};
} // namespace gfx