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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 namespace gfx { | 27 namespace gfx { |
28 | 28 |
29 class Range; | 29 class Range; |
30 class RangeF; | 30 class RangeF; |
31 | 31 |
32 namespace internal { | 32 namespace internal { |
33 | 33 |
34 struct GFX_EXPORT TextRunHarfBuzz { | 34 struct GFX_EXPORT TextRunHarfBuzz { |
35 // Construct the run with |template_font| since determining the details of a | 35 // Construct the run with |template_font| since determining the details of a |
36 // default-constructed gfx::Font is expensive, but it will always be replaced. | 36 // default-constructed gfx::Font is expensive, but it will always be replaced. |
37 explicit TextRunHarfBuzz(const gfx::Font& template_font); | 37 explicit TextRunHarfBuzz(const Font& template_font); |
38 ~TextRunHarfBuzz(); | 38 ~TextRunHarfBuzz(); |
39 | 39 |
40 // Returns the index of the first glyph that corresponds to the character at | 40 // Returns the index of the first glyph that corresponds to the character at |
41 // |pos|. | 41 // |pos|. |
42 size_t CharToGlyph(size_t pos) const; | 42 size_t CharToGlyph(size_t pos) const; |
43 | 43 |
44 // Returns the corresponding glyph range of the given character range. | 44 // Returns the corresponding glyph range of the given character range. |
45 // |range| is in text-space (0 corresponds to |GetDisplayText()[0]|). Returned | 45 // |range| is in text-space (0 corresponds to |GetDisplayText()[0]|). Returned |
46 // value is in run-space (0 corresponds to the first glyph in the run). | 46 // value is in run-space (0 corresponds to the first glyph in the run). |
47 Range CharRangeToGlyphRange(const Range& range) const; | 47 Range CharRangeToGlyphRange(const Range& range) const; |
(...skipping 26 matching lines...) Expand all Loading... |
74 std::unique_ptr<SkPoint[]> positions; | 74 std::unique_ptr<SkPoint[]> positions; |
75 std::vector<uint32_t> glyph_to_char; | 75 std::vector<uint32_t> glyph_to_char; |
76 size_t glyph_count; | 76 size_t glyph_count; |
77 | 77 |
78 Font font; | 78 Font font; |
79 sk_sp<SkTypeface> skia_face; | 79 sk_sp<SkTypeface> skia_face; |
80 FontRenderParams render_params; | 80 FontRenderParams render_params; |
81 int font_size; | 81 int font_size; |
82 int baseline_offset; | 82 int baseline_offset; |
83 int baseline_type; | 83 int baseline_type; |
84 int font_style; | 84 bool italic; |
| 85 Font::Weight weight; |
85 bool strike; | 86 bool strike; |
86 bool diagonal_strike; | 87 bool diagonal_strike; |
87 bool underline; | 88 bool underline; |
88 | 89 |
89 private: | 90 private: |
90 DISALLOW_COPY_AND_ASSIGN(TextRunHarfBuzz); | 91 DISALLOW_COPY_AND_ASSIGN(TextRunHarfBuzz); |
91 }; | 92 }; |
92 | 93 |
93 // Manages the list of TextRunHarfBuzz and its logical <-> visual index mapping. | 94 // Manages the list of TextRunHarfBuzz and its logical <-> visual index mapping. |
94 class TextRunList { | 95 class TextRunList { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 void ItemizeTextToRuns(const base::string16& string, | 224 void ItemizeTextToRuns(const base::string16& string, |
224 internal::TextRunList* run_list_out); | 225 internal::TextRunList* run_list_out); |
225 | 226 |
226 // Helper method for ShapeRun() that calls ShapeRunWithFont() with |text|, | 227 // Helper method for ShapeRun() that calls ShapeRunWithFont() with |text|, |
227 // |run|, |font|, and |render_params|, returning true if the font provides | 228 // |run|, |font|, and |render_params|, returning true if the font provides |
228 // all the glyphs needed for |run|, and false otherwise. Additionally updates | 229 // all the glyphs needed for |run|, and false otherwise. Additionally updates |
229 // |best_font|, |best_render_params|, and |best_missing_glyphs| if |font| | 230 // |best_font|, |best_render_params|, and |best_missing_glyphs| if |font| |
230 // has fewer than |best_missing_glyphs| missing glyphs. | 231 // has fewer than |best_missing_glyphs| missing glyphs. |
231 bool CompareFamily(const base::string16& text, | 232 bool CompareFamily(const base::string16& text, |
232 const Font& font, | 233 const Font& font, |
233 const gfx::FontRenderParams& render_params, | 234 const FontRenderParams& render_params, |
234 internal::TextRunHarfBuzz* run, | 235 internal::TextRunHarfBuzz* run, |
235 Font* best_font, | 236 Font* best_font, |
236 gfx::FontRenderParams* best_render_params, | 237 FontRenderParams* best_render_params, |
237 size_t* best_missing_glyphs); | 238 size_t* best_missing_glyphs); |
238 | 239 |
239 // Shape the glyphs of all runs in |run_list| using |text|. | 240 // Shape the glyphs of all runs in |run_list| using |text|. |
240 void ShapeRunList(const base::string16& text, | 241 void ShapeRunList(const base::string16& text, |
241 internal::TextRunList* run_list); | 242 internal::TextRunList* run_list); |
242 | 243 |
243 // Shape the glyphs needed for the |run| within the |text|. | 244 // Shape the glyphs needed for the |run| within the |text|. |
244 void ShapeRun(const base::string16& text, | 245 void ShapeRun(const base::string16& text, |
245 internal::TextRunHarfBuzz* run); | 246 internal::TextRunHarfBuzz* run); |
246 bool ShapeRunWithFont(const base::string16& text, | 247 bool ShapeRunWithFont(const base::string16& text, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 279 |
279 // Fixed width of glyphs. This should only be set in test environments. | 280 // Fixed width of glyphs. This should only be set in test environments. |
280 float glyph_width_for_test_; | 281 float glyph_width_for_test_; |
281 | 282 |
282 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 283 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
283 }; | 284 }; |
284 | 285 |
285 } // namespace gfx | 286 } // namespace gfx |
286 | 287 |
287 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 288 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |