Bug 1397361 - Apply skew transform to glyphs to undo inverse transform in font code. r?jrmuizel
MozReview-Commit-ID: GBpDmWp1Hnm
--- a/layout/generic/TextDrawTarget.h
+++ b/layout/generic/TextDrawTarget.h
@@ -114,16 +114,29 @@ public:
fragment = &mText.LastElement();
}
nsTArray<Glyph>& glyphs = fragment->glyphs;
size_t oldLength = glyphs.Length();
glyphs.SetLength(oldLength + aBuffer.mNumGlyphs);
PodCopy(glyphs.Elements() + oldLength, aBuffer.mGlyphs, aBuffer.mNumGlyphs);
+
+ // If there's a skew for synthetic italics we need to apply it, as the font
+ // code applies the inverse transformation to glyph positions in anticipation.
+ Matrix trans = GetTransform();
+ if (trans._21 != 0) {
+ Matrix skew = Matrix(1, trans._12,
+ trans._21, 1,
+ 0, 0);
+ for (size_t i = oldLength; i < oldLength + aBuffer.mNumGlyphs; ++i) {
+ auto position = &glyphs[i].mPosition;
+ *position = skew.TransformPoint(*position);
+ }
+ }
}
void AppendShadow(const wr::TextShadow& aShadow) { mShadows.AppendElement(aShadow); }
void
AppendSelection(const LayoutDeviceRect& aRect, const Color& aColor)
{
SelectionFragment frag;