Skip to content

Commit

Permalink
Merge pull request #1501 from contour-terminal/fix/merged_codepoints
Browse files Browse the repository at this point in the history
Fix font rendering for long glyphs
  • Loading branch information
christianparpart authored Apr 25, 2024
2 parents b7cfdc4 + 352400c commit f11a560
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit f11a560

Please sign in to comment.