[pango] Win32: Enable rendering colored text



commit bb774bce7f99e839851834c1688c12d898f9c5ab
Author: Nicolas Hake <nh nosebud de>
Date:   Mon Jul 11 13:03:32 2016 +0200

    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

 pango/pangowin32.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index b663473..bdebc5f 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;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]