Skip to content

Commit

Permalink
Merge pull request #1014 from fxliang/fix-trailing-whitespace
Browse files Browse the repository at this point in the history
fix trailing white space
  • Loading branch information
fxliang authored Oct 16, 2023
2 parents 60c7a71 + 4344ccb commit 680de26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WeaselUI/StandardLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ void weasel::StandardLayout::GetTextSizeDW(const std::wstring text, size_t nCoun
// 获取文本尺寸
DWRITE_TEXT_METRICS textMetrics;
hr = pDWR->GetLayoutMetrics(&textMetrics);
sz = D2D1::SizeF(ceil(textMetrics.width), ceil(textMetrics.height));
sz = D2D1::SizeF(ceil(textMetrics.widthIncludingTrailingWhitespace), ceil(textMetrics.height));

lpSize->cx = (int)sz.width;
lpSize->cy = (int)sz.height;
pDWR->ResetLayout();

if(_style.layout_type != UIStyle::LAYOUT_VERTICAL_TEXT)
{
size_t max_width = _style.max_width == 0 ? textMetrics.width : _style.max_width;
size_t max_width = _style.max_width == 0 ? textMetrics.widthIncludingTrailingWhitespace : _style.max_width;
hr = pDWR->CreateTextLayout(text.c_str(), nCount, pTextFormat.Get(), max_width, textMetrics.height);
}
else
{
size_t max_height = _style.max_height == 0 ? textMetrics.height : _style.max_height;
hr = pDWR->CreateTextLayout(text.c_str(), nCount, pTextFormat.Get(), textMetrics.width, max_height);
hr = pDWR->CreateTextLayout(text.c_str(), nCount, pTextFormat.Get(), textMetrics.widthIncludingTrailingWhitespace, max_height);
}

if (_style.layout_type == UIStyle::LAYOUT_VERTICAL_TEXT)
Expand Down

0 comments on commit 680de26

Please sign in to comment.