| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 pixels_in_point = pango_dpi / 72.0; // 72 points in an inch | 116 pixels_in_point = pango_dpi / 72.0; // 72 points in an inch |
| 117 determined_value = true; | 117 determined_value = true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 return pixels_in_point; | 120 return pixels_in_point; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 | 124 |
| 125 PangoContext* GetPangoContext() { | 125 PangoContext* GetPangoContext() { |
| 126 #if defined(USE_AURA) | 126 #if defined(TOOLKIT_GTK) |
| 127 return gdk_pango_context_get(); |
| 128 #else |
| 127 PangoFontMap* font_map = pango_cairo_font_map_get_default(); | 129 PangoFontMap* font_map = pango_cairo_font_map_get_default(); |
| 128 return pango_font_map_create_context(font_map); | 130 return pango_font_map_create_context(font_map); |
| 129 #else | |
| 130 return gdk_pango_context_get(); | |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 double GetPangoResolution() { | 134 double GetPangoResolution() { |
| 135 static double resolution; | 135 static double resolution; |
| 136 static bool determined_resolution = false; | 136 static bool determined_resolution = false; |
| 137 if (!determined_resolution) { | 137 if (!determined_resolution) { |
| 138 determined_resolution = true; | 138 determined_resolution = true; |
| 139 PangoContext* default_context = GetPangoContext(); | 139 PangoContext* default_context = GetPangoContext(); |
| 140 resolution = pango_cairo_context_get_resolution(default_context); | 140 resolution = pango_cairo_context_get_resolution(default_context); |
| (...skipping 266 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 |