2 * Copyright © 2018 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
27 #ifndef HB_OT_SHAPE_COMPLEX_KHMER_PRIVATE_HH
28 #define HB_OT_SHAPE_COMPLEX_KHMER_PRIVATE_HH
30 #include "hb-private.hh"
32 #include "hb-ot-shape-complex-indic-private.hh"
35 /* buffer var allocations */
36 #define khmer_category() indic_category() /* khmer_category_t */
37 #define khmer_position() indic_position() /* khmer_position_t */
40 typedef indic_category_t khmer_category_t;
41 typedef indic_position_t khmer_position_t;
44 static inline khmer_position_t
45 matra_position_khmer (khmer_position_t side)
55 return POS_AFTER_POST;
63 is_consonant_or_vowel (const hb_glyph_info_t &info)
65 return is_one_of (info, CONSONANT_FLAGS | FLAG (OT_V));
69 is_coeng (const hb_glyph_info_t &info)
71 return is_one_of (info, FLAG (OT_Coeng));
75 set_khmer_properties (hb_glyph_info_t &info)
77 hb_codepoint_t u = info.codepoint;
78 unsigned int type = hb_indic_get_categories (u);
79 khmer_category_t cat = (khmer_category_t) (type & 0x7Fu);
80 khmer_position_t pos = (khmer_position_t) (type >> 8);
87 if (unlikely (u == 0x17C6u)) cat = OT_N; /* Khmer Bindu doesn't like to be repositioned. */
88 else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x17CDu, 0x17D1u) ||
89 u == 0x17CBu || u == 0x17D3u || u == 0x17DDu)) /* Khmer Various signs */
91 /* These can occur mid-syllable (eg. before matras), even though Unicode marks them as Syllable_Modifier.
92 * https://github.com/roozbehp/unicode-data/issues/5 */
96 else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x2010u, 0x2011u))) cat = OT_PLACEHOLDER;
97 else if (unlikely (u == 0x25CCu)) cat = OT_DOTTEDCIRCLE;
101 * Re-assign position.
104 if ((FLAG_UNSAFE (cat) & CONSONANT_FLAGS))
110 else if (cat == OT_M)
112 pos = matra_position_khmer (pos);
114 else if ((FLAG_UNSAFE (cat) & (FLAG (OT_SM) | FLAG (OT_A) | FLAG (OT_Symbol))))
119 info.khmer_category() = cat;
120 info.khmer_position() = pos;
124 #endif /* HB_OT_SHAPE_COMPLEX_KHMER_PRIVATE_HH */