Skip to content

Commit 234c62f

Browse files
committed
Lower safety padding for text measure (it is needed because sometimes the text doesn't fit in the measured rectangle).
1 parent c84521b commit 234c62f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/WindowsAppSupport/WAS_Direct2DContext.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,16 @@ void Direct2DContext::DrawFormattedText (const NUIE::Rect& rect, const NUIE::Fon
276276

277277
NUIE::Size Direct2DContext::MeasureText (const NUIE::Font& font, const std::wstring& text)
278278
{
279+
static const float SafetyPadding = 1.05f;
280+
279281
IDWriteTextLayout* textLayout = nullptr;
280282
IDWriteTextFormat* textFormat = CreateTextFormat (renderTarget, font);
281283
direct2DHandler.directWriteFactory->CreateTextLayout (text.c_str (), (UINT32) text.length (), textFormat, 1000.0, 1000.0, &textLayout);
282284
DWRITE_TEXT_METRICS metrics;
283285
textLayout->GetMetrics (&metrics);
284286
SafeRelease (&textFormat);
285287
SafeRelease (&textLayout);
286-
return NUIE::Size (metrics.width * 1.1f, metrics.height * 1.1f);
288+
return NUIE::Size (metrics.width * SafetyPadding, metrics.height * SafetyPadding);
287289
}
288290

289291
}

0 commit comments

Comments
 (0)