| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 BreakList<bool>::const_iterator bold = styles()[BOLD].breaks().begin(); | 348 BreakList<bool>::const_iterator bold = styles()[BOLD].breaks().begin(); |
| 349 BreakList<bool>::const_iterator italic = styles()[ITALIC].breaks().begin(); | 349 BreakList<bool>::const_iterator italic = styles()[ITALIC].breaks().begin(); |
| 350 while (bold != styles()[BOLD].breaks().end() && | 350 while (bold != styles()[BOLD].breaks().end() && |
| 351 italic != styles()[ITALIC].breaks().end()) { | 351 italic != styles()[ITALIC].breaks().end()) { |
| 352 const int style = (bold->second ? Font::BOLD : 0) | | 352 const int style = (bold->second ? Font::BOLD : 0) | |
| 353 (italic->second ? Font::ITALIC : 0); | 353 (italic->second ? Font::ITALIC : 0); |
| 354 const size_t bold_end = styles()[BOLD].GetRange(bold).end(); | 354 const size_t bold_end = styles()[BOLD].GetRange(bold).end(); |
| 355 const size_t italic_end = styles()[ITALIC].GetRange(italic).end(); | 355 const size_t italic_end = styles()[ITALIC].GetRange(italic).end(); |
| 356 const size_t style_end = std::min(bold_end, italic_end); | 356 const size_t style_end = std::min(bold_end, italic_end); |
| 357 if (style != font_list().GetFontStyle()) { | 357 if (style != font_list().GetFontStyle()) { |
| 358 // TODO(derat): Don't interpret gfx::FontList font descriptions as Pango |
| 359 // font descriptions: http://crbug.com/393067 |
| 358 FontList derived_font_list = font_list().DeriveWithStyle(style); | 360 FontList derived_font_list = font_list().DeriveWithStyle(style); |
| 359 ScopedPangoFontDescription desc(pango_font_description_from_string( | 361 ScopedPangoFontDescription desc( |
| 360 derived_font_list.GetFontDescriptionString().c_str())); | 362 derived_font_list.GetFontDescriptionString()); |
| 361 | 363 |
| 362 PangoAttribute* pango_attr = pango_attr_font_desc_new(desc.get()); | 364 PangoAttribute* pango_attr = pango_attr_font_desc_new(desc.get()); |
| 363 pango_attr->start_index = | 365 pango_attr->start_index = |
| 364 TextIndexToLayoutIndex(std::max(bold->first, italic->first)); | 366 TextIndexToLayoutIndex(std::max(bold->first, italic->first)); |
| 365 pango_attr->end_index = TextIndexToLayoutIndex(style_end); | 367 pango_attr->end_index = TextIndexToLayoutIndex(style_end); |
| 366 pango_attr_list_insert(attrs, pango_attr); | 368 pango_attr_list_insert(attrs, pango_attr); |
| 367 } | 369 } |
| 368 bold += bold_end == style_end ? 1 : 0; | 370 bold += bold_end == style_end ? 1 : 0; |
| 369 italic += italic_end == style_end ? 1 : 0; | 371 italic += italic_end == style_end ? 1 : 0; |
| 370 } | 372 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 int glyph_index) const { | 503 int glyph_index) const { |
| 502 return LayoutIndexToTextIndex(run->item->offset + | 504 return LayoutIndexToTextIndex(run->item->offset + |
| 503 run->glyphs->log_clusters[glyph_index]); | 505 run->glyphs->log_clusters[glyph_index]); |
| 504 } | 506 } |
| 505 | 507 |
| 506 RenderText* RenderText::CreateNativeInstance() { | 508 RenderText* RenderText::CreateNativeInstance() { |
| 507 return new RenderTextPango; | 509 return new RenderTextPango; |
| 508 } | 510 } |
| 509 | 511 |
| 510 } // namespace gfx | 512 } // namespace gfx |
| OLD | NEW |