10 * all copies of this software. 11 * 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 16 * DAMAGE. 17 * 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. 23 * 24 * Google Author(s): Garret Rieger 25 */ 26 27 #ifndef HB_OT_OS2_UNICODE_RANGES_HH 28 #define HB_OT_OS2_UNICODE_RANGES_HH 29 30 #include "hb-private.hh" 31 #include "hb-dsalgs.hh" 32 33 namespace OT { 34 35 struct Range { 36 hb_codepoint_t start; 37 hb_codepoint_t end; 38 unsigned int bit; 39 }; 40 41 /* Note: The contents of this array was generated using src/gen-unicode-ranges.py. */ 42 static Range os2UnicodeRangesSorted[] = 43 { 44 { 0x0, 0x7F, 0}, // Basic Latin 45 { 0x80, 0xFF, 1}, // Latin-1 Supplement 46 { 0x100, 0x17F, 2}, // Latin Extended-A 47 { 0x180, 0x24F, 3}, // Latin Extended-B 48 { 0x250, 0x2AF, 4}, // IPA Extensions 49 { 0x2B0, 0x2FF, 5}, // Spacing Modifier Letters 50 { 0x300, 0x36F, 6}, // Combining Diacritical Marks 51 { 0x370, 0x3FF, 7}, // Greek and Coptic 52 { 0x400, 0x4FF, 9}, // Cyrillic 53 { 0x500, 0x52F, 9}, // Cyrillic Supplement 54 { 0x530, 0x58F, 10}, // Armenian 55 { 0x590, 0x5FF, 11}, // Hebrew 56 { 0x600, 0x6FF, 13}, // Arabic 57 { 0x700, 0x74F, 71}, // Syriac 58 { 0x750, 0x77F, 13}, // Arabic Supplement 59 { 0x780, 0x7BF, 72}, // Thaana 60 { 0x7C0, 0x7FF, 14}, // NKo 61 { 0x900, 0x97F, 15}, // Devanagari 62 { 0x980, 0x9FF, 16}, // Bengali 195 { 0x10920, 0x1093F, 121}, // Lydian 196 { 0x10A00, 0x10A5F, 108}, // Kharoshthi 197 { 0x12000, 0x123FF, 110}, // Cuneiform 198 { 0x12400, 0x1247F, 110}, // Cuneiform Numbers and Punctuation 199 { 0x1D000, 0x1D0FF, 88}, // Byzantine Musical Symbols 200 { 0x1D100, 0x1D1FF, 88}, // Musical Symbols 201 { 0x1D200, 0x1D24F, 88}, // Ancient Greek Musical Notation 202 { 0x1D300, 0x1D35F, 109}, // Tai Xuan Jing Symbols 203 { 0x1D360, 0x1D37F, 111}, // Counting Rod Numerals 204 { 0x1D400, 0x1D7FF, 89}, // Mathematical Alphanumeric Symbols 205 { 0x1F000, 0x1F02F, 122}, // Mahjong Tiles 206 { 0x1F030, 0x1F09F, 122}, // Domino Tiles 207 { 0x20000, 0x2A6DF, 59}, // CJK Unified Ideographs Extension B 208 { 0x2F800, 0x2FA1F, 61}, // CJK Compatibility Ideographs Supplement 209 { 0xE0000, 0xE007F, 92}, // Tags 210 { 0xE0100, 0xE01EF, 91}, // Variation Selectors Supplement 211 { 0xF0000, 0xFFFFD, 90}, // Private Use (plane 15) 212 {0x100000, 0x10FFFD, 90}, // Private Use (plane 16) 213 }; 214 215 static int 216 _compare_range (const void *_key, const void *_item, void *_arg) 217 { 218 hb_codepoint_t cp = *((hb_codepoint_t *) _key); 219 const Range *range = (Range *) _item; 220 221 if (cp < range->start) 222 return -1; 223 else if (cp <= range->end) 224 return 0; 225 else 226 return 1; 227 } 228 229 /** 230 * hb_get_unicode_range_bit: 231 * Returns the bit to be set in os/2 ulUnicodeRange for a given codepoint. 232 **/ 233 static unsigned int 234 hb_get_unicode_range_bit (hb_codepoint_t cp) 235 { 236 Range *range = (Range*) hb_bsearch_r (&cp, os2UnicodeRangesSorted, 237 sizeof (os2UnicodeRangesSorted) / sizeof(Range), 238 sizeof(Range), 239 _compare_range, nullptr); 240 if (range != nullptr) 241 return range->bit; 242 return -1; 243 } 244 245 } /* namespace OT */ 246 247 #endif /* HB_OT_OS2_UNICODE_RANGES_HH */ | 10 * all copies of this software. 11 * 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 16 * DAMAGE. 17 * 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. 23 * 24 * Google Author(s): Garret Rieger 25 */ 26 27 #ifndef HB_OT_OS2_UNICODE_RANGES_HH 28 #define HB_OT_OS2_UNICODE_RANGES_HH 29 30 #include "hb.hh" 31 32 namespace OT { 33 34 struct OS2Range 35 { 36 static int 37 cmp (const void *_key, const void *_item) 38 { 39 hb_codepoint_t cp = *((hb_codepoint_t *) _key); 40 const OS2Range *range = (OS2Range *) _item; 41 42 if (cp < range->start) 43 return -1; 44 else if (cp <= range->end) 45 return 0; 46 else 47 return +1; 48 } 49 50 hb_codepoint_t start; 51 hb_codepoint_t end; 52 unsigned int bit; 53 }; 54 55 /* Note: The contents of this array was generated using gen-os2-unicode-ranges.py. */ 56 static const OS2Range _hb_os2_unicode_ranges[] = 57 { 58 { 0x0, 0x7F, 0}, // Basic Latin 59 { 0x80, 0xFF, 1}, // Latin-1 Supplement 60 { 0x100, 0x17F, 2}, // Latin Extended-A 61 { 0x180, 0x24F, 3}, // Latin Extended-B 62 { 0x250, 0x2AF, 4}, // IPA Extensions 63 { 0x2B0, 0x2FF, 5}, // Spacing Modifier Letters 64 { 0x300, 0x36F, 6}, // Combining Diacritical Marks 65 { 0x370, 0x3FF, 7}, // Greek and Coptic 66 { 0x400, 0x4FF, 9}, // Cyrillic 67 { 0x500, 0x52F, 9}, // Cyrillic Supplement 68 { 0x530, 0x58F, 10}, // Armenian 69 { 0x590, 0x5FF, 11}, // Hebrew 70 { 0x600, 0x6FF, 13}, // Arabic 71 { 0x700, 0x74F, 71}, // Syriac 72 { 0x750, 0x77F, 13}, // Arabic Supplement 73 { 0x780, 0x7BF, 72}, // Thaana 74 { 0x7C0, 0x7FF, 14}, // NKo 75 { 0x900, 0x97F, 15}, // Devanagari 76 { 0x980, 0x9FF, 16}, // Bengali 209 { 0x10920, 0x1093F, 121}, // Lydian 210 { 0x10A00, 0x10A5F, 108}, // Kharoshthi 211 { 0x12000, 0x123FF, 110}, // Cuneiform 212 { 0x12400, 0x1247F, 110}, // Cuneiform Numbers and Punctuation 213 { 0x1D000, 0x1D0FF, 88}, // Byzantine Musical Symbols 214 { 0x1D100, 0x1D1FF, 88}, // Musical Symbols 215 { 0x1D200, 0x1D24F, 88}, // Ancient Greek Musical Notation 216 { 0x1D300, 0x1D35F, 109}, // Tai Xuan Jing Symbols 217 { 0x1D360, 0x1D37F, 111}, // Counting Rod Numerals 218 { 0x1D400, 0x1D7FF, 89}, // Mathematical Alphanumeric Symbols 219 { 0x1F000, 0x1F02F, 122}, // Mahjong Tiles 220 { 0x1F030, 0x1F09F, 122}, // Domino Tiles 221 { 0x20000, 0x2A6DF, 59}, // CJK Unified Ideographs Extension B 222 { 0x2F800, 0x2FA1F, 61}, // CJK Compatibility Ideographs Supplement 223 { 0xE0000, 0xE007F, 92}, // Tags 224 { 0xE0100, 0xE01EF, 91}, // Variation Selectors Supplement 225 { 0xF0000, 0xFFFFD, 90}, // Private Use (plane 15) 226 {0x100000, 0x10FFFD, 90}, // Private Use (plane 16) 227 }; 228 229 /** 230 * _hb_ot_os2_get_unicode_range_bit: 231 * Returns the bit to be set in os/2 ulUnicodeOS2Range for a given codepoint. 232 **/ 233 static unsigned int 234 _hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp) 235 { 236 OS2Range *range = (OS2Range*) hb_bsearch (&cp, _hb_os2_unicode_ranges, 237 ARRAY_LENGTH (_hb_os2_unicode_ranges), 238 sizeof (OS2Range), 239 OS2Range::cmp); 240 if (range != nullptr) 241 return range->bit; 242 return -1; 243 } 244 245 } /* namespace OT */ 246 247 #endif /* HB_OT_OS2_UNICODE_RANGES_HH */ |