diff options
author | nick87720z <nick87720z@gmail.com> | 2020-05-12 15:05:56 +0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 12:05:56 +0200 |
commit | 8a2e67f6fec417a874a09ccf1eb3e2a7fbb3d423 (patch) | |
tree | 24a7b4ceb49b8d0343a0d848c47a126945e6b07e | |
parent | 2ccc65ff5284c3f7344443e3ee0b7f38f207b235 (diff) |
workaround for #303 (#1122)
* workaround for #303
Subpixel rendering may be disabled by some clip paths or when text
itself is clipped.
* optimize draw_pango_layout()
-rw-r--r-- | source/widgets/textbox.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 482d1037..01c0dc41 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -404,6 +404,30 @@ static void textbox_free ( widget *wid ) g_slice_free ( textbox, tb ); } +/* FIXME: workaround for cairo bug, when subpixel rendering failed with some cairo clip paths */ +static void draw_pango_layout (cairo_t * cr, PangoLayout * layout, int x, int y) +{ + cairo_surface_t * txt_surf; + cairo_t * txt_cr; + + txt_surf = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL); + txt_cr = cairo_create (txt_surf); + + cairo_set_source (txt_cr, cairo_get_source (cr)); + pango_cairo_show_layout (txt_cr, layout); + cairo_destroy (txt_cr); + { + cairo_pattern_t * pat = cairo_get_source (cr); + cairo_pattern_reference (pat); + + cairo_set_source_surface (cr, txt_surf, x, y); + cairo_paint (cr); + + cairo_set_source (cr, pat); + } + cairo_surface_destroy (txt_surf); +} + static void textbox_draw ( widget *wid, cairo_t *draw ) { if ( wid == NULL ) { @@ -447,7 +471,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) // Set ARGB // We need to set over, otherwise subpixel hinting wont work. cairo_move_to ( draw, x, top ); - pango_cairo_show_layout ( draw, tb->layout ); + draw_pango_layout (draw, tb->layout, x, top); // draw the cursor rofi_theme_get_color ( WIDGET ( tb ), "text-color", draw ); |