Skip to content

Commit

Permalink
Fix #2256
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Dec 5, 2024
1 parent e507327 commit 775b752
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/platform/mac/Device-mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ static bool _initWithString(std::string_view text,
{
break;
}
height = (short)info.height;
width = (short)info.width;
height = static_cast<int>(info.height);
width = static_cast<int>(info.width);
ret.fastSet(info.data, width * height * 4);
hasPremultipliedAlpha = true;
} while (0);
Expand Down
4 changes: 2 additions & 2 deletions core/platform/win32/Device-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ Data Device::getTextureDataForText(std::string_view text,
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
AX_BREAK_IF(!GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0, nullptr, (LPBITMAPINFO)&bi, DIB_RGB_COLORS));

width = (short)size.cx;
height = (short)size.cy;
width = static_cast<int>(size.cx);
height = static_cast<int>(size.cy);

// copy pixel data
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0) ? -bi.bmiHeader.biHeight : bi.bmiHeader.biHeight;
Expand Down
6 changes: 6 additions & 0 deletions core/renderer/Texture2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,13 @@ bool Texture2D::initWithString(std::string_view text, const FontDefinition& text
bool hasPremultipliedAlpha;
Data outData = Device::getTextureDataForText(text, textDef, align, imageWidth, imageHeight, hasPremultipliedAlpha);
if (outData.isNull())
return false;

const auto maxTextureSize = backend::DriverBase::getInstance()->getMaxTextureSize();
if (imageWidth > maxTextureSize || imageHeight > maxTextureSize)
{
AXLOGW("Texture2D::initWithString fail, the texture size:{}x{} too large, max texture size:{}", imageWidth,
imageHeight, maxTextureSize);
return false;
}

Expand Down

0 comments on commit 775b752

Please sign in to comment.