149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod/* 2cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod * Copyright © 2010,2011,2012 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 3216c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod#include "hb-ot-shape-private.hh" 3311138ccff71f442da1fcf64faa0e1d22e083e775Behdad Esfahbod#include "hb-ot-shape-normalize-private.hh" 3449baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 3649baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 37b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod/* buffer var allocations, used by complex shapers */ 38cd0c6e148f6d078b364370cb2f808b793b921be2Behdad Esfahbod#define complex_var_u8_0() var2.u8[2] 39cd0c6e148f6d078b364370cb2f808b793b921be2Behdad Esfahbod#define complex_var_u8_1() var2.u8[3] 40b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod 4176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod 4271b4c999a511bf018acaf48a45e070470c0daf12Behdad Esfahbodenum hb_ot_shape_zero_width_marks_type_t { 43568000274c8edb5f41bc4f876ce21fcc8bdaeed8Behdad Esfahbod HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, 44127daf15e0b2f509ebd29a104236c8b38884efb0Behdad Esfahbod// HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_EARLY, 45127daf15e0b2f509ebd29a104236c8b38884efb0Behdad Esfahbod HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_LATE, 46127daf15e0b2f509ebd29a104236c8b38884efb0Behdad Esfahbod HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, 476300cd72539284ca294ee8286bbbb7f9c72af320Behdad Esfahbod HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, 486300cd72539284ca294ee8286bbbb7f9c72af320Behdad Esfahbod 496300cd72539284ca294ee8286bbbb7f9c72af320Behdad Esfahbod HB_OT_SHAPE_ZERO_WIDTH_MARKS_DEFAULT = HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_LATE 50568000274c8edb5f41bc4f876ce21fcc8bdaeed8Behdad Esfahbod}; 51568000274c8edb5f41bc4f876ce21fcc8bdaeed8Behdad Esfahbod 52693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 53693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod/* Master OT shaper list */ 54d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod#define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ 55d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ 56d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ 57c98b7183f7dc453d5bac1f2503017cded317a495Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \ 58f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (hebrew) \ 59d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ 6098628cac9f733f2674d6409954cddb7d0634c233Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (myanmar) \ 613a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (sea) \ 623b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (thai) \ 63f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod HB_COMPLEX_SHAPER_IMPLEMENT (tibetan) \ 64d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod /* ^--- Add new shapers here */ 65d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod 66693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 67693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbodstruct hb_ot_complex_shaper_t 68693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod{ 69693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod char name[8]; 70693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 71693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod /* collect_features() 72693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod * Called during shape_plan(). 7316c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod * Shapers should use plan->map to add their features and callbacks. 740736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 75693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod */ 7616c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod void (*collect_features) (hb_ot_shape_planner_t *plan); 77693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 78693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod /* override_features() 79693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod * Called during shape_plan(). 8016c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod * Shapers should use plan->map to override features and add callbacks after 81693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod * common features are added. 820736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 83693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod */ 8416c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod void (*override_features) (hb_ot_shape_planner_t *plan); 85693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 86a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod 87a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod /* data_create() 88a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * Called at the end of shape_plan(). 89a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * Whatever shapers return will be accessible through plan->data later. 90a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * If NULL is returned, means a plan failure. 919f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod */ 92a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod void *(*data_create) (const hb_ot_shape_plan_t *plan); 93a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod 94a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod /* data_destroy() 95a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * Called when the shape_plan is being destroyed. 96a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * plan->data is passed here for destruction. 97a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod * If NULL is returned, means a plan failure. 980736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 990736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod */ 100a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod void (*data_destroy) (void *data); 101a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod 1029f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod 1039f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod /* preprocess_text() 1049f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod * Called during shape(). 1059f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod * Shapers can use to modify text before shaping starts. 1060736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 1079f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod */ 1089f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod void (*preprocess_text) (const hb_ot_shape_plan_t *plan, 1099f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod hb_buffer_t *buffer, 1109f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod hb_font_t *font); 1119f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod 1129f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod 1133d6ca0d32e5c6597acfcf59301cb1905586ddb52Behdad Esfahbod hb_ot_shape_normalization_mode_t normalization_preference; 1140736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod 1150736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod /* decompose() 1160736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * Called during shape()'s normalization. 1170736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 1180736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod */ 119eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod bool (*decompose) (const hb_ot_shape_normalize_context_t *c, 120eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t ab, 121eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t *a, 122eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t *b); 1230736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod 1240736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod /* compose() 1250736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * Called during shape()'s normalization. 1260736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 1270736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod */ 128eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod bool (*compose) (const hb_ot_shape_normalize_context_t *c, 129eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t a, 130eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t b, 131eba312c8d1b2bbe8cb9b6414e843e78d2c521aa4Behdad Esfahbod hb_codepoint_t *ab); 132693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 133693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod /* setup_masks() 13416c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod * Called during shape(). 135693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod * Shapers should use map to get feature masks and set on buffer. 1369f9f04c2229227bb0712166e824157bbbf5cef80Behdad Esfahbod * Shapers may NOT modify characters. 1370736915b8ed789a209205fec762997af3a8af89cBehdad Esfahbod * May be NULL. 138693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod */ 13916c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod void (*setup_masks) (const hb_ot_shape_plan_t *plan, 14016c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod hb_buffer_t *buffer, 14116c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod hb_font_t *font); 1422bc3b9a616cedbc56ff4a915f9e3439ff3a6bf13Behdad Esfahbod 14371b4c999a511bf018acaf48a45e070470c0daf12Behdad Esfahbod hb_ot_shape_zero_width_marks_type_t zero_width_marks; 144568000274c8edb5f41bc4f876ce21fcc8bdaeed8Behdad Esfahbod 145865745b5b87236651f5663cae3461db9cb505eedBehdad Esfahbod bool fallback_position; 14676f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod}; 14776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod 148693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod#define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name; 149693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad EsfahbodHB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS 150693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod#undef HB_COMPLEX_SHAPER_IMPLEMENT 151693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 152693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod 153693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbodstatic inline const hb_ot_complex_shaper_t * 1549b37b4c5800b158f61602d2aba8a01349e24d251Behdad Esfahbodhb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner) 15549baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod{ 1569b37b4c5800b158f61602d2aba8a01349e24d251Behdad Esfahbod switch ((hb_tag_t) planner->props.script) 15762879eebd9965179af8602ba29ac0a64a739b757Behdad Esfahbod { 158d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod default: 159693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod return &_hb_ot_complex_shaper_default; 160d05dded1676924e8894c90f7a7c3527b492bcdffBehdad Esfahbod 161c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod 162317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod /* Unicode-1.1 additions */ 16349baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod case HB_SCRIPT_ARABIC: 16454e6f6c588a164f7de62ff88b3eff4f25adb8f17Behdad Esfahbod 16554e6f6c588a164f7de62ff88b3eff4f25adb8f17Behdad Esfahbod /* Unicode-3.0 additions */ 166d86a5b3c5752abcc791724035ba4115958e6b5e2Behdad Esfahbod case HB_SCRIPT_MONGOLIAN: 167b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SYRIAC: 168317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod 169317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod /* Unicode-5.0 additions */ 170317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod case HB_SCRIPT_NKO: 1713ba7bc14ea652d27639f34109e51a497a678a54aBehdad Esfahbod case HB_SCRIPT_PHAGS_PA: 172317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod 173317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod /* Unicode-6.0 additions */ 174317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod case HB_SCRIPT_MANDAIC: 175317b9504d7a4faa70dcf21e5c2aff4792dbd201aBehdad Esfahbod 1767cfee3827636f0dff7df5c8975a4fadd1b4bfbd5Behdad Esfahbod /* Unicode-7.0 additions */ 1777cfee3827636f0dff7df5c8975a4fadd1b4bfbd5Behdad Esfahbod case HB_SCRIPT_MANICHAEAN: 1787cfee3827636f0dff7df5c8975a4fadd1b4bfbd5Behdad Esfahbod case HB_SCRIPT_PSALTER_PAHLAVI: 1797cfee3827636f0dff7df5c8975a4fadd1b4bfbd5Behdad Esfahbod 1809e92978c8aa3d3cdab4d20c81698c56adbb3dbddBehdad Esfahbod /* For Arabic script, use the Arabic shaper even if no OT script tag was found. 1819e92978c8aa3d3cdab4d20c81698c56adbb3dbddBehdad Esfahbod * This is because we do fallback shaping for Arabic script (and not others). */ 1825ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod if (planner->map.chosen_script[0] != HB_OT_TAG_DEFAULT_SCRIPT || 1835ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod planner->props.script == HB_SCRIPT_ARABIC) 1845ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod return &_hb_ot_complex_shaper_arabic; 1855ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod else 1865ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod return &_hb_ot_complex_shaper_default; 18749baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod 188c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod 189c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod /* Unicode-1.1 additions */ 1903b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod case HB_SCRIPT_THAI: 1913b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod case HB_SCRIPT_LAO: 1923b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod 193693918ef8541014a5ef7dfb91c6ea0ae36d9c368Behdad Esfahbod return &_hb_ot_complex_shaper_thai; 1943b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod 1953b26f96ebe859570d14c6902afc23462bca40712Behdad Esfahbod 196587e5753e088b4d0b82c74ddbde790a8369a7517Behdad Esfahbod /* Unicode-1.1 additions */ 197587e5753e088b4d0b82c74ddbde790a8369a7517Behdad Esfahbod case HB_SCRIPT_HANGUL: 198587e5753e088b4d0b82c74ddbde790a8369a7517Behdad Esfahbod 199587e5753e088b4d0b82c74ddbde790a8369a7517Behdad Esfahbod return &_hb_ot_complex_shaper_hangul; 200587e5753e088b4d0b82c74ddbde790a8369a7517Behdad Esfahbod 201c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod 202f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod /* Unicode-2.0 additions */ 203f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod case HB_SCRIPT_TIBETAN: 204f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 205f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod return &_hb_ot_complex_shaper_tibetan; 206f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 207f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 208f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod /* Unicode-1.1 additions */ 209f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod case HB_SCRIPT_HEBREW: 210f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 211f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod return &_hb_ot_complex_shaper_hebrew; 212f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 213f14bb7de631b20e2868fb62e5311cd0d9e24bb49Behdad Esfahbod 214c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod /* ^--- Add new shapers here */ 215c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod 216c9a841f4452921c5361b8f5697bbff7736ce60cdBehdad Esfahbod 217bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod#if 0 218bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod /* Note: 219bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod * 220bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod * These disabled scripts are listed in ucd/IndicSyllabicCategory.txt, but according 221f91136cb528e298651c4a8a8a1d6dc54136e09ceBehdad Esfahbod * to Martin Hosken and Jonathan Kew do not require complex shaping. 222f91136cb528e298651c4a8a8a1d6dc54136e09ceBehdad Esfahbod * 223f91136cb528e298651c4a8a8a1d6dc54136e09ceBehdad Esfahbod * TODO We should automate figuring out which scripts do not need complex shaping 224bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod * 225bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod * TODO We currently keep data for these scripts in our indic table. Need to fix the 226bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod * generator to not do that. 227b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod */ 228bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod 229cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 230bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod /* Simple? */ 231cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 232cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-3.2 additions */ 233183224684a45d7dcd7d28510d4383a7a7cb3dff3Behdad Esfahbod case HB_SCRIPT_BUHID: 234bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_HANUNOO: 235cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 236cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.1 additions */ 237bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_SAURASHTRA: 238bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod 239cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-6.0 additions */ 240cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_BATAK: 241cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_BRAHMI: 242cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 243cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 244bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod /* Simple */ 245cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 246cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-1.1 additions */ 2475b1260909350bffa3e3d06da346f9f86ce651dbbBehdad Esfahbod /* These have their own shaper now. */ 248bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_LAO: 249cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_THAI: 250cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 251cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-3.2 additions */ 252bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_TAGALOG: 253bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_TAGBANWA: 254cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 255cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-4.0 additions */ 256cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_LIMBU: 257bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_TAI_LE: 258cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 259cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-4.1 additions */ 2600f80a89de99293ddbf0b8b815fe360677d057e38Behdad Esfahbod case HB_SCRIPT_KHAROSHTHI: 261cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_SYLOTI_NAGRI: 262cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 263cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.1 additions */ 264cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_KAYAH_LI: 265cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 266cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.2 additions */ 267bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_TAI_VIET: 268cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 269bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod 270bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod#endif 271bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod 272cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-1.1 additions */ 273bc187e5ac7433f5561b0e97e8c62172c73883f3fBehdad Esfahbod case HB_SCRIPT_BENGALI: 274b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_DEVANAGARI: 275b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_GUJARATI: 276b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_GURMUKHI: 277b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_KANNADA: 278b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_MALAYALAM: 2797a4a848db27d1605195f677c9c8632cde558aa05Behdad Esfahbod case HB_SCRIPT_ORIYA: 280cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_TAMIL: 281cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_TELUGU: 282cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 283cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-3.0 additions */ 284b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SINHALA: 285cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 286cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.0 additions */ 287cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_BALINESE: 288cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 289cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.1 additions */ 290cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_LEPCHA: 291cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_REJANG: 292b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod case HB_SCRIPT_SUNDANESE: 293cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 294cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-5.2 additions */ 295cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_JAVANESE: 296cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_KAITHI: 29743149afbc0007ea075a7017c0e56056c3c0f3614Behdad Esfahbod case HB_SCRIPT_MEETEI_MAYEK: 298cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 2993a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod /* Unicode-6.0 additions */ 30043149afbc0007ea075a7017c0e56056c3c0f3614Behdad Esfahbod 301cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod /* Unicode-6.1 additions */ 302cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_CHAKMA: 303cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod case HB_SCRIPT_SHARADA: 304f91136cb528e298651c4a8a8a1d6dc54136e09ceBehdad Esfahbod case HB_SCRIPT_TAKRI: 305cad3821f3d5b68d490b0728bd37bd57428ec809cBehdad Esfahbod 3065676d5d52784e16068ae483103d59111a8081854Behdad Esfahbod /* If the designer designed the font for the 'DFLT' script, 3075676d5d52784e16068ae483103d59111a8081854Behdad Esfahbod * use the default shaper. Otherwise, use the Indic shaper. 3083a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod * Note that for some simple scripts, there may not be *any* 3093a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod * GSUB/GPOS needed, so there may be no scripts found! */ 3105676d5d52784e16068ae483103d59111a8081854Behdad Esfahbod if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T')) 311851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod return &_hb_ot_complex_shaper_default; 3125676d5d52784e16068ae483103d59111a8081854Behdad Esfahbod else 3135676d5d52784e16068ae483103d59111a8081854Behdad Esfahbod return &_hb_ot_complex_shaper_indic; 314981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod 315981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod case HB_SCRIPT_KHMER: 31616c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod /* A number of Khmer fonts in the wild don't have a 'pref' feature, 31716c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod * and as such won't shape properly via the Indic shaper; 31816c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod * however, they typically have 'liga' / 'clig' features that implement 31916c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod * the necessary "reordering" by means of ligature substitutions. 32016c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod * So we send such pref-less fonts through the generic shaper instead. */ 32116c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod if (planner->map.found_script[0] && 322851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod hb_ot_layout_language_find_feature (planner->face, HB_OT_TAG_GSUB, 323851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod planner->map.script_index[0], 324851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod planner->map.language_index[0], 32516c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod HB_TAG ('p','r','e','f'), 32616c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod NULL)) 327981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod return &_hb_ot_complex_shaper_indic; 32816c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod else 32916c914c2a6efeb6999054333985b1f711e33cf94Behdad Esfahbod return &_hb_ot_complex_shaper_default; 330981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod 331981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod case HB_SCRIPT_MYANMAR: 33298628cac9f733f2674d6409954cddb7d0634c233Behdad Esfahbod /* For Myanmar, we only want to use the Myanmar shaper if the "new" script 3339e92978c8aa3d3cdab4d20c81698c56adbb3dbddBehdad Esfahbod * tag is found. For "old" script tag we want to use the default shaper. */ 334981748cb2e9b48b77177b19ec1f972cab7afda89Behdad Esfahbod if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2')) 33598628cac9f733f2674d6409954cddb7d0634c233Behdad Esfahbod return &_hb_ot_complex_shaper_myanmar; 3365ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod else 3375ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod return &_hb_ot_complex_shaper_default; 3383a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod 3393a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod /* Unicode-4.1 additions */ 340321df83fb4f0b8a5310888129cb70bfda8ae0c96Behdad Esfahbod case HB_SCRIPT_BUGINESE: 3413a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod case HB_SCRIPT_NEW_TAI_LUE: 3423a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod 3433a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod /* Unicode-5.1 additions */ 3443a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod case HB_SCRIPT_CHAM: 3453a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod 3463a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod /* Unicode-5.2 additions */ 3473a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod case HB_SCRIPT_TAI_THAM: 3483a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod 3493a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod /* If the designer designed the font for the 'DFLT' script, 3503a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod * use the default shaper. Otherwise, use the Indic shaper. 3513a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod * Note that for some simple scripts, there may not be *any* 3523a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod * GSUB/GPOS needed, so there may be no scripts found! */ 3533a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T')) 3543a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod return &_hb_ot_complex_shaper_default; 3553a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod else 3563a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbod return &_hb_ot_complex_shaper_sea; 35702cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod } 35802cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod} 35902cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod 36002cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod 36149baa1f69efb0e3c62e45bd59dd88459a84bf390Behdad Esfahbod#endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ 362