Bug 915938 - Honour the glyph rendering options set by the platform when drawing text on a <canvas>. r=jfkthame, a=akeybl
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -2353,16 +2353,18 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
RefPtr<ScaledFont> scaledFont =
gfxPlatform::GetPlatform()->GetScaledFontForFont(mCtx->mTarget, font);
if (!scaledFont) {
// This can occur when something switched DirectWrite off.
return;
}
+ RefPtr<GlyphRenderingOptions> renderingOptions = font->GetGlyphRenderingOptions();
+
GlyphBuffer buffer;
std::vector<Glyph> glyphBuf;
for (uint32_t i = runs[c].mCharacterOffset; i < endRun; i++) {
Glyph newGlyph;
if (glyphs[i].IsSimpleGlyph()) {
newGlyph.mIndex = glyphs[i].GetSimpleGlyph();
@@ -2424,17 +2426,18 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
Rect bounds = mCtx->mTarget->GetTransform().
TransformBounds(Rect(mBoundingBox.x, mBoundingBox.y,
mBoundingBox.width, mBoundingBox.height));
if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL) {
AdjustedTarget(mCtx, &bounds)->
FillGlyphs(scaledFont, buffer,
CanvasGeneralPattern().
ForStyle(mCtx, CanvasRenderingContext2D::STYLE_FILL, mCtx->mTarget),
- DrawOptions(mState->globalAlpha, mCtx->UsedOperation()));
+ DrawOptions(mState->globalAlpha, mCtx->UsedOperation()),
+ renderingOptions);
} else if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE) {
// stroke glyphs one at a time to avoid poor CoreGraphics performance
// when stroking a path with a very large number of points
buffer.mGlyphs = &glyphBuf.front();
buffer.mNumGlyphs = 1;
const ContextState& state = *mState;
AdjustedTarget target(mCtx, &bounds);
const StrokeOptions strokeOpts(state.lineWidth, state.lineJoin,