blob: 4c28bb0cdfa523dae06ecea35e14e8ad6acfd78e [file] [log] [blame]
Behdad Esfahbodfb194b82011-04-20 02:00:47 -04001/*
Behdad Esfahbod2409d5f2011-04-21 17:14:28 -04002 * Copyright © 2009 Red Hat, Inc.
Behdad Esfahbod6af9cff2011-04-29 12:00:38 -04003 * Copyright © 2011 Codethink Limited
Behdad Esfahbod6adf4172012-08-01 18:07:42 -04004 * Copyright © 2010,2011,2012 Google, Inc.
Behdad Esfahbodfb194b82011-04-20 02:00:47 -04005 *
6 * This is part of HarfBuzz, a text shaping library.
7 *
8 * Permission is hereby granted, without written agreement and without
9 * license or royalty fees, to use, copy, modify, and distribute this
10 * software and its documentation for any purpose, provided that the
11 * above copyright notice and the following two paragraphs appear in
12 * all copies of this software.
13 *
14 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * DAMAGE.
19 *
20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 *
26 * Red Hat Author(s): Behdad Esfahbod
27 * Codethink Author(s): Ryan Lortie
28 * Google Author(s): Behdad Esfahbod
29 */
30
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070031#ifndef HB_UNICODE_HH
32#define HB_UNICODE_HH
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040033
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070034#include "hb.hh"
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040035
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040036
Behdad Esfahbod6adf4172012-08-01 18:07:42 -040037extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256];
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040038
39/*
40 * hb_unicode_funcs_t
41 */
42
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -040043#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS \
Behdad Esfahbod891c4752011-07-07 23:19:27 -040044 HB_UNICODE_FUNC_IMPLEMENT (combining_class) \
Behdad Esfahbodfca27862019-05-11 00:37:01 -070045 HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (eastasian_width)) \
Behdad Esfahbod891c4752011-07-07 23:19:27 -040046 HB_UNICODE_FUNC_IMPLEMENT (general_category) \
47 HB_UNICODE_FUNC_IMPLEMENT (mirroring) \
48 HB_UNICODE_FUNC_IMPLEMENT (script) \
Behdad Esfahbodc4641722011-07-07 23:47:19 -040049 HB_UNICODE_FUNC_IMPLEMENT (compose) \
50 HB_UNICODE_FUNC_IMPLEMENT (decompose) \
Behdad Esfahbodfca27862019-05-11 00:37:01 -070051 HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility)) \
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -040052 /* ^--- Add new callbacks here */
53
Behdad Esfahbod891c4752011-07-07 23:19:27 -040054/* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */
55#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
Behdad Esfahbod21fdcee2012-08-01 16:23:44 -040056 HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
Behdad Esfahbodfca27862019-05-11 00:37:01 -070057 HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width)) \
Behdad Esfahbod891c4752011-07-07 23:19:27 -040058 HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \
59 HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \
60 HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \
61 /* ^--- Add new simple callbacks here */
62
Behdad Esfahbod35066722018-08-06 06:17:48 -070063struct hb_unicode_funcs_t
64{
Behdad Esfahbodfca368c2011-04-21 18:24:02 -040065 hb_object_header_t header;
66
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040067 hb_unicode_funcs_t *parent;
68
Behdad Esfahbod74703152012-08-01 17:01:59 -040069#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033070 return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
Behdad Esfahbod74703152012-08-01 17:01:59 -040071HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
72#undef HB_UNICODE_FUNC_IMPLEMENT
73
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033074 hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b,
75 hb_codepoint_t *ab)
Behdad Esfahbod74703152012-08-01 17:01:59 -040076 {
77 *ab = 0;
Behdad Esfahbodd5045a52012-08-11 21:26:25 -040078 if (unlikely (!a || !b)) return false;
Behdad Esfahbod0f8881d2012-08-07 16:57:02 -040079 return func.compose (this, a, b, ab, user_data.compose);
Behdad Esfahbod74703152012-08-01 17:01:59 -040080 }
81
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033082 hb_bool_t decompose (hb_codepoint_t ab,
83 hb_codepoint_t *a, hb_codepoint_t *b)
Behdad Esfahbod74703152012-08-01 17:01:59 -040084 {
Behdad Esfahbodd5045a52012-08-11 21:26:25 -040085 *a = ab; *b = 0;
Behdad Esfahbod74703152012-08-01 17:01:59 -040086 return func.decompose (this, ab, a, b, user_data.decompose);
87 }
88
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033089 unsigned int decompose_compatibility (hb_codepoint_t u,
90 hb_codepoint_t *decomposed)
Behdad Esfahbod74703152012-08-01 17:01:59 -040091 {
Behdad Esfahbodfca27862019-05-11 00:37:01 -070092#ifdef HB_DISABLE_DEPRECATED
93 unsigned int ret = 0;
94#else
Behdad Esfahbod74703152012-08-01 17:01:59 -040095 unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility);
Behdad Esfahbodfca27862019-05-11 00:37:01 -070096#endif
Behdad Esfahbod74703152012-08-01 17:01:59 -040097 if (ret == 1 && u == decomposed[0]) {
98 decomposed[0] = 0;
99 return 0;
100 }
101 decomposed[ret] = 0;
102 return ret;
103 }
104
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330105 unsigned int
Behdad Esfahbod01b91482018-09-14 14:23:09 +0200106 modified_combining_class (hb_codepoint_t u)
Behdad Esfahbod6adf4172012-08-01 18:07:42 -0400107 {
Behdad Esfahboda252ad62017-10-04 13:07:08 +0200108 /* XXX This hack belongs to the USE shaper (for Tai Tham):
Behdad Esfahbod15f67042013-12-27 19:33:28 -0500109 * Reorder SAKOT to ensure it comes after any tone marks. */
Behdad Esfahbod01b91482018-09-14 14:23:09 +0200110 if (unlikely (u == 0x1A60u)) return 254;
Behdad Esfahbod1c8654e2013-02-11 14:27:02 -0500111
Behdad Esfahbod9c941182014-04-28 12:38:25 -0700112 /* XXX This hack belongs to the Tibetan shaper:
113 * Reorder PADMA to ensure it comes after any vowel marks. */
Behdad Esfahbod01b91482018-09-14 14:23:09 +0200114 if (unlikely (u == 0x0FC6u)) return 254;
Behdad Esfahbod2f560ee2016-04-27 03:11:41 -0700115 /* Reorder TSA -PHRU to reorder before U+0F74 */
Behdad Esfahbod01b91482018-09-14 14:23:09 +0200116 if (unlikely (u == 0x0F39u)) return 127;
Behdad Esfahbod9c941182014-04-28 12:38:25 -0700117
Behdad Esfahbod01b91482018-09-14 14:23:09 +0200118 return _hb_modified_combining_class[combining_class (u)];
Behdad Esfahbod6adf4172012-08-01 18:07:42 -0400119 }
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400120
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330121 static hb_bool_t
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400122 is_variation_selector (hb_codepoint_t unicode)
123 {
David Corbett8c654422021-09-25 16:38:32 -0400124 /* U+180B..180D, U+180F MONGOLIAN FREE VARIATION SELECTORs are handled in the
Behdad Esfahbod164c13d2014-07-17 14:16:38 -0400125 * Arabic shaper. No need to match them here. */
Ebrahim Byagowi3b0e47c2017-06-19 14:47:09 +0430126 return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330127 0xFE00u, 0xFE0Fu, /* VARIATION SELECTOR-1..16 */
128 0xE0100u, 0xE01EFu)); /* VARIATION SELECTOR-17..256 */
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400129 }
130
Behdad Esfahbodcf3afd82012-10-25 16:32:54 -0700131 /* Default_Ignorable codepoints:
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400132 *
Jonathan Kew391934d2014-01-20 10:37:32 +0000133 * Note: While U+115F, U+1160, U+3164 and U+FFA0 are Default_Ignorable,
134 * we do NOT want to hide them, as the way Uniscribe has implemented them
135 * is with regular spacing glyphs, and that's the way fonts are made to work.
136 * As such, we make exceptions for those four.
ebraminio7c6937e2017-11-20 14:49:22 -0500137 * Also ignoring U+1BCA0..1BCA3. https://github.com/harfbuzz/harfbuzz/issues/503
Behdad Esfahbodcc50bf52013-03-19 06:59:40 -0400138 *
David Corbett4645c3b2021-10-07 08:52:02 -0400139 * Unicode 14.0:
Behdad Esfahbod577ca482014-06-18 12:29:23 -0400140 * $ grep '; Default_Ignorable_Code_Point ' DerivedCoreProperties.txt | sed 's/;.*#/#/'
141 * 00AD # Cf SOFT HYPHEN
142 * 034F # Mn COMBINING GRAPHEME JOINER
143 * 061C # Cf ARABIC LETTER MARK
144 * 115F..1160 # Lo [2] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG FILLER
145 * 17B4..17B5 # Mn [2] KHMER VOWEL INHERENT AQ..KHMER VOWEL INHERENT AA
146 * 180B..180D # Mn [3] MONGOLIAN FREE VARIATION SELECTOR ONE..MONGOLIAN FREE VARIATION SELECTOR THREE
147 * 180E # Cf MONGOLIAN VOWEL SEPARATOR
David Corbett4645c3b2021-10-07 08:52:02 -0400148 * 180F # Mn MONGOLIAN FREE VARIATION SELECTOR FOUR
Behdad Esfahbod577ca482014-06-18 12:29:23 -0400149 * 200B..200F # Cf [5] ZERO WIDTH SPACE..RIGHT-TO-LEFT MARK
150 * 202A..202E # Cf [5] LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
151 * 2060..2064 # Cf [5] WORD JOINER..INVISIBLE PLUS
152 * 2065 # Cn <reserved-2065>
153 * 2066..206F # Cf [10] LEFT-TO-RIGHT ISOLATE..NOMINAL DIGIT SHAPES
154 * 3164 # Lo HANGUL FILLER
155 * FE00..FE0F # Mn [16] VARIATION SELECTOR-1..VARIATION SELECTOR-16
156 * FEFF # Cf ZERO WIDTH NO-BREAK SPACE
157 * FFA0 # Lo HALFWIDTH HANGUL FILLER
158 * FFF0..FFF8 # Cn [9] <reserved-FFF0>..<reserved-FFF8>
159 * 1BCA0..1BCA3 # Cf [4] SHORTHAND FORMAT LETTER OVERLAP..SHORTHAND FORMAT UP STEP
160 * 1D173..1D17A # Cf [8] MUSICAL SYMBOL BEGIN BEAM..MUSICAL SYMBOL END PHRASE
161 * E0000 # Cn <reserved-E0000>
162 * E0001 # Cf LANGUAGE TAG
163 * E0002..E001F # Cn [30] <reserved-E0002>..<reserved-E001F>
164 * E0020..E007F # Cf [96] TAG SPACE..CANCEL TAG
165 * E0080..E00FF # Cn [128] <reserved-E0080>..<reserved-E00FF>
166 * E0100..E01EF # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
167 * E01F0..E0FFF # Cn [3600] <reserved-E01F0>..<reserved-E0FFF>
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400168 */
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330169 static hb_bool_t
Behdad Esfahbodcf3afd82012-10-25 16:32:54 -0700170 is_default_ignorable (hb_codepoint_t ch)
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400171 {
Behdad Esfahbodcf3afd82012-10-25 16:32:54 -0700172 hb_codepoint_t plane = ch >> 16;
173 if (likely (plane == 0))
174 {
175 /* BMP */
176 hb_codepoint_t page = ch >> 8;
177 switch (page) {
Behdad Esfahbod76271002014-07-11 14:54:42 -0400178 case 0x00: return unlikely (ch == 0x00ADu);
179 case 0x03: return unlikely (ch == 0x034Fu);
180 case 0x06: return unlikely (ch == 0x061Cu);
Ebrahim Byagowi3b0e47c2017-06-19 14:47:09 +0430181 case 0x17: return hb_in_range<hb_codepoint_t> (ch, 0x17B4u, 0x17B5u);
182 case 0x18: return hb_in_range<hb_codepoint_t> (ch, 0x180Bu, 0x180Eu);
183 case 0x20: return hb_in_ranges<hb_codepoint_t> (ch, 0x200Bu, 0x200Fu,
Behdad Esfahbodf80c34e2016-07-12 11:18:26 -0700184 0x202Au, 0x202Eu,
185 0x2060u, 0x206Fu);
Ebrahim Byagowi3b0e47c2017-06-19 14:47:09 +0430186 case 0xFE: return hb_in_range<hb_codepoint_t> (ch, 0xFE00u, 0xFE0Fu) || ch == 0xFEFFu;
187 case 0xFF: return hb_in_range<hb_codepoint_t> (ch, 0xFFF0u, 0xFFF8u);
Behdad Esfahbodcf3afd82012-10-25 16:32:54 -0700188 default: return false;
189 }
190 }
191 else
192 {
193 /* Other planes */
194 switch (plane) {
Behdad Esfahbodd695cac2017-10-04 11:33:47 +0200195 case 0x01: return hb_in_range<hb_codepoint_t> (ch, 0x1D173u, 0x1D17Au);
Ebrahim Byagowi3b0e47c2017-06-19 14:47:09 +0430196 case 0x0E: return hb_in_range<hb_codepoint_t> (ch, 0xE0000u, 0xE0FFFu);
Behdad Esfahbodcf3afd82012-10-25 16:32:54 -0700197 default: return false;
198 }
199 }
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400200 }
201
Behdad Esfahbod49ef6302015-11-04 17:27:07 -0800202 /* Space estimates based on:
Ebrahim Byagowif24b0b92018-04-12 13:40:45 +0430203 * https://unicode.org/charts/PDF/U2000.pdf
204 * https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace
Behdad Esfahbod49ef6302015-11-04 17:27:07 -0800205 */
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800206 enum space_t {
207 NOT_SPACE = 0,
Behdad Esfahbod49ef6302015-11-04 17:27:07 -0800208 SPACE_EM = 1,
209 SPACE_EM_2 = 2,
210 SPACE_EM_3 = 3,
211 SPACE_EM_4 = 4,
212 SPACE_EM_5 = 5,
213 SPACE_EM_6 = 6,
214 SPACE_EM_16 = 16,
215 SPACE_4_EM_18, /* 4/18th of an EM! */
216 SPACE,
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800217 SPACE_FIGURE,
218 SPACE_PUNCTUATION,
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800219 SPACE_NARROW,
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800220 };
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330221 static space_t
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800222 space_fallback_type (hb_codepoint_t u)
223 {
224 switch (u)
225 {
226 /* All GC=Zs chars that can use a fallback. */
Behdad Esfahbod3e104602016-03-11 18:45:19 -0800227 default: return NOT_SPACE; /* U+1680 OGHAM SPACE MARK */
Behdad Esfahbod49ef6302015-11-04 17:27:07 -0800228 case 0x0020u: return SPACE; /* U+0020 SPACE */
229 case 0x00A0u: return SPACE; /* U+00A0 NO-BREAK SPACE */
230 case 0x2000u: return SPACE_EM_2; /* U+2000 EN QUAD */
231 case 0x2001u: return SPACE_EM; /* U+2001 EM QUAD */
232 case 0x2002u: return SPACE_EM_2; /* U+2002 EN SPACE */
233 case 0x2003u: return SPACE_EM; /* U+2003 EM SPACE */
234 case 0x2004u: return SPACE_EM_3; /* U+2004 THREE-PER-EM SPACE */
235 case 0x2005u: return SPACE_EM_4; /* U+2005 FOUR-PER-EM SPACE */
236 case 0x2006u: return SPACE_EM_6; /* U+2006 SIX-PER-EM SPACE */
237 case 0x2007u: return SPACE_FIGURE; /* U+2007 FIGURE SPACE */
238 case 0x2008u: return SPACE_PUNCTUATION; /* U+2008 PUNCTUATION SPACE */
239 case 0x2009u: return SPACE_EM_5; /* U+2009 THIN SPACE */
240 case 0x200Au: return SPACE_EM_16; /* U+200A HAIR SPACE */
241 case 0x202Fu: return SPACE_NARROW; /* U+202F NARROW NO-BREAK SPACE */
242 case 0x205Fu: return SPACE_4_EM_18; /* U+205F MEDIUM MATHEMATICAL SPACE */
243 case 0x3000u: return SPACE_EM; /* U+3000 IDEOGRAPHIC SPACE */
Behdad Esfahbod7793aad2015-11-04 14:48:46 -0800244 }
245 }
Behdad Esfahbod208f70f2012-08-01 17:13:10 -0400246
Behdad Esfahbodfb194b82011-04-20 02:00:47 -0400247 struct {
Behdad Esfahbodc4641722011-07-07 23:47:19 -0400248#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name;
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -0400249 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
250#undef HB_UNICODE_FUNC_IMPLEMENT
Behdad Esfahbodc4641722011-07-07 23:47:19 -0400251 } func;
Behdad Esfahbodfb194b82011-04-20 02:00:47 -0400252
253 struct {
Behdad Esfahbod891c4752011-07-07 23:19:27 -0400254#define HB_UNICODE_FUNC_IMPLEMENT(name) void *name;
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -0400255 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
256#undef HB_UNICODE_FUNC_IMPLEMENT
Behdad Esfahbodfb194b82011-04-20 02:00:47 -0400257 } user_data;
258
259 struct {
Behdad Esfahbod891c4752011-07-07 23:19:27 -0400260#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -0400261 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
262#undef HB_UNICODE_FUNC_IMPLEMENT
Behdad Esfahbodfb194b82011-04-20 02:00:47 -0400263 } destroy;
264};
Behdad Esfahbod35066722018-08-06 06:17:48 -0700265DECLARE_NULL_INSTANCE (hb_unicode_funcs_t);
Behdad Esfahbodd4bee9f2011-04-27 09:24:37 -0400266
Behdad Esfahbodfb194b82011-04-20 02:00:47 -0400267
Behdad Esfahbod1e8f1952018-10-03 17:46:48 +0200268/*
269 * Modified combining marks
270 */
Behdad Esfahbod21756932012-08-08 01:20:45 -0400271
272/* Hebrew
273 *
274 * We permute the "fixed-position" classes 10-26 into the order
275 * described in the SBL Hebrew manual:
276 *
Ebrahim Byagowif24b0b92018-04-12 13:40:45 +0430277 * https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
Behdad Esfahbod21756932012-08-08 01:20:45 -0400278 *
279 * (as recommended by:
Ebrahim Byagowif24b0b92018-04-12 13:40:45 +0430280 * https://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering/msg22823/)
Behdad Esfahbod21756932012-08-08 01:20:45 -0400281 *
282 * More details here:
283 * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
284 */
285#define HB_MODIFIED_COMBINING_CLASS_CCC10 22 /* sheva */
286#define HB_MODIFIED_COMBINING_CLASS_CCC11 15 /* hataf segol */
287#define HB_MODIFIED_COMBINING_CLASS_CCC12 16 /* hataf patah */
288#define HB_MODIFIED_COMBINING_CLASS_CCC13 17 /* hataf qamats */
289#define HB_MODIFIED_COMBINING_CLASS_CCC14 23 /* hiriq */
290#define HB_MODIFIED_COMBINING_CLASS_CCC15 18 /* tsere */
291#define HB_MODIFIED_COMBINING_CLASS_CCC16 19 /* segol */
292#define HB_MODIFIED_COMBINING_CLASS_CCC17 20 /* patah */
Ben Denckla43d95522021-04-12 14:01:56 -0400293#define HB_MODIFIED_COMBINING_CLASS_CCC18 21 /* qamats & qamats qatan */
294#define HB_MODIFIED_COMBINING_CLASS_CCC19 14 /* holam & holam haser for vav*/
Behdad Esfahbod21756932012-08-08 01:20:45 -0400295#define HB_MODIFIED_COMBINING_CLASS_CCC20 24 /* qubuts */
296#define HB_MODIFIED_COMBINING_CLASS_CCC21 12 /* dagesh */
297#define HB_MODIFIED_COMBINING_CLASS_CCC22 25 /* meteg */
298#define HB_MODIFIED_COMBINING_CLASS_CCC23 13 /* rafe */
299#define HB_MODIFIED_COMBINING_CLASS_CCC24 10 /* shin dot */
300#define HB_MODIFIED_COMBINING_CLASS_CCC25 11 /* sin dot */
301#define HB_MODIFIED_COMBINING_CLASS_CCC26 26 /* point varika */
302
303/*
304 * Arabic
305 *
306 * Modify to move Shadda (ccc=33) before other marks. See:
Ebrahim Byagowif24b0b92018-04-12 13:40:45 +0430307 * https://unicode.org/faq/normalization.html#8
308 * https://unicode.org/faq/normalization.html#9
Behdad Esfahbod21756932012-08-08 01:20:45 -0400309 */
310#define HB_MODIFIED_COMBINING_CLASS_CCC27 28 /* fathatan */
311#define HB_MODIFIED_COMBINING_CLASS_CCC28 29 /* dammatan */
312#define HB_MODIFIED_COMBINING_CLASS_CCC29 30 /* kasratan */
313#define HB_MODIFIED_COMBINING_CLASS_CCC30 31 /* fatha */
314#define HB_MODIFIED_COMBINING_CLASS_CCC31 32 /* damma */
315#define HB_MODIFIED_COMBINING_CLASS_CCC32 33 /* kasra */
316#define HB_MODIFIED_COMBINING_CLASS_CCC33 27 /* shadda */
317#define HB_MODIFIED_COMBINING_CLASS_CCC34 34 /* sukun */
318#define HB_MODIFIED_COMBINING_CLASS_CCC35 35 /* superscript alef */
319
320/* Syriac */
321#define HB_MODIFIED_COMBINING_CLASS_CCC36 36 /* superscript alaph */
322
323/* Telugu
324 *
325 * Modify Telugu length marks (ccc=84, ccc=91).
326 * These are the only matras in the main Indic scripts range that have
David Corbettd6cb2442019-06-15 21:38:27 -0400327 * a non-zero ccc. That makes them reorder with the Halant (ccc=9).
David Corbett76c27462019-11-19 16:51:33 -0500328 * Assign 4 and 5, which are otherwise unassigned.
Behdad Esfahbod21756932012-08-08 01:20:45 -0400329 */
David Corbett76c27462019-11-19 16:51:33 -0500330#define HB_MODIFIED_COMBINING_CLASS_CCC84 4 /* length mark */
331#define HB_MODIFIED_COMBINING_CLASS_CCC91 5 /* ai length mark */
Behdad Esfahbod21756932012-08-08 01:20:45 -0400332
333/* Thai
334 *
Behdad Esfahbod56c9e7c2012-08-09 21:12:30 -0400335 * Modify U+0E38 and U+0E39 (ccc=103) to be reordered before U+0E3A (ccc=9).
336 * Assign 3, which is unassigned otherwise.
337 * Uniscribe does this reordering too.
Behdad Esfahbod21756932012-08-08 01:20:45 -0400338 */
339#define HB_MODIFIED_COMBINING_CLASS_CCC103 3 /* sara u / sara uu */
340#define HB_MODIFIED_COMBINING_CLASS_CCC107 107 /* mai * */
341
342/* Lao */
343#define HB_MODIFIED_COMBINING_CLASS_CCC118 118 /* sign u / sign uu */
344#define HB_MODIFIED_COMBINING_CLASS_CCC122 122 /* mai * */
345
Behdad Esfahbod2f560ee2016-04-27 03:11:41 -0700346/* Tibetan
Ebrahim Byagowif24b0b92018-04-12 13:40:45 +0430347 *
348 * In case of multiple vowel-signs, use u first (but after achung)
349 * this allows Dzongkha multi-vowel shortcuts to render correctly
Behdad Esfahbod2f560ee2016-04-27 03:11:41 -0700350 */
Behdad Esfahbod21756932012-08-08 01:20:45 -0400351#define HB_MODIFIED_COMBINING_CLASS_CCC129 129 /* sign aa */
Dominik Schlösser4e21ec52017-07-14 13:14:23 +0200352#define HB_MODIFIED_COMBINING_CLASS_CCC130 132 /* sign i */
353#define HB_MODIFIED_COMBINING_CLASS_CCC132 131 /* sign u */
Behdad Esfahbod21756932012-08-08 01:20:45 -0400354
Behdad Esfahbod028a1702012-09-06 14:25:48 -0400355/* Misc */
356
357#define HB_UNICODE_GENERAL_CATEGORY_IS_MARK(gen_cat) \
Behdad Esfahbod6058f982017-10-19 11:39:52 -0700358 (FLAG_UNSAFE (gen_cat) & \
Behdad Esfahbod028a1702012-09-06 14:25:48 -0400359 (FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) | \
360 FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | \
361 FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
362
Khaled Hosnyc3be28e2021-06-23 17:39:23 +0200363#define HB_UNICODE_GENERAL_CATEGORY_IS_LETTER(gen_cat) \
364 (FLAG_UNSAFE (gen_cat) & \
365 (FLAG (HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) | \
366 FLAG (HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER) | \
367 FLAG (HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER) | \
368 FLAG (HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER) | \
369 FLAG (HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER)))
Behdad Esfahbod1e8f1952018-10-03 17:46:48 +0200370
371/*
372 * Ranges, used for bsearch tables.
373 */
374
375struct hb_unicode_range_t
376{
377 static int
Behdad Esfahbod69f5da02018-10-23 20:30:40 -0700378 cmp (const void *_key, const void *_item)
Behdad Esfahbod1e8f1952018-10-03 17:46:48 +0200379 {
380 hb_codepoint_t cp = *((hb_codepoint_t *) _key);
381 const hb_unicode_range_t *range = (hb_unicode_range_t *) _item;
382
383 if (cp < range->start)
384 return -1;
385 else if (cp <= range->end)
386 return 0;
387 else
388 return +1;
389 }
390
391 hb_codepoint_t start;
392 hb_codepoint_t end;
393};
394
395/*
396 * Emoji.
397 */
398
399HB_INTERNAL bool
400_hb_unicode_is_emoji_Extended_Pictographic (hb_codepoint_t cp);
401
402
Behdad Esfahbodceb4c212019-07-02 16:02:13 -0700403extern "C" HB_INTERNAL hb_unicode_funcs_t *hb_ucd_get_unicode_funcs ();
404
405
Behdad Esfahbodc77ae402018-08-25 22:36:36 -0700406#endif /* HB_UNICODE_HH */