1/* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 27/* 28 * 29 * (C) Copyright IBM Corp. 1998-2009 - All Rights Reserved 30 * 31 */ 32 33#ifndef __INDICLAYOUTENGINE_H 34#define __INDICLAYOUTENGINE_H 35 36#include "LETypes.h" 37#include "LEFontInstance.h" 38#include "LEGlyphFilter.h" 39#include "LayoutEngine.h" 40#include "OpenTypeLayoutEngine.h" 41 42#include "GlyphSubstitutionTables.h" 43#include "GlyphDefinitionTables.h" 44#include "GlyphPositioningTables.h" 45 46U_NAMESPACE_BEGIN 47 48class MPreFixups; 49class LEGlyphStorage; 50 51/** 52 * This class implements OpenType layout for Indic OpenType fonts, as 53 * specified by Microsoft in "Creating and Supporting OpenType Fonts for 54 * Indic Scripts" (http://www.microsoft.com/typography/otspec/indicot/default.htm) 55 * 56 * This class overrides the characterProcessing method to do Indic character processing 57 * and reordering, and the glyphProcessing method to implement post-GSUB processing for 58 * left matras. (See the MS spec. for more details) 59 * 60 * @internal 61 */ 62class IndicOpenTypeLayoutEngine : public OpenTypeLayoutEngine 63{ 64public: 65 /** 66 * This is the main constructor. It constructs an instance of IndicOpenTypeLayoutEngine for 67 * a particular font, script and language. It takes the GSUB table as a parameter since 68 * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an 69 * Indic OpenType font. 70 * 71 * @param fontInstance - the font 72 * @param scriptCode - the script 73 * @param langaugeCode - the language 74 * @param gsubTable - the GSUB table 75 * @param success - set to an error code if the operation fails 76 * 77 * @see LayoutEngine::layoutEngineFactory 78 * @see OpenTypeLayoutEngine 79 * @see ScriptAndLangaugeTags.h for script and language codes 80 * 81 * @internal 82 */ 83 IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, 84 le_int32 typoFlags, le_bool version2, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success); 85 86 /** 87 * This constructor is used when the font requires a "canned" GSUB table which can't be known 88 * until after this constructor has been invoked. 89 * 90 * @param fontInstance - the font 91 * @param scriptCode - the script 92 * @param langaugeCode - the language 93 * @param success - set to an error code if the operation fails 94 * 95 * @see OpenTypeLayoutEngine 96 * @see ScriptAndLangaugeTags.h for script and language codes 97 * 98 * @internal 99 */ 100 IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, 101 le_int32 typoFlags, LEErrorCode &success); 102 103 /** 104 * The destructor, virtual for correct polymorphic invocation. 105 * 106 * @internal 107 */ 108 virtual ~IndicOpenTypeLayoutEngine(); 109 110 /** 111 * ICU "poor man's RTTI", returns a UClassID for the actual class. 112 * 113 * @stable ICU 2.8 114 */ 115 virtual UClassID getDynamicClassID() const; 116 117 /** 118 * ICU "poor man's RTTI", returns a UClassID for this class. 119 * 120 * @stable ICU 2.8 121 */ 122 static UClassID getStaticClassID(); 123 124protected: 125 126 /** 127 * This method does Indic OpenType character processing. It assigns the OpenType feature 128 * tags to the characters, and may generate output characters which have been reordered. For 129 * some Indic scripts, it may also split some vowels, resulting in more output characters 130 * than input characters. 131 * 132 * Input parameters: 133 * @param chars - the input character context 134 * @param offset - the index of the first character to process 135 * @param count - the number of characters to process 136 * @param max - the number of characters in the input context 137 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run 138 * @param glyphStorage - the glyph storage object. The glyph and character index arrays will be set. 139 * the auxillary data array will be set to the feature tags. 140 * 141 * Output parameters: 142 * @param success - set to an error code if the operation fails 143 * 144 * @return the output character count 145 * 146 * @internal 147 */ 148 virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, 149 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success); 150 151 /** 152 * This method does character to glyph mapping, applies the GSUB table and applies 153 * any post GSUB fixups for left matras. It calls OpenTypeLayoutEngine::glyphProcessing 154 * to do the character to glyph mapping, and apply the GSUB table. 155 * 156 * Note that in the case of "canned" GSUB tables, the output glyph indices may be 157 * "fake" glyph indices that need to be converted to "real" glyph indices by the 158 * glyphPostProcessing method. 159 * 160 * Input parameters: 161 * @param chars - the input character context 162 * @param offset - the index of the first character to process 163 * @param count - the number of characters to process 164 * @param max - the number of characters in the input context 165 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run 166 * @param featureTags - the feature tag array 167 * @param glyphStorage - the glyph storage object. The glyph and char index arrays will be set. 168 * 169 * Output parameters: 170 * @param success - set to an error code if the operation fails 171 * 172 * @return the number of glyphs in the output glyph index array 173 * 174 * Note: if the character index array was already set by the characterProcessing 175 * method, this method won't change it. 176 * 177 * @internal 178 */ 179 virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, 180 LEGlyphStorage &glyphStorage, LEErrorCode &success); 181 182 le_bool fVersion2; 183 184private: 185 186 MPreFixups *fMPreFixups; 187 188}; 189 190U_NAMESPACE_END 191#endif 192 193