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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 BreakList<bool>::const_iterator bold = styles()[BOLD].breaks().begin(); | 346 BreakList<bool>::const_iterator bold = styles()[BOLD].breaks().begin(); |
347 BreakList<bool>::const_iterator italic = styles()[ITALIC].breaks().begin(); | 347 BreakList<bool>::const_iterator italic = styles()[ITALIC].breaks().begin(); |
348 while (bold != styles()[BOLD].breaks().end() && | 348 while (bold != styles()[BOLD].breaks().end() && |
349 italic != styles()[ITALIC].breaks().end()) { | 349 italic != styles()[ITALIC].breaks().end()) { |
350 const int style = (bold->second ? Font::BOLD : 0) | | 350 const int style = (bold->second ? Font::BOLD : 0) | |
351 (italic->second ? Font::ITALIC : 0); | 351 (italic->second ? Font::ITALIC : 0); |
352 const size_t bold_end = styles()[BOLD].GetRange(bold).end(); | 352 const size_t bold_end = styles()[BOLD].GetRange(bold).end(); |
353 const size_t italic_end = styles()[ITALIC].GetRange(italic).end(); | 353 const size_t italic_end = styles()[ITALIC].GetRange(italic).end(); |
354 const size_t style_end = std::min(bold_end, italic_end); | 354 const size_t style_end = std::min(bold_end, italic_end); |
355 if (style != font_list().GetFontStyle()) { | 355 if (style != font_list().GetFontStyle()) { |
356 FontList derived_font_list = font_list().DeriveFontList(style); | 356 FontList derived_font_list = font_list().DeriveWithStyle(style); |
357 ScopedPangoFontDescription desc(pango_font_description_from_string( | 357 ScopedPangoFontDescription desc(pango_font_description_from_string( |
358 derived_font_list.GetFontDescriptionString().c_str())); | 358 derived_font_list.GetFontDescriptionString().c_str())); |
359 | 359 |
360 PangoAttribute* pango_attr = pango_attr_font_desc_new(desc.get()); | 360 PangoAttribute* pango_attr = pango_attr_font_desc_new(desc.get()); |
361 pango_attr->start_index = | 361 pango_attr->start_index = |
362 TextIndexToLayoutIndex(std::max(bold->first, italic->first)); | 362 TextIndexToLayoutIndex(std::max(bold->first, italic->first)); |
363 pango_attr->end_index = TextIndexToLayoutIndex(style_end); | 363 pango_attr->end_index = TextIndexToLayoutIndex(style_end); |
364 pango_attr_list_insert(attrs, pango_attr); | 364 pango_attr_list_insert(attrs, pango_attr); |
365 } | 365 } |
366 bold += bold_end == style_end ? 1 : 0; | 366 bold += bold_end == style_end ? 1 : 0; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 int glyph_index) const { | 522 int glyph_index) const { |
523 return LayoutIndexToTextIndex(run->item->offset + | 523 return LayoutIndexToTextIndex(run->item->offset + |
524 run->glyphs->log_clusters[glyph_index]); | 524 run->glyphs->log_clusters[glyph_index]); |
525 } | 525 } |
526 | 526 |
527 RenderText* RenderText::CreateInstance() { | 527 RenderText* RenderText::CreateInstance() { |
528 return new RenderTextPango; | 528 return new RenderTextPango; |
529 } | 529 } |
530 | 530 |
531 } // namespace gfx | 531 } // namespace gfx |
OLD | NEW |