aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--win32/PlatWin.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 3fdfc6065..37724ced8 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1793,12 +1793,13 @@ XYPOSITION SurfaceD2D::AverageCharWidth(Font &font_) {
// Create a layout
IDWriteTextLayout *pTextLayout = 0;
const WCHAR wszAllAlpha[] = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast<UINT32>(wcslen(wszAllAlpha)),
+ const size_t lenAllAlpha = wcslen(wszAllAlpha);
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast<UINT32>(lenAllAlpha),
pTextFormat, 1000.0, 1000.0, &pTextLayout);
if (SUCCEEDED(hr)) {
DWRITE_TEXT_METRICS textMetrics;
if (SUCCEEDED(pTextLayout->GetMetrics(&textMetrics)))
- width = textMetrics.width / wcslen(wszAllAlpha);
+ width = textMetrics.width / lenAllAlpha;
pTextLayout->Release();
}
}