devenum: Implement IMoniker::GetClassID().
[wine.git] / dlls / usp10 / usp10_internal.h
blobfa9b6c2bead2a47a0bf52c372d0416fce14e6ea8
1 /*
2 * Implementation of Uniscribe Script Processor (usp10.dll)
4 * Copyright 2010 CodeWeavers, Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
22 ( ( (ULONG)_x4 << 24 ) | \
23 ( (ULONG)_x3 << 16 ) | \
24 ( (ULONG)_x2 << 8 ) | \
25 (ULONG)_x1 )
27 #ifndef ARRAY_SIZE
28 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
29 #endif
31 enum usp10_script
33 Script_Undefined = 0x00,
34 Script_Latin = 0x01,
35 Script_CR = 0x02,
36 Script_Numeric = 0x03,
37 Script_Control = 0x04,
38 Script_Punctuation = 0x05,
39 Script_Arabic = 0x06,
40 Script_Arabic_Numeric = 0x07,
41 Script_Hebrew = 0x08,
42 Script_Syriac = 0x09,
43 Script_Persian = 0x0a,
44 Script_Thaana = 0x0b,
45 Script_Greek = 0x0c,
46 Script_Cyrillic = 0x0d,
47 Script_Armenian = 0x0e,
48 Script_Georgian = 0x0f,
49 /* Unicode Chapter 10 */
50 Script_Sinhala = 0x10,
51 Script_Tibetan = 0x11,
52 Script_Tibetan_Numeric = 0x12,
53 Script_Phags_pa = 0x13,
54 /* Unicode Chapter 11 */
55 Script_Thai = 0x14,
56 Script_Thai_Numeric = 0x15,
57 Script_Lao = 0x16,
58 Script_Lao_Numeric = 0x17,
59 /* Unicode Chapter 9 */
60 Script_Devanagari = 0x18,
61 Script_Devanagari_Numeric = 0x19,
62 Script_Bengali = 0x1a,
63 Script_Bengali_Numeric = 0x1b,
64 Script_Bengali_Currency = 0x1c,
65 Script_Gurmukhi = 0x1d,
66 Script_Gurmukhi_Numeric = 0x1e,
67 Script_Gujarati = 0x1f,
68 Script_Gujarati_Numeric = 0x20,
69 Script_Gujarati_Currency = 0x21,
70 Script_Oriya = 0x22,
71 Script_Oriya_Numeric = 0x23,
72 Script_Tamil = 0x24,
73 Script_Tamil_Numeric = 0x25,
74 Script_Telugu = 0x26,
75 Script_Telugu_Numeric = 0x27,
76 Script_Kannada = 0x28,
77 Script_Kannada_Numeric = 0x29,
78 Script_Malayalam = 0x2a,
79 Script_Malayalam_Numeric = 0x2b,
80 /* More supplemental */
81 Script_Diacritical = 0x2c,
82 Script_Punctuation2 = 0x2d,
83 Script_Numeric2 = 0x2e,
84 /* Unicode Chapter 11 continued */
85 Script_Myanmar = 0x2f,
86 Script_Myanmar_Numeric = 0x30,
87 Script_Tai_Le = 0x31,
88 Script_New_Tai_Lue = 0x32,
89 Script_New_Tai_Lue_Numeric = 0x33,
90 Script_Khmer = 0x34,
91 Script_Khmer_Numeric = 0x35,
92 /* Unicode Chapter 12 */
93 Script_CJK_Han = 0x36,
94 Script_Ideograph = 0x37,
95 Script_Bopomofo = 0x38,
96 Script_Kana = 0x39,
97 Script_Hangul = 0x3a,
98 Script_Yi = 0x3b,
99 /* Unicode Chapter 13 */
100 Script_Ethiopic = 0x3c,
101 Script_Ethiopic_Numeric = 0x3d,
102 Script_Mongolian = 0x3e,
103 Script_Mongolian_Numeric = 0x3f,
104 Script_Tifinagh = 0x40,
105 Script_NKo = 0x41,
106 Script_Vai = 0x42,
107 Script_Vai_Numeric = 0x43,
108 Script_Cherokee = 0x44,
109 Script_Canadian = 0x45,
110 /* Unicode Chapter 14 */
111 Script_Ogham = 0x46,
112 Script_Runic = 0x47,
113 /* Unicode Chapter 15 */
114 Script_Braille = 0x48,
115 /* Unicode Chapter 16 */
116 Script_Surrogates = 0x49,
117 Script_Private = 0x4a,
118 /* Unicode Chapter 13 : Plane 1 */
119 Script_Deseret = 0x4b,
120 Script_Osmanya = 0x4c,
121 Script_Osmanya_Numeric = 0x4d,
122 /* Unicode Chapter 15 : Plane 1 */
123 Script_MathAlpha = 0x4e,
124 /* Additional Currency Scripts */
125 Script_Hebrew_Currency = 0x4f,
126 Script_Vietnamese_Currency = 0x50,
127 Script_Thai_Currency = 0x51,
130 #define GLYPH_BLOCK_SHIFT 8
131 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
132 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
133 #define GLYPH_MAX 65536
135 #define NUM_PAGES 17
137 #define GSUB_E_NOFEATURE -20
138 #define GSUB_E_NOGLYPH -10
140 #define FEATURE_ALL_TABLES 0
141 #define FEATURE_GSUB_TABLE 1
142 #define FEATURE_GPOS_TABLE 2
144 typedef struct {
145 OPENTYPE_TAG tag;
146 CHAR tableType;
147 LPCVOID feature;
148 INT lookup_count;
149 WORD *lookups;
150 } LoadedFeature;
152 typedef struct {
153 OPENTYPE_TAG tag;
154 LPCVOID gsub_table;
155 LPCVOID gpos_table;
156 BOOL features_initialized;
157 INT feature_count;
158 LoadedFeature *features;
159 } LoadedLanguage;
161 typedef struct {
162 OPENTYPE_TAG tag;
163 LPCVOID gsub_table;
164 LPCVOID gpos_table;
165 LoadedLanguage default_language;
166 BOOL languages_initialized;
167 INT language_count;
168 LoadedLanguage *languages;
169 } LoadedScript;
171 typedef struct {
172 WORD *glyphs[GLYPH_MAX / GLYPH_BLOCK_SIZE];
173 } CacheGlyphPage;
175 typedef struct {
176 LOGFONTW lf;
177 TEXTMETRICW tm;
178 OUTLINETEXTMETRICW *otm;
179 SCRIPT_FONTPROPERTIES sfp;
180 BOOL sfnt;
181 CacheGlyphPage *page[NUM_PAGES];
182 ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
183 LPVOID GSUB_Table;
184 LPVOID GDEF_Table;
185 LPVOID CMAP_Table;
186 LPVOID CMAP_format12_Table;
187 LPVOID GPOS_Table;
188 BOOL scripts_initialized;
189 INT script_count;
190 LoadedScript *scripts;
192 OPENTYPE_TAG userScript;
193 OPENTYPE_TAG userLang;
194 } ScriptCache;
196 typedef struct _scriptData
198 SCRIPT_ANALYSIS a;
199 SCRIPT_PROPERTIES props;
200 OPENTYPE_TAG scriptTag;
201 WCHAR fallbackFont[LF_FACESIZE];
202 } scriptData;
204 typedef struct {
205 INT start;
206 INT base;
207 INT ralf;
208 INT blwf;
209 INT pref;
210 INT end;
211 } IndicSyllable;
213 enum {lex_Halant, lex_Composed_Vowel, lex_Matra_post, lex_Matra_pre, lex_Matra_above, lex_Matra_below, lex_ZWJ, lex_ZWNJ, lex_NBSP, lex_Modifier, lex_Vowel, lex_Consonant, lex_Generic, lex_Ra, lex_Vedic, lex_Anudatta, lex_Nukta};
215 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
217 return HeapAlloc(GetProcessHeap(), 0, size);
220 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
222 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
225 static inline BOOL heap_free(void *mem)
227 return HeapFree(GetProcessHeap(), 0, mem);
230 static inline BOOL is_consonant( int type )
232 return (type == lex_Ra || type == lex_Consonant);
235 static inline unsigned short get_table_entry( const unsigned short *table, WCHAR ch )
237 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
240 typedef int (*lexical_function)(WCHAR c);
241 typedef void (*reorder_function)(LPWSTR pwChar, IndicSyllable *syllable, lexical_function lex);
243 #define odd(x) ((x) & 1)
244 #define BIDI_STRONG 1
245 #define BIDI_WEAK 2
246 #define BIDI_NEUTRAL 0
248 int USP10_FindGlyphInLogClust(const WORD* pwLogClust, int cChars, WORD target) DECLSPEC_HIDDEN;
250 BOOL BIDI_DetermineLevels( LPCWSTR lpString, INT uCount, const SCRIPT_STATE *s,
251 const SCRIPT_CONTROL *c, WORD *lpOutLevels, WORD *lpOutOverrides ) DECLSPEC_HIDDEN;
252 BOOL BIDI_GetStrengths(LPCWSTR lpString, INT uCount, const SCRIPT_CONTROL *c,
253 WORD* lpStrength) DECLSPEC_HIDDEN;
254 INT BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
255 INT BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
256 void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust) DECLSPEC_HIDDEN;
257 void SHAPE_ApplyDefaultOpentypeFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, INT cChars, WORD *pwLogClust) DECLSPEC_HIDDEN;
258 void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD* pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset ) DECLSPEC_HIDDEN;
259 HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) DECLSPEC_HIDDEN;
260 void SHAPE_CharGlyphProp(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN;
261 INT SHAPE_does_GSUB_feature_apply_to_chars(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *chars, INT write_dir, INT count, const char* feature) DECLSPEC_HIDDEN;
262 HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN;
263 HRESULT SHAPE_GetFontLanguageTags( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags) DECLSPEC_HIDDEN;
264 HRESULT SHAPE_GetFontFeatureTags( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags) DECLSPEC_HIDDEN;
266 void Indic_ReorderCharacters( HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR input, int cChars, IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f, reorder_function reorder_f, BOOL modern) DECLSPEC_HIDDEN;
267 void Indic_ParseSyllables( HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPCWSTR input, const int cChar, IndicSyllable **syllables, int *syllable_count, lexical_function lex, BOOL modern) DECLSPEC_HIDDEN;
269 void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la) DECLSPEC_HIDDEN;
271 DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
272 void OpenType_GDEF_UpdateGlyphProps(ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD* pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN;
273 INT OpenType_apply_GSUB_lookup(LPCVOID table, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count) DECLSPEC_HIDDEN;
274 INT OpenType_apply_GPOS_lookup(ScriptCache *psc, LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, const SCRIPT_ANALYSIS *analysis, INT* piAdvance, INT lookup_index, const WORD *glyphs, INT glyph_index, INT glyph_count, GOFFSET *pGoffset) DECLSPEC_HIDDEN;
275 HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN;
276 HRESULT OpenType_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags) DECLSPEC_HIDDEN;
277 HRESULT OpenType_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG language_tag, BOOL filtered, OPENTYPE_TAG searchingFor, char tableType, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags, LoadedFeature** feature) DECLSPEC_HIDDEN;