Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix font rendering for long glyphs #1501

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<li>Add generation of config file from internal state (#1282)</li>
<li>Add SGRSAVE and SGRRESTORE VT sequences to save and restore SGR state (They intentionally conflict with XTPUSHSGR and XTPOPSGR)</li>
<li>Update of contour.desktop file (#1423)</li>
<li>Fixed overlap of glyphs for long codepoints (#1349)</li>
<li>Fixed too verbose info during ssh session login (#1447)</li>
<li>Fixes corruption of sixel image on high resolution (#1049)</li>
<li>Fixes bad wording of OS/X to macOS (#1462)</li>
Expand Down
1 change: 1 addition & 0 deletions src/text_shaper/open_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ namespace
gpos.presentation = presentation;
result.emplace_back(gpos);
}

return crispy::none_of(result, glyphMissing);
}
} // namespace
Expand Down
11 changes: 7 additions & 4 deletions src/vtrasterizer/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,14 @@ void TextRenderer::renderTextGroup(std::u32string_view codepoints,
text::shape_result const& glyphPositions =
getOrCreateCachedGlyphPositions(hash, codepoints, clusters, style);
crispy::point pen = _gridMetrics.mapBottomLeft(initialPenPosition);
auto const advanceX = unbox(_gridMetrics.cellSize.width);

for (auto const& glyphPosition: glyphPositions)
{
if (auto const* attributes = ensureRasterizedIfDirectMapped(glyphPosition.glyph))
{
auto const pen1 = applyGlyphPositionToPen(pen, *attributes, glyphPosition);
renderRasterizedGlyph(pen1, color, *attributes);
pen.x += static_cast<decltype(pen.x)>(advanceX);
pen.x += unbox<decltype(pen.x)>(_gridMetrics.cellSize.width);
continue;
}

Expand All @@ -617,10 +616,14 @@ void TextRenderer::renderTextGroup(std::u32string_view codepoints,

if (glyphPosition.advance.x)
{

auto numberOfCellsToAdvance =
std::rint(glyphPosition.advance.x / unbox<double>(_gridMetrics.cellSize.width));
// Only advance horizontally, as we're (guess what) a terminal. :-)
// Only advance in fixed-width steps.
// Only advance iff there harfbuzz told us to.
pen.x += static_cast<decltype(pen.x)>(advanceX);
// Only advance if there harfbuzz told us to.
pen.x +=
static_cast<decltype(pen.x)>(numberOfCellsToAdvance * (unbox(_gridMetrics.cellSize.width)));
}
}
}
Expand Down
Loading