hb-ot-shape.cc revision a224b4d502d026fa642ee4098bf7bc0b4ba7ce27
12014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod/* 20e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod * Copyright (C) 2009,2010 Red Hat, Inc. 32014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * 4c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 52014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * 62014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * Permission is hereby granted, without written agreement and without 72014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 82014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * software and its documentation for any purpose, provided that the 92014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 102014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * all copies of this software. 112014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * 122014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 132014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 142014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 152014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 162014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * DAMAGE. 172014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * 182014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 192014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 202014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 212014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 222014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 232014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * 242014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod * Red Hat Author(s): Behdad Esfahbod 252014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod */ 262014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 2715c7379c16dbb9ee8ed1c0333ca7492532ce8423Behdad Esfahbod#include "hb-ot-shape.h" 282014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 2922da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#include "hb-buffer-private.hh" 302014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 310e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod#include "hb-open-type-private.hh" 320e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 332014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod#include "hb-ot-layout.h" 342014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3575f3469ca6d626b08eb411984a2ba7fd48ca5b5fBehdad Esfahbod/* XXX vertical */ 362014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodhb_tag_t default_features[] = { 37bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('c','a','l','t'), 382014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_TAG('c','c','m','p'), 392014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_TAG('c','l','i','g'), 40bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('c','s','w','h'), 41bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('c','u','r','s'), 422014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_TAG('k','e','r','n'), 43bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('l','i','g','a'), 44bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('l','o','c','l'), 452014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_TAG('m','a','r','k'), 462014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_TAG('m','k','m','k'), 47bd0987386b3a4dddf208ccf1a70ebfff6242ba73Behdad Esfahbod HB_TAG('r','l','i','g') 482014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod}; 492014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 501094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbodenum { 511094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod MASK_ALWAYS_ON = 1 << 0, 521094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod MASK_RTLM = 1 << 1 531094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod}; 541094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod#define MASK_BITS_USED 2 551094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 566b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbodstruct lookup_map { 576b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod unsigned int index; 586b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod hb_mask_t mask; 596b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod}; 606b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod 612014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 622014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodstatic void 632014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodadd_feature (hb_face_t *face, 642014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_tag_t table_tag, 652014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int feature_index, 666b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod hb_mask_t mask, 676b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookup_map *lookups, 682014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int *num_lookups, 692014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int room_lookups) 702014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod{ 712014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int i = room_lookups - *num_lookups; 726b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookups += *num_lookups; 736b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod 746b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod unsigned int *lookup_indices = (unsigned int *) lookups; 756b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod 762014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_layout_feature_get_lookup_indexes (face, table_tag, feature_index, 0, 772014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod &i, 786b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookup_indices); 796b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod 802014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod *num_lookups += i; 816b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod 826b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod while (i--) { 836b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookups[i].mask = mask; 846b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookups[i].index = lookup_indices[i]; 856b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod } 862014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod} 872014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 882014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodstatic int 892014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodcmp_lookups (const void *p1, const void *p2) 902014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod{ 916b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod const lookup_map *a = (const lookup_map *) p1; 926b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod const lookup_map *b = (const lookup_map *) p2; 932014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 946b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod return a->index - b->index; 952014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod} 962014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 9781c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 9881c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod#define MAX_FEATURES 100 9981c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 1000e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbodstruct hb_mask_allocator_t { 10181c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 1020e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod struct feature_info_t { 1030e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_tag_t tag; 1040e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int value; 10581a77b115db401f69e869690f24b9047370bdfdeBehdad Esfahbod unsigned int seq; 1060e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod bool global; 10781c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 1080e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod static int 1090e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod cmp (const void *p1, const void *p2) 1100e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod { 1110e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_info_t *a = (const feature_info_t *) p1; 1120e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_info_t *b = (const feature_info_t *) p2; 11381c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 1140e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (a->tag != b->tag) 1150e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod return a->tag < b->tag ? -1 : 1; 11681c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 11781a77b115db401f69e869690f24b9047370bdfdeBehdad Esfahbod return a->seq < b->seq ? -1 : 1; 1180e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 1190e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod }; 12081c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 1210e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod struct feature_map_t { 1220e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_tag_t tag; /* should be first */ 1230e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int index; 1240e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int shift; 1250e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_mask_t mask; 1260e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1270e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod static int 1280e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod cmp (const void *p1, const void *p2) 12981c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod { 1300e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_map_t *a = (const feature_map_t *) p1; 1310e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_map_t *b = (const feature_map_t *) p2; 1320e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1330e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; 1340e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 1350e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod }; 1360e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 137f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod hb_mask_allocator_t (void) : count (0) {} 1380e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 139e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod void add_feature (hb_tag_t tag, 140e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod unsigned int value, 141e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod bool global) 14281c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod { 1430e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod feature_info_t *info = &infos[count++]; 1440e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod info->tag = tag; 145e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod info->value = value; 14681a77b115db401f69e869690f24b9047370bdfdeBehdad Esfahbod info->seq = count; 1470e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod info->global = global; 14881c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod } 14981c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 150f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod void compile (hb_face_t *face, 151f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod hb_tag_t table_tag, 152f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod unsigned int script_index, 153f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod unsigned int language_index) 15481c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod { 1550e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod global_mask = 0; 1560e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod next_bit = MASK_BITS_USED; 1570e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1580e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (!count) 1590e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod return; 1600e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1610e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod qsort (infos, count, sizeof (infos[0]), feature_info_t::cmp); 1620e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1630e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int j = 0; 1640e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod for (unsigned int i = 1; i < count; i++) 1650e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (infos[i].tag != infos[j].tag) 1660e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod infos[++j] = infos[i]; 1670e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod else { 1688af45fda475d075c5a285002463a00a0423d3926Behdad Esfahbod if (infos[i].global) 1698af45fda475d075c5a285002463a00a0423d3926Behdad Esfahbod infos[j] = infos[i]; 1708af45fda475d075c5a285002463a00a0423d3926Behdad Esfahbod else { 1718af45fda475d075c5a285002463a00a0423d3926Behdad Esfahbod infos[j].global = infos[j].global && (infos[j].value == infos[i].value); 1720e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod infos[j].value = MAX (infos[j].value, infos[i].value); 1738af45fda475d075c5a285002463a00a0423d3926Behdad Esfahbod } 1740e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 1750e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod count = j + 1; 1760e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1770e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Allocate bits now */ 1780e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod j = 0; 1790e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod for (unsigned int i = 0; i < count; i++) { 1800e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_info_t *info = &infos[i]; 1810e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1820e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int bits_needed; 1830e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1840e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (info->global && info->value == 1) 1850e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Uses the global bit */ 1860e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod bits_needed = 0; 1870e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod else 1880e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod bits_needed = _hb_bit_storage (info->value); 1890e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1900e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (!info->value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) 1910e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod continue; /* Feature disabled, or not enough bits. */ 1920e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1930e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int feature_index; 1940e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (!hb_ot_layout_language_find_feature (face, table_tag, script_index, language_index, 1950e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod info->tag, &feature_index)) 1960e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod continue; 1970e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 1980e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod feature_map_t *map = &maps[j++]; 1990e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2000e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->tag = info->tag; 2010e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->index = feature_index; 2020e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (info->global && info->value == 1) { 2030e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Uses the global bit */ 2040e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->shift = 0; 2050e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->mask = 1; 2060e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } else { 2070e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->shift = next_bit; 2080e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit); 2090e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod next_bit += bits_needed; 2100e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 2110e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2120e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (info->global && map->mask != 1) 2130e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod global_mask |= map->mask; 2140e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 2150e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod count = j; 21681c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod } 21781c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 2180e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_mask_t get_global_mask (void) { return global_mask; } 2190e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_map_t *find_feature (hb_tag_t tag) const { 2200e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod static const feature_map_t off_map = { HB_TAG_NONE, Index::NOT_FOUND_INDEX, 0, 0 }; 2210e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const feature_map_t *map = (const feature_map_t *) bsearch (&tag, maps, count, sizeof (maps[0]), feature_map_t::cmp); 2220e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod return map ? map : &off_map; 22381c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod } 22481c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 2250e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2260e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod private: 2270e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2280e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int count; 2290e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod feature_info_t infos[MAX_FEATURES]; 2300e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod feature_map_t maps[MAX_FEATURES]; 2310e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2320e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_mask_t global_mask; 2330e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod unsigned int next_bit; 2340e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod}; 23581c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 2362014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbodstatic void 2374206e9511a222c0c50cc9b4fe72ec421983bba2cBehdad Esfahbodsetup_lookups (hb_face_t *face, 2382014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_buffer_t *buffer, 2392014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_feature_t *features, 2402014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int num_features, 2412014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_tag_t table_tag, 2426b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookup_map *lookups, 243074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod unsigned int *num_lookups, 244074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod hb_direction_t original_direction) 2452014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod{ 2462014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int i, j, script_index, language_index, feature_index, room_lookups; 2472014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 2482014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod room_lookups = *num_lookups; 2492014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod *num_lookups = 0; 2502014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 2512014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_layout_table_choose_script (face, table_tag, 2522014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_tags_from_script (buffer->script), 2532014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod &script_index); 2542014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_layout_script_find_language (face, table_tag, script_index, 2552014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_tag_from_language (buffer->language), 2562014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod &language_index); 2572014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 2582014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod if (hb_ot_layout_language_get_required_feature_index (face, table_tag, script_index, language_index, 2592014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod &feature_index)) 2606b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod add_feature (face, table_tag, feature_index, 1, lookups, num_lookups, room_lookups); 2612014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 26281c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 263f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod hb_mask_allocator_t allocator; 2640e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2650e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod switch (original_direction) { 2660e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod case HB_DIRECTION_LTR: 267e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (HB_TAG ('l','t','r','a'), 1, true); 268e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (HB_TAG ('l','t','r','m'), 1, true); 2690e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod break; 2700e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod case HB_DIRECTION_RTL: 271e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (HB_TAG ('r','t','l','a'), 1, true); 272e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod //allocator.add_feature (HB_TAG ('r','t','l','m'), false); 273e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (HB_TAG ('r','t','l','m'), 1, true); 2740e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod break; 2750e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod case HB_DIRECTION_TTB: 2760e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod case HB_DIRECTION_BTT: 2770e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod default: 2780e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod break; 2790e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod } 2800e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2810e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod for (i = 0; i < ARRAY_LENGTH (default_features); i++) 282e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (default_features[i], 1, true); 283e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod 284e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod /* XXX complex-shaper features go here */ 285e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod 286e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod for (unsigned int i = 0; i < num_features; i++) { 287e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod const hb_feature_t *feature = &features[i]; 288e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod allocator.add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1)); 289e04685ee7be01695ec437fab50f919f1b7423c57Behdad Esfahbod } 2900e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2910e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2920e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Compile features */ 293f062ec6bb24b1c21d37b12adc7e944a5fe53526aBehdad Esfahbod allocator.compile (face, table_tag, script_index, language_index); 2940e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2950e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2960e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Gather lookup indices for features and set buffer masks at the same time */ 2970e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod 2980e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod const hb_mask_allocator_t::feature_map_t *map; 29981c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 3000e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_mask_t global_mask = allocator.get_global_mask (); 3010e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (global_mask) 3020e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod buffer->set_masks (global_mask, global_mask, 0, (unsigned int) -1); 303074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod 304074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod switch (original_direction) { 305074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod case HB_DIRECTION_LTR: 3060e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map = allocator.find_feature (HB_TAG ('l','t','r','a')); 3070e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, map->mask, lookups, num_lookups, room_lookups); 3080e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map = allocator.find_feature (HB_TAG ('l','t','r','m')); 3090e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, map->mask, lookups, num_lookups, room_lookups); 310074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod break; 311074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod case HB_DIRECTION_RTL: 3120e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map = allocator.find_feature (HB_TAG ('r','t','l','a')); 3130e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, map->mask, lookups, num_lookups, room_lookups); 3140e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod //map = allocator.find_feature (HB_TAG ('r','t','l','m')); 3150e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, MASK_RTLM, lookups, num_lookups, room_lookups); 316074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod break; 317074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod case HB_DIRECTION_TTB: 318074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod case HB_DIRECTION_BTT: 319074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod default: 320074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod break; 3212014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod } 3222014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 32381c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod for (i = 0; i < ARRAY_LENGTH (default_features); i++) 3247f411dbfd9f8d5360c948531ff9f6c3998d1d897Behdad Esfahbod { 3250e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map = allocator.find_feature (default_features[i]); 3260e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, map->mask, lookups, num_lookups, room_lookups); 32781c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod } 3286774463883978b00b4d8c719ed75edfc4537c77fBehdad Esfahbod 32981c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod for (i = 0; i < num_features; i++) 33081c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod { 3310e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod hb_feature_t *feature = &features[i]; 3320e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod map = allocator.find_feature (feature->tag); 3330e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod add_feature (face, table_tag, map->index, map->mask, lookups, num_lookups, room_lookups); 3340e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod if (!(feature->start == 0 && feature->end == (unsigned int)-1)) 3350e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod buffer->set_masks (features[i].value << map->shift, map->mask, feature->start, feature->end); 3367f411dbfd9f8d5360c948531ff9f6c3998d1d897Behdad Esfahbod } 3377f411dbfd9f8d5360c948531ff9f6c3998d1d897Behdad Esfahbod 33881c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod 3390e235d0fc9bdeeaffa7215c21abc5d40767a10c7Behdad Esfahbod /* Sort lookups and merge duplicates */ 340e53d77142ac4ecbe38ab3235491fa93cb7ff16abBehdad Esfahbod 3412014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod qsort (lookups, *num_lookups, sizeof (lookups[0]), cmp_lookups); 3422014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3432014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod if (*num_lookups) 3442014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod { 3452014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod for (i = 1, j = 0; i < *num_lookups; i++) 3466b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod if (lookups[i].index != lookups[j].index) 3472014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod lookups[++j] = lookups[i]; 3486b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod else 3496b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookups[j].mask |= lookups[i].mask; 3506b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod j++; 3512014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod *num_lookups = j; 3522014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod } 3532014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod} 3542014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3552014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 356ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic hb_bool_t 357ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_ot_substitute_complex (hb_font_t *font HB_UNUSED, 358ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 359ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 360ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features, 361074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod unsigned int num_features, 362074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod hb_direction_t original_direction) 3632014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod{ 36481c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod lookup_map lookups[1000]; /* FIXME */ 3652014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int num_lookups = ARRAY_LENGTH (lookups); 3662014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int i; 3672014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3682014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod if (!hb_ot_layout_has_substitution (face)) 3692014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod return FALSE; 3702014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3714206e9511a222c0c50cc9b4fe72ec421983bba2cBehdad Esfahbod setup_lookups (face, buffer, features, num_features, 3722014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_OT_TAG_GSUB, 373074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod lookups, &num_lookups, 374074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod original_direction); 3752014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3762014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod for (i = 0; i < num_lookups; i++) 3776b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod hb_ot_layout_substitute_lookup (face, buffer, lookups[i].index, lookups[i].mask); 3782014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 379e70f45eb522bcb41388cc218b79bbd6aaecf8050Behdad Esfahbod return TRUE; 3802014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod} 3812014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 382ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic hb_bool_t 383ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_ot_position_complex (hb_font_t *font, 384ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 385ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 386ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features, 387074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod unsigned int num_features, 388074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod hb_direction_t original_direction) 3892014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod{ 3906b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod lookup_map lookups[1000]; 3912014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int num_lookups = ARRAY_LENGTH (lookups); 3922014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod unsigned int i; 3932014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3942014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod if (!hb_ot_layout_has_positioning (face)) 3952014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod return FALSE; 3962014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 3974206e9511a222c0c50cc9b4fe72ec421983bba2cBehdad Esfahbod setup_lookups (face, buffer, features, num_features, 3982014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod HB_OT_TAG_GPOS, 399074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod lookups, &num_lookups, 400074ea787493a37ae8f68d17be7820f13fff57520Behdad Esfahbod original_direction); 4012014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 4022014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod for (i = 0; i < num_lookups; i++) 4036b1b957f6d2955cbe4fa97e2659e033b3eaaf4d2Behdad Esfahbod hb_ot_layout_position_lookup (font, face, buffer, lookups[i].index, lookups[i].mask); 4042014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 4052014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod hb_ot_layout_position_finish (font, face, buffer); 4062014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod 407e70f45eb522bcb41388cc218b79bbd6aaecf8050Behdad Esfahbod return TRUE; 4082014b8d110231b13e524008282ece7451f1ae9e7Behdad Esfahbod} 409ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 410ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 411ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod/* Main shaper */ 412ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 413ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod/* Prepare */ 414ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 415ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic inline hb_bool_t 416ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodis_variation_selector (hb_codepoint_t unicode) 417ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 418ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod return unlikely ((unicode >= 0x180B && unicode <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */ 419ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod (unicode >= 0xFE00 && unicode <= 0xFE0F) || /* VARIATION SELECTOR-1..16 */ 420ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod (unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SELECTOR-17..256 */ 421ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 422ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 423ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 424ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_form_clusters (hb_buffer_t *buffer) 425ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 426ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int count = buffer->len; 427ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod for (unsigned int i = 1; i < count; i++) 428bf36a1074ab23abeab0a7a6c47db26770dc1ab0aBehdad Esfahbod if (buffer->unicode->v.get_general_category (buffer->info[i].codepoint) == HB_CATEGORY_NON_SPACING_MARK) 429ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->info[i].cluster = buffer->info[i - 1].cluster; 430ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 431ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 432ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic hb_direction_t 433ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_ensure_native_direction (hb_buffer_t *buffer) 434ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 435ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_direction_t original_direction = buffer->direction; 436ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 437ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod /* TODO vertical */ 438ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod if (HB_DIRECTION_IS_HORIZONTAL (original_direction) && 439ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod original_direction != _hb_script_get_horizontal_direction (buffer->script)) 440ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod { 441ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_reverse_clusters (buffer); 442ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->direction = HB_DIRECTION_REVERSE (buffer->direction); 443ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 444ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 445ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod return original_direction; 446ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 447ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 448ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 449ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod/* Substitute */ 450ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 451ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 452ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_mirror_chars (hb_buffer_t *buffer) 453ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 454bf36a1074ab23abeab0a7a6c47db26770dc1ab0aBehdad Esfahbod hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->v.get_mirroring; 455ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 456ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod if (HB_DIRECTION_IS_FORWARD (buffer->direction)) 457ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod return; 458ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 459ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int count = buffer->len; 460ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) { 4611094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod hb_codepoint_t codepoint = get_mirroring (buffer->info[i].codepoint); 4621094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod if (likely (codepoint == buffer->info[i].codepoint)) 4631094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod buffer->info[i].mask |= MASK_RTLM; 4641094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod else 4651094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod buffer->info[i].codepoint = codepoint; 466ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 467ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 468ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 469ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 470ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_map_glyphs (hb_font_t *font, 471ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 472ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer) 473ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 474ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod if (unlikely (!buffer->len)) 475ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod return; 476ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 477a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->clear_output (); 478ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int count = buffer->len - 1; 479a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod for (buffer->i = 0; buffer->i < count;) { 480a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod if (unlikely (is_variation_selector (buffer->info[buffer->i + 1].codepoint))) { 481a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->add_output_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, buffer->info[buffer->i + 1].codepoint)); 482a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->i++; 483ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } else { 484a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->add_output_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, 0)); 485ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 486ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 487a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->add_output_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, 0)); 488a224b4d502d026fa642ee4098bf7bc0b4ba7ce27Behdad Esfahbod buffer->swap (); 489ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 490ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 491ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 492ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_substitute_default (hb_font_t *font, 493ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 494ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 495ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features HB_UNUSED, 496ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int num_features HB_UNUSED) 497ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 498ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_map_glyphs (font, face, buffer); 499ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 500ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 501ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 5029722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbodhb_substitute_complex_fallback (hb_font_t *font HB_UNUSED, 5039722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_face_t *face HB_UNUSED, 5049722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_buffer_t *buffer HB_UNUSED, 5059722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_feature_t *features HB_UNUSED, 5069722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod unsigned int num_features HB_UNUSED) 507ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 508ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod /* TODO Arabic */ 509ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 510ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 511ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 512ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod/* Position */ 513ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 514ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 515ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_position_default (hb_font_t *font, 516ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 517ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 518ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features HB_UNUSED, 519ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int num_features HB_UNUSED) 520ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 521ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_clear_positions (buffer); 522ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 523ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int count = buffer->len; 524ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) { 525ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_glyph_metrics_t metrics; 526ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_font_get_glyph_metrics (font, face, buffer->info[i].codepoint, &metrics); 527ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->pos[i].x_advance = metrics.x_advance; 528ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->pos[i].y_advance = metrics.y_advance; 529ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 530ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 531ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 532ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 5339722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbodhb_position_complex_fallback (hb_font_t *font HB_UNUSED, 5349722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_face_t *face HB_UNUSED, 5359722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_buffer_t *buffer HB_UNUSED, 5369722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_feature_t *features HB_UNUSED, 5379722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod unsigned int num_features HB_UNUSED) 538ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 539ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod /* TODO Mark pos */ 540ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 541ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 542ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 543ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_truetype_kern (hb_font_t *font, 544ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 545ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 546ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features HB_UNUSED, 547ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int num_features HB_UNUSED) 548ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 549ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod /* TODO Check for kern=0 */ 550ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int count = buffer->len; 551ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod for (unsigned int i = 1; i < count; i++) { 552ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_position_t kern, kern1, kern2; 553ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod kern = hb_font_get_kerning (font, face, buffer->info[i - 1].codepoint, buffer->info[i].codepoint); 554ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod kern1 = kern >> 1; 555ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod kern2 = kern - kern1; 556ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->pos[i - 1].x_advance += kern1; 557ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->pos[i].x_advance += kern2; 558ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->pos[i].x_offset += kern2; 559ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod } 560ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 561ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 562ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodstatic void 5639722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbodhb_position_complex_fallback_visual (hb_font_t *font, 5649722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_face_t *face, 5659722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_buffer_t *buffer, 5669722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod hb_feature_t *features, 5679722b8f005a10fd16e841df4da3ccd80be66e296Behdad Esfahbod unsigned int num_features) 568ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 569ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_truetype_kern (font, face, buffer, features, num_features); 570ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 571ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 572ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 573ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod/* Do it! */ 574ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 575ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodvoid 576ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbodhb_ot_shape (hb_font_t *font, 577ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_face_t *face, 578ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_buffer_t *buffer, 579ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_feature_t *features, 580ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod unsigned int num_features) 581ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod{ 582ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_direction_t original_direction; 583ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_bool_t substitute_fallback, position_fallback; 584ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 585ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod hb_form_clusters (buffer); 586ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 5871094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod /* SUBSTITUTE */ 588fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod { 5891094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 590fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod buffer->clear_masks (); 5911094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 592fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod /* Mirroring needs to see the original direction */ 593fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_mirror_chars (buffer); 594ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 595fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod original_direction = hb_ensure_native_direction (buffer); 596ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 597fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_substitute_default (font, face, buffer, features, num_features); 598bbc7a99d01298f9be1ebaaceacbc9bc961e247e5Behdad Esfahbod 599fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod substitute_fallback = !hb_ot_substitute_complex (font, face, buffer, features, num_features, original_direction); 600ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 601fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod if (substitute_fallback) 602fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_substitute_complex_fallback (font, face, buffer, features, num_features); 603ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 604fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod } 6051094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 6061094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod /* POSITION */ 607fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod { 6081094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 609fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod buffer->clear_masks (); 6101094a294f6a44c47fc75867983f2b135a6442babBehdad Esfahbod 611fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_position_default (font, face, buffer, features, num_features); 612ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 613fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod position_fallback = !hb_ot_position_complex (font, face, buffer, features, num_features, original_direction); 614ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 615fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod if (position_fallback) 616fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_position_complex_fallback (font, face, buffer, features, num_features); 617ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 618fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod if (HB_DIRECTION_IS_BACKWARD (buffer->direction)) 619fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_buffer_reverse (buffer); 620ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 621fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod if (position_fallback) 622fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod hb_position_complex_fallback_visual (font, face, buffer, features, num_features); 623fdc322a82047c4bda9fa3dab4338a0eac1c1bde7Behdad Esfahbod } 624ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod 625ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod buffer->direction = original_direction; 626ca663bb23c16f6a1f04efa6e10dad0e3e7c260a3Behdad Esfahbod} 627