From 6aab840dfb8ce170af2f6b89e1532c92d29b3671 Mon Sep 17 00:00:00 2001 From: Brian Ferguson Date: Sun, 28 Jul 2013 11:20:28 -0600 Subject: [PATCH] D2D: Adjusted character spacing for AccurateText=0 --- Common/Gfx/CanvasD2D.cpp | 11 +++++++++++ Common/Gfx/CanvasD2D.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Common/Gfx/CanvasD2D.cpp b/Common/Gfx/CanvasD2D.cpp index 3ab6ae6a..ee0920ef 100644 --- a/Common/Gfx/CanvasD2D.cpp +++ b/Common/Gfx/CanvasD2D.cpp @@ -318,6 +318,17 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma formatD2D.m_TextLayout->GetFontSize(0, &xOffset); xOffset /= 6.0f; + if (!m_AccurateText) + { + float emOffset = xOffset / 22.0f; + + DWRITE_TEXT_RANGE range = {0, strLen}; + Microsoft::WRL::ComPtr textLayout; + formatD2D.m_TextLayout.As(&textLayout); + + textLayout->SetCharacterSpacing(emOffset, emOffset, 0.0f, range); + } + m_Target->DrawTextLayout( D2D1::Point2F(m_AccurateText ? rect.X : right ? rect.X - xOffset : rect.X + xOffset, m_AccurateText || !bottom ? rect.Y : rect.Y - 1.0f), diff --git a/Common/Gfx/CanvasD2D.h b/Common/Gfx/CanvasD2D.h index e2d42603..a4841d59 100644 --- a/Common/Gfx/CanvasD2D.h +++ b/Common/Gfx/CanvasD2D.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include