J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 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. Sun designates this |
| 7 | * particular file as subject to the "Classpath" exception as provided |
| 8 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 21 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 22 | * have any questions. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | /* |
| 28 | * |
| 29 | * (C) Copyright IBM Corp. 1998-2005 - 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 | |
| 46 | class MPreFixups; |
| 47 | class LEGlyphStorage; |
| 48 | |
| 49 | /** |
| 50 | * This class implements OpenType layout for Indic OpenType fonts, as |
| 51 | * specified by Microsoft in "Creating and Supporting OpenType Fonts for |
| 52 | * Indic Scripts" (http://www.microsoft.com/typography/otspec/indicot/default.htm) |
| 53 | * |
| 54 | * This class overrides the characterProcessing method to do Indic character processing |
| 55 | * and reordering, and the glyphProcessing method to implement post-GSUB processing for |
| 56 | * left matras. (See the MS spec. for more details) |
| 57 | * |
| 58 | * @internal |
| 59 | */ |
| 60 | class IndicOpenTypeLayoutEngine : public OpenTypeLayoutEngine |
| 61 | { |
| 62 | public: |
| 63 | /** |
| 64 | * This is the main constructor. It constructs an instance of IndicOpenTypeLayoutEngine for |
| 65 | * a particular font, script and language. It takes the GSUB table as a parameter since |
| 66 | * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an |
| 67 | * Indic OpenType font. |
| 68 | * |
| 69 | * @param fontInstance - the font |
| 70 | * @param scriptCode - the script |
| 71 | * @param langaugeCode - the language |
| 72 | * @param gsubTable - the GSUB table |
| 73 | * |
| 74 | * @see LayoutEngine::layoutEngineFactory |
| 75 | * @see OpenTypeLayoutEngine |
| 76 | * @see ScriptAndLangaugeTags.h for script and language codes |
| 77 | * |
| 78 | * @internal |
| 79 | */ |
| 80 | IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, |
| 81 | le_int32 scriptCode, le_int32 languageCode, |
| 82 | le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable); |
| 83 | |
| 84 | /** |
| 85 | * This constructor is used when the font requires a "canned" GSUB table which can't be known |
| 86 | * until after this constructor has been invoked. |
| 87 | * |
| 88 | * @param fontInstance - the font |
| 89 | * @param scriptCode - the script |
| 90 | * @param langaugeCode - the language |
| 91 | * |
| 92 | * @see OpenTypeLayoutEngine |
| 93 | * @see ScriptAndLangaugeTags.h for script and language codes |
| 94 | * |
| 95 | * @internal |
| 96 | */ |
| 97 | IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, |
| 98 | le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags); |
| 99 | |
| 100 | /** |
| 101 | * The destructor, virtual for correct polymorphic invocation. |
| 102 | * |
| 103 | * @internal |
| 104 | */ |
| 105 | virtual ~IndicOpenTypeLayoutEngine(); |
| 106 | |
| 107 | protected: |
| 108 | |
| 109 | /** |
| 110 | * This method does Indic OpenType character processing. It assigns the OpenType feature |
| 111 | * tags to the characters, and may generate output characters which have been reordered. For |
| 112 | * some Indic scripts, it may also split some vowels, resulting in more output characters |
| 113 | * than input characters. |
| 114 | * |
| 115 | * Input parameters: |
| 116 | * @param chars - the input character context |
| 117 | * @param offset - the index of the first character to process |
| 118 | * @param count - the number of characters to process |
| 119 | * @param max - the number of characters in the input context |
| 120 | * @param rightToLeft - <code>TRUE</code> if the characters are in a |
| 121 | * right to left directional run |
| 122 | * @param glyphStorage - the glyph storage object. The glyph and character |
| 123 | * index arrays will be set. The auxillary data array will be set to the feature tags. |
| 124 | * |
| 125 | * Output parameters: |
| 126 | * @param success - set to an error code if the operation fails |
| 127 | * |
| 128 | * @return the output character count |
| 129 | * |
| 130 | * @internal |
| 131 | */ |
| 132 | virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, |
| 133 | le_int32 count, le_int32 max, le_bool rightToLeft, |
| 134 | LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success); |
| 135 | |
| 136 | /** |
| 137 | * This method does character to glyph mapping, applies the GSUB table and applies |
| 138 | * any post GSUB fixups for left matras. It calls OpenTypeLayoutEngine::glyphProcessing |
| 139 | * to do the character to glyph mapping, and apply the GSUB table. |
| 140 | * |
| 141 | * Note that in the case of "canned" GSUB tables, the output glyph indices may be |
| 142 | * "fake" glyph indices that need to be converted to "real" glyph indices by the |
| 143 | * glyphPostProcessing method. |
| 144 | * |
| 145 | * Input parameters: |
| 146 | * @param chars - the input character context |
| 147 | * @param offset - the index of the first character to process |
| 148 | * @param count - the number of characters to process |
| 149 | * @param max - the number of characters in the input context |
| 150 | * @param rightToLeft - <code>TRUE</code> if the characters are in a |
| 151 | * right to left directional run |
| 152 | * @param featureTags - the feature tag array |
| 153 | * @param glyphStorage - the glyph storage object. The glyph and char |
| 154 | * index arrays will be set. |
| 155 | * |
| 156 | * Output parameters: |
| 157 | * @param success - set to an error code if the operation fails |
| 158 | * |
| 159 | * @return the number of glyphs in the output glyph index array |
| 160 | * |
| 161 | * Note: if the character index array was already set by the characterProcessing |
| 162 | * method, this method won't change it. |
| 163 | * |
| 164 | * @internal |
| 165 | */ |
| 166 | virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset, |
| 167 | le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, |
| 168 | LEErrorCode &success); |
| 169 | |
| 170 | private: |
| 171 | MPreFixups *fMPreFixups; |
| 172 | }; |
| 173 | |
| 174 | #endif |