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 | * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved |
| 29 | * |
| 30 | */ |
| 31 | |
| 32 | #ifndef __GXLAYOUTENGINE_H |
| 33 | #define __GXLAYOUTENGINE_H |
| 34 | |
| 35 | #include "LETypes.h" |
| 36 | #include "LayoutEngine.h" |
| 37 | |
| 38 | #include "MorphTables.h" |
| 39 | |
| 40 | class LEFontInstance; |
| 41 | class LEGlyphStorage; |
| 42 | |
| 43 | /** |
| 44 | * This class implements layout for QuickDraw GX or Apple Advanced Typograyph (AAT) |
| 45 | * fonts. A font is a GX or AAT font if it contains a 'mort' table. See Apple's |
| 46 | * TrueType Reference Manual (http://fonts.apple.com/TTRefMan/index.html) for details. |
| 47 | * Information about 'mort' tables is in the chapter titled "Font Files." |
| 48 | * |
| 49 | * @internal |
| 50 | */ |
| 51 | class GXLayoutEngine : public LayoutEngine |
| 52 | { |
| 53 | public: |
| 54 | /** |
| 55 | * This is the main constructor. It constructs an instance of GXLayoutEngine for |
| 56 | * a particular font, script and language. It takes the 'mort' table as a parameter since |
| 57 | * LayoutEngine::layoutEngineFactory has to read the 'mort' table to know that it has a |
| 58 | * GX font. |
| 59 | * |
| 60 | * Note: GX and AAT fonts don't contain any script and language specific tables, so |
| 61 | * the script and language are ignored. |
| 62 | * |
| 63 | * @param fontInstance - the font |
| 64 | * @param scriptCode - the script |
| 65 | * @param langaugeCode - the language |
| 66 | * @param morphTable - the 'mort' table |
| 67 | * |
| 68 | * @see LayoutEngine::layoutEngineFactory |
| 69 | * @see ScriptAndLangaugeTags.h for script and language codes |
| 70 | * |
| 71 | * @internal |
| 72 | */ |
| 73 | GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, |
| 74 | le_int32 languageCode, const MorphTableHeader *morphTable); |
| 75 | |
| 76 | /** |
| 77 | * The destructor, virtual for correct polymorphic invocation. |
| 78 | * |
| 79 | * @internal |
| 80 | */ |
| 81 | virtual ~GXLayoutEngine(); |
| 82 | |
| 83 | protected: |
| 84 | |
| 85 | /** |
| 86 | * The address of the 'mort' table |
| 87 | * |
| 88 | * @internal |
| 89 | */ |
| 90 | const MorphTableHeader *fMorphTable; |
| 91 | |
| 92 | /** |
| 93 | * This method does GX layout using the font's 'mort' table. It converts the |
| 94 | * input character codes to glyph indices using mapCharsToGlyphs, and then |
| 95 | * applies the 'mort' table. |
| 96 | * |
| 97 | * Input parameters: |
| 98 | * @param chars - the input character context |
| 99 | * @param offset - the index of the first character to process |
| 100 | * @param count - the number of characters to process |
| 101 | * @param max - the number of characters in the input context |
| 102 | * @param rightToLeft - <code>TRUE</code> if the text is in a |
| 103 | * right to left directional run |
| 104 | * @param glyphStorage - the glyph storage object. The glyph |
| 105 | * and char index arrays will be set. |
| 106 | * |
| 107 | * Output parameters: |
| 108 | * @param success - set to an error code if the operation fails |
| 109 | * |
| 110 | * @return the number of glyphs in the glyph index array |
| 111 | * |
| 112 | * @internal |
| 113 | */ |
| 114 | virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, |
| 115 | le_int32 count, le_int32 max, le_bool rightToLeft, |
| 116 | LEGlyphStorage &glyphStorage, LEErrorCode &success); |
| 117 | |
| 118 | /** |
| 119 | * This method adjusts the glyph positions using the font's |
| 120 | * 'kern', 'trak', 'bsln', 'opbd' and 'just' tables. |
| 121 | * |
| 122 | * Input parameters: |
| 123 | * @param glyphStorage - the object holding the glyph storage. |
| 124 | * The positions will be updated as needed. |
| 125 | * |
| 126 | * Output parameters: |
| 127 | * @param success - set to an error code if the operation fails |
| 128 | * |
| 129 | * @internal |
| 130 | */ |
| 131 | virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, |
| 132 | le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success); |
| 133 | }; |
| 134 | |
| 135 | #endif |