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/i18n/break_iterator.h" | |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
10 #include "third_party/harfbuzz-ng/src/hb.h" | 11 #include "third_party/harfbuzz-ng/src/hb.h" |
11 #include "third_party/icu/source/common/unicode/ubidi.h" | 12 #include "third_party/icu/source/common/unicode/ubidi.h" |
12 #include "third_party/icu/source/common/unicode/uscript.h" | 13 #include "third_party/icu/source/common/unicode/uscript.h" |
13 #include "ui/gfx/render_text.h" | 14 #include "ui/gfx/render_text.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 | 17 |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 struct GFX_EXPORT TextRunHarfBuzz { | 20 struct GFX_EXPORT TextRunHarfBuzz { |
20 TextRunHarfBuzz(); | 21 TextRunHarfBuzz(); |
21 ~TextRunHarfBuzz(); | 22 ~TextRunHarfBuzz(); |
22 | 23 |
23 // Returns the index of the first glyph that corresponds to the character at | 24 // Returns the index of the first glyph that corresponds to the character at |
24 // |pos|. | 25 // |pos|. |
25 size_t CharToGlyph(size_t pos) const; | 26 size_t CharToGlyph(size_t pos) const; |
26 | 27 |
27 // Returns the corresponding glyph range of the given character range. | 28 // Returns the corresponding glyph range of the given character range. |
28 // |range| is in text-space (0 corresponds to |GetLayoutText()[0]|). Returned | 29 // |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). | 30 // value is in run-space (0 corresponds to the first glyph in the run). |
30 Range CharRangeToGlyphRange(const Range& range) const; | 31 Range CharRangeToGlyphRange(const Range& range) const; |
31 | 32 |
33 // Writes the character and glyph ranges of the cluster containing |pos|. | |
34 void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; | |
35 | |
36 // Returns bounds of the grapheme at |text_index|. Handles multi-grapheme | |
msw
2014/06/29 22:29:10
nit: s/bounds of the grapheme/the grapheme bounds/
ckocagil
2014/07/24 21:46:56
Done.
| |
37 // glyphs. | |
38 Range GetGraphemeBounds(const base::string16& text, size_t text_index); | |
39 | |
32 // Returns whether the given shaped run contains any missing glyphs. | 40 // Returns whether the given shaped run contains any missing glyphs. |
33 bool HasMissingGlyphs() const; | 41 bool HasMissingGlyphs() const; |
34 | 42 |
35 // Returns the X coordinate of the leading or |trailing| edge of the glyph | 43 base::i18n::BreakIterator* GetGraphemeIterator(const base::string16& text); |
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; | |
38 | 44 |
39 int width; | 45 int width; |
40 int preceding_run_widths; | 46 int preceding_run_widths; |
41 Range range; | 47 Range range; |
42 bool is_rtl; | 48 bool is_rtl; |
43 UBiDiLevel level; | 49 UBiDiLevel level; |
44 UScriptCode script; | 50 UScriptCode script; |
51 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator; | |
45 | 52 |
46 scoped_ptr<uint16[]> glyphs; | 53 scoped_ptr<uint16[]> glyphs; |
47 scoped_ptr<SkPoint[]> positions; | 54 scoped_ptr<SkPoint[]> positions; |
48 scoped_ptr<uint32[]> glyph_to_char; | 55 std::vector<uint32> glyph_to_char; |
49 size_t glyph_count; | 56 size_t glyph_count; |
50 | 57 |
51 skia::RefPtr<SkTypeface> skia_face; | 58 skia::RefPtr<SkTypeface> skia_face; |
52 int font_size; | 59 int font_size; |
53 int font_style; | 60 int font_style; |
54 bool strike; | 61 bool strike; |
55 bool diagonal_strike; | 62 bool diagonal_strike; |
56 bool underline; | 63 bool underline; |
57 | 64 |
58 private: | 65 private: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 std::vector<int32_t> logical_to_visual_; | 128 std::vector<int32_t> logical_to_visual_; |
122 | 129 |
123 bool needs_layout_; | 130 bool needs_layout_; |
124 | 131 |
125 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 132 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
126 }; | 133 }; |
127 | 134 |
128 } // namespace gfx | 135 } // namespace gfx |
129 | 136 |
130 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 137 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |