usp10: Introduce an enumeration for script types.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Aric Stewart <aric@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
502d23986c
commit
a523b46d0b
|
@ -43,16 +43,16 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(uniscribe);
|
||||
|
||||
typedef struct _scriptRange
|
||||
static const struct
|
||||
{
|
||||
WORD script;
|
||||
enum usp10_script script;
|
||||
DWORD rangeFirst;
|
||||
DWORD rangeLast;
|
||||
WORD numericScript;
|
||||
WORD punctScript;
|
||||
} scriptRange;
|
||||
|
||||
static const scriptRange scriptRanges[] = {
|
||||
enum usp10_script numericScript;
|
||||
enum usp10_script punctScript;
|
||||
}
|
||||
scriptRanges[] =
|
||||
{
|
||||
/* Basic Latin: U+0000–U+007A */
|
||||
{ Script_Latin, 0x00, 0x07a , Script_Numeric, Script_Punctuation},
|
||||
/* Latin-1 Supplement: U+0080–U+00FF */
|
||||
|
@ -888,7 +888,8 @@ static inline DWORD decode_surrogate_pair(LPCWSTR str, INT index, INT end)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static WORD get_char_script( LPCWSTR str, INT index, INT end, INT *consumed)
|
||||
static enum usp10_script get_char_script(const WCHAR *str, unsigned int index,
|
||||
unsigned int end, unsigned int *consumed)
|
||||
{
|
||||
static const WCHAR latin_punc[] = {'#','$','&','\'',',',';','<','>','?','@','\\','^','_','`','{','|','}','~', 0x00a0, 0};
|
||||
WORD type = 0, type2 = 0;
|
||||
|
@ -1220,12 +1221,12 @@ HRESULT WINAPI ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE *sds,
|
|||
}
|
||||
}
|
||||
|
||||
static inline BOOL is_indic(WORD script)
|
||||
static inline BOOL is_indic(enum usp10_script script)
|
||||
{
|
||||
return (script >= Script_Devanagari && script <= Script_Malayalam_Numeric);
|
||||
}
|
||||
|
||||
static inline WORD base_indic(WORD script)
|
||||
static inline enum usp10_script base_indic(enum usp10_script script)
|
||||
{
|
||||
switch (script)
|
||||
{
|
||||
|
@ -1250,11 +1251,11 @@ static inline WORD base_indic(WORD script)
|
|||
case Script_Malayalam:
|
||||
case Script_Malayalam_Numeric: return Script_Malayalam;
|
||||
default:
|
||||
return -1;
|
||||
return Script_Undefined;
|
||||
};
|
||||
}
|
||||
|
||||
static BOOL script_is_numeric(WORD script)
|
||||
static BOOL script_is_numeric(enum usp10_script script)
|
||||
{
|
||||
return scriptInformation[script].props.fNumeric;
|
||||
}
|
||||
|
@ -1270,21 +1271,21 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
|
|||
#define ZWNJ 0x200C
|
||||
#define ZWJ 0x200D
|
||||
|
||||
enum usp10_script last_indic = Script_Undefined;
|
||||
int cnt = 0, index = 0, str = 0;
|
||||
int New_Script = -1;
|
||||
enum usp10_script New_Script = -1;
|
||||
int i;
|
||||
WORD *levels = NULL;
|
||||
WORD *layout_levels = NULL;
|
||||
WORD *overrides = NULL;
|
||||
WORD *strength = NULL;
|
||||
WORD *scripts = NULL;
|
||||
enum usp10_script *scripts;
|
||||
WORD baselevel = 0;
|
||||
WORD baselayout = 0;
|
||||
BOOL new_run;
|
||||
WORD last_indic = -1;
|
||||
WORD layoutRTL = 0;
|
||||
BOOL forceLevels = FALSE;
|
||||
INT consumed = 0;
|
||||
unsigned int consumed = 0;
|
||||
HRESULT res = E_OUTOFMEMORY;
|
||||
|
||||
TRACE("%s,%d,%d,%p,%p,%p,%p\n", debugstr_wn(pwcInChars, cInChars), cInChars, cMaxItems,
|
||||
|
@ -1293,13 +1294,12 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
|
|||
if (!pwcInChars || !cInChars || !pItems || cMaxItems < 2)
|
||||
return E_INVALIDARG;
|
||||
|
||||
scripts = heap_alloc(cInChars * sizeof(WORD));
|
||||
if (!scripts)
|
||||
if (!(scripts = heap_alloc(cInChars * sizeof(*scripts))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
for (i = 0; i < cInChars; i++)
|
||||
{
|
||||
if (consumed <= 0)
|
||||
if (!consumed)
|
||||
{
|
||||
scripts[i] = get_char_script(pwcInChars,i,cInChars,&consumed);
|
||||
consumed --;
|
||||
|
@ -1311,7 +1311,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
|
|||
}
|
||||
/* Devanagari danda (U+0964) and double danda (U+0965) are used for
|
||||
all Indic scripts */
|
||||
if ((pwcInChars[i] == 0x964 || pwcInChars[i] ==0x965) && last_indic > 0)
|
||||
if ((pwcInChars[i] == 0x964 || pwcInChars[i] ==0x965) && last_indic != Script_Undefined)
|
||||
scripts[i] = last_indic;
|
||||
else if (is_indic(scripts[i]))
|
||||
last_indic = base_indic(scripts[i]);
|
||||
|
@ -1338,10 +1338,10 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
|
|||
{
|
||||
int j;
|
||||
BOOL asian = FALSE;
|
||||
WORD first_script = scripts[i-1];
|
||||
enum usp10_script first_script = scripts[i-1];
|
||||
for (j = i-1; j >= 0 && scripts[j] == first_script && pwcInChars[j] != Numeric_space; j--)
|
||||
{
|
||||
WORD original = scripts[j];
|
||||
enum usp10_script original = scripts[j];
|
||||
if (original == Script_Ideograph || original == Script_Kana || original == Script_Yi || original == Script_CJK_Han || original == Script_Bopomofo)
|
||||
{
|
||||
asian = TRUE;
|
||||
|
@ -1877,7 +1877,7 @@ static BOOL requires_fallback(HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void find_fallback_font(DWORD scriptid, LPWSTR FaceName)
|
||||
static void find_fallback_font(enum usp10_script scriptid, WCHAR *FaceName)
|
||||
{
|
||||
HKEY hkey;
|
||||
|
||||
|
@ -2995,14 +2995,13 @@ HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS
|
|||
*/
|
||||
HRESULT WINAPI ScriptIsComplex(const WCHAR *chars, int len, DWORD flag)
|
||||
{
|
||||
int i;
|
||||
INT consumed = 0;
|
||||
enum usp10_script script;
|
||||
unsigned int i, consumed;
|
||||
|
||||
TRACE("(%s,%d,0x%x)\n", debugstr_wn(chars, len), len, flag);
|
||||
|
||||
for (i = 0; i < len; i+=consumed)
|
||||
{
|
||||
int script;
|
||||
if (i >= len)
|
||||
break;
|
||||
|
||||
|
|
|
@ -25,100 +25,104 @@
|
|||
(ULONG)_x1 )
|
||||
|
||||
|
||||
#define Script_Latin 1
|
||||
#define Script_CR 2
|
||||
#define Script_Numeric 3
|
||||
#define Script_Control 4
|
||||
#define Script_Punctuation 5
|
||||
#define Script_Arabic 6
|
||||
#define Script_Arabic_Numeric 7
|
||||
#define Script_Hebrew 8
|
||||
#define Script_Syriac 9
|
||||
#define Script_Persian 10
|
||||
#define Script_Thaana 11
|
||||
#define Script_Greek 12
|
||||
#define Script_Cyrillic 13
|
||||
#define Script_Armenian 14
|
||||
#define Script_Georgian 15
|
||||
/* Unicode Chapter 10 */
|
||||
#define Script_Sinhala 16
|
||||
#define Script_Tibetan 17
|
||||
#define Script_Tibetan_Numeric 18
|
||||
#define Script_Phags_pa 19
|
||||
/* Unicode Chapter 11 */
|
||||
#define Script_Thai 20
|
||||
#define Script_Thai_Numeric 21
|
||||
#define Script_Lao 22
|
||||
#define Script_Lao_Numeric 23
|
||||
/* Unicode Chapter 9 */
|
||||
#define Script_Devanagari 24
|
||||
#define Script_Devanagari_Numeric 25
|
||||
#define Script_Bengali 26
|
||||
#define Script_Bengali_Numeric 27
|
||||
#define Script_Bengali_Currency 28
|
||||
#define Script_Gurmukhi 29
|
||||
#define Script_Gurmukhi_Numeric 30
|
||||
#define Script_Gujarati 31
|
||||
#define Script_Gujarati_Numeric 32
|
||||
#define Script_Gujarati_Currency 33
|
||||
#define Script_Oriya 34
|
||||
#define Script_Oriya_Numeric 35
|
||||
#define Script_Tamil 36
|
||||
#define Script_Tamil_Numeric 37
|
||||
#define Script_Telugu 38
|
||||
#define Script_Telugu_Numeric 39
|
||||
#define Script_Kannada 40
|
||||
#define Script_Kannada_Numeric 41
|
||||
#define Script_Malayalam 42
|
||||
#define Script_Malayalam_Numeric 43
|
||||
/* More supplemental */
|
||||
#define Script_Diacritical 44
|
||||
#define Script_Punctuation2 45
|
||||
#define Script_Numeric2 46
|
||||
/* Unicode Chapter 11 continued */
|
||||
#define Script_Myanmar 47
|
||||
#define Script_Myanmar_Numeric 48
|
||||
#define Script_Tai_Le 49
|
||||
#define Script_New_Tai_Lue 50
|
||||
#define Script_New_Tai_Lue_Numeric 51
|
||||
#define Script_Khmer 52
|
||||
#define Script_Khmer_Numeric 53
|
||||
/* Unicode Chapter 12 */
|
||||
#define Script_CJK_Han 54
|
||||
#define Script_Ideograph 55
|
||||
#define Script_Bopomofo 56
|
||||
#define Script_Kana 57
|
||||
#define Script_Hangul 58
|
||||
#define Script_Yi 59
|
||||
/* Unicode Chapter 13 */
|
||||
#define Script_Ethiopic 60
|
||||
#define Script_Ethiopic_Numeric 61
|
||||
#define Script_Mongolian 62
|
||||
#define Script_Mongolian_Numeric 63
|
||||
#define Script_Tifinagh 64
|
||||
#define Script_NKo 65
|
||||
#define Script_Vai 66
|
||||
#define Script_Vai_Numeric 67
|
||||
#define Script_Cherokee 68
|
||||
#define Script_Canadian 69
|
||||
/* Unicode Chapter 14 */
|
||||
#define Script_Ogham 70
|
||||
#define Script_Runic 71
|
||||
/* Unicode Chapter 15 */
|
||||
#define Script_Braille 72
|
||||
/* Unicode Chapter 16 */
|
||||
#define Script_Surrogates 73
|
||||
#define Script_Private 74
|
||||
/* Unicode Chapter 13 : Plane 1 */
|
||||
#define Script_Deseret 75
|
||||
#define Script_Osmanya 76
|
||||
#define Script_Osmanya_Numeric 77
|
||||
/* Unicode Chapter 15 : Plane 1 */
|
||||
#define Script_MathAlpha 78
|
||||
/* Additional Currency Scripts */
|
||||
#define Script_Hebrew_Currency 79
|
||||
#define Script_Vietnamese_Currency 80
|
||||
#define Script_Thai_Currency 81
|
||||
enum usp10_script
|
||||
{
|
||||
Script_Undefined = 0x00,
|
||||
Script_Latin = 0x01,
|
||||
Script_CR = 0x02,
|
||||
Script_Numeric = 0x03,
|
||||
Script_Control = 0x04,
|
||||
Script_Punctuation = 0x05,
|
||||
Script_Arabic = 0x06,
|
||||
Script_Arabic_Numeric = 0x07,
|
||||
Script_Hebrew = 0x08,
|
||||
Script_Syriac = 0x09,
|
||||
Script_Persian = 0x0a,
|
||||
Script_Thaana = 0x0b,
|
||||
Script_Greek = 0x0c,
|
||||
Script_Cyrillic = 0x0d,
|
||||
Script_Armenian = 0x0e,
|
||||
Script_Georgian = 0x0f,
|
||||
/* Unicode Chapter 10 */
|
||||
Script_Sinhala = 0x10,
|
||||
Script_Tibetan = 0x11,
|
||||
Script_Tibetan_Numeric = 0x12,
|
||||
Script_Phags_pa = 0x13,
|
||||
/* Unicode Chapter 11 */
|
||||
Script_Thai = 0x14,
|
||||
Script_Thai_Numeric = 0x15,
|
||||
Script_Lao = 0x16,
|
||||
Script_Lao_Numeric = 0x17,
|
||||
/* Unicode Chapter 9 */
|
||||
Script_Devanagari = 0x18,
|
||||
Script_Devanagari_Numeric = 0x19,
|
||||
Script_Bengali = 0x1a,
|
||||
Script_Bengali_Numeric = 0x1b,
|
||||
Script_Bengali_Currency = 0x1c,
|
||||
Script_Gurmukhi = 0x1d,
|
||||
Script_Gurmukhi_Numeric = 0x1e,
|
||||
Script_Gujarati = 0x1f,
|
||||
Script_Gujarati_Numeric = 0x20,
|
||||
Script_Gujarati_Currency = 0x21,
|
||||
Script_Oriya = 0x22,
|
||||
Script_Oriya_Numeric = 0x23,
|
||||
Script_Tamil = 0x24,
|
||||
Script_Tamil_Numeric = 0x25,
|
||||
Script_Telugu = 0x26,
|
||||
Script_Telugu_Numeric = 0x27,
|
||||
Script_Kannada = 0x28,
|
||||
Script_Kannada_Numeric = 0x29,
|
||||
Script_Malayalam = 0x2a,
|
||||
Script_Malayalam_Numeric = 0x2b,
|
||||
/* More supplemental */
|
||||
Script_Diacritical = 0x2c,
|
||||
Script_Punctuation2 = 0x2d,
|
||||
Script_Numeric2 = 0x2e,
|
||||
/* Unicode Chapter 11 continued */
|
||||
Script_Myanmar = 0x2f,
|
||||
Script_Myanmar_Numeric = 0x30,
|
||||
Script_Tai_Le = 0x31,
|
||||
Script_New_Tai_Lue = 0x32,
|
||||
Script_New_Tai_Lue_Numeric = 0x33,
|
||||
Script_Khmer = 0x34,
|
||||
Script_Khmer_Numeric = 0x35,
|
||||
/* Unicode Chapter 12 */
|
||||
Script_CJK_Han = 0x36,
|
||||
Script_Ideograph = 0x37,
|
||||
Script_Bopomofo = 0x38,
|
||||
Script_Kana = 0x39,
|
||||
Script_Hangul = 0x3a,
|
||||
Script_Yi = 0x3b,
|
||||
/* Unicode Chapter 13 */
|
||||
Script_Ethiopic = 0x3c,
|
||||
Script_Ethiopic_Numeric = 0x3d,
|
||||
Script_Mongolian = 0x3e,
|
||||
Script_Mongolian_Numeric = 0x3f,
|
||||
Script_Tifinagh = 0x40,
|
||||
Script_NKo = 0x41,
|
||||
Script_Vai = 0x42,
|
||||
Script_Vai_Numeric = 0x43,
|
||||
Script_Cherokee = 0x44,
|
||||
Script_Canadian = 0x45,
|
||||
/* Unicode Chapter 14 */
|
||||
Script_Ogham = 0x46,
|
||||
Script_Runic = 0x47,
|
||||
/* Unicode Chapter 15 */
|
||||
Script_Braille = 0x48,
|
||||
/* Unicode Chapter 16 */
|
||||
Script_Surrogates = 0x49,
|
||||
Script_Private = 0x4a,
|
||||
/* Unicode Chapter 13 : Plane 1 */
|
||||
Script_Deseret = 0x4b,
|
||||
Script_Osmanya = 0x4c,
|
||||
Script_Osmanya_Numeric = 0x4d,
|
||||
/* Unicode Chapter 15 : Plane 1 */
|
||||
Script_MathAlpha = 0x4e,
|
||||
/* Additional Currency Scripts */
|
||||
Script_Hebrew_Currency = 0x4f,
|
||||
Script_Vietnamese_Currency = 0x50,
|
||||
Script_Thai_Currency = 0x51,
|
||||
};
|
||||
|
||||
#define GLYPH_BLOCK_SHIFT 8
|
||||
#define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
|
||||
|
|
Loading…
Reference in New Issue