ole32: Use the real proxy IID in ClientRpcChannelBuffer_GetBuffer().
[wine.git] / dlls / usp10 / usp10_internal.h
blobbd55d8694f142ea43ead9674e2ab320613e00c58
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
22 #include "wine/list.h"
24 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
25 ( ( (ULONG)_x4 << 24 ) | \
26 ( (ULONG)_x3 << 16 ) | \
27 ( (ULONG)_x2 << 8 ) | \
28 (ULONG)_x1 )
30 enum usp10_script
32 Script_Undefined = 0x00,
33 Script_Latin = 0x01,
34 Script_CR = 0x02,
35 Script_Numeric = 0x03,
36 Script_Control = 0x04,
37 Script_Punctuation = 0x05,
38 Script_Arabic = 0x06,
39 Script_Arabic_Numeric = 0x07,
40 Script_Hebrew = 0x08,
41 Script_Syriac = 0x09,
42 Script_Persian = 0x0a,
43 Script_Thaana = 0x0b,
44 Script_Greek = 0x0c,
45 Script_Cyrillic = 0x0d,
46 Script_Armenian = 0x0e,
47 Script_Georgian = 0x0f,
48 /* Unicode Chapter 10 */
49 Script_Sinhala = 0x10,
50 Script_Tibetan = 0x11,
51 Script_Tibetan_Numeric = 0x12,
52 Script_Phags_pa = 0x13,
53 /* Unicode Chapter 11 */
54 Script_Thai = 0x14,
55 Script_Thai_Numeric = 0x15,
56 Script_Lao = 0x16,
57 Script_Lao_Numeric = 0x17,
58 /* Unicode Chapter 9 */
59 Script_Devanagari = 0x18,
60 Script_Devanagari_Numeric = 0x19,
61 Script_Bengali = 0x1a,
62 Script_Bengali_Numeric = 0x1b,
63 Script_Bengali_Currency = 0x1c,
64 Script_Gurmukhi = 0x1d,
65 Script_Gurmukhi_Numeric = 0x1e,
66 Script_Gujarati = 0x1f,
67 Script_Gujarati_Numeric = 0x20,
68 Script_Gujarati_Currency = 0x21,
69 Script_Oriya = 0x22,
70 Script_Oriya_Numeric = 0x23,
71 Script_Tamil = 0x24,
72 Script_Tamil_Numeric = 0x25,
73 Script_Telugu = 0x26,
74 Script_Telugu_Numeric = 0x27,
75 Script_Kannada = 0x28,
76 Script_Kannada_Numeric = 0x29,
77 Script_Malayalam = 0x2a,
78 Script_Malayalam_Numeric = 0x2b,
79 /* More supplemental */
80 Script_Diacritical = 0x2c,
81 Script_Punctuation2 = 0x2d,
82 Script_Numeric2 = 0x2e,
83 /* Unicode Chapter 11 continued */
84 Script_Myanmar = 0x2f,
85 Script_Myanmar_Numeric = 0x30,
86 Script_Tai_Le = 0x31,
87 Script_New_Tai_Lue = 0x32,
88 Script_New_Tai_Lue_Numeric = 0x33,
89 Script_Khmer = 0x34,
90 Script_Khmer_Numeric = 0x35,
91 /* Unicode Chapter 12 */
92 Script_CJK_Han = 0x36,
93 Script_Ideograph = 0x37,
94 Script_Bopomofo = 0x38,
95 Script_Kana = 0x39,
96 Script_Hangul = 0x3a,
97 Script_Yi = 0x3b,
98 /* Unicode Chapter 13 */
99 Script_Ethiopic = 0x3c,
100 Script_Ethiopic_Numeric = 0x3d,
101 Script_Mongolian = 0x3e,
102 Script_Mongolian_Numeric = 0x3f,
103 Script_Tifinagh = 0x40,
104 Script_NKo = 0x41,
105 Script_Vai = 0x42,
106 Script_Vai_Numeric = 0x43,
107 Script_Cherokee = 0x44,
108 Script_Canadian = 0x45,
109 /* Unicode Chapter 14 */
110 Script_Ogham = 0x46,
111 Script_Runic = 0x47,
112 /* Unicode Chapter 15 */
113 Script_Braille = 0x48,
114 /* Unicode Chapter 16 */
115 Script_Surrogates = 0x49,
116 Script_Private = 0x4a,
117 /* Unicode Chapter 13 : Plane 1 */
118 Script_Deseret = 0x4b,
119 Script_Osmanya = 0x4c,
120 Script_Osmanya_Numeric = 0x4d,
121 /* Unicode Chapter 15 : Plane 1 */
122 Script_MathAlpha = 0x4e,
123 /* Additional Currency Scripts */
124 Script_Hebrew_Currency = 0x4f,
125 Script_Vietnamese_Currency = 0x50,
126 Script_Thai_Currency = 0x51,
129 #define GLYPH_BLOCK_SHIFT 8
130 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
131 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
132 #define GLYPH_MAX 65536
134 #define NUM_PAGES 17
136 #define GSUB_E_NOFEATURE -20
137 #define GSUB_E_NOGLYPH -10
139 #define FEATURE_ALL_TABLES 0
140 #define FEATURE_GSUB_TABLE 1
141 #define FEATURE_GPOS_TABLE 2
143 typedef struct {
144 OPENTYPE_TAG tag;
145 CHAR tableType;
146 const void *feature;
147 INT lookup_count;
148 WORD *lookups;
149 } LoadedFeature;
151 enum usp10_language_table
153 USP10_LANGUAGE_TABLE_GSUB = 0,
154 USP10_LANGUAGE_TABLE_GPOS,
155 USP10_LANGUAGE_TABLE_COUNT
158 typedef struct {
159 OPENTYPE_TAG tag;
160 const void *table[USP10_LANGUAGE_TABLE_COUNT];
161 BOOL features_initialized;
162 LoadedFeature *features;
163 SIZE_T features_size;
164 SIZE_T feature_count;
165 } LoadedLanguage;
167 enum usp10_script_table
169 USP10_SCRIPT_TABLE_GSUB = 0,
170 USP10_SCRIPT_TABLE_GPOS,
171 USP10_SCRIPT_TABLE_COUNT
174 typedef struct {
175 OPENTYPE_TAG tag;
176 const void *table[USP10_SCRIPT_TABLE_COUNT];
177 LoadedLanguage default_language;
178 BOOL languages_initialized;
179 LoadedLanguage *languages;
180 SIZE_T languages_size;
181 SIZE_T language_count;
182 } LoadedScript;
184 typedef struct {
185 WORD *glyphs[GLYPH_MAX / GLYPH_BLOCK_SIZE];
186 } CacheGlyphPage;
188 typedef struct {
189 struct list entry;
190 DWORD refcount;
191 LOGFONTW lf;
192 TEXTMETRICW tm;
193 OUTLINETEXTMETRICW *otm;
194 SCRIPT_FONTPROPERTIES sfp;
195 BOOL sfnt;
196 CacheGlyphPage *page[NUM_PAGES];
197 ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
198 void *GSUB_Table;
199 void *GDEF_Table;
200 void *CMAP_Table;
201 void *CMAP_format12_Table;
202 void *GPOS_Table;
203 BOOL scripts_initialized;
204 LoadedScript *scripts;
205 SIZE_T scripts_size;
206 SIZE_T script_count;
208 OPENTYPE_TAG userScript;
209 OPENTYPE_TAG userLang;
210 } ScriptCache;
212 typedef struct _scriptData
214 SCRIPT_ANALYSIS a;
215 SCRIPT_PROPERTIES props;
216 OPENTYPE_TAG scriptTag;
217 WCHAR fallbackFont[LF_FACESIZE];
218 } scriptData;
220 typedef struct {
221 INT start;
222 INT base;
223 INT ralf;
224 INT blwf;
225 INT pref;
226 INT end;
227 } IndicSyllable;
229 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};
231 static inline BOOL is_consonant( int type )
233 return (type == lex_Ra || type == lex_Consonant);
236 static inline unsigned short get_table_entry( const unsigned short *table, WCHAR ch )
238 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
241 typedef int (*lexical_function)(WCHAR c);
242 typedef void (*reorder_function)(WCHAR *chars, IndicSyllable *syllable, lexical_function lex);
244 #define odd(x) ((x) & 1)
245 #define BIDI_STRONG 1
246 #define BIDI_WEAK 2
247 #define BIDI_NEUTRAL 0
249 BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
250 int USP10_FindGlyphInLogClust(const WORD* pwLogClust, int cChars, WORD target) DECLSPEC_HIDDEN;
252 BOOL BIDI_DetermineLevels(const WCHAR *string, unsigned int count, const SCRIPT_STATE *s,
253 const SCRIPT_CONTROL *c, WORD *levels, WORD *overrides) DECLSPEC_HIDDEN;
254 BOOL BIDI_GetStrengths(const WCHAR *string, unsigned int count,
255 const SCRIPT_CONTROL *c, WORD *strength) DECLSPEC_HIDDEN;
256 INT BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
257 INT BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
258 void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust) DECLSPEC_HIDDEN;
259 void SHAPE_ApplyDefaultOpentypeFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, INT cChars, WORD *pwLogClust) DECLSPEC_HIDDEN;
260 void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD* pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset ) DECLSPEC_HIDDEN;
261 HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) DECLSPEC_HIDDEN;
262 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;
263 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;
264 HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN;
265 HRESULT SHAPE_GetFontLanguageTags( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags) DECLSPEC_HIDDEN;
266 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;
268 void Indic_ReorderCharacters(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, WCHAR *input, unsigned int cChars,
269 IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f,
270 reorder_function reorder_f, BOOL modern) DECLSPEC_HIDDEN;
271 void Indic_ParseSyllables(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *input, unsigned int cChar,
272 IndicSyllable **syllables, int *syllable_count, lexical_function lex, BOOL modern) DECLSPEC_HIDDEN;
274 void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la) DECLSPEC_HIDDEN;
276 DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
277 void OpenType_GDEF_UpdateGlyphProps(ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD* pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN;
278 int OpenType_apply_GSUB_lookup(const void *table, unsigned int lookup_index, WORD *glyphs,
279 unsigned int glyph_index, int write_dir, int *glyph_count) DECLSPEC_HIDDEN;
280 unsigned int OpenType_apply_GPOS_lookup(const ScriptCache *psc, const OUTLINETEXTMETRICW *otm,
281 const LOGFONTW *logfont, const SCRIPT_ANALYSIS *analysis, int *advance, unsigned int lookup_index,
282 const WORD *glyphs, unsigned int glyph_index, unsigned int glyph_count, GOFFSET *goffset) DECLSPEC_HIDDEN;
283 HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN;
284 HRESULT OpenType_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags) DECLSPEC_HIDDEN;
285 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;