Skip to content

Commit 350dd37

Browse files
WIP: [terminal_rendewrer] Fixes glyph rendering for some unexpectly oversized glyphs (#423).
1 parent 07f78a6 commit 350dd37

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 0.3.2 (unreleased)
22

3+
- Fixes glyph rendering for some unexpectly oversized glyphs (#423).
34
- Fixes writing to a non-empty line sometimes destroying the contents of that line (#702).
45
- Fixes underline decoration for wide character cells.
56
- Fixes SGR 8 (Conceal/Hidden) attribute doesn't work as expected (#699).

src/terminal_renderer/TextRenderer.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,23 @@ auto TextRenderer::createRasterizedGlyph(atlas::TileLocation tileLocation,
748748
// As I only know of emoji being colored fonts, and those take up 2 cell with units.
749749

750750
// Scale bitmap down iff bitmap is emoji and overflowing in diemensions
751-
if (presentation == unicode::PresentationStyle::Emoji && glyph.format == text::bitmap_format::rgba)
751+
if (/*presentation == unicode::PresentationStyle::Emoji &&*/ glyph.format == text::bitmap_format::rgba)
752752
{
753753
auto const emojiBoundingBox =
754754
ImageSize { Width(_gridMetrics.cellSize.width.value * numCells),
755755
Height::cast_from(unbox<int>(_gridMetrics.cellSize.height) - _gridMetrics.baseline) };
756756
if (glyph.bitmapSize.height > emojiBoundingBox.height)
757757
{
758+
RasterizerLog()("Scaling oversized glyph of {}+{} down to bounding box {}.",
759+
glyph.bitmapSize,
760+
glyph.position,
761+
emojiBoundingBox);
758762
auto [scaledGlyph, scaleFactor] = text::scale(glyph, emojiBoundingBox);
759763
glyph = move(scaledGlyph);
760764
// glyph.position.y = unbox<int>(glyph.bitmapSize.height) - _gridMetrics.underline.position;
765+
// TODO(pr) Adapt glyph.position's x and y accordingly.
766+
glyph.position.x = 0; // int(float(glyph.position.x) * scaleFactor);
767+
glyph.position.y = unbox<int>(emojiBoundingBox.height); // int(float(glyph.position.y) * scaleFactor);
761768
}
762769
}
763770

src/text_shaper/shaper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tuple<rasterized_glyph, float> scale(rasterized_glyph const& _bitmap, crispy::Im
3939

4040
auto const ratioX = unbox<double>(_bitmap.bitmapSize.width) / unbox<double>(_newSize.width);
4141
auto const ratioY = unbox<double>(_bitmap.bitmapSize.height) / unbox<double>(_newSize.height);
42-
auto const ratio = min(ratioX, ratioY);
42+
auto const ratio = max(ratioX, ratioY);
4343
auto const factor = static_cast<unsigned>(ceil(ratio));
4444

4545
vector<uint8_t> dest;

0 commit comments

Comments
 (0)