OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/pango_util.h" | 5 #include "ui/gfx/pango_util.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
9 #include <pango/pango.h> | 9 #include <pango/pango.h> |
10 #include <pango/pangocairo.h> | 10 #include <pango/pangocairo.h> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 pattern = cairo_pattern_create_linear( | 339 pattern = cairo_pattern_create_linear( |
340 fade_x, bounds.y(), bounds.x() + bounds.width(), bounds.y()); | 340 fade_x, bounds.y(), bounds.x() + bounds.width(), bounds.y()); |
341 cairo_pattern_add_color_stop_rgba(pattern, 0, r, g, b, a); | 341 cairo_pattern_add_color_stop_rgba(pattern, 0, r, g, b, a); |
342 cairo_pattern_add_color_stop_rgba(pattern, 1, r, g, b, kFadeFinalAlpha); | 342 cairo_pattern_add_color_stop_rgba(pattern, 1, r, g, b, kFadeFinalAlpha); |
343 cairo_set_source(cr, pattern); | 343 cairo_set_source(cr, pattern); |
344 } | 344 } |
345 | 345 |
346 cairo_move_to(cr, text_rect.x(), text_rect.y()); | 346 cairo_move_to(cr, text_rect.x(), text_rect.y()); |
347 pango_cairo_show_layout(cr, layout); | 347 pango_cairo_show_layout(cr, layout); |
348 | 348 |
349 if (font.GetStyle() & gfx::Font::UNDERLINED) { | 349 if (font.GetStyle() & gfx::Font::UNDERLINE) { |
350 gfx::PlatformFontPango* platform_font = | 350 gfx::PlatformFontPango* platform_font = |
351 static_cast<gfx::PlatformFontPango*>(font.platform_font()); | 351 static_cast<gfx::PlatformFontPango*>(font.platform_font()); |
352 DrawPangoTextUnderline(cr, platform_font, 0.0, text_rect); | 352 DrawPangoTextUnderline(cr, platform_font, 0.0, text_rect); |
353 } | 353 } |
354 | 354 |
355 if (pattern) | 355 if (pattern) |
356 cairo_pattern_destroy(pattern); | 356 cairo_pattern_destroy(pattern); |
357 | 357 |
358 cairo_restore(cr); | 358 cairo_restore(cr); |
359 } | 359 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 if (i == desc_to_metrics->end()) { | 408 if (i == desc_to_metrics->end()) { |
409 PangoFontMetrics* metrics = pango_context_get_metrics(context, desc, NULL); | 409 PangoFontMetrics* metrics = pango_context_get_metrics(context, desc, NULL); |
410 desc_to_metrics->insert(std::make_pair(desc_hash, metrics)); | 410 desc_to_metrics->insert(std::make_pair(desc_hash, metrics)); |
411 return metrics; | 411 return metrics; |
412 } | 412 } |
413 return i->second; | 413 return i->second; |
414 } | 414 } |
415 | 415 |
416 } // namespace gfx | 416 } // namespace gfx |
OLD | NEW |