mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Fix incorrect text X-position for StringAlign=Center with D2D
This commit is contained in:
parent
21f5ff1303
commit
38ec6c3832
@ -312,13 +312,23 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
|||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
TextFormatD2D& formatD2D = (TextFormatD2D&)format;
|
TextFormatD2D& formatD2D = (TextFormatD2D&)format;
|
||||||
const bool right = formatD2D.GetHorizontalAlignment() == Gfx::HorizontalAlignment::Right;
|
formatD2D.CreateLayout(
|
||||||
|
str, strLen, rect.Width, rect.Height, !m_AccurateText && m_TextAntiAliasing);
|
||||||
|
|
||||||
formatD2D.CreateLayout(str, strLen, rect.Width, rect.Height);
|
const float xOffset = formatD2D.m_TextFormat->GetFontSize() / 6.0f;
|
||||||
|
const float xPos = [&]()
|
||||||
|
{
|
||||||
|
if (!m_AccurateText)
|
||||||
|
{
|
||||||
|
switch (formatD2D.GetHorizontalAlignment())
|
||||||
|
{
|
||||||
|
case HorizontalAlignment::Left: return rect.X + xOffset;
|
||||||
|
case HorizontalAlignment::Right: return rect.X - xOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float xOffset = 0.0f;
|
return rect.X;
|
||||||
formatD2D.m_TextLayout->GetFontSize(0, &xOffset);
|
} ();
|
||||||
xOffset /= 6.0f;
|
|
||||||
|
|
||||||
if (!m_AccurateText && m_TextAntiAliasing)
|
if (!m_AccurateText && m_TextAntiAliasing)
|
||||||
{
|
{
|
||||||
@ -332,7 +342,7 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Target->DrawTextLayout(
|
m_Target->DrawTextLayout(
|
||||||
D2D1::Point2F(m_AccurateText ? rect.X : right ? rect.X - xOffset : rect.X + xOffset, rect.Y - 1.0f),
|
D2D1::Point2F(xPos, rect.Y - 1.0f),
|
||||||
formatD2D.m_TextLayout.Get(),
|
formatD2D.m_TextLayout.Get(),
|
||||||
solidBrush.Get());
|
solidBrush.Get());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user