| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/render_text_linux.h" | 5 #include "ui/gfx/render_text_linux.h" |
| 6 | 6 |
| 7 #include <pango/pangocairo.h> | 7 #include <pango/pangocairo.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/i18n/break_iterator.h" | 12 #include "base/i18n/break_iterator.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "third_party/skia/include/core/SkTypeface.h" |
| 14 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 15 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 16 #include "ui/gfx/pango_util.h" | 17 #include "ui/gfx/pango_util.h" |
| 17 #include "unicode/uchar.h" | 18 #include "unicode/uchar.h" |
| 18 #include "unicode/ustring.h" | 19 #include "unicode/ustring.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Returns whether the given Pango item is Left to Right. | 23 // Returns whether the given Pango item is Left to Right. |
| 23 bool IsRunLTR(const PangoItem* item) { | 24 bool IsRunLTR(const PangoItem* item) { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 style = i; | 313 style = i; |
| 313 break; | 314 break; |
| 314 } | 315 } |
| 315 } | 316 } |
| 316 DCHECK_GE(style, 0); | 317 DCHECK_GE(style, 0); |
| 317 | 318 |
| 318 PangoFontDescription* native_font = | 319 PangoFontDescription* native_font = |
| 319 pango_font_describe(run->item->analysis.font); | 320 pango_font_describe(run->item->analysis.font); |
| 320 { | 321 { |
| 321 TRACE_EVENT0("gfx", "RenderTextLinux::DrawVisualText SetFont"); | 322 TRACE_EVENT0("gfx", "RenderTextLinux::DrawVisualText SetFont"); |
| 322 renderer.SetFont(gfx::Font(native_font)); | 323 const char* family_name = pango_font_description_get_family(native_font); |
| 324 SkAutoTUnref<SkTypeface> typeface( |
| 325 SkTypeface::CreateFromName(family_name, SkTypeface::kNormal)); |
| 326 renderer.SetTypeface(typeface.get()); |
| 327 renderer.SetTextSize(GetPangoFontSizeInPixels(native_font)); |
| 323 } | 328 } |
| 324 pango_font_description_free(native_font); | 329 pango_font_description_free(native_font); |
| 325 | 330 |
| 326 SkScalar glyph_x = x; | 331 SkScalar glyph_x = x; |
| 327 SkScalar start_x = x; | 332 SkScalar start_x = x; |
| 328 int start = 0; | 333 int start = 0; |
| 329 | 334 |
| 330 glyphs.resize(glyph_count); | 335 glyphs.resize(glyph_count); |
| 331 pos.resize(glyph_count); | 336 pos.resize(glyph_count); |
| 332 | 337 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 765 } |
| 761 | 766 |
| 762 void RenderTextLinux::GetSelectionBounds(std::vector<Rect>* bounds) { | 767 void RenderTextLinux::GetSelectionBounds(std::vector<Rect>* bounds) { |
| 763 if (selection_visual_bounds_.empty()) | 768 if (selection_visual_bounds_.empty()) |
| 764 CalculateSubstringBounds(GetSelectionStart(), GetCursorPosition(), | 769 CalculateSubstringBounds(GetSelectionStart(), GetCursorPosition(), |
| 765 &selection_visual_bounds_); | 770 &selection_visual_bounds_); |
| 766 *bounds = selection_visual_bounds_; | 771 *bounds = selection_visual_bounds_; |
| 767 } | 772 } |
| 768 | 773 |
| 769 } // namespace gfx | 774 } // namespace gfx |
| OLD | NEW |