| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // This needs to be done early on; it has no effect when called just before | 197 // This needs to be done early on; it has no effect when called just before |
| 198 // pango_cairo_show_layout(). | 198 // pango_cairo_show_layout(). |
| 199 pango_cairo_context_set_font_options( | 199 pango_cairo_context_set_font_options( |
| 200 pango_layout_get_context(layout), cairo_font_options); | 200 pango_layout_get_context(layout), cairo_font_options); |
| 201 | 201 |
| 202 if (copied_cairo_font_options) { | 202 if (copied_cairo_font_options) { |
| 203 cairo_font_options_destroy(cairo_font_options); | 203 cairo_font_options_destroy(cairo_font_options); |
| 204 cairo_font_options = NULL; | 204 cairo_font_options = NULL; |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Callers of DrawStringInt handle RTL layout themselves, so tell pango to not | 207 // Set Pango's base text direction explicitly from |text_direction|. |
| 208 // scope out RTL characters. | |
| 209 pango_layout_set_auto_dir(layout, FALSE); | 208 pango_layout_set_auto_dir(layout, FALSE); |
| 209 pango_context_set_base_dir(pango_layout_get_context(layout), |
| 210 (text_direction == base::i18n::RIGHT_TO_LEFT ? |
| 211 PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR)); |
| 210 | 212 |
| 211 if (width > 0) | 213 if (width > 0) |
| 212 pango_layout_set_width(layout, width * PANGO_SCALE); | 214 pango_layout_set_width(layout, width * PANGO_SCALE); |
| 213 | 215 |
| 214 if (flags & Canvas::TEXT_ALIGN_CENTER) { | 216 if (flags & Canvas::TEXT_ALIGN_CENTER) { |
| 215 // We don't support center aligned w/ eliding. | 217 // We don't support center aligned w/ eliding. |
| 216 DCHECK(gfx::Canvas::NO_ELLIPSIS); | 218 DCHECK(gfx::Canvas::NO_ELLIPSIS); |
| 217 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); | 219 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); |
| 218 } else if (flags & Canvas::TEXT_ALIGN_RIGHT) { | 220 } else if (flags & Canvas::TEXT_ALIGN_RIGHT) { |
| 219 pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); | 221 pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 424 |
| 423 if (i == desc_to_metrics->end()) { | 425 if (i == desc_to_metrics->end()) { |
| 424 PangoFontMetrics* metrics = pango_context_get_metrics(context, desc, NULL); | 426 PangoFontMetrics* metrics = pango_context_get_metrics(context, desc, NULL); |
| 425 desc_to_metrics->insert(std::make_pair(desc_hash, metrics)); | 427 desc_to_metrics->insert(std::make_pair(desc_hash, metrics)); |
| 426 return metrics; | 428 return metrics; |
| 427 } | 429 } |
| 428 return i->second; | 430 return i->second; |
| 429 } | 431 } |
| 430 | 432 |
| 431 } // namespace gfx | 433 } // namespace gfx |
| OLD | NEW |