14924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2009,2010 Red Hat, Inc. 306a44e859328f5f1e2f6034e711b474116d22e22Behdad Esfahbod * Copyright © 2010,2011,2012,2013 Google, Inc. 44924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * 54924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * This is part of HarfBuzz, a text shaping library. 64924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * 74924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * Permission is hereby granted, without written agreement and without 84924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 94924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * software and its documentation for any purpose, provided that the 104924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * above copyright notice and the following two paragraphs appear in 114924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * all copies of this software. 124924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * 134924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 144924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 154924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 164924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 174924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * DAMAGE. 184924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * 194924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 204924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 214924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 224924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 234924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 244924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * 254924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * Red Hat Author(s): Behdad Esfahbod 264924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod * Google Author(s): Behdad Esfahbod 274924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod */ 284924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 294924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod#ifndef HB_OT_MAP_PRIVATE_HH 304924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod#define HB_OT_MAP_PRIVATE_HH 314924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 32895fb5d364e7ae5d9d2e34b9f68b8651804369efBehdad Esfahbod#include "hb-buffer-private.hh" 334924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 344924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 352265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbodstruct hb_ot_shape_plan_t; 364924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 374924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbodstatic const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS}; 384924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 3990645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbodstruct hb_ot_map_t 4090645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod{ 4190645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod friend struct hb_ot_map_builder_t; 424924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 438f08c3275040870a645ef034a38d30c05c619f21Behdad Esfahbod public: 444924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 45610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod struct feature_map_t { 46610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod hb_tag_t tag; /* should be first for our bsearch to work */ 47610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod unsigned int index[2]; /* GSUB/GPOS */ 48610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod unsigned int stage[2]; /* GSUB/GPOS */ 49610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod unsigned int shift; 50610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod hb_mask_t mask; 51610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod hb_mask_t _1_mask; /* mask for value=1, for quick access */ 52cfc507c5432e6327e8484b07b9e091212653bc92Behdad Esfahbod unsigned int needs_fallback : 1; 53cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod unsigned int auto_zwnj : 1; 54a8cf7b43fa795150ae3d42d64424bb6e0373d0b2Behdad Esfahbod unsigned int auto_zwj : 1; 55610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 56db5f7ef18916abb0907bc8b569a65c9c6bbd4015Behdad Esfahbod inline int cmp (const hb_tag_t *tag_) const 57db5f7ef18916abb0907bc8b569a65c9c6bbd4015Behdad Esfahbod { return *tag_ < tag ? -1 : *tag_ > tag ? 1 : 0; } 58610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod }; 59610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 60610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod struct lookup_map_t { 61cfc507c5432e6327e8484b07b9e091212653bc92Behdad Esfahbod unsigned short index; 62cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod unsigned short auto_zwnj : 1; 63a8cf7b43fa795150ae3d42d64424bb6e0373d0b2Behdad Esfahbod unsigned short auto_zwj : 1; 64610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod hb_mask_t mask; 65610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 660712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod static int cmp (const void *pa, const void *pb) 670712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod { 680712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod const lookup_map_t *a = (const lookup_map_t *) pa; 690712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod const lookup_map_t *b = (const lookup_map_t *) pb; 700712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; 710712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod } 72610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod }; 73610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 748bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod typedef void (*pause_func_t) (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); 75610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 768ac3c9c0b6b8e76bce282825b9bb706c0c78c2a6Behdad Esfahbod struct stage_map_t { 77893f57b32f01da3411b5596d59170bc340e9fa39Behdad Esfahbod unsigned int last_lookup; /* Cumulative */ 78893f57b32f01da3411b5596d59170bc340e9fa39Behdad Esfahbod pause_func_t pause_func; 79610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod }; 80610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 81610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 828336186a52813b53e90b4399dc462d55750e2d37Behdad Esfahbod hb_ot_map_t (void) { memset (this, 0, sizeof (*this)); } 838336186a52813b53e90b4399dc462d55750e2d37Behdad Esfahbod 8439dede9ffffe732f78cbd092ccb3b48d77ddd66dBehdad Esfahbod inline hb_mask_t get_global_mask (void) const { return global_mask; } 854924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 86dbdbfe3d7b36613d893832dcb1884c756c20bfdaBehdad Esfahbod inline hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = nullptr) const { 87f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod const feature_map_t *map = features.bsearch (&feature_tag); 888f08c3275040870a645ef034a38d30c05c619f21Behdad Esfahbod if (shift) *shift = map ? map->shift : 0; 898f08c3275040870a645ef034a38d30c05c619f21Behdad Esfahbod return map ? map->mask : 0; 904924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod } 914924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 92fabd3113a98c5f4114f48920fa7ea38bd65a8d32Behdad Esfahbod inline bool needs_fallback (hb_tag_t feature_tag) const { 93fabd3113a98c5f4114f48920fa7ea38bd65a8d32Behdad Esfahbod const feature_map_t *map = features.bsearch (&feature_tag); 94fabd3113a98c5f4114f48920fa7ea38bd65a8d32Behdad Esfahbod return map ? map->needs_fallback : false; 95fabd3113a98c5f4114f48920fa7ea38bd65a8d32Behdad Esfahbod } 96fabd3113a98c5f4114f48920fa7ea38bd65a8d32Behdad Esfahbod 97f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod inline hb_mask_t get_1_mask (hb_tag_t feature_tag) const { 98f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod const feature_map_t *map = features.bsearch (&feature_tag); 9939dede9ffffe732f78cbd092ccb3b48d77ddd66dBehdad Esfahbod return map ? map->_1_mask : 0; 10039dede9ffffe732f78cbd092ccb3b48d77ddd66dBehdad Esfahbod } 10139dede9ffffe732f78cbd092ccb3b48d77ddd66dBehdad Esfahbod 102610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod inline unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const { 103f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod const feature_map_t *map = features.bsearch (&feature_tag); 104f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod return map ? map->index[table_index] : HB_OT_LAYOUT_NO_FEATURE_INDEX; 105f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod } 106f055442716ec7543ed156d4789955b19c11a5255Behdad Esfahbod 107610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod inline unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const { 108610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod const feature_map_t *map = features.bsearch (&feature_tag); 109610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod return map ? map->stage[table_index] : (unsigned int) -1; 110610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod } 111610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 112610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod inline void get_stage_lookups (unsigned int table_index, unsigned int stage, 113610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod const struct lookup_map_t **plookups, unsigned int *lookup_count) const { 114610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod if (unlikely (stage == (unsigned int) -1)) { 115dbdbfe3d7b36613d893832dcb1884c756c20bfdaBehdad Esfahbod *plookups = nullptr; 116610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod *lookup_count = 0; 117610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod return; 118610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod } 1198ac3c9c0b6b8e76bce282825b9bb706c0c78c2a6Behdad Esfahbod assert (stage <= stages[table_index].len); 120893f57b32f01da3411b5596d59170bc340e9fa39Behdad Esfahbod unsigned int start = stage ? stages[table_index][stage - 1].last_lookup : 0; 121893f57b32f01da3411b5596d59170bc340e9fa39Behdad Esfahbod unsigned int end = stage < stages[table_index].len ? stages[table_index][stage].last_lookup : lookups[table_index].len; 122dbdbfe3d7b36613d893832dcb1884c756c20bfdaBehdad Esfahbod *plookups = end == start ? nullptr : &lookups[table_index][start]; 123610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod *lookup_count = end - start; 124610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod } 125610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod 126f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_INTERNAL void collect_lookups (unsigned int table_index, hb_set_t *lookups) const; 127bac1dd6a0ff4d4fae4254506d38ae662b7e9dda7Behdad Esfahbod template <typename Proxy> 128bac1dd6a0ff4d4fae4254506d38ae662b7e9dda7Behdad Esfahbod HB_INTERNAL inline void apply (const Proxy &proxy, 129bac1dd6a0ff4d4fae4254506d38ae662b7e9dda7Behdad Esfahbod const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const; 1308bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod HB_INTERNAL void substitute (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const; 1318bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod HB_INTERNAL void position (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const; 1321827dc208c867e433a95237d1ed3fc7a73d1d9a7Behdad Esfahbod 1336a7ac79e26e85f6781186cf708a12825c0857324Behdad Esfahbod inline void finish (void) { 13490645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod features.finish (); 1352265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod for (unsigned int table_index = 0; table_index < 2; table_index++) 1362265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod { 1372265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod lookups[table_index].finish (); 1382265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod stages[table_index].finish (); 1392265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod } 1406a7ac79e26e85f6781186cf708a12825c0857324Behdad Esfahbod } 1416a7ac79e26e85f6781186cf708a12825c0857324Behdad Esfahbod 142851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod public: 143851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod hb_tag_t chosen_script[2]; 144851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod bool found_script[2]; 14590645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod 146610e5e8f713bb2a68939b72cb2b801a7aaede4f9Behdad Esfahbod private: 147b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod 14890645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod hb_mask_t global_mask; 14990645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod 15090645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod hb_prealloced_array_t<feature_map_t, 8> features; 15190645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod hb_prealloced_array_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */ 152ea86efa486a5076e9bf844239bccf86d67577f88Behdad Esfahbod hb_prealloced_array_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */ 15390645fb24bcbb78183576d3641a99560d87e49f2Behdad Esfahbod}; 1544924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 155ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbodenum hb_ot_map_feature_flags_t { 1567627100f428ac0ec8509d961d368d2d25d8f0b6eBehdad Esfahbod F_NONE = 0x0000u, 1570f98fe88f42471eb8fb28d08d45eca9cd8303f7aBehdad Esfahbod F_GLOBAL = 0x0001u, /* Feature applies to all characters; results in no mask allocated for it. */ 1580f98fe88f42471eb8fb28d08d45eca9cd8303f7aBehdad Esfahbod F_HAS_FALLBACK = 0x0002u, /* Has fallback implementation, so include mask bit even if feature not found. */ 159cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod F_MANUAL_ZWNJ = 0x0004u, /* Don't skip over ZWNJ when matching **context**. */ 160cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod F_MANUAL_ZWJ = 0x0008u, /* Don't skip over ZWJ when matching **input**. */ 161cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod F_GLOBAL_SEARCH = 0x0010u /* If feature not found in LangSys, look for it in global feature list and pick one. */ 162ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod}; 163167c3271778cd1a8c4433b9d2230901ce17c099eChun-wei FanHB_MARK_AS_FLAG_T (hb_ot_map_feature_flags_t); 16441732f1fe3ce856d8bb95850635034537b6ba047Behdad Esfahbod/* Macro version for where const is desired. */ 16541732f1fe3ce856d8bb95850635034537b6ba047Behdad Esfahbod#define F_COMBINE(l,r) (hb_ot_map_feature_flags_t ((unsigned int) (l) | (unsigned int) (r))) 166ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod 1674924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 168f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbodstruct hb_ot_map_builder_t 169f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod{ 170f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod public: 171f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 1726fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod HB_INTERNAL hb_ot_map_builder_t (hb_face_t *face_, 1736fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod const hb_segment_properties_t *props_); 1748336186a52813b53e90b4399dc462d55750e2d37Behdad Esfahbod 175ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value, 176ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod hb_ot_map_feature_flags_t flags); 177f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 178e7ffcfafb1108801ac504f18f820e497226bf07fBehdad Esfahbod inline void add_global_bool_feature (hb_tag_t tag) 179ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod { add_feature (tag, 1, F_GLOBAL); } 180f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 1813e38c0f2886c38d2f0a9d80a97a36edf2479d2c7Behdad Esfahbod inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func) 1823e38c0f2886c38d2f0a9d80a97a36edf2479d2c7Behdad Esfahbod { add_pause (0, pause_func); } 1833e38c0f2886c38d2f0a9d80a97a36edf2479d2c7Behdad Esfahbod inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func) 1843e38c0f2886c38d2f0a9d80a97a36edf2479d2c7Behdad Esfahbod { add_pause (1, pause_func); } 185b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod 18672ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod HB_INTERNAL void compile (hb_ot_map_t &m, 18772ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod const int *coords, 18872ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod unsigned int num_coords); 189f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 190f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod inline void finish (void) { 191f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod feature_infos.finish (); 1922265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod for (unsigned int table_index = 0; table_index < 2; table_index++) 1932265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod { 1942265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod stages[table_index].finish (); 1952265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod } 196f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod } 197f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 198f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod private: 199f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 20072ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod HB_INTERNAL void add_lookups (hb_ot_map_t &m, 20172ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod hb_face_t *face, 20272ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod unsigned int table_index, 20372ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod unsigned int feature_index, 20472ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod unsigned int variations_index, 20572ada4f0c6998fc2a282efc2a573733e37db8be5Behdad Esfahbod hb_mask_t mask, 206cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod bool auto_zwnj = true, 207cdf1fd0627c5517c948ca05d2e9427c3e441adf9Behdad Esfahbod bool auto_zwj = true); 208bde5e3959c0ffdb92db87668035b01aaee9b2352Behdad Esfahbod 209f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod struct feature_info_t { 210f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod hb_tag_t tag; 211f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod unsigned int seq; /* sequence#, used for stable sorting only */ 212f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod unsigned int max_value; 213ec5448667b30ad662401c2b4f5fc0da524c013fdBehdad Esfahbod hb_ot_map_feature_flags_t flags; 214f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod unsigned int default_value; /* for non-global features, what should the unset glyphs take */ 215b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod unsigned int stage[2]; /* GSUB/GPOS */ 216f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 2170712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod static int cmp (const void *pa, const void *pb) 2180712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod { 2190712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod const feature_info_t *a = (const feature_info_t *) pa; 2200712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod const feature_info_t *b = (const feature_info_t *) pb; 2210712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : 2220712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod (a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0); 2230712e915b4814e350aa1d833c1dee5010cdbd8f9Behdad Esfahbod } 224f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod }; 225f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 2268ac3c9c0b6b8e76bce282825b9bb706c0c78c2a6Behdad Esfahbod struct stage_info_t { 2278ac3c9c0b6b8e76bce282825b9bb706c0c78c2a6Behdad Esfahbod unsigned int index; 228893f57b32f01da3411b5596d59170bc340e9fa39Behdad Esfahbod hb_ot_map_t::pause_func_t pause_func; 229b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod }; 230b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod 2313e38c0f2886c38d2f0a9d80a97a36edf2479d2c7Behdad Esfahbod HB_INTERNAL void add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func); 232d8d0c480c85246a74d47dd5297019c7e39391ab0Behdad Esfahbod 2335ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod public: 2345ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod 2356fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod hb_face_t *face; 2366fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod hb_segment_properties_t props; 2376fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod 2386fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod hb_tag_t chosen_script[2]; 239851784f8372004e0a40b698c0cdc2d7db8629aa2Behdad Esfahbod bool found_script[2]; 2406fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod unsigned int script_index[2], language_index[2]; 2416fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod 2425ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod private: 2435ab3855f8106158ee7e68797e8c35e63e9216e5dBehdad Esfahbod 244b70c96dbe41d6512b80fe3d966a1942e1ef64a4bBehdad Esfahbod unsigned int current_stage[2]; /* GSUB/GPOS */ 245ea86efa486a5076e9bf844239bccf86d67577f88Behdad Esfahbod hb_prealloced_array_t<feature_info_t, 32> feature_infos; 246ea86efa486a5076e9bf844239bccf86d67577f88Behdad Esfahbod hb_prealloced_array_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */ 247f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod}; 248f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 249f6d7a9bb4c19e605f1f16d9ca40adefba138c37eBehdad Esfahbod 2504924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod 2514924affe0f0adf75f2a0e2137a71206b0576d63fBehdad Esfahbod#endif /* HB_OT_MAP_PRIVATE_HH */ 252