Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: webkit/port/platform/graphics/UniscribeHelper.h

Issue 10785: Debase our Uniscribe code. This moves FontUtils and all our Uniscribe code fr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/base/gfx/uniscribe.h:r69-2775
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // A wrapper around Uniscribe that provides a reasonable API. 5 // A wrapper around Uniscribe that provides a reasonable API.
6 6
7 #ifndef BASE_GFX_UNISCRIBE_H__ 7 #ifndef UniscribeHelper_h
8 #define BASE_GFX_UNISCRIBE_H__ 8 #define UniscribeHelper_h
9 9
10 #include <windows.h> 10 #include <windows.h>
11 #include <usp10.h> 11 #include <usp10.h>
12 #include <wchar.h>
13 #include <map> 12 #include <map>
14 #include <vector>
15 13
16 #include "base/stack_container.h" 14 #include "wtf/Vector.h"
15
17 #include "testing/gtest/include/gtest/gtest_prod.h" 16 #include "testing/gtest/include/gtest/gtest_prod.h"
17 #include "unicode/uchar.h"
18 18
19 namespace gfx { 19 namespace WebCore {
20 20
21 #define UNISCRIBE_STATE_STACK_RUNS 8 21 #define UNISCRIBE_HELPER_STACK_RUNS 8
22 #define UNISCRIBE_STATE_STACK_CHARS 32 22 #define UNISCRIBE_HELPER_STACK_CHARS 32
23 23
24 // This object should be safe to create & destroy frequently, as long as the 24 // This object should be safe to create & destroy frequently, as long as the
25 // caller preserves the script_cache when possible (this data may be slow to 25 // caller preserves the script_cache when possible (this data may be slow to
26 // compute). 26 // compute).
27 // 27 //
28 // This object is "kind of large" (~1K) because it reserves a lot of space for 28 // This object is "kind of large" (~1K) because it reserves a lot of space for
29 // working with to avoid expensive heap operations. Therefore, not only should 29 // working with to avoid expensive heap operations. Therefore, not only should
30 // you not worry about creating and destroying it, you should try to not keep 30 // you not worry about creating and destroying it, you should try to not keep
31 // them around. 31 // them around.
32 class UniscribeState { 32 class UniscribeHelper {
33 public: 33 public:
34 // Initializes this Uniscribe run with the text pointed to by |run| with 34 // Initializes this Uniscribe run with the text pointed to by |run| with
35 // |length|. The input is NOT null terminated. 35 // |length|. The input is NOT null terminated.
36 // 36 //
37 // The is_rtl flag should be set if the input script is RTL. It is assumed 37 // The is_rtl flag should be set if the input script is RTL. It is assumed
38 // that the caller has already divided up the input text (using ICU, for 38 // that the caller has already divided up the input text (using ICU, for
39 // example) into runs of the same direction of script. This avoids 39 // example) into runs of the same direction of script. This avoids
40 // disagreements between the caller and Uniscribe later (see FillItems). 40 // disagreements between the caller and Uniscribe later (see FillItems).
41 // 41 //
42 // A script cache should be provided by the caller that is initialized to 42 // A script cache should be provided by the caller that is initialized to
43 // NULL. When the caller is done with the cache (it may be stored between 43 // NULL. When the caller is done with the cache (it may be stored between
44 // runs as long as it is used consistently with the same HFONT), it should 44 // runs as long as it is used consistently with the same HFONT), it should
45 // call ScriptFreeCache(). 45 // call ScriptFreeCache().
46 UniscribeState(const wchar_t* input, 46 UniscribeHelper(const UChar* input,
47 int input_length, 47 int inputLength,
48 bool is_rtl, 48 bool isRtl,
49 HFONT hfont, 49 HFONT hfont,
50 SCRIPT_CACHE* script_cache, 50 SCRIPT_CACHE* scriptCache,
51 SCRIPT_FONTPROPERTIES* font_properties); 51 SCRIPT_FONTPROPERTIES* fontProperties);
52 52
53 virtual ~UniscribeState(); 53 virtual ~UniscribeHelper();
54 54
55 // Sets Uniscribe's directional override flag. False by default. 55 // Sets Uniscribe's directional override flag. False by default.
56 bool directional_override() const { 56 bool directionalOverride() const
57 return directional_override_; 57 {
58 } 58 return m_directionalOverride;
59 void set_directional_override(bool override) { 59 }
60 directional_override_ = override; 60 void setDirectionalOverride(bool override)
61 } 61 {
62 62 m_directionalOverride = override;
63 // Set's Uniscribe's no-ligate override flag. False by default. 63 }
64 bool inhibit_ligate() const { 64
65 return inhibit_ligate_; 65 // Set's Uniscribe's no-ligate override flag. False by default.
66 } 66 bool inhibitLigate() const
67 void set_inhibit_ligate(bool inhibit) { 67 {
68 inhibit_ligate_ = inhibit; 68 return m_inhibitLigate;
69 } 69 }
70 70 void setInhibitLigate(bool inhibit)
71 // Set letter spacing. We will try to insert this much space between 71 {
72 // graphemes (one or more glyphs perceived as a single unit by ordinary users 72 m_inhibitLigate = inhibit;
73 // of a script). Positive values increase letter spacing, negative values 73 }
74 // decrease it. 0 by default. 74
75 int letter_spacing() const { 75 // Set letter spacing. We will try to insert this much space between
76 return letter_spacing_; 76 // graphemes (one or more glyphs perceived as a single unit by ordinary
77 } 77 // users of a script). Positive values increase letter spacing, negative
78 void set_letter_spacing(int letter_spacing) { 78 // values decrease it. 0 by default.
79 letter_spacing_ = letter_spacing; 79 int letterSpacing() const
80 } 80 {
81 81 return m_letterSpacing;
82 // Set the width of a standard space character. We use this to normalize 82 }
83 // space widths. Windows will make spaces after Hindi characters larger than 83 void setLetterSpacing(int letterSpacing)
84 // other spaces. A space_width of 0 means to use the default space width. 84 {
85 // 85 m_letterSpacing = letterSpacing;
86 // Must be set before Init() is called. 86 }
87 int space_width() const { 87
88 return space_width_; 88 // Set the width of a standard space character. We use this to normalize
89 } 89 // space widths. Windows will make spaces after Hindi characters larger than
90 void set_space_width(int space_width) { 90 // other spaces. A space_width of 0 means to use the default space width.
91 space_width_ = space_width; 91 //
92 } 92 // Must be set before Init() is called.
93 93 int spaceWidth() const
94 // Set word spacing. We will try to insert this much extra space between 94 {
95 // each word in the input (beyond whatever whitespace character separates 95 return m_spaceWidth;
96 // words). Positive values lead to increased letter spacing, negative values 96 }
97 // decrease it. 0 by default. 97 void setSpaceWidth(int spaceWidth)
98 // 98 {
99 // Must be set before Init() is called. 99 m_spaceWidth = spaceWidth;
100 int word_spacing() const { 100 }
101 return word_spacing_; 101
102 } 102 // Set word spacing. We will try to insert this much extra space between
103 void set_word_spacing(int word_spacing) { 103 // each word in the input (beyond whatever whitespace character separates
104 word_spacing_ = word_spacing; 104 // words). Positive values lead to increased letter spacing, negative values
105 } 105 // decrease it. 0 by default.
106 void set_ascent(int ascent) { 106 //
107 ascent_ = ascent; 107 // Must be set before Init() is called.
108 } 108 int wordSpacing() const
109 109 {
110 // You must call this after setting any options but before doing any 110 return m_wordSpacing;
111 // other calls like asking for widths or drawing. 111 }
112 void Init() { InitWithOptionalLengthProtection(true); } 112 void setWordSpacing(int wordSpacing)
113 113 {
114 // Returns the total width in pixels of the text run. 114 m_wordSpacing = wordSpacing;
115 int Width() const; 115 }
116 116
117 // Call to justify the text, with the amount of space that should be ADDED to 117 void setAscent(int ascent)
118 // get the desired width that the column should be justified to. Normally, 118 {
119 // spaces are inserted, but for Arabic there will be kashidas (extra strokes) 119 m_ascent = ascent;
120 // inserted instead. 120 }
121 // 121
122 // This function MUST be called AFTER Init(). 122 // You must call this after setting any options but before doing any
123 void Justify(int additional_space); 123 // other calls like asking for widths or drawing.
124 124 void Init()
125 // Computes the given character offset into a pixel offset of the beginning 125 {
126 // of that character. 126 InitWithOptionalLengthProtection(true);
127 int CharacterToX(int offset) const; 127 }
128 128
129 // Converts the given pixel X position into a logical character offset into 129 // Returns the total width in pixels of the text run.
130 // the run. For positions appearing before the first character, this will 130 int Width() const;
131 // return -1. 131
132 int XToCharacter(int x) const; 132 // Call to justify the text, with the amount of space that should be ADDED
133 133 // to get the desired width that the column should be justified to.
134 // Draws the given characters to (x, y) in the given DC. The font will be 134 // Normally, spaces are inserted, but for Arabic there will be kashidas
135 // handled by this function, but the font color and other attributes should 135 // (extra strokes) inserted instead.
136 // be pre-set. 136 //
137 // 137 // This function MUST be called AFTER Init().
138 // The y position is the upper left corner, NOT the baseline. 138 void Justify(int additionalSpace);
139 void Draw(HDC dc, int x, int y, int from, int to); 139
140 140 // Computes the given character offset into a pixel offset of the beginning
141 // Returns the first glyph assigned to the character at the given offset. 141 // of that character.
142 // This function is used to retrieve glyph information when Uniscribe is 142 int CharacterToX(int offset) const;
143 // being used to generate glyphs for non-complex, non-BMP (above U+FFFF) 143
144 // characters. These characters are not otherwise special and have no 144 // Converts the given pixel X position into a logical character offset into
145 // complex shaping rules, so we don't otherwise need Uniscribe, except 145 // the run. For positions appearing before the first character, this will
146 // Uniscribe is the only way to get glyphs for non-BMP characters. 146 // return -1.
147 // 147 int XToCharacter(int x) const;
148 // Returns 0 if there is no glyph for the given character. 148
149 WORD FirstGlyphForCharacter(int char_offset) const; 149 // Draws the given characters to (x, y) in the given DC. The font will be
150 150 // handled by this function, but the font color and other attributes should
151 protected: 151 // be pre-set.
152 // Backend for init. The flag allows the unit test to specify whether we 152 //
153 // should fail early for very long strings like normal, or try to pass the 153 // The y position is the upper left corner, NOT the baseline.
154 // long string to Uniscribe. The latter provides a way to force failure of 154 void Draw(HDC dc, int x, int y, int from, int to);
155 // shaping. 155
156 void InitWithOptionalLengthProtection(bool length_protection); 156 // Returns the first glyph assigned to the character at the given offset.
157 157 // This function is used to retrieve glyph information when Uniscribe is
158 // Tries to preload the font when the it is not accessible. 158 // being used to generate glyphs for non-complex, non-BMP (above U+FFFF)
159 // This is the default implementation and it does not do anything. 159 // characters. These characters are not otherwise special and have no
160 virtual void TryToPreloadFont(HFONT font) {} 160 // complex shaping rules, so we don't otherwise need Uniscribe, except
161 161 // Uniscribe is the only way to get glyphs for non-BMP characters.
162 private: 162 //
163 FRIEND_TEST(UniscribeTest, TooBig); 163 // Returns 0 if there is no glyph for the given character.
164 164 WORD FirstGlyphForCharacter(int charOffset) const;
165 // An array corresponding to each item in runs_ containing information 165
166 // on each of the glyphs that were generated. Like runs_, this is in 166 protected:
167 // reading order. However, for rtl text, the characters within each 167 // Backend for init. The flag allows the unit test to specify whether we
168 // item will be reversed. 168 // should fail early for very long strings like normal, or try to pass the
169 struct Shaping { 169 // long string to Uniscribe. The latter provides a way to force failure of
170 Shaping() 170 // shaping.
171 : pre_padding(0), 171 void InitWithOptionalLengthProtection(bool lengthProtection);
172 hfont_(NULL), 172
173 script_cache_(NULL), 173 // Tries to preload the font when the it is not accessible.
174 ascent_offset_(0) { 174 // This is the default implementation and it does not do anything.
175 abc.abcA = 0; 175 virtual void TryToPreloadFont(HFONT font) {}
176 abc.abcB = 0; 176
177 abc.abcC = 0; 177 private:
178 } 178 FRIEND_TEST(UniscribeTest, TooBig);
179 179
180 // Returns the number of glyphs (which will be drawn to the screen) 180 // An array corresponding to each item in runs_ containing information
181 // in this run. 181 // on each of the glyphs that were generated. Like runs_, this is in
182 int glyph_length() const { 182 // reading order. However, for rtl text, the characters within each
183 return static_cast<int>(glyphs->size()); 183 // item will be reversed.
184 } 184 struct Shaping {
185 185 Shaping()
186 // Returns the number of characters (that we started with) in this run. 186 : m_prePadding(0)
187 int char_length() const { 187 , m_hfont(NULL)
188 return static_cast<int>(logs->size()); 188 , m_scriptCache(NULL)
189 } 189 , m_ascentOffset(0) {
190 190 m_abc.abcA = 0;
191 // Returns the advance array that should be used when measuring glyphs. 191 m_abc.abcB = 0;
192 // The returned pointer will indicate an array with glyph_length() elements 192 m_abc.abcC = 0;
193 // and the advance that should be used for each one. This is either the 193 }
194 // real advance, or the justified advances if there is one, and is the 194
195 // array we want to use for measurement. 195 // Returns the number of glyphs (which will be drawn to the screen)
196 const int* effective_advances() const { 196 // in this run.
197 if (advance->empty()) 197 int glyphLength() const
198 return 0; 198 {
199 if (justify->empty()) 199 return static_cast<int>(m_glyphs.size());
200 return &advance[0]; 200 }
201 return &justify[0]; 201
202 } 202 // Returns the number of characters (that we started with) in this run.
203 203 int charLength() const
204 // This is the advance amount of space that we have added to the beginning 204 {
205 // of the run. It is like the ABC's |A| advance but one that we create and 205 return static_cast<int>(m_logs.size());
206 // must handle internally whenever computing with pixel offsets. 206 }
207 int pre_padding; 207
208 208 // Returns the advance array that should be used when measuring glyphs.
209 // Glyph indices in the font used to display this item. These indices 209 // The returned pointer will indicate an array with glyph_length()
210 // are in screen order. 210 // elements and the advance that should be used for each one. This is
211 StackVector<WORD, UNISCRIBE_STATE_STACK_CHARS> glyphs; 211 // either the real advance, or the justified advances if there is one,
212 212 // and is the array we want to use for measurement.
213 // For each input character, this tells us the first glyph index it 213 const int* effectiveAdvances() const
214 // generated. This is the only array with size of the input chars. 214 {
215 // 215 if (m_advance.size() == 0)
216 // All offsets are from the beginning of this run. Multiple characters can 216 return 0;
217 // generate one glyph, in which case there will be adjacent duplicates in 217 if (m_justify.size() == 0)
218 // this list. One character can also generate multiple glyphs, in which 218 return &m_advance[0];
219 // case there will be skipped indices in this list. 219 return &m_justify[0];
220 StackVector<WORD, UNISCRIBE_STATE_STACK_CHARS> logs; 220 }
221 221
222 // Flags and such for each glyph. 222 // This is the advance amount of space that we have added to the
223 StackVector<SCRIPT_VISATTR, UNISCRIBE_STATE_STACK_CHARS> visattr; 223 // beginning of the run. It is like the ABC's |A| advance but one that
224 224 // we create and must handle internally whenever computing with pixel
225 // Horizontal advances for each glyph listed above, this is basically 225 // offsets.
226 // how wide each glyph is. 226 int m_prePadding;
227 StackVector<int, UNISCRIBE_STATE_STACK_CHARS> advance; 227
228 228 // Glyph indices in the font used to display this item. These indices
229 // This contains glyph offsets, from the nominal position of a glyph. It 229 // are in screen order.
230 // is used to adjust the positions of multiple combining characters 230 Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_glyphs;
231 // around/above/below base characters in a context-sensitive manner so 231
232 // that they don't bump against each other and the base character. 232 // For each input character, this tells us the first glyph index it
233 StackVector<GOFFSET, UNISCRIBE_STATE_STACK_CHARS> offsets; 233 // generated. This is the only array with size of the input chars.
234 234 //
235 // Filled by a call to Justify, this is empty for nonjustified text. 235 // All offsets are from the beginning of this run. Multiple characters
236 // If nonempty, this contains the array of justify characters for each 236 // can generate one glyph, in which case there will be adjacent
237 // character as returned by ScriptJustify. 237 // duplicates in this list. One character can also generate multiple
238 // 238 // glyphs, in which case there will be skipped indices in this list.
239 // This is the same as the advance array, but with extra space added for 239 Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_logs;
240 // some characters. The difference between a glyph's |justify| width and 240
241 // it's |advance| width is the extra space added. 241 // Flags and such for each glyph.
242 StackVector<int, UNISCRIBE_STATE_STACK_CHARS> justify; 242 Vector<SCRIPT_VISATTR, UNISCRIBE_HELPER_STACK_CHARS> m_visattr;
243 243
244 // Sizing information for this run. This treats the entire run as a 244 // Horizontal advances for each glyph listed above, this is basically
245 // character with a preceeding advance, width, and ending advance. 245 // how wide each glyph is.
246 // The B width is the sum of the |advance| array, and the A and C widths 246 Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_advance;
247 // are any extra spacing applied to each end. 247
248 // 248 // This contains glyph offsets, from the nominal position of a glyph.
249 // It is unclear from the documentation what this actually means. From 249 // It is used to adjust the positions of multiple combining characters
250 // experimentation, it seems that the sum of the character advances is 250 // around/above/below base characters in a context-sensitive manner so
251 // always the sum of the ABC values, and I'm not sure what you're supposed 251 // that they don't bump against each other and the base character.
252 // to do with the ABC values. 252 Vector<GOFFSET, UNISCRIBE_HELPER_STACK_CHARS> m_offsets;
253 ABC abc; 253
254 254 // Filled by a call to Justify, this is empty for nonjustified text.
255 // Pointers to windows font data used to render this run. 255 // If nonempty, this contains the array of justify characters for each
256 HFONT hfont_; 256 // character as returned by ScriptJustify.
257 SCRIPT_CACHE* script_cache_; 257 //
258 258 // This is the same as the advance array, but with extra space added
259 // Ascent offset between the ascent of the primary font 259 // for some characters. The difference between a glyph's |justify|
260 // and that of the fallback font. The offset needs to be applied, 260 // width and it's |advance| width is the extra space added.
261 // when drawing a string, to align multiple runs rendered with 261 Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_justify;
262 // different fonts. 262
263 int ascent_offset_; 263 // Sizing information for this run. This treats the entire run as a
264 }; 264 // character with a preceeding advance, width, and ending advance. The
265 265 // B width is the sum of the |advance| array, and the A and C widths
266 // Computes the runs_ array from the text run. 266 // are any extra spacing applied to each end.
267 void FillRuns(); 267 //
268 268 // It is unclear from the documentation what this actually means. From
269 // Computes the shapes_ array given an runs_ array already filled in. 269 // experimentation, it seems that the sum of the character advances is
270 void FillShapes(); 270 // always the sum of the ABC values, and I'm not sure what you're
271 271 // supposed to do with the ABC values.
272 // Fills in the screen_order_ array (see below). 272 ABC m_abc;
273 void FillScreenOrder(); 273
274 274 // Pointers to windows font data used to render this run.
275 // Called to update the glyph positions based on the current spacing options 275 HFONT m_hfont;
276 // that are set. 276 SCRIPT_CACHE* m_scriptCache;
277 void ApplySpacing(); 277
278 278 // Ascent offset between the ascent of the primary font
279 // Normalizes all advances for spaces to the same width. This keeps windows 279 // and that of the fallback font. The offset needs to be applied,
280 // from making spaces after Hindi characters larger, which is then 280 // when drawing a string, to align multiple runs rendered with
281 // inconsistent with our meaure of the width since WebKit doesn't include 281 // different fonts.
282 // spaces in text-runs sent to uniscribe unless white-space:pre. 282 int m_ascentOffset;
283 void AdjustSpaceAdvances(); 283 };
284 284
285 // Returns the total width of a single item. 285 // Computes the runs_ array from the text run.
286 int AdvanceForItem(int item_index) const; 286 void FillRuns();
287 287
288 // Shapes a run (pointed to by |input|) using |hfont| first. 288 // Computes the shapes_ array given an runs_ array already filled in.
289 // Tries a series of fonts specified retrieved with NextWinFontData 289 void FillShapes();
290 // and finally a font covering characters in |*input|. A string pointed 290
291 // by |input| comes from ScriptItemize and is supposed to contain 291 // Fills in the screen_order_ array (see below).
292 // characters belonging to a single script aside from characters 292 void FillScreenOrder();
293 // common to all scripts (e.g. space). 293
294 bool Shape(const wchar_t* input, 294 // Called to update the glyph positions based on the current spacing
295 int item_length, 295 // options that are set.
296 int num_glyphs, 296 void ApplySpacing();
297 SCRIPT_ITEM& run, 297
298 Shaping& shaping); 298 // Normalizes all advances for spaces to the same width. This keeps windows
299 299 // from making spaces after Hindi characters larger, which is then
300 // Gets Windows font data for the next best font to try in the list 300 // inconsistent with our meaure of the width since WebKit doesn't include
301 // of fonts. When there's no more font available, returns false 301 // spaces in text-runs sent to uniscribe unless white-space:pre.
302 // without touching any of out params. Need to call ResetFontIndex 302 void AdjustSpaceAdvances();
303 // to start scanning of the font list from the beginning. 303
304 virtual bool NextWinFontData(HFONT* hfont, 304 // Returns the total width of a single item.
305 SCRIPT_CACHE** script_cache, 305 int AdvanceForItem(int item_index) const;
306 SCRIPT_FONTPROPERTIES** font_properties, 306
307 int* ascent) { 307 // Shapes a run (pointed to by |input|) using |hfont| first.
308 return false; 308 // Tries a series of fonts specified retrieved with NextWinFontData
309 } 309 // and finally a font covering characters in |*input|. A string pointed
310 310 // by |input| comes from ScriptItemize and is supposed to contain
311 // Resets the font index to the first in the list of fonts 311 // characters belonging to a single script aside from characters common to
312 // to try after the primaryFont turns out not to work. With font_index 312 // all scripts (e.g. space).
313 // reset, NextWinFontData scans fallback fonts from the beginning. 313 bool Shape(const UChar* input,
314 virtual void ResetFontIndex() {} 314 int item_length,
315 315 int num_glyphs,
316 // The input data for this run of Uniscribe. See the constructor. 316 SCRIPT_ITEM& run,
317 const wchar_t* input_; 317 Shaping& shaping);
318 const int input_length_; 318
319 const bool is_rtl_; 319 // Gets Windows font data for the next best font to try in the list
320 320 // of fonts. When there's no more font available, returns false
321 // Windows font data for the primary font : 321 // without touching any of out params. Need to call ResetFontIndex
322 // In a sense, logfont_ and style_ are redundant because 322 // to start scanning of the font list from the beginning.
323 // hfont_ contains all the information. However, invoking GetObject, 323 virtual bool NextWinFontData(HFONT* hfont,
324 // everytime we need the height and the style, is rather expensive so 324 SCRIPT_CACHE** script_cache,
325 // that we cache them. Would it be better to add getter and (virtual) 325 SCRIPT_FONTPROPERTIES** font_properties,
326 // setter for the height and the style of the primary font, instead of 326 int* ascent) {
327 // logfont_? Then, a derived class ctor can set ascent_, height_ and style_ 327 return false;
328 // if they're known. Getters for them would have to 'infer' their values from 328 }
329 // hfont_ ONLY when they're not set. 329
330 HFONT hfont_; 330 // Resets the font index to the first in the list of fonts to try after the
331 SCRIPT_CACHE* script_cache_; 331 // primaryFont turns out not to work. With fontIndex reset,
332 SCRIPT_FONTPROPERTIES* font_properties_; 332 // NextWinFontData scans fallback fonts from the beginning.
333 int ascent_; 333 virtual void ResetFontIndex() {}
334 LOGFONT logfont_; 334
335 int style_; 335 // The input data for this run of Uniscribe. See the constructor.
336 336 const UChar* m_input;
337 // Options, see the getters/setters above. 337 const int m_inputLength;
338 bool directional_override_; 338 const bool m_isRtl;
339 bool inhibit_ligate_; 339
340 int letter_spacing_; 340 // Windows font data for the primary font. In a sense, m_logfont and m_style
341 int space_width_; 341 // are redundant because m_hfont contains all the information. However,
342 int word_spacing_; 342 // invoking GetObject, everytime we need the height and the style, is rather
343 int justification_width_; 343 // expensive so that we cache them. Would it be better to add getter and
344 344 // (virtual) setter for the height and the style of the primary font,
345 // Uniscribe breaks the text into Runs. These are one length of text that is 345 // instead of m_logfont? Then, a derived class ctor can set m_ascent,
346 // in one script and one direction. This array is in reading order. 346 // m_height and m_style if they're known. Getters for them would have to
347 StackVector<SCRIPT_ITEM, UNISCRIBE_STATE_STACK_RUNS> runs_; 347 // 'infer' their values from m_hfont ONLY when they're not set.
348 348 HFONT m_hfont;
349 StackVector<Shaping, UNISCRIBE_STATE_STACK_RUNS> shapes_; 349 SCRIPT_CACHE* m_scriptCache;
350 350 SCRIPT_FONTPROPERTIES* m_fontProperties;
351 // This is a mapping between reading order and screen order for the items. 351 int m_ascent;
352 // Uniscribe's items array are in reading order. For right-to-left text, 352 LOGFONT m_logfont;
353 // or mixed (although WebKit's |TextRun| should really be only one 353 int m_style;
354 // direction), this makes it very difficult to compute character offsets 354
355 // and positions. This list is in screen order from left to right, and 355 // Options, see the getters/setters above.
356 // gives the index into the |runs_| and |shapes_| arrays of each 356 bool m_directionalOverride;
357 // subsequent item. 357 bool m_inhibitLigate;
358 StackVector<int, UNISCRIBE_STATE_STACK_RUNS> screen_order_; 358 int m_letterSpacing;
359 359 int m_spaceWidth;
360 DISALLOW_EVIL_CONSTRUCTORS(UniscribeState); 360 int m_wordSpacing;
361
362 // Uniscribe breaks the text into Runs. These are one length of text that is
363 // in one script and one direction. This array is in reading order.
364 Vector<SCRIPT_ITEM, UNISCRIBE_HELPER_STACK_RUNS> m_runs;
365
366 Vector<Shaping, UNISCRIBE_HELPER_STACK_RUNS> m_shapes;
367
368 // This is a mapping between reading order and screen order for the items.
369 // Uniscribe's items array are in reading order. For right-to-left text,
370 // or mixed (although WebKit's |TextRun| should really be only one
371 // direction), this makes it very difficult to compute character offsets
372 // and positions. This list is in screen order from left to right, and
373 // gives the index into the |m_runs| and |m_shapes| arrays of each
374 // subsequent item.
375 Vector<int, UNISCRIBE_HELPER_STACK_RUNS> m_screenOrder;
361 }; 376 };
362 377
363 } // namespace gfx 378 } // namespace WebCore
364 379
365 #endif // BASE_GFX_UNISCRIBE_H__ 380 #endif // UniscribeHelper_h
366
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698