From e882dd48e3c3d6aa443383016c36f53683cd3048 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 6 Jan 2022 14:02:43 +0800 Subject: [PATCH] Fix duplicate overhang display on GNUstep * src/nsfont.m (nsfont_draw): Stop saving DPS clip and remove workaround for bad clipping. * src/nsterm.m (ns_draw_glyph_string): Clip to glyph string rect when displaying overhangs. --- src/nsfont.m | 12 ------------ src/nsterm.m | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/nsfont.m b/src/nsfont.m index d4ea4fa5044..f3c8a82930b 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -1222,22 +1222,10 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, /* render under GNUstep using DPS */ { NSGraphicsContext *context = [NSGraphicsContext currentContext]; - DPSgsave (context); - if (s->clip_head) - { - DPSrectclip (context, s->clip_head->x, 0, - FRAME_PIXEL_WIDTH (s->f), - FRAME_PIXEL_HEIGHT (s->f)); - } [font->nsfont set]; - [col set]; - DPSmoveto (context, r.origin.x, r.origin.y); GSShowGlyphs (context, c, len); - DPSstroke (context); - - DPSgrestore (context); } unblock_input (); diff --git a/src/nsterm.m b/src/nsterm.m index 41c311e04dc..382aa57a125 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4063,19 +4063,22 @@ ns_draw_glyph_string (struct glyph_string *s) /* As prev was drawn while clipped to its own area, we must draw the right_overhang part using s->hl now. */ enum draw_glyphs_face save = prev->hl; - struct face *save_face = prev->face; - prev->face = s->face; + prev->hl = s->hl; NSRect r = NSMakeRect (s->x, s->y, s->width, s->height); + NSRect rc; + get_glyph_string_clip_rect (s, &rc); [[NSGraphicsContext currentContext] saveGraphicsState]; NSRectClip (r); + if (n) + NSRectClip (rc); #ifdef NS_IMPL_GNUSTEP DPSgsave ([NSGraphicsContext currentContext]); DPSrectclip ([NSGraphicsContext currentContext], s->x, s->y, s->width, s->height); + DPSrectclip ([NSGraphicsContext currentContext], NSMinX (rc), + NSMinY (rc), NSWidth (rc), NSHeight (rc)); #endif - prev->num_clips = 1; - prev->hl = s->hl; if (prev->first_glyph->type == CHAR_GLYPH) ns_draw_glyph_string_foreground (prev); else @@ -4085,8 +4088,6 @@ ns_draw_glyph_string (struct glyph_string *s) #endif [[NSGraphicsContext currentContext] restoreGraphicsState]; prev->hl = save; - prev->face = save_face; - prev->num_clips = 0; } ns_unfocus (s->f); } @@ -4103,19 +4104,21 @@ ns_draw_glyph_string (struct glyph_string *s) /* As next will be drawn while clipped to its own area, we must draw the left_overhang part using s->hl now. */ enum draw_glyphs_face save = next->hl; - struct face *save_face = next->face; next->hl = s->hl; - next->face = s->face; NSRect r = NSMakeRect (s->x, s->y, s->width, s->height); + NSRect rc; + get_glyph_string_clip_rect (s, &rc); [[NSGraphicsContext currentContext] saveGraphicsState]; NSRectClip (r); + NSRectClip (rc); #ifdef NS_IMPL_GNUSTEP DPSgsave ([NSGraphicsContext currentContext]); DPSrectclip ([NSGraphicsContext currentContext], s->x, s->y, s->width, s->height); + DPSrectclip ([NSGraphicsContext currentContext], NSMinX (rc), + NSMinY (rc), NSWidth (rc), NSHeight (rc)); #endif - next->num_clips = 1; if (next->first_glyph->type == CHAR_GLYPH) ns_draw_glyph_string_foreground (next); else @@ -4125,10 +4128,7 @@ ns_draw_glyph_string (struct glyph_string *s) #endif [[NSGraphicsContext currentContext] restoreGraphicsState]; next->hl = save; - next->num_clips = 0; - next->face = save_face; - next->clip_head = next; - next->background_filled_p = 0; + next->clip_head = s->next; } ns_unfocus (s->f); } -- 2.39.2