| 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/render_text_pango.h" | 5 #include "ui/gfx/render_text_pango.h" |
| 6 | 6 |
| 7 #include <pango/pangocairo.h> | 7 #include <pango/pangocairo.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); | 300 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); |
| 301 CHECK_EQ(CAIRO_STATUS_SUCCESS, cairo_surface_status(surface)); | 301 CHECK_EQ(CAIRO_STATUS_SUCCESS, cairo_surface_status(surface)); |
| 302 cairo_t* cr = cairo_create(surface); | 302 cairo_t* cr = cairo_create(surface); |
| 303 CHECK_EQ(CAIRO_STATUS_SUCCESS, cairo_status(cr)); | 303 CHECK_EQ(CAIRO_STATUS_SUCCESS, cairo_status(cr)); |
| 304 | 304 |
| 305 layout_ = pango_cairo_create_layout(cr); | 305 layout_ = pango_cairo_create_layout(cr); |
| 306 CHECK_NE(static_cast<PangoLayout*>(NULL), layout_); | 306 CHECK_NE(static_cast<PangoLayout*>(NULL), layout_); |
| 307 cairo_destroy(cr); | 307 cairo_destroy(cr); |
| 308 cairo_surface_destroy(surface); | 308 cairo_surface_destroy(surface); |
| 309 | 309 |
| 310 SetupPangoLayoutWithFontDescription(layout_, | 310 SetUpPangoLayout(layout_, GetLayoutText(), font_list(), GetTextDirection(), |
| 311 GetLayoutText(), | 311 Canvas::DefaultCanvasTextAlignment()); |
| 312 font_list().GetFontDescriptionString(), | |
| 313 0, | |
| 314 GetTextDirection(), | |
| 315 Canvas::DefaultCanvasTextAlignment()); | |
| 316 | 312 |
| 317 // No width set so that the x-axis position is relative to the start of the | 313 // No width set so that the x-axis position is relative to the start of the |
| 318 // text. ToViewPoint and ToTextPoint take care of the position conversion | 314 // text. ToViewPoint and ToTextPoint take care of the position conversion |
| 319 // between text space and view spaces. | 315 // between text space and view spaces. |
| 320 pango_layout_set_width(layout_, -1); | 316 pango_layout_set_width(layout_, -1); |
| 321 // TODO(xji): If RenderText will be used for displaying purpose, such as | 317 // TODO(xji): If RenderText will be used for displaying purpose, such as |
| 322 // label, we will need to remove the single-line-mode setting. | 318 // label, we will need to remove the single-line-mode setting. |
| 323 pango_layout_set_single_paragraph_mode(layout_, true); | 319 pango_layout_set_single_paragraph_mode(layout_, true); |
| 324 | 320 |
| 325 layout_text_ = pango_layout_get_text(layout_); | 321 layout_text_ = pango_layout_get_text(layout_); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 int glyph_index) const { | 515 int glyph_index) const { |
| 520 return LayoutIndexToTextIndex(run->item->offset + | 516 return LayoutIndexToTextIndex(run->item->offset + |
| 521 run->glyphs->log_clusters[glyph_index]); | 517 run->glyphs->log_clusters[glyph_index]); |
| 522 } | 518 } |
| 523 | 519 |
| 524 RenderText* RenderText::CreateNativeInstance() { | 520 RenderText* RenderText::CreateNativeInstance() { |
| 525 return new RenderTextPango; | 521 return new RenderTextPango; |
| 526 } | 522 } |
| 527 | 523 |
| 528 } // namespace gfx | 524 } // namespace gfx |
| OLD | NEW |