OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void setDrawRange(int from, int to); | 54 void setDrawRange(int from, int to); |
55 bool shape(GlyphBuffer* = 0); | 55 bool shape(GlyphBuffer* = 0); |
56 FloatPoint adjustStartPoint(const FloatPoint&); | 56 FloatPoint adjustStartPoint(const FloatPoint&); |
57 float totalWidth() { return m_totalWidth; } | 57 float totalWidth() { return m_totalWidth; } |
58 int offsetForPosition(float targetX); | 58 int offsetForPosition(float targetX); |
59 FloatRect selectionRect(const FloatPoint&, int height, int from, int to); | 59 FloatRect selectionRect(const FloatPoint&, int height, int from, int to); |
60 | 60 |
61 private: | 61 private: |
62 class HarfBuzzRun { | 62 class HarfBuzzRun { |
63 public: | 63 public: |
64 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un
signed startIndex, unsigned numCharacters, TextDirection direction) | 64 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un
signed startIndex, unsigned numCharacters, TextDirection direction, hb_script_t
script) |
65 { | 65 { |
66 return adoptPtr(new HarfBuzzRun(fontData, startIndex, numCharacters,
direction)); | 66 return adoptPtr(new HarfBuzzRun(fontData, startIndex, numCharacters,
direction, script)); |
67 } | 67 } |
68 | 68 |
69 void applyShapeResult(hb_buffer_t*); | 69 void applyShapeResult(hb_buffer_t*); |
70 void setGlyphAndPositions(unsigned index, uint16_t glyphId, float advanc
e, float offsetX, float offsetY); | 70 void setGlyphAndPositions(unsigned index, uint16_t glyphId, float advanc
e, float offsetX, float offsetY); |
71 void setWidth(float width) { m_width = width; } | 71 void setWidth(float width) { m_width = width; } |
72 | 72 |
73 int characterIndexForXPosition(float targetX); | 73 int characterIndexForXPosition(float targetX); |
74 float xPositionForOffset(unsigned offset); | 74 float xPositionForOffset(unsigned offset); |
75 | 75 |
76 const SimpleFontData* fontData() { return m_fontData; } | 76 const SimpleFontData* fontData() { return m_fontData; } |
77 unsigned startIndex() const { return m_startIndex; } | 77 unsigned startIndex() const { return m_startIndex; } |
78 unsigned numCharacters() const { return m_numCharacters; } | 78 unsigned numCharacters() const { return m_numCharacters; } |
79 unsigned numGlyphs() const { return m_numGlyphs; } | 79 unsigned numGlyphs() const { return m_numGlyphs; } |
80 uint16_t* glyphs() { return &m_glyphs[0]; } | 80 uint16_t* glyphs() { return &m_glyphs[0]; } |
81 float* advances() { return &m_advances[0]; } | 81 float* advances() { return &m_advances[0]; } |
82 FloatPoint* offsets() { return &m_offsets[0]; } | 82 FloatPoint* offsets() { return &m_offsets[0]; } |
83 uint16_t* glyphToCharacterIndexes() { return &m_glyphToCharacterIndexes[
0]; } | 83 uint16_t* glyphToCharacterIndexes() { return &m_glyphToCharacterIndexes[
0]; } |
84 float width() { return m_width; } | 84 float width() { return m_width; } |
| 85 bool rtl() { return m_direction == RTL; } |
| 86 hb_script_t script() { return m_script; } |
85 | 87 |
86 private: | 88 private: |
87 HarfBuzzRun(const SimpleFontData*, unsigned startIndex, unsigned numChar
acters, TextDirection); | 89 HarfBuzzRun(const SimpleFontData*, unsigned startIndex, unsigned numChar
acters, TextDirection, hb_script_t); |
88 bool rtl() { return m_direction == RTL; } | |
89 | 90 |
90 const SimpleFontData* m_fontData; | 91 const SimpleFontData* m_fontData; |
91 unsigned m_startIndex; | 92 unsigned m_startIndex; |
92 size_t m_numCharacters; | 93 size_t m_numCharacters; |
93 unsigned m_numGlyphs; | 94 unsigned m_numGlyphs; |
94 TextDirection m_direction; | 95 TextDirection m_direction; |
| 96 hb_script_t m_script; |
95 Vector<uint16_t, 256> m_glyphs; | 97 Vector<uint16_t, 256> m_glyphs; |
96 Vector<float, 256> m_advances; | 98 Vector<float, 256> m_advances; |
97 Vector<uint16_t, 256> m_glyphToCharacterIndexes; | 99 Vector<uint16_t, 256> m_glyphToCharacterIndexes; |
98 Vector<FloatPoint, 256> m_offsets; | 100 Vector<FloatPoint, 256> m_offsets; |
99 float m_width; | 101 float m_width; |
100 }; | 102 }; |
101 | 103 |
102 void setFontFeatures(); | 104 void setFontFeatures(); |
103 | 105 |
104 bool collectHarfBuzzRuns(); | 106 bool collectHarfBuzzRuns(); |
105 bool shapeHarfBuzzRuns(); | 107 bool shapeHarfBuzzRuns(bool shouldSetDirection); |
106 bool fillGlyphBuffer(GlyphBuffer*); | 108 bool fillGlyphBuffer(GlyphBuffer*); |
107 void fillGlyphBufferFromHarfBuzzRun(GlyphBuffer*, HarfBuzzRun*, FloatPoint&
firstOffsetOfNextRun); | 109 void fillGlyphBufferFromHarfBuzzRun(GlyphBuffer*, HarfBuzzRun*, FloatPoint&
firstOffsetOfNextRun); |
108 void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, hb_buffer_t*); | 110 void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, hb_buffer_t*); |
109 | 111 |
110 GlyphBufferAdvance createGlyphBufferAdvance(float, float); | 112 GlyphBufferAdvance createGlyphBufferAdvance(float, float); |
111 | 113 |
112 Vector<hb_feature_t, 4> m_features; | 114 Vector<hb_feature_t, 4> m_features; |
113 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfbuzzRuns; | 115 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfbuzzRuns; |
114 | 116 |
115 FloatPoint m_startOffset; | 117 FloatPoint m_startOffset; |
116 | 118 |
117 int m_fromIndex; | 119 int m_fromIndex; |
118 int m_toIndex; | 120 int m_toIndex; |
119 | 121 |
120 float m_totalWidth; | 122 float m_totalWidth; |
121 }; | 123 }; |
122 | 124 |
123 } // namespace WebCore | 125 } // namespace WebCore |
124 | 126 |
125 #endif // HarfBuzzShaper_h | 127 #endif // HarfBuzzShaper_h |
OLD | NEW |