ReactOS  0.4.15-dev-321-g2d9b385
usp10_internal.h
Go to the documentation of this file.
1 /*
2  * Implementation of Uniscribe Script Processor (usp10.dll)
3  *
4  * Copyright 2010 CodeWeavers, Aric Stewart
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21 
22 #pragma once
23 
24 #include "wine/list.h"
25 
26 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
27  ( ( (ULONG)_x4 << 24 ) | \
28  ( (ULONG)_x3 << 16 ) | \
29  ( (ULONG)_x2 << 8 ) | \
30  (ULONG)_x1 )
31 
33 {
35  Script_Latin = 0x01,
36  Script_CR = 0x02,
40  Script_Arabic = 0x06,
42  Script_Hebrew = 0x08,
43  Script_Syriac = 0x09,
45  Script_Thaana = 0x0b,
46  Script_Greek = 0x0c,
50  /* Unicode Chapter 10 */
55  /* Unicode Chapter 11 */
56  Script_Thai = 0x14,
58  Script_Lao = 0x16,
60  /* Unicode Chapter 9 */
71  Script_Oriya = 0x22,
73  Script_Tamil = 0x24,
75  Script_Telugu = 0x26,
81  /* More supplemental */
85  /* Unicode Chapter 11 continued */
88  Script_Tai_Le = 0x31,
91  Script_Khmer = 0x34,
93  /* Unicode Chapter 12 */
97  Script_Kana = 0x39,
98  Script_Hangul = 0x3a,
99  Script_Yi = 0x3b,
100  /* Unicode Chapter 13 */
106  Script_NKo = 0x41,
107  Script_Vai = 0x42,
111  /* Unicode Chapter 14 */
112  Script_Ogham = 0x46,
113  Script_Runic = 0x47,
114  /* Unicode Chapter 15 */
116  /* Unicode Chapter 16 */
119  /* Unicode Chapter 13 : Plane 1 */
123  /* Unicode Chapter 15 : Plane 1 */
125  /* Additional Currency Scripts */
129 };
130 
131 #define GLYPH_BLOCK_SHIFT 8
132 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
133 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
134 #define GLYPH_MAX 65536
135 
136 #define NUM_PAGES 17
137 
138 #define GSUB_E_NOFEATURE -20
139 #define GSUB_E_NOGLYPH -10
140 
141 #define FEATURE_ALL_TABLES 0
142 #define FEATURE_GSUB_TABLE 1
143 #define FEATURE_GPOS_TABLE 2
144 
145 typedef struct {
148  const void *feature;
151 } LoadedFeature;
152 
154 {
158 };
159 
160 typedef struct {
168 
170 {
174 };
175 
176 typedef struct {
184 } LoadedScript;
185 
186 typedef struct {
189 
190 typedef struct {
191  struct list entry;
200  void *GSUB_Table;
201  void *GDEF_Table;
202  void *CMAP_Table;
204  void *GPOS_Table;
209 
212 } ScriptCache;
213 
214 typedef struct _scriptData
215 {
220 } scriptData;
221 
222 typedef struct {
229 } IndicSyllable;
230 
232 
233 static inline BOOL is_consonant( int type )
234 {
235  return (type == lex_Ra || type == lex_Consonant);
236 }
237 
238 static inline unsigned short get_table_entry( const unsigned short *table, WCHAR ch )
239 {
240  return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
241 }
242 
244 typedef void (*reorder_function)(WCHAR *chars, IndicSyllable *syllable, lexical_function lex);
245 
246 #define odd(x) ((x) & 1)
247 #define BIDI_STRONG 1
248 #define BIDI_WEAK 2
249 #define BIDI_NEUTRAL 0
250 
251 BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
253 
254 BOOL BIDI_DetermineLevels(const WCHAR *string, unsigned int count, const SCRIPT_STATE *s,
255  const SCRIPT_CONTROL *c, WORD *levels, WORD *overrides) DECLSPEC_HIDDEN;
256 BOOL BIDI_GetStrengths(const WCHAR *string, unsigned int count,
257  const SCRIPT_CONTROL *c, WORD *strength) DECLSPEC_HIDDEN;
258 INT BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
259 INT BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN;
262 void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD* pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset ) DECLSPEC_HIDDEN;
269 
271  IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f,
272  reorder_function reorder_f, BOOL modern) DECLSPEC_HIDDEN;
273 void Indic_ParseSyllables(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *input, unsigned int cChar,
274  IndicSyllable **syllables, int *syllable_count, lexical_function lex, BOOL modern) DECLSPEC_HIDDEN;
275 
276 void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la) DECLSPEC_HIDDEN;
277 
280 int OpenType_apply_GSUB_lookup(const void *table, unsigned int lookup_index, WORD *glyphs,
281  unsigned int glyph_index, int write_dir, int *glyph_count) DECLSPEC_HIDDEN;
282 unsigned int OpenType_apply_GPOS_lookup(const ScriptCache *psc, const OUTLINETEXTMETRICW *otm,
283  const LOGFONTW *logfont, const SCRIPT_ANALYSIS *analysis, int *advance, unsigned int lookup_index,
284  const WORD *glyphs, unsigned int glyph_index, unsigned int glyph_count, GOFFSET *goffset) DECLSPEC_HIDDEN;
void Indic_ReorderCharacters(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, WCHAR *input, unsigned int cChars, IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f, reorder_function reorder_f, BOOL modern) DECLSPEC_HIDDEN
Definition: indic.c:373
INTERNETFEATURELIST feature
Definition: misc.c:1719
SCRIPT_PROPERTIES props
GLint level
Definition: gl.h:1546
struct _scriptData scriptData
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
Definition: shape.c:3523
LoadedFeature * features
#define LF_FACESIZE
Definition: dimm.idl:39
Definition: wingdi.h:1409
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
OPENTYPE_TAG userScript
SIZE_T scripts_size
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int WORD * pwLogClust
Definition: usp10.c:64
GLsizei levels
Definition: glext.h:7884
void OpenType_GDEF_UpdateGlyphProps(ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD *pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN
Definition: opentype.c:751
void * CMAP_format12_Table
HRESULT OpenType_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags) DECLSPEC_HIDDEN
Definition: opentype.c:2761
void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR *pwcChars, INT cChars, WORD *pwOutGlyphs, INT *pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust) DECLSPEC_HIDDEN
Definition: shape.c:3388
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
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
_In_ FONTOBJ _In_ ULONG _In_ ULONG cGlyphs
Definition: winddi.h:3799
static int int const SCRIPT_CONTROL const SCRIPT_STATE SCRIPT_ITEM ULONG * pScriptTags
Definition: usp10.c:62
static HDC
Definition: imagelist.c:92
void * GSUB_Table
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
SIZE_T language_count
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
OPENTYPE_TAG userLang
void(* reorder_function)(WCHAR *chars, IndicSyllable *syllable, lexical_function lex)
static UINT UINT LPWORD glyphs
Definition: font.c:44
int32_t INT
Definition: typedefs.h:57
BOOL BIDI_GetStrengths(const WCHAR *string, unsigned int count, const SCRIPT_CONTROL *c, WORD *strength) DECLSPEC_HIDDEN
Definition: bidi.c:1249
OPENTYPE_TAG tag
OPENTYPE_TAG scriptTag
WCHAR fallbackFont[LF_FACESIZE]
void SHAPE_ApplyDefaultOpentypeFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WORD *pwOutGlyphs, INT *pcGlyphs, INT cMaxGlyphs, INT cChars, WORD *pwLogClust) DECLSPEC_HIDDEN
Definition: shape.c:3421
unsigned int BOOL
Definition: ntddk_ex.h:94
usp10_script_table
LoadedScript * scripts
#define GLYPH_BLOCK_SIZE
int(* lexical_function)(WCHAR c)
OPENTYPE_TAG tag
static LPCSTR INT LPWORD pgi
Definition: font.c:51
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
SCRIPT_ANALYSIS a
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG tagLangSys
Definition: usp10.c:64
HRESULT SHAPE_GetFontScriptTags(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN
Definition: shape.c:3477
Definition: module.h:566
BOOL scripts_initialized
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG int OPENTYPE_TAG * pLangSysTags
Definition: usp10.c:67
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
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
Definition: shape.c:3378
static unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
GLsizeiptr size
Definition: glext.h:5919
void * GDEF_Table
__wchar_t WCHAR
Definition: xmlstorage.h:180
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int WORD SCRIPT_CHARPROP WORD SCRIPT_GLYPHPROP int * pcGlyphs
Definition: usp10.c:64
LONG HRESULT
Definition: typedefs.h:78
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int cMaxGlyphs
Definition: usp10.c:64
DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN
HRESULT SHAPE_GetFontLanguageTags(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags) DECLSPEC_HIDDEN
Definition: shape.c:3495
const GLubyte * c
Definition: glext.h:8905
BOOL languages_initialized
unsigned short WORD
Definition: ntddk_ex.h:93
HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) DECLSPEC_HIDDEN
Definition: shape.c:3454
unsigned long DWORD
Definition: ntddk_ex.h:95
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG tagScript
Definition: usp10.c:64
GLbitfield flags
Definition: glext.h:7161
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int OPENTYPE_TAG * pFeatureTags
Definition: usp10.c:68
INT BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN
Definition: bidi.c:1215
OUTLINETEXTMETRICW * otm
usp10_language_table
HDC hdc
Definition: main.c:9
uint32_t entry
Definition: isohybrid.c:63
GLdouble s
Definition: gl.h:2039
Definition: _list.h:228
_STLP_MOVE_TO_STD_NAMESPACE void _STLP_CALL advance(_InputIterator &__i, _Distance __n)
INT BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN
Definition: bidi.c:1188
static BOOL is_consonant(int type)
TEXTMETRICW tm
void Indic_ParseSyllables(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const WCHAR *input, unsigned int cChar, IndicSyllable **syllables, int *syllable_count, lexical_function lex, BOOL modern) DECLSPEC_HIDDEN
Definition: indic.c:324
void * CMAP_Table
unsigned char BYTE
Definition: xxhash.c:193
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int WORD SCRIPT_CHARPROP WORD * pwOutGlyphs
Definition: usp10.c:64
uint16_t * LPWORD
Definition: typedefs.h:55
HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN
Definition: opentype.c:2647
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR * pwcChars
Definition: usp10.c:64
static SCRIPT_CACHE SCRIPT_ANALYSIS int cMaxTags
Definition: usp10.c:66
ULONG_PTR SIZE_T
Definition: typedefs.h:79
int OpenType_apply_GSUB_lookup(const void *table, unsigned int lookup_index, WORD *glyphs, unsigned int glyph_index, int write_dir, int *glyph_count) DECLSPEC_HIDDEN
Definition: opentype.c:1540
GLenum GLenum GLenum input
Definition: glext.h:9031
SIZE_T languages_size
static SCRIPT_CACHE * psc
Definition: usp10.c:64
BOOL BIDI_DetermineLevels(const WCHAR *string, unsigned int count, const SCRIPT_STATE *s, const SCRIPT_CONTROL *c, WORD *levels, WORD *overrides) DECLSPEC_HIDDEN
Definition: bidi.c:1088
void * GPOS_Table
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la) DECLSPEC_HIDDEN
Definition: breaking.c:77
SIZE_T script_count
#define c
Definition: ke_i.h:80
OPENTYPE_TAG tag
void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD *pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset) DECLSPEC_HIDDEN
Definition: shape.c:3429
GLenum target
Definition: glext.h:7315
LoadedLanguage * languages
const void * feature
#define GLYPH_MAX
unsigned int OpenType_apply_GPOS_lookup(const ScriptCache *psc, const OUTLINETEXTMETRICW *otm, const LOGFONTW *logfont, const SCRIPT_ANALYSIS *analysis, int *advance, unsigned int lookup_index, const WORD *glyphs, unsigned int glyph_index, unsigned int glyph_count, GOFFSET *goffset) DECLSPEC_HIDDEN
Definition: opentype.c:2557
SCRIPT_FONTPROPERTIES sfp
ULONG OPENTYPE_TAG
Definition: usp10.h:205
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static SCRIPT_CACHE SCRIPT_ANALYSIS int OPENTYPE_TAG int * pcTags
Definition: usp10.c:66
int USP10_FindGlyphInLogClust(const WORD *pwLogClust, int cChars, WORD target) DECLSPEC_HIDDEN
Definition: usp10.c:1044
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
Definition: opentype.c:2872
LoadedLanguage default_language
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define NUM_PAGES
BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN
Definition: usp10.c:730
usp10_script