hb-ot-shape-complex-private.hh revision 3361c9a323575309d9fd55fe076697a3e22073c0
149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod/* 2359dcaa0d33271025ca42a5f54ecbac7ae3b56d3Behdad Esfahbod * Copyright © 2010,2011 Google, Inc. 349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * Permission is hereby granted, without written agreement and without 749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * software and its documentation for any purpose, provided that the 949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 1049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * all copies of this software. 1149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 1249baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * DAMAGE. 1749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 1849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 2049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 2149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 2249baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 2349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 2449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * Google Author(s): Behdad Esfahbod 2549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod */ 2649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 2749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod#ifndef HB_OT_SHAPE_COMPLEX_PRIVATE_HH 2849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod#define HB_OT_SHAPE_COMPLEX_PRIVATE_HH 2949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 30c57d454accff66e5f2c58006e8fb40bc020b6182Behdad Esfahbod#include "hb-private.hh" 3149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3276f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod#include "hb-ot-map-private.hh" 3349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad EsfahbodHB_BEGIN_DECLS 3549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod/* buffer var allocations, used by all shapers */ 3876f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod#define general_category() var1.u8[0] /* unicode general_category (hb_unicode_general_category_t) */ 3976f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod#define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */ 4076f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod 4176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod 4276f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbodenum hb_ot_complex_shaper_t { 433361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod hb_ot_complex_shaper_default, 4476f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod hb_ot_complex_shaper_arabic, 4576f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod hb_ot_complex_shaper_indic 4676f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod}; 4776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod 4849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbodstatic inline hb_ot_complex_shaper_t 4949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbodhb_ot_shape_complex_categorize (const hb_segment_properties_t *props) 5049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod{ 5162879eebd9965179af8602ba29ac0a64a739b757Behdad Esfahbod switch ((int) props->script) 5262879eebd9965179af8602ba29ac0a64a739b757Behdad Esfahbod { 5349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod case HB_SCRIPT_ARABIC: 54b0e7378fa9a4fc6fc74d9b3c27d927602eaacc5bBehdad Esfahbod case HB_SCRIPT_MANDAIC: 55d86a5b3c5752abcc791724035ba4115958e6b5e2Behdad Esfahbod case HB_SCRIPT_MONGOLIAN: 56b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_NKO: 57b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SYRIAC: 5849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod return hb_ot_complex_shaper_arabic; 5949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 60b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod /* TODO: These are all the scripts that the ucd/IndicSyllabicCategory.txt covers. 61b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * Quite possibly many of these need no shaping, and some other are encoded visually. 62b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * Needs to be refined. 63b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod */ 64b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BALINESE: 65b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BATAK: 66b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BENGALI: 67b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BRAHMI: 68b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BUGINESE: 69b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_BUHID: 70b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_CHAM: 71b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_DEVANAGARI: 72b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_GUJARATI: 73b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_GURMUKHI: 74b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_HANUNOO: 75b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_JAVANESE: 76b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KAITHI: 77b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KANNADA: 78b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KAYAH_LI: 79b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KHAROSHTHI: 80b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KHMER: 81b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_LAO: 82b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_LEPCHA: 83b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_LIMBU: 84b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_MALAYALAM: 85b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_MEETEI_MAYEK: 86b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_MYANMAR: 87b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_NEW_TAI_LUE: 88b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_ORIYA: 89b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_PHAGS_PA: 90b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_REJANG: 91b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SAURASHTRA: 92b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SINHALA: 93b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SUNDANESE: 94b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SYLOTI_NAGRI: 95b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAGALOG: 96b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAGBANWA: 97b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAI_LE: 98b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAI_THAM: 99b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAI_VIET: 100b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TAMIL: 101b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TELUGU: 102b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_THAI: 103b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_TIBETAN: 104b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod return hb_ot_complex_shaper_indic; 105b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 10649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod default: 1073361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod return hb_ot_complex_shaper_default; 10849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod } 10949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod} 11049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 11149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 11249baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 11349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod/* 11449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * collect_features() 11549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod * 11613403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod * Called during shape_plan(). 11713403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod * 11876f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod * Shapers should use map to add their features and callbacks. 11949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod */ 12049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 12176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbodtypedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_map_builder_t *map, const hb_segment_properties_t *props); 1223361c9a323575309d9fd55fe076697a3e22073c0Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_default; 123e88bff9b4d77dc86c04832163081effbff752216Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_arabic; 124e88bff9b4d77dc86c04832163081effbff752216Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_indic; 12549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 12649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbodstatic inline void 12776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbodhb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper, 12876f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod hb_ot_map_builder_t *map, 12949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod const hb_segment_properties_t *props) 13049baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod{ 13176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod switch (shaper) { 1323361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod default: 1333361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod case hb_ot_complex_shaper_default: _hb_ot_shape_complex_collect_features_default (map, props); return; 13476f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_collect_features_arabic (map, props); return; 13576f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_collect_features_indic (map, props); return; 13649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod } 13749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod} 13849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 13949baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 14013403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod/* setup_masks() 14113403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod * 14213403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod * Called during shape_execute(). 14313403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod * 14476f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod * Shapers should use map to get feature masks and set on buffer. 14513403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod */ 14613403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod 14776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbodtypedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer); 1483361c9a323575309d9fd55fe076697a3e22073c0Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_default; 149e88bff9b4d77dc86c04832163081effbff752216Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_arabic; 150e88bff9b4d77dc86c04832163081effbff752216Behdad EsfahbodHB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_indic; 15113403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod 15213403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbodstatic inline void 15376f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbodhb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper, 15476f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod hb_ot_map_t *map, 15576f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod hb_buffer_t *buffer) 15613403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod{ 15776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod switch (shaper) { 1583361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod default: 1593361c9a323575309d9fd55fe076697a3e22073c0Behdad Esfahbod case hb_ot_complex_shaper_default: _hb_ot_shape_complex_setup_masks_default(map, buffer); return; 16076f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_setup_masks_arabic (map, buffer); return; 16176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_setup_masks_indic (map, buffer); return; 16213403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod } 16313403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod} 16413403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod 16549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 16649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad EsfahbodHB_END_DECLS 16749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 16849baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod#endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ 169