diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp index fbabbe8047..8b36041dec 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp @@ -1681,17 +1681,18 @@ void Direct2DGraphicsContext::drawGlyphs (Span glyphNumbers, return; const auto fontScale = font.getHorizontalScale(); - const auto scaledTransform = AffineTransform::scale (fontScale, 1.0f).followedBy (transform); - const auto glyphRunTransform = scaledTransform.followedBy (currentState->currentTransform.getTransform()); - const auto onlyTranslated = glyphRunTransform.isOnlyTranslation(); + const auto textTransform = AffineTransform::scale (fontScale, 1.0f).followedBy (transform); + const auto worldTransform = currentState->currentTransform.getTransform(); + const auto textAndWorldTransform = textTransform.followedBy (worldTransform); + const auto onlyTranslated = textAndWorldTransform.isOnlyTranslation(); const auto fillTransform = onlyTranslated ? SavedState::BrushTransformFlags::applyWorldAndFillTypeTransforms : SavedState::BrushTransformFlags::applyFillTypeTransform; - const auto brush = currentState->getBrush (fillTransform); + auto brush = currentState->getBrush (fillTransform); - if (! brush) + if (brush == nullptr) return; applyPendingClipList(); @@ -1699,9 +1700,17 @@ void Direct2DGraphicsContext::drawGlyphs (Span glyphNumbers, D2D1_POINT_2F baselineOrigin { 0.0f, 0.0f }; if (onlyTranslated) - baselineOrigin = { glyphRunTransform.getTranslationX(), glyphRunTransform.getTranslationY() }; + { + baselineOrigin = { textAndWorldTransform.getTranslationX(), textAndWorldTransform.getTranslationY() }; + } else - getPimpl()->setDeviceContextTransform (glyphRunTransform); + { + D2D1::Matrix3x2F matrix{}; + brush->GetTransform (&matrix); + const auto brushTransform = D2DUtilities::matrixToTransform (matrix); + brush->SetTransform (D2DUtilities::transformToMatrix (brushTransform.followedBy (textTransform.inverted()))); + getPimpl()->setDeviceContextTransform (textAndWorldTransform); + } auto& run = getPimpl()->glyphRun; run.replace (positions, fontScale); diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index e76eccffc0..b7f19264fe 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -324,9 +324,14 @@ struct D2DUtilities return { c.getFloatRed(), c.getFloatGreen(), c.getFloatBlue(), c.getFloatAlpha() }; } - static D2D1::Matrix3x2F transformToMatrix (const AffineTransform& transform) + static D2D1::Matrix3x2F transformToMatrix (const AffineTransform& t) { - return { transform.mat00, transform.mat10, transform.mat01, transform.mat11, transform.mat02, transform.mat12 }; + return { t.mat00, t.mat10, t.mat01, t.mat11, t.mat02, t.mat12 }; + } + + static AffineTransform matrixToTransform (const D2D1_MATRIX_3X2_F& m) + { + return { m._11, m._21, m._31, m._12, m._22, m._32 }; } static Rectangle rectFromSize (D2D1_SIZE_U s)