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 __THAILAYOUTENGINE_H |
| 34 | #define __THAILAYOUTENGINE_H |
| 35 | |
| 36 | #include "LETypes.h" |
| 37 | #include "LEFontInstance.h" |
| 38 | #include "LayoutEngine.h" |
| 39 | |
| 40 | #include "ThaiShaping.h" |
| 41 | |
| 42 | class LEGlyphStorage; |
| 43 | |
| 44 | /** |
| 45 | * This class implements layout for the Thai script, using the ThaiShapingClass. |
| 46 | * All existing Thai fonts use an encoding which assigns character codes to all |
| 47 | * the variant forms needed to display accents and tone marks correctly in context. |
| 48 | * This class can deal with fonts using the Microsoft, Macintosh, and WorldType encodings. |
| 49 | * |
| 50 | * @internal |
| 51 | */ |
| 52 | class ThaiLayoutEngine : public LayoutEngine |
| 53 | { |
| 54 | public: |
| 55 | /** |
| 56 | * This constructs an instance of ThaiLayoutEngine for the given font, script and |
| 57 | * language. It examines the font, using LEFontInstance::canDisplay, to set fGlyphSet |
| 58 | * and fErrorChar. (see below) |
| 59 | * |
| 60 | * @param fontInstance - the font |
| 61 | * @param scriptCode - the script |
| 62 | * @param languageCode - the language |
| 63 | * |
| 64 | * @see LEFontInstance |
| 65 | * @see ScriptAndLanguageTags.h for script and language codes |
| 66 | * |
| 67 | * @internal |
| 68 | */ |
| 69 | ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, |
| 70 | le_int32 languageCode, le_int32 typoFlags); |
| 71 | |
| 72 | /** |
| 73 | * The destructor, virtual for correct polymorphic invocation. |
| 74 | * |
| 75 | * @internal |
| 76 | */ |
| 77 | virtual ~ThaiLayoutEngine(); |
| 78 | |
| 79 | protected: |
| 80 | /** |
| 81 | * A small integer indicating which Thai encoding |
| 82 | * the font uses. |
| 83 | * |
| 84 | * @see ThaiShaping |
| 85 | * |
| 86 | * @internal |
| 87 | */ |
| 88 | le_uint8 fGlyphSet; |
| 89 | |
| 90 | /** |
| 91 | * The character used as a base for vowels and |
| 92 | * tone marks that are out of sequence. Usually |
| 93 | * this will be Unicode 0x25CC, if the font can |
| 94 | * display it. |
| 95 | * |
| 96 | * @see ThaiShaping |
| 97 | * |
| 98 | * @internal |
| 99 | */ |
| 100 | LEUnicode fErrorChar; |
| 101 | |
| 102 | /** |
| 103 | * This method performs Thai layout. It calls ThaiShaping::compose to |
| 104 | * generate the correct contextual character codes, and then calls |
| 105 | * mapCharsToGlyphs to generate the glyph indices. |
| 106 | * |
| 107 | * Input parameters: |
| 108 | * @param chars - the input character context |
| 109 | * @param offset - the index of the first character to process |
| 110 | * @param count - the number of characters to process |
| 111 | * @param max - the number of characters in the input context |
| 112 | * @param rightToLeft - <code>TRUE</code> if the text is in a |
| 113 | * right to left directional run |
| 114 | * @param glyphStorage - the glyph storage object. The glyph and |
| 115 | * char index arrays will be set. |
| 116 | * |
| 117 | * Output parameters: |
| 118 | * @param success - set to an error code if the operation fails |
| 119 | * |
| 120 | * @return the number of glyphs in the glyph index array |
| 121 | * |
| 122 | * @see ThaiShaping |
| 123 | * |
| 124 | * @internal |
| 125 | */ |
| 126 | virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, |
| 127 | le_int32 count, le_int32 max, le_bool rightToLeft, |
| 128 | LEGlyphStorage &glyphStorage, LEErrorCode &success); |
| 129 | |
| 130 | }; |
| 131 | |
| 132 | #endif |