mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
FreeType: Move rescaled glyphs right to eliminate left overhang
As with the CoreText renderer, a glyph that is rescaled to fit its cell is moved so that its ink starts at the left edge of the cell, so that marks that hang to the left of it, as in polytonic Greek capitals, are no longer cut off.
This commit is contained in:
parent
fd795df1ff
commit
2e77ef3d4b
3 changed files with 9 additions and 7 deletions
|
|
@ -256,7 +256,7 @@ Detailed list of changes
|
|||
healing alternates of the Monaspace and 0xProto fonts, being rendered
|
||||
smaller than the surrounding text at some font sizes
|
||||
|
||||
- macOS: Fix accents and breathing marks that hang to the left of wide glyphs,
|
||||
- Fix accents and breathing marks that hang to the left of wide glyphs,
|
||||
such as polytonic Greek capitals, being cut off
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -670,7 +670,7 @@ typedef struct {
|
|||
size_t start_x, width, stride;
|
||||
size_t rows;
|
||||
FT_Pixel_Mode pixel_mode;
|
||||
bool needs_free;
|
||||
bool needs_free, rescaled;
|
||||
unsigned int factor, right_edge;
|
||||
int bitmap_left, bitmap_top;
|
||||
} ProcessedBitmap;
|
||||
|
|
@ -791,6 +791,7 @@ render_bitmap(
|
|||
fg->fcm.cell_height)) {
|
||||
free_processed_bitmap(ans);
|
||||
if (!render_bitmap(self, glyph_id, ans, cell_width, cell_height, num_cells, bold, italic, false, fg)) return false;
|
||||
ans->rescaled = true;
|
||||
if (!set_font_size(self, char_width, char_height, self->xdpi, self->ydpi, 0, fg->fcm.cell_height)) return false;
|
||||
} else return false;
|
||||
}
|
||||
|
|
@ -1178,6 +1179,9 @@ place_bitmap_in_canvas(
|
|||
// Calculate column bounds
|
||||
int32_t xoff = (int32_t)(x_offset + bm->bitmap_left);
|
||||
if (debug_placement) printf(" bitmap_left: %d xoff: %d", bm->bitmap_left, xoff);
|
||||
// A rescaled glyph, such as a letter with marks that hang to the left of
|
||||
// its cell, shift it so the marks are not cut off
|
||||
if (bm->rescaled && xoff < 0) xoff = 0;
|
||||
if (xoff < 0) src.left += -xoff;
|
||||
else dest.left = xoff;
|
||||
// Move the dest start column back if the width overflows because of it, but only if we are not in a very long/infinite ligature
|
||||
|
|
|
|||
|
|
@ -555,11 +555,9 @@ class Rendering(FontBaseTest):
|
|||
# at most 23 rows. Drawn at full size it covers at least 27.
|
||||
height, width, cell_width = self.glyph_ink('LiberationMono-Regular.ttf', 'Ὦ', 32)
|
||||
self.assertLessEqual(height, 23)
|
||||
if is_macos:
|
||||
# The rescaled glyph is moved into the cell so that the marks are
|
||||
# not cut off and it spans the whole cell. The FreeType renderer
|
||||
# still crops whatever lies to the left of the cell.
|
||||
self.assertGreaterEqual(width, cell_width - 1)
|
||||
# The rescaled glyph is moved into the cell so that the marks are
|
||||
# not cut off and it spans the whole cell.
|
||||
self.assertGreaterEqual(width, cell_width - 1)
|
||||
|
||||
def test_shaping(self):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue