Advertisement
Vultraz

Untitled

Jul 16th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1.     // Add a path to the cairo context tracing the current text.
  2.     pango_cairo_layout_path(cr.get(), &layout);
  3.  
  4.     if(add_outline_) {
  5.         // Set color for background outline (black).
  6.         cairo_set_source_rgba(cr.get(), 0.0, 0.0, 0.0, 1.0);
  7.  
  8.         cairo_set_line_join(cr.get(), CAIRO_LINE_JOIN_ROUND);
  9.         cairo_set_line_width(cr.get(), 3.0); // Adjust as necessary
  10.  
  11.         // Stroke path to draw outline. Don't delete it the path.
  12.         cairo_stroke_preserve(cr.get());
  13.     }
  14.  
  15.     // Set main text color.
  16.     cairo_set_source_rgba(cr.get(),
  17.         foreground_color_.r / 255.0,
  18.         foreground_color_.g / 255.0,
  19.         foreground_color_.b / 255.0,
  20.         foreground_color_.a / 255.0
  21.     );
  22.  
  23.     // Fill text path. This is a hack to work around bug #1744 (bad alpha blending when rendering the
  24.     // output surface). Instead of calling pango_cairo_show_layout twice, we fill the layout path here
  25.     // It greatly improves the look of text, but it shouldn't really be necessary and probably messes
  26.     // with certain OS settings like disabling AA.
  27.     cairo_fill(cr.get());
  28.  
  29.     // Necessary for pango markup to be properly rendered.
  30.     pango_cairo_show_layout(cr.get(), &layout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement