Add hb_unicode_combining_class_t

This commit is contained in:
Behdad Esfahbod 2012-08-01 16:23:44 -04:00
parent 84186a6400
commit 21fdcee001
6 changed files with 134 additions and 49 deletions

View File

@ -141,47 +141,11 @@ hb_language_t
hb_language_get_default (void); hb_language_get_default (void);
/* hb_unicode_general_category_t */
typedef enum
{
HB_UNICODE_GENERAL_CATEGORY_CONTROL, /* Cc */
HB_UNICODE_GENERAL_CATEGORY_FORMAT, /* Cf */
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, /* Cn */
HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, /* Co */
HB_UNICODE_GENERAL_CATEGORY_SURROGATE, /* Cs */
HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, /* Ll */
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, /* Lm */
HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, /* Lo */
HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, /* Lt */
HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, /* Lu */
HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, /* Mc */
HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, /* Me */
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, /* Mn */
HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, /* Nd */
HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, /* Nl */
HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, /* No */
HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, /* Pc */
HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, /* Pd */
HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, /* Pe */
HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, /* Pf */
HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, /* Pi */
HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, /* Po */
HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, /* Ps */
HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, /* Sc */
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, /* Sk */
HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, /* Sm */
HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL, /* So */
HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, /* Zl */
HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, /* Zp */
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR /* Zs */
} hb_unicode_general_category_t;
/* hb_script_t */ /* hb_script_t */
/* http://unicode.org/iso15924/ */ /* http://unicode.org/iso15924/ */
/* http://goo.gl/x9ilM */ /* http://goo.gl/x9ilM */
/* Unicode Character Database property: Script (sc) */
typedef enum typedef enum
{ {
/* Unicode-1.1 additions */ /* Unicode-1.1 additions */

View File

@ -192,13 +192,13 @@ hb_glib_script_from_script (hb_script_t script)
} }
static unsigned int static hb_unicode_combining_class_t
hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode, hb_codepoint_t unicode,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return g_unichar_combining_class (unicode); return (hb_unicode_combining_class_t) g_unichar_combining_class (unicode);
} }
static unsigned int static unsigned int

View File

@ -63,13 +63,13 @@ hb_icu_script_from_script (hb_script_t script)
} }
static unsigned int static hb_unicode_combining_class_t
hb_icu_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, hb_icu_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode, hb_codepoint_t unicode,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return u_getCombiningClass (unicode); return (hb_unicode_combining_class_t) u_getCombiningClass (unicode);
} }
static unsigned int static unsigned int

View File

@ -55,7 +55,7 @@
/* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */ /* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \ #define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
HB_UNICODE_FUNC_IMPLEMENT (unsigned int, combining_class) \ HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width) \ HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width) \
HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \ HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \
HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \ HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \

View File

@ -38,12 +38,12 @@
* hb_unicode_funcs_t * hb_unicode_funcs_t
*/ */
static unsigned int static hb_unicode_combining_class_t
hb_unicode_combining_class_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED, hb_unicode_combining_class_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode HB_UNUSED, hb_codepoint_t unicode HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return 0; return HB_UNICODE_COMBINING_CLASS_NOT_REORDERED;
} }
static unsigned int static unsigned int
@ -354,11 +354,11 @@ _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
*/ */
c = c == 33 ? 27 : c + 1; c = c == 33 ? 27 : c + 1;
} }
else if (unlikely (hb_in_range<int> (c, 10, 25))) else if (unlikely (hb_in_range<int> (c, 10, 26)))
{ {
/* The equivalent fix for Hebrew is more complex. /* The equivalent fix for Hebrew is more complex.
* *
* We permute the "fixed-position" classes 10-25 into the order * We permute the "fixed-position" classes 10-26 into the order
* described in the SBL Hebrew manual: * described in the SBL Hebrew manual:
* *
* http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf * http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
@ -369,7 +369,7 @@ _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
* More details here: * More details here:
* https://bugzilla.mozilla.org/show_bug.cgi?id=662055 * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
*/ */
static const int permuted_hebrew_classes[25 - 10 + 1] = { static const int permuted_hebrew_classes[26 - 10 + 1] = {
/* 10 sheva */ 22, /* 10 sheva */ 22,
/* 11 hataf segol */ 15, /* 11 hataf segol */ 15,
/* 12 hataf patah */ 16, /* 12 hataf patah */ 16,
@ -386,6 +386,7 @@ _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
/* 23 rafe */ 13, /* 23 rafe */ 13,
/* 24 shin dot */ 10, /* 24 shin dot */ 10,
/* 25 sin dot */ 11, /* 25 sin dot */ 11,
/* 26 point varika */ 26,
}; };
c = permuted_hebrew_classes[c - 10]; c = permuted_hebrew_classes[c - 10];
} }

View File

@ -40,6 +40,126 @@
HB_BEGIN_DECLS HB_BEGIN_DECLS
/* hb_unicode_general_category_t */
/* Unicode Character Database property: General_Category (gc) */
typedef enum
{
HB_UNICODE_GENERAL_CATEGORY_CONTROL, /* Cc */
HB_UNICODE_GENERAL_CATEGORY_FORMAT, /* Cf */
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, /* Cn */
HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, /* Co */
HB_UNICODE_GENERAL_CATEGORY_SURROGATE, /* Cs */
HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, /* Ll */
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, /* Lm */
HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, /* Lo */
HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, /* Lt */
HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, /* Lu */
HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, /* Mc */
HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, /* Me */
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, /* Mn */
HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, /* Nd */
HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, /* Nl */
HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, /* No */
HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, /* Pc */
HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, /* Pd */
HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, /* Pe */
HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, /* Pf */
HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, /* Pi */
HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, /* Po */
HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, /* Ps */
HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, /* Sc */
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, /* Sk */
HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, /* Sm */
HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL, /* So */
HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, /* Zl */
HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, /* Zp */
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR /* Zs */
} hb_unicode_general_category_t;
/* hb_unicode_combining_class_t */
/* Unicode Character Database property: Canonical_Combining_Class (ccc) */
typedef enum
{
HB_UNICODE_COMBINING_CLASS_NOT_REORDERED = 0,
HB_UNICODE_COMBINING_CLASS_OVERLAY = 1,
HB_UNICODE_COMBINING_CLASS_NUKTA = 7,
HB_UNICODE_COMBINING_CLASS_KANA_VOICING = 8,
HB_UNICODE_COMBINING_CLASS_VIRAMA = 9,
/* Hebrew */
HB_UNICODE_COMBINING_CLASS_CCC10 = 10,
HB_UNICODE_COMBINING_CLASS_CCC11 = 11,
HB_UNICODE_COMBINING_CLASS_CCC12 = 12,
HB_UNICODE_COMBINING_CLASS_CCC13 = 13,
HB_UNICODE_COMBINING_CLASS_CCC14 = 14,
HB_UNICODE_COMBINING_CLASS_CCC15 = 15,
HB_UNICODE_COMBINING_CLASS_CCC16 = 16,
HB_UNICODE_COMBINING_CLASS_CCC17 = 17,
HB_UNICODE_COMBINING_CLASS_CCC18 = 18,
HB_UNICODE_COMBINING_CLASS_CCC19 = 19,
HB_UNICODE_COMBINING_CLASS_CCC20 = 20,
HB_UNICODE_COMBINING_CLASS_CCC21 = 21,
HB_UNICODE_COMBINING_CLASS_CCC22 = 22,
HB_UNICODE_COMBINING_CLASS_CCC23 = 23,
HB_UNICODE_COMBINING_CLASS_CCC24 = 24,
HB_UNICODE_COMBINING_CLASS_CCC25 = 25,
HB_UNICODE_COMBINING_CLASS_CCC26 = 26,
/* Arabic */
HB_UNICODE_COMBINING_CLASS_CCC27 = 27,
HB_UNICODE_COMBINING_CLASS_CCC28 = 28,
HB_UNICODE_COMBINING_CLASS_CCC29 = 29,
HB_UNICODE_COMBINING_CLASS_CCC30 = 30,
HB_UNICODE_COMBINING_CLASS_CCC31 = 31,
HB_UNICODE_COMBINING_CLASS_CCC32 = 32,
HB_UNICODE_COMBINING_CLASS_CCC33 = 33,
HB_UNICODE_COMBINING_CLASS_CCC34 = 34,
HB_UNICODE_COMBINING_CLASS_CCC35 = 35,
/* Syriac */
HB_UNICODE_COMBINING_CLASS_CCC36 = 36,
/* Telugu */
HB_UNICODE_COMBINING_CLASS_CCC84 = 84,
HB_UNICODE_COMBINING_CLASS_CCC91 = 91,
/* Thai */
HB_UNICODE_COMBINING_CLASS_CCC103 = 103,
HB_UNICODE_COMBINING_CLASS_CCC107 = 107,
/* Lao */
HB_UNICODE_COMBINING_CLASS_CCC118 = 118,
HB_UNICODE_COMBINING_CLASS_CCC122 = 122,
/* Tibetan */
HB_UNICODE_COMBINING_CLASS_CCC129 = 129,
HB_UNICODE_COMBINING_CLASS_CCC130 = 130,
HB_UNICODE_COMBINING_CLASS_CCC133 = 132,
HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT = 200,
HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW = 202,
HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE = 214,
HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE_RIGHT = 216,
HB_UNICODE_COMBINING_CLASS_BELOW_LEFT = 218,
HB_UNICODE_COMBINING_CLASS_BELOW = 220,
HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT = 222,
HB_UNICODE_COMBINING_CLASS_LEFT = 224,
HB_UNICODE_COMBINING_CLASS_RIGHT = 226,
HB_UNICODE_COMBINING_CLASS_ABOVE_LEFT = 228,
HB_UNICODE_COMBINING_CLASS_ABOVE = 230,
HB_UNICODE_COMBINING_CLASS_ABOVE_RIGHT = 232,
HB_UNICODE_COMBINING_CLASS_DOUBLE_BELOW = 233,
HB_UNICODE_COMBINING_CLASS_DOUBLE_ABOVE = 234,
HB_UNICODE_COMBINING_CLASS_IOTA_SUBSCRIPT = 240,
HB_UNICODE_COMBINING_CLASS_INVALID = 255
} hb_unicode_combining_class_t;
/* /*
* hb_unicode_funcs_t * hb_unicode_funcs_t
*/ */
@ -95,7 +215,7 @@ hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs);
/* typedefs */ /* typedefs */
typedef unsigned int (*hb_unicode_combining_class_func_t) (hb_unicode_funcs_t *ufuncs, typedef hb_unicode_combining_class_t (*hb_unicode_combining_class_func_t) (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode, hb_codepoint_t unicode,
void *user_data); void *user_data);
typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs, typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs,
@ -192,7 +312,7 @@ hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs,
/* accessors */ /* accessors */
unsigned int hb_unicode_combining_class_t
hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs, hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode); hb_codepoint_t unicode);