mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Dont move back glyph on overflow in infinite ligatures
This commit is contained in:
@@ -567,7 +567,7 @@ copy_color_bitmap(uint8_t *src, pixel* dest, Region *src_rect, Region *dest_rect
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
place_bitmap_in_canvas(pixel *cell, ProcessedBitmap *bm, size_t cell_width, size_t cell_height, float x_offset, float y_offset, size_t baseline) {
|
place_bitmap_in_canvas(pixel *cell, ProcessedBitmap *bm, size_t cell_width, size_t cell_height, float x_offset, float y_offset, size_t baseline, unsigned int glyph_num) {
|
||||||
// We want the glyph to be positioned inside the cell based on the bearingX
|
// We want the glyph to be positioned inside the cell based on the bearingX
|
||||||
// and bearingY values, making sure that it does not overflow the cell.
|
// and bearingY values, making sure that it does not overflow the cell.
|
||||||
|
|
||||||
@@ -577,8 +577,8 @@ place_bitmap_in_canvas(pixel *cell, ProcessedBitmap *bm, size_t cell_width, size
|
|||||||
int32_t xoff = (ssize_t)(x_offset + bm->bitmap_left);
|
int32_t xoff = (ssize_t)(x_offset + bm->bitmap_left);
|
||||||
if (xoff < 0) src.left += -xoff;
|
if (xoff < 0) src.left += -xoff;
|
||||||
else dest.left = xoff;
|
else dest.left = xoff;
|
||||||
// Move the dest start column back if the width overflows because of it
|
// 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
|
||||||
if (dest.left > 0 && dest.left + bm->width > cell_width) {
|
if (glyph_num < 4 && dest.left > 0 && dest.left + bm->width > cell_width) {
|
||||||
uint32_t extra = dest.left + bm->width - cell_width;
|
uint32_t extra = dest.left + bm->width - cell_width;
|
||||||
dest.left = extra > dest.left ? 0 : dest.left - extra;
|
dest.left = extra > dest.left ? 0 : dest.left - extra;
|
||||||
}
|
}
|
||||||
@@ -630,7 +630,7 @@ render_glyphs_in_cells(PyObject *f, bool bold, bool italic, hb_glyph_info_t *inf
|
|||||||
x_offset = x + (float)positions[i].x_offset / 64.0f;
|
x_offset = x + (float)positions[i].x_offset / 64.0f;
|
||||||
y = (float)positions[i].y_offset / 64.0f;
|
y = (float)positions[i].y_offset / 64.0f;
|
||||||
if ((*was_colored || self->face->glyph->metrics.width > 0) && bm.width > 0) {
|
if ((*was_colored || self->face->glyph->metrics.width > 0) && bm.width > 0) {
|
||||||
place_bitmap_in_canvas(canvas, &bm, canvas_width, cell_height, x_offset, y, baseline);
|
place_bitmap_in_canvas(canvas, &bm, canvas_width, cell_height, x_offset, y, baseline, i);
|
||||||
}
|
}
|
||||||
x += (float)positions[i].x_advance / 64.0f;
|
x += (float)positions[i].x_advance / 64.0f;
|
||||||
free_processed_bitmap(&bm);
|
free_processed_bitmap(&bm);
|
||||||
@@ -683,7 +683,7 @@ render_simple_text_impl(PyObject *s, const char *text, unsigned int baseline) {
|
|||||||
FT_Bitmap *bitmap = &self->face->glyph->bitmap;
|
FT_Bitmap *bitmap = &self->face->glyph->bitmap;
|
||||||
pbm = EMPTY_PBM;
|
pbm = EMPTY_PBM;
|
||||||
populate_processed_bitmap(self->face->glyph, bitmap, &pbm, false);
|
populate_processed_bitmap(self->face->glyph, bitmap, &pbm, false);
|
||||||
place_bitmap_in_canvas(canvas, &pbm, canvas_width, canvas_height, pen_x, 0, baseline);
|
place_bitmap_in_canvas(canvas, &pbm, canvas_width, canvas_height, pen_x, 0, baseline, n);
|
||||||
pen_x += self->face->glyph->advance.x >> 6;
|
pen_x += self->face->glyph->advance.x >> 6;
|
||||||
}
|
}
|
||||||
ans.width = pen_x; ans.height = canvas_height;
|
ans.width = pen_x; ans.height = canvas_height;
|
||||||
|
|||||||
Reference in New Issue
Block a user