2
|
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 __ARABICLAYOUTENGINE_H
|
|
34 |
#define __ARABICLAYOUTENGINE_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 |
/**
|
|
47 |
* This class implements OpenType layout for Arabic fonts. It overrides
|
|
48 |
* the characerProcessing method to assign the correct OpenType feature
|
|
49 |
* tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions
|
|
50 |
* method to guarantee that all vowel and accent glyphs have zero advance width.
|
|
51 |
*
|
|
52 |
* @internal
|
|
53 |
*/
|
|
54 |
class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
|
|
55 |
{
|
|
56 |
public:
|
|
57 |
/**
|
|
58 |
* This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for
|
|
59 |
* a particular font, script and language. It takes the GSUB table as a parameter since
|
|
60 |
* LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
|
|
61 |
* Indic OpenType font.
|
|
62 |
*
|
|
63 |
* @param fontInstance - the font
|
|
64 |
* @param scriptCode - the script
|
|
65 |
* @param langaugeCode - the language
|
|
66 |
* @param gsubTable - the GSUB table
|
|
67 |
*
|
|
68 |
* @see LayoutEngine::layoutEngineFactory
|
|
69 |
* @see OpenTypeLayoutEngine
|
|
70 |
* @see ScriptAndLanguageTags.h for script and language codes
|
|
71 |
*
|
|
72 |
* @internal
|
|
73 |
*/
|
|
74 |
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
|
|
75 |
le_int32 languageCode, le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
|
|
76 |
|
|
77 |
/**
|
|
78 |
* This constructor is used when the font requires a "canned" GSUB table which can't be known
|
|
79 |
* until after this constructor has been invoked.
|
|
80 |
*
|
|
81 |
* @param fontInstance - the font
|
|
82 |
* @param scriptCode - the script
|
|
83 |
* @param langaugeCode - the language
|
|
84 |
*
|
|
85 |
* @see OpenTypeLayoutEngine
|
|
86 |
* @see ScriptAndLanguageTags.h for script and language codes
|
|
87 |
*
|
|
88 |
* @internal
|
|
89 |
*/
|
|
90 |
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
|
|
91 |
le_int32 languageCode, le_int32 typoFlags);
|
|
92 |
|
|
93 |
/**
|
|
94 |
* The destructor, virtual for correct polymorphic invocation.
|
|
95 |
*
|
|
96 |
* @internal
|
|
97 |
*/
|
|
98 |
virtual ~ArabicOpenTypeLayoutEngine();
|
|
99 |
|
|
100 |
protected:
|
|
101 |
|
|
102 |
/**
|
|
103 |
* This method does Arabic OpenType character processing. It assigns the OpenType feature
|
|
104 |
* tags to the characters to generate the correct contextual forms and ligatures.
|
|
105 |
*
|
|
106 |
* Input parameters:
|
|
107 |
* @param chars - the input character context
|
|
108 |
* @param offset - the index of the first character to process
|
|
109 |
* @param count - the number of characters to process
|
|
110 |
* @param max - the number of characters in the input context
|
|
111 |
* @param rightToLeft - <code>TRUE</code> if the characters are in a
|
|
112 |
* right to left directional run
|
|
113 |
*
|
|
114 |
* Output parameters:
|
|
115 |
* @param outChars - the output character arrayt
|
|
116 |
* @param charIndices - the output character index array
|
|
117 |
* @param featureTags - the output feature tag array
|
|
118 |
* @param success - set to an error code if the operation fails
|
|
119 |
*
|
|
120 |
* @return the output character count
|
|
121 |
*
|
|
122 |
* @internal
|
|
123 |
*/
|
|
124 |
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
|
|
125 |
le_int32 count, le_int32 max, le_bool rightToLeft,
|
|
126 |
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
127 |
|
|
128 |
/**
|
|
129 |
* This method applies the GPOS table if it is present, otherwise it ensures that all vowel
|
|
130 |
* and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
|
|
131 |
* If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
|
|
132 |
* the character codes are used.
|
|
133 |
*
|
|
134 |
* @param chars - the input character context
|
|
135 |
* @param offset - the offset of the first character to process
|
|
136 |
* @param count - the number of characters to process
|
|
137 |
* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
|
|
138 |
* @param glyphs - the input glyph array
|
|
139 |
* @param glyphCount - the number of glyphs
|
|
140 |
* @param positions - the position array, will be updated as needed
|
|
141 |
* @param success - output parameter set to an error code if the operation fails
|
|
142 |
*
|
|
143 |
* @internal
|
|
144 |
*/
|
|
145 |
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
|
|
146 |
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
147 |
|
|
148 |
// static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
|
|
149 |
// le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
150 |
|
|
151 |
};
|
|
152 |
|
|
153 |
/**
|
|
154 |
* The class implements OpenType layout for Arabic fonts which don't
|
|
155 |
* contain a GSUB table, using a canned GSUB table based on Unicode
|
|
156 |
* Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
|
|
157 |
* to use the Presentation Forms as logical glyph indices. It overrides the
|
|
158 |
* glyphPostProcessing method to convert the Presentation Forms to actual
|
|
159 |
* glyph indices.
|
|
160 |
*
|
|
161 |
* @see ArabicOpenTypeLayoutEngine
|
|
162 |
*
|
|
163 |
* @internal
|
|
164 |
*/
|
|
165 |
class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
|
|
166 |
{
|
|
167 |
public:
|
|
168 |
/**
|
|
169 |
* This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
|
|
170 |
* script and language.
|
|
171 |
*
|
|
172 |
* @param fontInstance - the font
|
|
173 |
* @param scriptCode - the script
|
|
174 |
* @param languageCode - the language
|
|
175 |
*
|
|
176 |
* @see LEFontInstance
|
|
177 |
* @see ScriptAndLanguageTags.h for script and language codes
|
|
178 |
*
|
|
179 |
* @internal
|
|
180 |
*/
|
|
181 |
UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
|
|
182 |
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
|
|
183 |
|
|
184 |
/**
|
|
185 |
* The destructor, virtual for correct polymorphic invocation.
|
|
186 |
*
|
|
187 |
* @internal
|
|
188 |
*/
|
|
189 |
virtual ~UnicodeArabicOpenTypeLayoutEngine();
|
|
190 |
|
|
191 |
protected:
|
|
192 |
|
|
193 |
/**
|
|
194 |
* This method converts the Arabic Presentation Forms in the temp glyph array
|
|
195 |
* into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
|
|
196 |
*
|
|
197 |
* Input paramters:
|
|
198 |
* @param tempGlyphs - the input presentation forms
|
|
199 |
* @param tempCharIndices - the input character index array
|
|
200 |
* @param tempGlyphCount - the number of Presentation Froms
|
|
201 |
*
|
|
202 |
* Output parameters:
|
|
203 |
* @param glyphs - the output glyph index array
|
|
204 |
* @param charIndices - the output character index array
|
|
205 |
* @param success - set to an error code if the operation fails
|
|
206 |
*
|
|
207 |
* @return the number of glyph indices in the output glyph index array
|
|
208 |
*
|
|
209 |
* @internal
|
|
210 |
*/
|
|
211 |
virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage,
|
|
212 |
LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
213 |
|
|
214 |
/**
|
|
215 |
* This method copies the input characters into the output glyph index array,
|
|
216 |
* for use by the canned GSUB table. It also generates the character index array.
|
|
217 |
*
|
|
218 |
* Input parameters:
|
|
219 |
* @param chars - the input character context
|
|
220 |
* @param offset - the offset of the first character to be mapped
|
|
221 |
* @param count - the number of characters to be mapped
|
|
222 |
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
|
|
223 |
* @param mirror - if <code>TRUE</code>, do character mirroring
|
|
224 |
* @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
|
|
225 |
*
|
|
226 |
* @param success - set to an error code if the operation fails
|
|
227 |
*
|
|
228 |
* @internal
|
|
229 |
*/
|
|
230 |
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
|
|
231 |
le_int32 count, le_bool reverse, le_bool mirror,
|
|
232 |
LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
233 |
|
|
234 |
/**
|
|
235 |
* This method ensures that all vowel and accent glyphs have a zero advance width by calling
|
|
236 |
* the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
|
|
237 |
* glyphs.
|
|
238 |
*
|
|
239 |
* @param chars - the input character context
|
|
240 |
* @param offset - the offset of the first character to process
|
|
241 |
* @param count - the number of characters to process
|
|
242 |
* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
|
|
243 |
* @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
|
|
244 |
* @param success - output parameter set to an error code if the operation fails
|
|
245 |
*
|
|
246 |
* @internal
|
|
247 |
*/
|
|
248 |
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
|
|
249 |
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
|
250 |
};
|
|
251 |
|
|
252 |
#endif
|