Skip to content

Commit

Permalink
[terminal_renderer] TextRenderer: Fixes a problem with oversized glyp…
Browse files Browse the repository at this point in the history
…hs being wrongly cut off (#821).
  • Loading branch information
christianparpart committed Sep 19, 2022
1 parent c5b4a40 commit e6fd4b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<release version="0.3.5" urgency="medium" type="development">
<description>
<ul>
<li> ... </li>
<li>Fixes a problem with oversized glyphs being wrongly cut off (#821).</li>
</ul>
</description>
</release>
Expand Down
9 changes: 8 additions & 1 deletion src/terminal_renderer/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,21 @@ void TextRenderer::restrictToTileSize(TextureAtlas::TileCreateData& tileCreateDa
auto const subSize = ImageSize { subWidth, tileCreateData.bitmapSize.height };
auto const subPitch = unbox<uintptr_t>(subSize.width) * colorComponentCount;
auto const xOffset = 0;
auto const sourcePitch = unbox<uintptr_t>(tileCreateData.bitmapSize.width) * colorComponentCount;

auto slicedBitmap = vector<uint8_t>(subSize.area() * colorComponentCount);

if (RasterizerLog)
RasterizerLog()("Cutting off oversized {} tile from {} down to {}.",
tileCreateData.bitmapFormat,
tileCreateData.bitmapSize,
_textureAtlas->tileSize());

for (uintptr_t rowIndex = 0; rowIndex < unbox<uintptr_t>(subSize.height); ++rowIndex)
{
uint8_t* targetRow = slicedBitmap.data() + rowIndex * subPitch;
uint8_t const* sourceRow =
tileCreateData.bitmap.data() + rowIndex * subPitch + uintptr_t(xOffset) * colorComponentCount;
tileCreateData.bitmap.data() + rowIndex * sourcePitch + uintptr_t(xOffset) * colorComponentCount;
Require(sourceRow + subPitch <= tileCreateData.bitmap.data() + tileCreateData.bitmap.size());
std::memcpy(targetRow, sourceRow, subPitch);
}
Expand Down

0 comments on commit e6fd4b3

Please sign in to comment.