UniscribeHelper.h revision 635860845790a19bf50bbc51ba8fb66a96dde068
19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved. 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Redistribution and use in source and binary forms, with or without 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * modification, are permitted provided that the following conditions are 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * met: 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * * Redistributions of source code must retain the above copyright 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * notice, this list of conditions and the following disclaimer. 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * * Redistributions in binary form must reproduce the above 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * copyright notice, this list of conditions and the following disclaimer 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * in the documentation and/or other materials provided with the 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distribution. 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * * Neither the name of Google Inc. nor the names of its 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * contributors may be used to endorse or promote products derived from 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * this software without specific prior written permission. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// A wrapper around Uniscribe that provides a reasonable API. 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#ifndef UniscribeHelper_h 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#define UniscribeHelper_h 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include <windows.h> 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include <usp10.h> 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include <map> 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include <unicode/uchar.h> 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include <wtf/Vector.h> 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonclass UniscribeTest_TooBig_Test; // A gunit test for UniscribeHelper. 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonnamespace WebCore { 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#define UNISCRIBE_HELPER_STACK_RUNS 8 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#define UNISCRIBE_HELPER_STACK_CHARS 32 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// This object should be safe to create & destroy frequently, as long as the 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// caller preserves the script_cache when possible (this data may be slow to 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// compute). 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// This object is "kind of large" (~1K) because it reserves a lot of space for 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// working with to avoid expensive heap operations. Therefore, not only should 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// you not worry about creating and destroying it, you should try to not keep 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// them around. 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonclass UniscribeHelper { 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic: 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Initializes this Uniscribe run with the text pointed to by |run| with 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // |length|. The input is NOT null terminated. 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // The is_rtl flag should be set if the input script is RTL. It is assumed 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // that the caller has already divided up the input text (using ICU, for 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // example) into runs of the same direction of script. This avoids 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // disagreements between the caller and Uniscribe later (see FillItems). 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // A script cache should be provided by the caller that is initialized to 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // NULL. When the caller is done with the cache (it may be stored between 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // runs as long as it is used consistently with the same HFONT), it should 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // call ScriptFreeCache(). 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson UniscribeHelper(const UChar* input, 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int inputLength, 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool isRtl, 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson HFONT, 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson SCRIPT_CACHE*, 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson SCRIPT_FONTPROPERTIES*); 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson virtual ~UniscribeHelper(); 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Sets Uniscribe's directional override flag. False by default. 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool directionalOverride() const 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_directionalOverride; 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setDirectionalOverride(bool override) 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_directionalOverride = override; 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Set's Uniscribe's no-ligate override flag. False by default. 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool inhibitLigate() const 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_inhibitLigate; 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setInhibitLigate(bool inhibit) 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_inhibitLigate = inhibit; 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Set letter spacing. We will try to insert this much space between 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // graphemes (one or more glyphs perceived as a single unit by ordinary 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // users of a script). Positive values increase letter spacing, negative 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // values decrease it. 0 by default. 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int letterSpacing() const 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_letterSpacing; 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setLetterSpacing(int letterSpacing) 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_letterSpacing = letterSpacing; 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Set the width of a standard space character. We use this to normalize 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // space widths. Windows will make spaces after Hindi characters larger than 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // other spaces. A space_width of 0 means to use the default space width. 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Must be set before Init() is called. 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int spaceWidth() const 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_spaceWidth; 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setSpaceWidth(int spaceWidth) 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_spaceWidth = spaceWidth; 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Set word spacing. We will try to insert this much extra space between 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // each word in the input (beyond whatever whitespace character separates 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // words). Positive values lead to increased letter spacing, negative values 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // decrease it. 0 by default. 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Must be set before Init() is called. 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int wordSpacing() const 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_wordSpacing; 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setWordSpacing(int wordSpacing) 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_wordSpacing = wordSpacing; 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setAscent(int ascent) 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_ascent = ascent; 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // You must call this after setting any options but before doing any 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // other calls like asking for widths or drawing. 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void init() 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson initWithOptionalLengthProtection(true); 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the total width in pixels of the text run. 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int width() const; 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Call to justify the text, with the amount of space that should be ADDED 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // to get the desired width that the column should be justified to. 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Normally, spaces are inserted, but for Arabic there will be kashidas 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // (extra strokes) inserted instead. 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This function MUST be called AFTER Init(). 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void justify(int additionalSpace); 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Computes the given character offset into a pixel offset of the beginning 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // of that character. 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int characterToX(int offset) const; 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Converts the given pixel X position into a logical character offset into 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // the run. For positions appearing before the first character, this will 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // return -1. 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int xToCharacter(int x) const; 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Draws the given characters to (x, y) in the given DC. The font will be 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // handled by this function, but the font color and other attributes should 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // be pre-set. 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // The y position is the upper left corner, NOT the baseline. 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void draw(HDC, int x, int y, int from, int to); 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the first glyph assigned to the character at the given offset. 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This function is used to retrieve glyph information when Uniscribe is 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // being used to generate glyphs for non-complex, non-BMP (above U+FFFF) 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // characters. These characters are not otherwise special and have no 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // complex shaping rules, so we don't otherwise need Uniscribe, except 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Uniscribe is the only way to get glyphs for non-BMP characters. 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns 0 if there is no glyph for the given character. 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson WORD firstGlyphForCharacter(int charOffset) const; 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonprotected: 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Backend for init. The flag allows the unit test to specify whether we 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // should fail early for very long strings like normal, or try to pass the 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // long string to Uniscribe. The latter provides a way to force failure of 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // shaping. 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void initWithOptionalLengthProtection(bool lengthProtection); 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Tries to preload the font when the it is not accessible. 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This is the default implementation and it does not do anything. 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson virtual void tryToPreloadFont(HFONT) {} 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonprivate: 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson friend class UniscribeTest_TooBig_Test; 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // An array corresponding to each item in runs_ containing information 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // on each of the glyphs that were generated. Like runs_, this is in 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // reading order. However, for rtl text, the characters within each 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // item will be reversed. 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson struct Shaping { 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Shaping() 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson : m_prePadding(0) 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson , m_hfont(NULL) 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson , m_scriptCache(NULL) 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson , m_ascentOffset(0) { 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_abc.abcA = 0; 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_abc.abcB = 0; 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_abc.abcC = 0; 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the number of glyphs (which will be drawn to the screen) 2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // in this run. 2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int glyphLength() const 2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return static_cast<int>(m_glyphs.size()); 2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the number of characters (that we started with) in this run. 2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int charLength() const 2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return static_cast<int>(m_logs.size()); 2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the advance array that should be used when measuring glyphs. 2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // The returned pointer will indicate an array with glyph_length() 2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // elements and the advance that should be used for each one. This is 2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // either the real advance, or the justified advances if there is one, 2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // and is the array we want to use for measurement. 2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const int* effectiveAdvances() const 2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (m_advance.size() == 0) 2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return 0; 2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (m_justify.size() == 0) 2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return &m_advance[0]; 2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return &m_justify[0]; 2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This is the advance amount of space that we have added to the 2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // beginning of the run. It is like the ABC's |A| advance but one that 2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // we create and must handle internally whenever computing with pixel 2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // offsets. 2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_prePadding; 2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Glyph indices in the font used to display this item. These indices 2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // are in screen order. 2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_glyphs; 2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // For each input character, this tells us the first glyph index it 2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // generated. This is the only array with size of the input chars. 2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // All offsets are from the beginning of this run. Multiple characters 2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // can generate one glyph, in which case there will be adjacent 2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // duplicates in this list. One character can also generate multiple 2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // glyphs, in which case there will be skipped indices in this list. 2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_logs; 2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Flags and such for each glyph. 2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<SCRIPT_VISATTR, UNISCRIBE_HELPER_STACK_CHARS> m_visualAttributes; 2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Horizontal advances for each glyph listed above, this is basically 2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // how wide each glyph is. 2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_advance; 2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This contains glyph offsets, from the nominal position of a glyph. 2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // It is used to adjust the positions of multiple combining characters 2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // around/above/below base characters in a context-sensitive manner so 2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // that they don't bump against each other and the base character. 2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<GOFFSET, UNISCRIBE_HELPER_STACK_CHARS> m_offsets; 2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Filled by a call to Justify, this is empty for nonjustified text. 2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If nonempty, this contains the array of justify characters for each 2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // character as returned by ScriptJustify. 2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This is the same as the advance array, but with extra space added 2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // for some characters. The difference between a glyph's |justify| 2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // width and it's |advance| width is the extra space added. 2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_justify; 2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Sizing information for this run. This treats the entire run as a 2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // character with a preceeding advance, width, and ending advance. The 2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // B width is the sum of the |advance| array, and the A and C widths 2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // are any extra spacing applied to each end. 2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // It is unclear from the documentation what this actually means. From 2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // experimentation, it seems that the sum of the character advances is 2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // always the sum of the ABC values, and I'm not sure what you're 2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // supposed to do with the ABC values. 2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ABC m_abc; 2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Pointers to windows font data used to render this run. 3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson HFONT m_hfont; 3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson SCRIPT_CACHE* m_scriptCache; 3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Ascent offset between the ascent of the primary font 3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // and that of the fallback font. The offset needs to be applied, 3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // when drawing a string, to align multiple runs rendered with 3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // different fonts. 3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_ascentOffset; 3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson }; 3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Computes the runs_ array from the text run. 3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void fillRuns(); 3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Computes the shapes_ array given an runs_ array already filled in. 3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void fillShapes(); 3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Fills in the screen_order_ array (see below). 3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void fillScreenOrder(); 3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Called to update the glyph positions based on the current spacing 3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // options that are set. 3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void applySpacing(); 3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Normalizes all advances for spaces to the same width. This keeps windows 3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // from making spaces after Hindi characters larger, which is then 3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // inconsistent with our meaure of the width since WebKit doesn't include 3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // spaces in text-runs sent to uniscribe unless white-space:pre. 3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void adjustSpaceAdvances(); 3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Returns the total width of a single item. 3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int advanceForItem(int) const; 3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Shapes a run (pointed to by |input|) using |hfont| first. 3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Tries a series of fonts specified retrieved with NextWinFontData 3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // and finally a font covering characters in |*input|. A string pointed 3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // by |input| comes from ScriptItemize and is supposed to contain 3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // characters belonging to a single script aside from characters common to 3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // all scripts (e.g. space). 3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool shape(const UChar* input, int itemLength, int numGlyphs, SCRIPT_ITEM& run, Shaping&); 3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Gets Windows font data for the next best font to try in the list 3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // of fonts. When there's no more font available, returns false 3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // without touching any of out params. Need to call ResetFontIndex 3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // to start scanning of the font list from the beginning. 3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson virtual bool nextWinFontData(HFONT*, SCRIPT_CACHE**, SCRIPT_FONTPROPERTIES**, int* ascent) 3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return false; 3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Resets the font index to the first in the list of fonts to try after the 3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // primaryFont turns out not to work. With fontIndex reset, 3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // NextWinFontData scans fallback fonts from the beginning. 3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson virtual void resetFontIndex() {} 3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // The input data for this run of Uniscribe. See the constructor. 3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const UChar* m_input; 3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const int m_inputLength; 3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const bool m_isRtl; 3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Windows font data for the primary font. In a sense, m_logfont and m_style 3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // are redundant because m_hfont contains all the information. However, 3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // invoking GetObject, everytime we need the height and the style, is rather 3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // expensive so that we cache them. Would it be better to add getter and 3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // (virtual) setter for the height and the style of the primary font, 3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // instead of m_logfont? Then, a derived class ctor can set m_ascent, 3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // m_height and m_style if they're known. Getters for them would have to 3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 'infer' their values from m_hfont ONLY when they're not set. 3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson HFONT m_hfont; 3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson SCRIPT_CACHE* m_scriptCache; 3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson SCRIPT_FONTPROPERTIES* m_fontProperties; 3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_ascent; 3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson LOGFONT m_logfont; 3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_style; 3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Options, see the getters/setters above. 3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool m_directionalOverride; 3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson bool m_inhibitLigate; 3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_letterSpacing; 3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_spaceWidth; 3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_wordSpacing; 3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Uniscribe breaks the text into Runs. These are one length of text that is 3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // in one script and one direction. This array is in reading order. 3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<SCRIPT_ITEM, UNISCRIBE_HELPER_STACK_RUNS> m_runs; 3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<Shaping, UNISCRIBE_HELPER_STACK_RUNS> m_shapes; 3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // This is a mapping between reading order and screen order for the items. 3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Uniscribe's items array are in reading order. For right-to-left text, 3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // or mixed (although WebKit's |TextRun| should really be only one 3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // direction), this makes it very difficult to compute character offsets 3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // and positions. This list is in screen order from left to right, and 3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // gives the index into the |m_runs| and |m_shapes| arrays of each 3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // subsequent item. 3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector<int, UNISCRIBE_HELPER_STACK_RUNS> m_screenOrder; 3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}; 3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} // namespace WebCore 3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#endif // UniscribeHelper_h 4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson