Coverage Report

Created: 2025-08-24 06:26

/src/harfbuzz/src/hb-unicode.hh
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2009  Red Hat, Inc.
3
 * Copyright © 2011  Codethink Limited
4
 * Copyright © 2010,2011,2012  Google, Inc.
5
 *
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
31
#ifndef HB_UNICODE_HH
32
#define HB_UNICODE_HH
33
34
#include "hb.hh"
35
36
37
extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256];
38
39
/*
40
 * hb_unicode_funcs_t
41
 */
42
43
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS \
44
1
  HB_UNICODE_FUNC_IMPLEMENT (combining_class) \
45
1
  HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (eastasian_width)) \
46
1
  HB_UNICODE_FUNC_IMPLEMENT (general_category) \
47
1
  HB_UNICODE_FUNC_IMPLEMENT (mirroring) \
48
1
  HB_UNICODE_FUNC_IMPLEMENT (script) \
49
1
  HB_UNICODE_FUNC_IMPLEMENT (compose) \
50
1
  HB_UNICODE_FUNC_IMPLEMENT (decompose) \
51
1
  HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility)) \
52
  /* ^--- Add new callbacks here */
53
54
/* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */
55
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
56
  HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
57
  HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width)) \
58
  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
63
struct hb_unicode_funcs_t
64
{
65
  hb_object_header_t header;
66
67
  hb_unicode_funcs_t *parent;
68
69
#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
70
1.96M
  return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
hb_unicode_funcs_t::script(unsigned int)
Line
Count
Source
70
982k
  return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
hb_unicode_funcs_t::combining_class(unsigned int)
Line
Count
Source
70
71
  return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
hb_unicode_funcs_t::general_category(unsigned int)
Line
Count
Source
70
979k
  return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
hb_unicode_funcs_t::mirroring(unsigned int)
Line
Count
Source
70
32
  return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
71
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
72
#undef HB_UNICODE_FUNC_IMPLEMENT
73
74
  hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b,
75
         hb_codepoint_t *ab)
76
68
  {
77
68
    *ab = 0;
78
68
    if (unlikely (!a || !b)) return false;
79
68
    return func.compose (this, a, b, ab, user_data.compose);
80
68
  }
81
82
  hb_bool_t decompose (hb_codepoint_t ab,
83
           hb_codepoint_t *a, hb_codepoint_t *b)
84
28.1k
  {
85
28.1k
    *a = ab; *b = 0;
86
28.1k
    return func.decompose (this, ab, a, b, user_data.decompose);
87
28.1k
  }
88
89
  unsigned int decompose_compatibility (hb_codepoint_t  u,
90
          hb_codepoint_t *decomposed)
91
0
  {
92
#ifdef HB_DISABLE_DEPRECATED
93
    unsigned int ret  = 0;
94
#else
95
0
    unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility);
96
0
#endif
97
0
    if (ret == 1 && u == decomposed[0]) {
98
0
      decomposed[0] = 0;
99
0
      return 0;
100
0
    }
101
0
    decomposed[ret] = 0;
102
0
    return ret;
103
0
  }
104
105
  unsigned int
106
  modified_combining_class (hb_codepoint_t u)
107
71
  {
108
    /* Reorder SAKOT to ensure it comes after any tone marks. */
109
71
    if (unlikely (u == 0x1A60u)) return 254;
110
    /* Reorder PADMA to ensure it comes after any vowel marks. */
111
71
    if (unlikely (u == 0x0FC6u)) return 254;
112
    /* Reorder TSA -PHRU to reorder before U+0F74 */
113
71
    if (unlikely (u == 0x0F39u)) return 127;
114
115
71
    return _hb_modified_combining_class[combining_class (u)];
116
71
  }
117
118
  static hb_bool_t
119
  is_variation_selector (hb_codepoint_t unicode)
120
136
  {
121
    /* U+180B..180D, U+180F MONGOLIAN FREE VARIATION SELECTORs are handled in the
122
     * Arabic shaper.  No need to match them here. */
123
136
    return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
124
136
               0xFE00u, 0xFE0Fu, /* VARIATION SELECTOR-1..16 */
125
136
               0xE0100u, 0xE01EFu));  /* VARIATION SELECTOR-17..256 */
126
136
  }
127
128
  /* Default_Ignorable codepoints:
129
   *
130
   * Note: While U+115F, U+1160, U+3164 and U+FFA0 are Default_Ignorable,
131
   * we do NOT want to hide them, as the way Uniscribe has implemented them
132
   * is with regular spacing glyphs, and that's the way fonts are made to work.
133
   * As such, we make exceptions for those four.
134
   * Also ignoring U+1BCA0..1BCA3. https://github.com/harfbuzz/harfbuzz/issues/503
135
   *
136
   * Unicode 14.0:
137
   * $ grep '; Default_Ignorable_Code_Point ' DerivedCoreProperties.txt | sed 's/;.*#/#/'
138
   * 00AD          # Cf       SOFT HYPHEN
139
   * 034F          # Mn       COMBINING GRAPHEME JOINER
140
   * 061C          # Cf       ARABIC LETTER MARK
141
   * 115F..1160    # Lo   [2] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG FILLER
142
   * 17B4..17B5    # Mn   [2] KHMER VOWEL INHERENT AQ..KHMER VOWEL INHERENT AA
143
   * 180B..180D    # Mn   [3] MONGOLIAN FREE VARIATION SELECTOR ONE..MONGOLIAN FREE VARIATION SELECTOR THREE
144
   * 180E          # Cf       MONGOLIAN VOWEL SEPARATOR
145
   * 180F          # Mn       MONGOLIAN FREE VARIATION SELECTOR FOUR
146
   * 200B..200F    # Cf   [5] ZERO WIDTH SPACE..RIGHT-TO-LEFT MARK
147
   * 202A..202E    # Cf   [5] LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
148
   * 2060..2064    # Cf   [5] WORD JOINER..INVISIBLE PLUS
149
   * 2065          # Cn       <reserved-2065>
150
   * 2066..206F    # Cf  [10] LEFT-TO-RIGHT ISOLATE..NOMINAL DIGIT SHAPES
151
   * 3164          # Lo       HANGUL FILLER
152
   * FE00..FE0F    # Mn  [16] VARIATION SELECTOR-1..VARIATION SELECTOR-16
153
   * FEFF          # Cf       ZERO WIDTH NO-BREAK SPACE
154
   * FFA0          # Lo       HALFWIDTH HANGUL FILLER
155
   * FFF0..FFF8    # Cn   [9] <reserved-FFF0>..<reserved-FFF8>
156
   * 1BCA0..1BCA3  # Cf   [4] SHORTHAND FORMAT LETTER OVERLAP..SHORTHAND FORMAT UP STEP
157
   * 1D173..1D17A  # Cf   [8] MUSICAL SYMBOL BEGIN BEAM..MUSICAL SYMBOL END PHRASE
158
   * E0000         # Cn       <reserved-E0000>
159
   * E0001         # Cf       LANGUAGE TAG
160
   * E0002..E001F  # Cn  [30] <reserved-E0002>..<reserved-E001F>
161
   * E0020..E007F  # Cf  [96] TAG SPACE..CANCEL TAG
162
   * E0080..E00FF  # Cn [128] <reserved-E0080>..<reserved-E00FF>
163
   * E0100..E01EF  # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
164
   * E01F0..E0FFF  # Cn [3600] <reserved-E01F0>..<reserved-E0FFF>
165
   */
166
  static hb_bool_t
167
  is_default_ignorable (hb_codepoint_t ch)
168
125k
  {
169
125k
    hb_codepoint_t plane = ch >> 16;
170
125k
    if (likely (plane == 0))
171
122k
    {
172
      /* BMP */
173
122k
      hb_codepoint_t page = ch >> 8;
174
122k
      switch (page) {
175
122k
  case 0x00: return unlikely (ch == 0x00ADu);
176
36
  case 0x03: return unlikely (ch == 0x034Fu);
177
0
  case 0x06: return unlikely (ch == 0x061Cu);
178
0
  case 0x17: return hb_in_range<hb_codepoint_t> (ch, 0x17B4u, 0x17B5u);
179
0
  case 0x18: return hb_in_range<hb_codepoint_t> (ch, 0x180Bu, 0x180Eu);
180
70
  case 0x20: return hb_in_ranges<hb_codepoint_t> (ch, 0x200Bu, 0x200Fu,
181
70
              0x202Au, 0x202Eu,
182
70
              0x2060u, 0x206Fu);
183
3
  case 0xFE: return hb_in_range<hb_codepoint_t> (ch, 0xFE00u, 0xFE0Fu) || ch == 0xFEFFu;
184
41
  case 0xFF: return hb_in_range<hb_codepoint_t> (ch, 0xFFF0u, 0xFFF8u);
185
595
  default: return false;
186
122k
      }
187
122k
    }
188
2.39k
    else
189
2.39k
    {
190
      /* Other planes */
191
2.39k
      switch (plane) {
192
0
  case 0x01: return hb_in_range<hb_codepoint_t> (ch, 0x1D173u, 0x1D17Au);
193
2.30k
  case 0x0E: return hb_in_range<hb_codepoint_t> (ch, 0xE0000u, 0xE0FFFu);
194
95
  default: return false;
195
2.39k
      }
196
2.39k
    }
197
125k
  }
198
199
  /* Space estimates based on:
200
   * https://unicode.org/charts/PDF/U2000.pdf
201
   * https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace
202
   */
203
  enum space_t {
204
    NOT_SPACE = 0,
205
    SPACE_EM   = 1,
206
    SPACE_EM_2 = 2,
207
    SPACE_EM_3 = 3,
208
    SPACE_EM_4 = 4,
209
    SPACE_EM_5 = 5,
210
    SPACE_EM_6 = 6,
211
    SPACE_EM_16 = 16,
212
    SPACE_4_EM_18,  /* 4/18th of an EM! */
213
    SPACE,
214
    SPACE_FIGURE,
215
    SPACE_PUNCTUATION,
216
    SPACE_NARROW,
217
  };
218
  static space_t
219
  space_fallback_type (hb_codepoint_t u)
220
0
  {
221
0
    switch (u)
222
0
    {
223
      /* All GC=Zs chars that can use a fallback. */
224
0
      default:      return NOT_SPACE; /* U+1680 OGHAM SPACE MARK */
225
0
      case 0x0020u: return SPACE; /* U+0020 SPACE */
226
0
      case 0x00A0u: return SPACE; /* U+00A0 NO-BREAK SPACE */
227
0
      case 0x2000u: return SPACE_EM_2; /* U+2000 EN QUAD */
228
0
      case 0x2001u: return SPACE_EM; /* U+2001 EM QUAD */
229
0
      case 0x2002u: return SPACE_EM_2; /* U+2002 EN SPACE */
230
0
      case 0x2003u: return SPACE_EM; /* U+2003 EM SPACE */
231
0
      case 0x2004u: return SPACE_EM_3; /* U+2004 THREE-PER-EM SPACE */
232
0
      case 0x2005u: return SPACE_EM_4; /* U+2005 FOUR-PER-EM SPACE */
233
0
      case 0x2006u: return SPACE_EM_6; /* U+2006 SIX-PER-EM SPACE */
234
0
      case 0x2007u: return SPACE_FIGURE; /* U+2007 FIGURE SPACE */
235
0
      case 0x2008u: return SPACE_PUNCTUATION; /* U+2008 PUNCTUATION SPACE */
236
0
      case 0x2009u: return SPACE_EM_5;   /* U+2009 THIN SPACE */
237
0
      case 0x200Au: return SPACE_EM_16;   /* U+200A HAIR SPACE */
238
0
      case 0x202Fu: return SPACE_NARROW; /* U+202F NARROW NO-BREAK SPACE */
239
0
      case 0x205Fu: return SPACE_4_EM_18; /* U+205F MEDIUM MATHEMATICAL SPACE */
240
0
      case 0x3000u: return SPACE_EM;   /* U+3000 IDEOGRAPHIC SPACE */
241
0
    }
242
0
  }
243
244
  static hb_codepoint_t
245
  vertical_char_for (hb_codepoint_t u)
246
0
  {
247
0
    switch (u >> 8)
248
0
    {
249
0
      case 0x20: switch (u) {
250
0
  case 0x2013u: return 0xfe32u; // EN DASH
251
0
  case 0x2014u: return 0xfe31u; // EM DASH
252
0
  case 0x2025u: return 0xfe30u; // TWO DOT LEADER
253
0
  case 0x2026u: return 0xfe19u; // HORIZONTAL ELLIPSIS
254
0
      } break;
255
0
      case 0x30: switch (u) {
256
0
  case 0x3001u: return 0xfe11u; // IDEOGRAPHIC COMMA
257
0
  case 0x3002u: return 0xfe12u; // IDEOGRAPHIC FULL STOP
258
0
  case 0x3008u: return 0xfe3fu; // LEFT ANGLE BRACKET
259
0
  case 0x3009u: return 0xfe40u; // RIGHT ANGLE BRACKET
260
0
  case 0x300au: return 0xfe3du; // LEFT DOUBLE ANGLE BRACKET
261
0
  case 0x300bu: return 0xfe3eu; // RIGHT DOUBLE ANGLE BRACKET
262
0
  case 0x300cu: return 0xfe41u; // LEFT CORNER BRACKET
263
0
  case 0x300du: return 0xfe42u; // RIGHT CORNER BRACKET
264
0
  case 0x300eu: return 0xfe43u; // LEFT WHITE CORNER BRACKET
265
0
  case 0x300fu: return 0xfe44u; // RIGHT WHITE CORNER BRACKET
266
0
  case 0x3010u: return 0xfe3bu; // LEFT BLACK LENTICULAR BRACKET
267
0
  case 0x3011u: return 0xfe3cu; // RIGHT BLACK LENTICULAR BRACKET
268
0
  case 0x3014u: return 0xfe39u; // LEFT TORTOISE SHELL BRACKET
269
0
  case 0x3015u: return 0xfe3au; // RIGHT TORTOISE SHELL BRACKET
270
0
  case 0x3016u: return 0xfe17u; // LEFT WHITE LENTICULAR BRACKET
271
0
  case 0x3017u: return 0xfe18u; // RIGHT WHITE LENTICULAR BRACKET
272
0
      } break;
273
0
      case 0xfe: switch (u) {
274
0
  case 0xfe4fu: return 0xfe34u; // WAVY LOW LINE
275
0
      } break;
276
0
      case 0xff: switch (u) {
277
0
  case 0xff01u: return 0xfe15u; // FULLWIDTH EXCLAMATION MARK
278
0
  case 0xff08u: return 0xfe35u; // FULLWIDTH LEFT PARENTHESIS
279
0
  case 0xff09u: return 0xfe36u; // FULLWIDTH RIGHT PARENTHESIS
280
0
  case 0xff0cu: return 0xfe10u; // FULLWIDTH COMMA
281
0
  case 0xff1au: return 0xfe13u; // FULLWIDTH COLON
282
0
  case 0xff1bu: return 0xfe14u; // FULLWIDTH SEMICOLON
283
0
  case 0xff1fu: return 0xfe16u; // FULLWIDTH QUESTION MARK
284
0
  case 0xff3bu: return 0xfe47u; // FULLWIDTH LEFT SQUARE BRACKET
285
0
  case 0xff3du: return 0xfe48u; // FULLWIDTH RIGHT SQUARE BRACKET
286
0
  case 0xff3fu: return 0xfe33u; // FULLWIDTH LOW LINE
287
0
  case 0xff5bu: return 0xfe37u; // FULLWIDTH LEFT CURLY BRACKET
288
0
  case 0xff5du: return 0xfe38u; // FULLWIDTH RIGHT CURLY BRACKET
289
0
      } break;
290
0
    }
291
292
0
    return u;
293
0
  }
294
295
  struct {
296
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name;
297
    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
298
#undef HB_UNICODE_FUNC_IMPLEMENT
299
  } func;
300
301
  struct {
302
#define HB_UNICODE_FUNC_IMPLEMENT(name) void *name;
303
    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
304
#undef HB_UNICODE_FUNC_IMPLEMENT
305
  } user_data;
306
307
  struct {
308
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
309
    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
310
#undef HB_UNICODE_FUNC_IMPLEMENT
311
  } destroy;
312
};
313
DECLARE_NULL_INSTANCE (hb_unicode_funcs_t);
314
315
316
/*
317
 * Modified combining marks
318
 */
319
320
/* Hebrew
321
 *
322
 * We permute the "fixed-position" classes 10-26 into the order
323
 * described in the SBL Hebrew manual:
324
 *
325
 * https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
326
 *
327
 * (as recommended by:
328
 *  https://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering/msg22823/)
329
 *
330
 * More details here:
331
 * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
332
 */
333
0
#define HB_MODIFIED_COMBINING_CLASS_CCC10 22 /* sheva */
334
0
#define HB_MODIFIED_COMBINING_CLASS_CCC11 15 /* hataf segol */
335
0
#define HB_MODIFIED_COMBINING_CLASS_CCC12 16 /* hataf patah */
336
0
#define HB_MODIFIED_COMBINING_CLASS_CCC13 17 /* hataf qamats */
337
0
#define HB_MODIFIED_COMBINING_CLASS_CCC14 23 /* hiriq */
338
0
#define HB_MODIFIED_COMBINING_CLASS_CCC15 18 /* tsere */
339
0
#define HB_MODIFIED_COMBINING_CLASS_CCC16 19 /* segol */
340
0
#define HB_MODIFIED_COMBINING_CLASS_CCC17 20 /* patah */
341
0
#define HB_MODIFIED_COMBINING_CLASS_CCC18 21 /* qamats & qamats qatan */
342
0
#define HB_MODIFIED_COMBINING_CLASS_CCC19 14 /* holam & holam haser for vav*/
343
0
#define HB_MODIFIED_COMBINING_CLASS_CCC20 24 /* qubuts */
344
0
#define HB_MODIFIED_COMBINING_CLASS_CCC21 12 /* dagesh */
345
0
#define HB_MODIFIED_COMBINING_CLASS_CCC22 25 /* meteg */
346
0
#define HB_MODIFIED_COMBINING_CLASS_CCC23 13 /* rafe */
347
0
#define HB_MODIFIED_COMBINING_CLASS_CCC24 10 /* shin dot */
348
0
#define HB_MODIFIED_COMBINING_CLASS_CCC25 11 /* sin dot */
349
0
#define HB_MODIFIED_COMBINING_CLASS_CCC26 26 /* point varika */
350
351
/*
352
 * Arabic
353
 *
354
 * Modify to move Shadda (ccc=33) before other marks.  See:
355
 * https://unicode.org/faq/normalization.html#8
356
 * https://unicode.org/faq/normalization.html#9
357
 */
358
0
#define HB_MODIFIED_COMBINING_CLASS_CCC27 28 /* fathatan */
359
0
#define HB_MODIFIED_COMBINING_CLASS_CCC28 29 /* dammatan */
360
0
#define HB_MODIFIED_COMBINING_CLASS_CCC29 30 /* kasratan */
361
0
#define HB_MODIFIED_COMBINING_CLASS_CCC30 31 /* fatha */
362
0
#define HB_MODIFIED_COMBINING_CLASS_CCC31 32 /* damma */
363
0
#define HB_MODIFIED_COMBINING_CLASS_CCC32 33 /* kasra */
364
0
#define HB_MODIFIED_COMBINING_CLASS_CCC33 27 /* shadda */
365
0
#define HB_MODIFIED_COMBINING_CLASS_CCC34 34 /* sukun */
366
0
#define HB_MODIFIED_COMBINING_CLASS_CCC35 35 /* superscript alef */
367
368
/* Syriac */
369
0
#define HB_MODIFIED_COMBINING_CLASS_CCC36 36 /* superscript alaph */
370
371
/* Telugu
372
 *
373
 * Modify Telugu length marks (ccc=84, ccc=91).
374
 * These are the only matras in the main Indic scripts range that have
375
 * a non-zero ccc.  That makes them reorder with the Halant (ccc=9).
376
 * Assign 4 and 5, which are otherwise unassigned.
377
 */
378
#define HB_MODIFIED_COMBINING_CLASS_CCC84 4 /* length mark */
379
#define HB_MODIFIED_COMBINING_CLASS_CCC91 5 /* ai length mark */
380
381
/* Thai
382
 *
383
 * Modify U+0E38 and U+0E39 (ccc=103) to be reordered before U+0E3A (ccc=9).
384
 * Assign 3, which is unassigned otherwise.
385
 * Uniscribe does this reordering too.
386
 */
387
0
#define HB_MODIFIED_COMBINING_CLASS_CCC103 3 /* sara u / sara uu */
388
0
#define HB_MODIFIED_COMBINING_CLASS_CCC107 107 /* mai * */
389
390
/* Lao */
391
0
#define HB_MODIFIED_COMBINING_CLASS_CCC118 118 /* sign u / sign uu */
392
0
#define HB_MODIFIED_COMBINING_CLASS_CCC122 122 /* mai * */
393
394
/* Tibetan
395
 *
396
 * In case of multiple vowel-signs, use u first (but after achung)
397
 * this allows Dzongkha multi-vowel shortcuts to render correctly
398
 */
399
0
#define HB_MODIFIED_COMBINING_CLASS_CCC129 129 /* sign aa */
400
0
#define HB_MODIFIED_COMBINING_CLASS_CCC130 132 /* sign i */
401
0
#define HB_MODIFIED_COMBINING_CLASS_CCC132 131 /* sign u */
402
403
/* Misc */
404
405
#define HB_UNICODE_GENERAL_CATEGORY_IS_MARK(gen_cat) \
406
857k
  (FLAG_UNSAFE (gen_cat) & \
407
857k
   (FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) | \
408
857k
    FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | \
409
857k
    FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
410
411
#define HB_UNICODE_GENERAL_CATEGORY_IS_LETTER(gen_cat) \
412
99
  (FLAG_UNSAFE (gen_cat) & \
413
99
   (FLAG (HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) | \
414
99
    FLAG (HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER) | \
415
99
    FLAG (HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER) | \
416
99
    FLAG (HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER) | \
417
99
    FLAG (HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER)))
418
419
/*
420
 * Ranges, used for bsearch tables.
421
 */
422
423
struct hb_unicode_range_t
424
{
425
  static int
426
  cmp (const void *_key, const void *_item)
427
0
  {
428
0
    hb_codepoint_t cp = *((hb_codepoint_t *) _key);
429
0
    const hb_unicode_range_t *range = (hb_unicode_range_t *) _item;
430
0
431
0
    if (cp < range->start)
432
0
      return -1;
433
0
    else if (cp <= range->end)
434
0
      return 0;
435
0
    else
436
0
      return +1;
437
0
  }
438
439
  hb_codepoint_t start;
440
  hb_codepoint_t end;
441
};
442
443
/*
444
 * Emoji.
445
 */
446
447
HB_INTERNAL bool
448
_hb_unicode_is_emoji_Extended_Pictographic (hb_codepoint_t cp);
449
450
451
extern "C" HB_INTERNAL hb_unicode_funcs_t *hb_ucd_get_unicode_funcs ();
452
453
454
#endif /* HB_UNICODE_HH */