diff options
author | Nicolas Hake <nh@nosebud.de> | 2016-07-11 13:03:32 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-04-07 21:54:29 -0400 |
commit | bb774bce7f99e839851834c1688c12d898f9c5ab (patch) | |
tree | d6602d7f701b8c280f00c66fd39783caed2b6b36 /pango | |
parent | 43b9668ba688b01553abb7b453aeb206d7fd56fa (diff) | |
download | pango-bb774bce7f99e839851834c1688c12d898f9c5ab.tar.gz |
Win32: Enable rendering colored text
Increasing the component values by 128 may overflow and result in that
component being treated as 0. Additionally, using a brush to color text
is wrong; ExtTextOut instead uses the color set by SetTextColor to draw
glyphs.
https://bugzilla.gnome.org/show_bug.cgi?id=768679
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pangowin32.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c index b6634739..bdebc5fa 100644 --- a/pango/pangowin32.c +++ b/pango/pangowin32.c @@ -1025,7 +1025,7 @@ pango_win32_render_layout_line (HDC hdc, while (tmp_list) { - HBRUSH oldfg = NULL; + COLORREF oldfg = 0; HBRUSH brush = NULL; POINT points[2]; PangoUnderline uline = PANGO_UNDERLINE_NONE; @@ -1062,15 +1062,18 @@ pango_win32_render_layout_line (HDC hdc, if (fg_set) { - brush = CreateSolidBrush (RGB ((fg_color.color.red + 128) >> 8, - (fg_color.color.green + 128) >> 8, - (fg_color.color.blue + 128) >> 8)); - oldfg = SelectObject (hdc, brush); + COLORREF fg_col = RGB ((fg_color.color.red) >> 8, + (fg_color.color.green) >> 8, + (fg_color.color.blue) >> 8); + oldfg = SetTextColor (hdc, fg_col); } pango_win32_render (hdc, run->item->analysis.font, run->glyphs, x + PANGO_PIXELS (x_off), y); + if (fg_set) + SetTextColor (hdc, oldfg); + switch (uline) { case PANGO_UNDERLINE_NONE: @@ -1120,11 +1123,6 @@ pango_win32_render_layout_line (HDC hdc, break; } - if (fg_set) - { - SelectObject (hdc, oldfg); - DeleteObject (brush); - } x_off += logical_rect.width; } |