OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "third_party/harfbuzz-ng/src/hb.h" | 10 #include "third_party/harfbuzz-ng/src/hb.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // Returns the index of the first glyph that corresponds to the character at | 23 // Returns the index of the first glyph that corresponds to the character at |
24 // |pos|. | 24 // |pos|. |
25 size_t CharToGlyph(size_t pos) const; | 25 size_t CharToGlyph(size_t pos) const; |
26 | 26 |
27 // Returns the corresponding glyph range of the given character range. | 27 // Returns the corresponding glyph range of the given character range. |
28 // |range| is in text-space (0 corresponds to |GetLayoutText()[0]|). Returned | 28 // |range| is in text-space (0 corresponds to |GetLayoutText()[0]|). Returned |
29 // value is in run-space (0 corresponds to the first glyph in the run). | 29 // value is in run-space (0 corresponds to the first glyph in the run). |
30 Range CharRangeToGlyphRange(const Range& range) const; | 30 Range CharRangeToGlyphRange(const Range& range) const; |
31 | 31 |
32 // Returns whether the given shaped run contains any missing glyphs. | 32 // Returns the number of missing glyphs in the shaped text run. |
33 bool HasMissingGlyphs() const; | 33 size_t CountMissingGlyphs() const; |
34 | 34 |
35 // Returns the X coordinate of the leading or |trailing| edge of the glyph | 35 // Returns the X coordinate of the leading or |trailing| edge of the glyph |
36 // starting at |text_index|, relative to the left of the text (not the view). | 36 // starting at |text_index|, relative to the left of the text (not the view). |
37 int GetGlyphXBoundary(size_t text_index, bool trailing) const; | 37 int GetGlyphXBoundary(size_t text_index, bool trailing) const; |
38 | 38 |
39 int width; | 39 int width; |
40 int preceding_run_widths; | 40 int preceding_run_widths; |
41 Range range; | 41 Range range; |
42 bool is_rtl; | 42 bool is_rtl; |
43 UBiDiLevel level; | 43 UBiDiLevel level; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 SelectionModel FirstSelectionModelInsideRun( | 105 SelectionModel FirstSelectionModelInsideRun( |
106 const internal::TextRunHarfBuzz* run); | 106 const internal::TextRunHarfBuzz* run); |
107 SelectionModel LastSelectionModelInsideRun( | 107 SelectionModel LastSelectionModelInsideRun( |
108 const internal::TextRunHarfBuzz* run); | 108 const internal::TextRunHarfBuzz* run); |
109 | 109 |
110 // Break the text into logical runs and populate the visual <-> logical maps. | 110 // Break the text into logical runs and populate the visual <-> logical maps. |
111 void ItemizeText(); | 111 void ItemizeText(); |
112 | 112 |
113 // Shape the glyphs needed for the text |run|. | 113 // Shape the glyphs needed for the text |run|. |
114 void ShapeRun(internal::TextRunHarfBuzz* run); | 114 void ShapeRun(internal::TextRunHarfBuzz* run); |
| 115 void ShapeRunWithFont(internal::TextRunHarfBuzz* run, |
| 116 const std::string& font); |
115 | 117 |
116 // Text runs in logical order. | 118 // Text runs in logical order. |
117 ScopedVector<internal::TextRunHarfBuzz> runs_; | 119 ScopedVector<internal::TextRunHarfBuzz> runs_; |
118 | 120 |
119 // Maps visual run indices to logical run indices and vice versa. | 121 // Maps visual run indices to logical run indices and vice versa. |
120 std::vector<int32_t> visual_to_logical_; | 122 std::vector<int32_t> visual_to_logical_; |
121 std::vector<int32_t> logical_to_visual_; | 123 std::vector<int32_t> logical_to_visual_; |
122 | 124 |
123 bool needs_layout_; | 125 bool needs_layout_; |
124 | 126 |
125 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 127 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
126 }; | 128 }; |
127 | 129 |
128 } // namespace gfx | 130 } // namespace gfx |
129 | 131 |
130 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 132 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |