2 Port from c++ is protected by a GNU Lesser GPLv3
3 Copyright © 2013 Sylvain BERTRAND <sylvain.bertrand@gmail.com>
9 #include "hb-private.h"
10 #include "hb-atomic-private.h"
11 #include "hb-unicode-private.h"
13 static hb_unicode_combining_class_t
14 hb_unicode_combining_class_nil(hb_unicode_funcs_t
* ufuncs HB_UNUSED
,
15 hb_codepoint_t unicode HB_UNUSED
,
16 void *user_data HB_UNUSED
)
18 return HB_UNICODE_COMBINING_CLASS_NOT_REORDERED
;
21 static unsigned int hb_unicode_eastasian_width_nil(hb_unicode_funcs_t
*
23 hb_codepoint_t unicode
25 void *user_data HB_UNUSED
)
30 static hb_unicode_general_category_t
31 hb_unicode_general_category_nil(hb_unicode_funcs_t
* ufuncs HB_UNUSED
,
32 hb_codepoint_t unicode HB_UNUSED
,
33 void *user_data HB_UNUSED
)
35 return HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER
;
38 static hb_codepoint_t
hb_unicode_mirroring_nil(hb_unicode_funcs_t
*
40 hb_codepoint_t unicode HB_UNUSED
,
41 void *user_data HB_UNUSED
)
46 static hb_script_t
hb_unicode_script_nil(hb_unicode_funcs_t
* ufuncs HB_UNUSED
,
47 hb_codepoint_t unicode HB_UNUSED
,
48 void *user_data HB_UNUSED
)
50 return HB_SCRIPT_UNKNOWN
;
53 static hb_bool_t
hb_unicode_compose_nil(hb_unicode_funcs_t
* ufuncs HB_UNUSED
,
54 hb_codepoint_t a HB_UNUSED
,
55 hb_codepoint_t b HB_UNUSED
,
56 hb_codepoint_t
* ab HB_UNUSED
,
57 void *user_data HB_UNUSED
)
62 static hb_bool_t
hb_unicode_decompose_nil(hb_unicode_funcs_t
* ufuncs HB_UNUSED
,
63 hb_codepoint_t ab HB_UNUSED
,
64 hb_codepoint_t
* a HB_UNUSED
,
65 hb_codepoint_t
* b HB_UNUSED
,
66 void *user_data HB_UNUSED
)
71 static unsigned int hb_unicode_decompose_compatibility_nil(hb_unicode_funcs_t
*
84 hb_unicode_funcs_t _hb_unicode_funcs_nil
= {
85 REF_CNT_INVALID_VAL
, /*ref_cnt */
89 hb_unicode_combining_class_nil
,
90 hb_unicode_eastasian_width_nil
,
91 hb_unicode_general_category_nil
,
92 hb_unicode_mirroring_nil
,
93 hb_unicode_script_nil
,
94 hb_unicode_compose_nil
,
95 hb_unicode_decompose_nil
,
96 hb_unicode_decompose_compatibility_nil
}
99 NULL
, /*combining_class */
100 NULL
, /*eastasian_width */
101 NULL
, /*general_category */
106 NULL
/*decompose_compatibility */
110 NULL
, /*combining_class */
111 NULL
, /*eastasian_width */
112 NULL
, /*general_category */
117 NULL
/*decompose_compatibility */
122 Default_Ignorable codepoints:
124 Note that as of Oct 2012 (Unicode 6.2), U+180E MONGOLIAN VOWEL SEPARATOR
125 is NOT Default_Ignorable, but it really behaves in a way that it should
126 be. That has been reported to the Unicode Technical Committee for
127 consideration. As such, we include it here, since Uniscribe removes it.
128 It *is* in Unicode 6.3 however. U+061C ARABIC LETTER MARK from Unicode
129 6.3 is also added manually. The new Unicode 6.3 bidi formatting
130 characters are encoded in a block that was Default_Ignorable already.
132 Note: While U+115F and U+1160 are Default_Ignorable, we do NOT want to
133 hide them, as the way Uniscribe has implemented them is with regular
134 spacing glyphs, and that's the way fonts are made to work. As such,
135 we make exceptions for those two.
138 http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:DI:]&abb=on&ucd=on&esc=on
140 Last updated to the page with the following versions:
141 Version 3.6; ICU version: 50.0.1.0; Unicode version: 6.1.0.0
145 [\u00AD\u034F\u115F\u1160\u17B4\u17B5\u180B-\u180D\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\U0001D173-\U0001D17A\U000E0000-\U000E0FFF]
148 034F ;COMBINING GRAPHEME JOINER
149 #115F ;HANGUL CHOSEONG FILLER
150 #1160 ;HANGUL JUNGSEONG FILLER
151 17B4 ;KHMER VOWEL INHERENT AQ
152 17B5 ;KHMER VOWEL INHERENT AA
153 180B..180D ;MONGOLIAN FREE VARIATION SELECTOR THREE
154 200B..200F ;RIGHT-TO-LEFT MARK
155 202A..202E ;RIGHT-TO-LEFT OVERRIDE
156 2060..206F ;NOMINAL DIGIT SHAPES
158 FE00..FE0F ;VARIATION SELECTOR-16
159 FEFF ;ZERO WIDTH NO-BREAK SPACE
160 FFA0 ;HALFWIDTH HANGUL FILLER
161 FFF0..FFF8 ;<unassigned-FFF8>
162 1D173..1D17A ;MUSICAL SYMBOL END PHRASE
163 E0000..E0FFF ;<unassigned-E0FFF>
166 hb_bool_t
hb_unicode_is_default_ignorable(hb_codepoint_t ch
)
168 hb_codepoint_t plane
;
173 /*BMP*/ page
= ch
>> 8;
182 return hb_codepoint_in_range(ch
, 0x17B4, 0x17B5);
184 return hb_codepoint_in_range(ch
, 0x180B, 0x180E);
186 return hb_codepoint_in_ranges(ch
, 0x200B, 0x200F,
187 0x202A, 0x202E, 0x2060,
192 return hb_codepoint_in_range(ch
, 0xFE00, 0xFE0F)
195 return hb_codepoint_in_range(ch
, 0xFFF0, 0xFFF8)
204 return hb_codepoint_in_range(ch
, 0x0001D173,
207 return hb_codepoint_in_range(ch
, 0x000E0000,
215 hb_unicode_funcs_t
*hb_unicode_funcs_get_empty(void)
217 return &_hb_unicode_funcs_nil
;
220 hb_unicode_funcs_t
*hb_unicode_funcs_reference(hb_unicode_funcs_t
* ufuncs
)
222 if (hb_atomic_int32_get(&ufuncs
->ref_cnt
) != REF_CNT_INVALID_VAL
)
223 hb_atomic_int32_add(&ufuncs
->ref_cnt
, 1);
227 extern hb_unicode_funcs_t
*hb_glib_get_unicode_funcs(void);
228 extern hb_unicode_funcs_t
*hb_nil_get_unicode_funcs(void);
230 hb_unicode_funcs_t
*hb_unicode_funcs_get_default(void)
233 return hb_glib_get_unicode_funcs();
235 return hb_unicode_funcs_get_empty();
239 void hb_unicode_funcs_destroy(hb_unicode_funcs_t
* ufuncs
)
243 if (hb_atomic_int32_get(&ufuncs
->ref_cnt
) == REF_CNT_INVALID_VAL
)
245 hb_atomic_int32_add(&ufuncs
->ref_cnt
, -1);
246 if (hb_atomic_int32_get(&ufuncs
->ref_cnt
) > 0)
248 hb_atomic_int32_set(&ufuncs
->ref_cnt
, REF_CNT_INVALID_VAL
);
250 if (ufuncs
->destroy
.combining_class
)
251 ufuncs
->destroy
.combining_class(ufuncs
->user_data
.
253 if (ufuncs
->destroy
.eastasian_width
)
254 ufuncs
->destroy
.eastasian_width(ufuncs
->user_data
.
256 if (ufuncs
->destroy
.general_category
)
257 ufuncs
->destroy
.general_category(ufuncs
->user_data
.
259 if (ufuncs
->destroy
.mirroring
)
260 ufuncs
->destroy
.mirroring(ufuncs
->user_data
.mirroring
);
261 if (ufuncs
->destroy
.script
)
262 ufuncs
->destroy
.script(ufuncs
->user_data
.script
);
263 if (ufuncs
->destroy
.compose
)
264 ufuncs
->destroy
.compose(ufuncs
->user_data
.compose
);
265 if (ufuncs
->destroy
.decompose
)
266 ufuncs
->destroy
.decompose(ufuncs
->user_data
.decompose
);
267 if (ufuncs
->destroy
.decompose_compatibility
)
268 ufuncs
->destroy
.decompose_compatibility(ufuncs
->user_data
.
269 decompose_compatibility
);
271 hb_unicode_funcs_destroy(ufuncs
->parent
);