fix GCC errors when -std=c++17 is specified

This commit is contained in:
Jinhao
2018-08-09 07:50:56 +08:00
parent 1ff1c55592
commit e91d3446eb
3 changed files with 33 additions and 31 deletions

View File

@@ -498,41 +498,42 @@ namespace paint
{
if (nullptr == impl_->handle || nullptr == impl_->handle->context) return {};
if (text.empty()) return std::unique_ptr<unsigned[]>{new unsigned[1]};
auto pxbuf = std::unique_ptr<unsigned[]>{ new unsigned[text.size() ? text.size() : 1] };
unsigned tab_pixels = impl_->handle->string.tab_length * impl_->handle->string.whitespace_pixels;
#if defined(NANA_WINDOWS)
int * dx = new int[text.size()];
SIZE extents;
::GetTextExtentExPoint(impl_->handle->context, text.data(), static_cast<int>(text.size()), 0, 0, dx, &extents);
auto pxbuf = std::unique_ptr<unsigned[]>{ new unsigned[text.size()] };
pxbuf[0] = (text[0] == '\t' ? tab_pixels : dx[0]);
for (std::size_t i = 1; i < text.size(); ++i)
if (!text.empty())
{
pxbuf[i] = (text[i] == '\t' ? tab_pixels : dx[i] - dx[i - 1]);
}
delete[] dx;
unsigned tab_pixels = impl_->handle->string.tab_length * impl_->handle->string.whitespace_pixels;
#if defined(NANA_WINDOWS)
int * dx = new int[text.size()];
SIZE extents;
::GetTextExtentExPoint(impl_->handle->context, text.data(), static_cast<int>(text.size()), 0, 0, dx, &extents);
pxbuf[0] = (text[0] == '\t' ? tab_pixels : dx[0]);
for (std::size_t i = 1; i < text.size(); ++i)
{
pxbuf[i] = (text[i] == '\t' ? tab_pixels : dx[i] - dx[i - 1]);
}
delete[] dx;
#elif defined(NANA_X11) && defined(NANA_USE_XFT)
auto disp = nana::detail::platform_spec::instance().open_display();
auto xft = reinterpret_cast<XftFont*>(impl_->handle->font->native_handle());
auto disp = nana::detail::platform_spec::instance().open_display();
auto xft = reinterpret_cast<XftFont*>(impl_->handle->font->native_handle());
XGlyphInfo extents;
for (std::size_t i = 0; i < len; ++i)
{
if (text[i] != '\t')
XGlyphInfo extents;
for (std::size_t i = 0; i < text.size(); ++i)
{
FT_UInt glyphs = ::XftCharIndex(disp, xft, text[i]);
::XftGlyphExtents(disp, xft, &glyphs, 1, &extents);
pxbuf[i] = extents.xOff;
if (text[i] != '\t')
{
FT_UInt glyphs = ::XftCharIndex(disp, xft, text[i]);
::XftGlyphExtents(disp, xft, &glyphs, 1, &extents);
pxbuf[i] = extents.xOff;
}
else
pxbuf[i] = tab_pixels;
}
else
pxbuf[i] = tab_pixels;
}
#endif
}
return pxbuf;
}