hb-ot-layout.cc 33.7 KB
Newer Older
B
Behdad Esfahbod 已提交
1
/*
B
Behdad Esfahbod 已提交
2 3 4
 * Copyright © 1998-2004  David Turner and Werner Lemberg
 * Copyright © 2006  Behdad Esfahbod
 * Copyright © 2007,2008,2009  Red Hat, Inc.
5
 * Copyright © 2012,2013  Google, Inc.
B
Behdad Esfahbod 已提交
6
 *
B
Behdad Esfahbod 已提交
7
 *  This is part of HarfBuzz, a text shaping library.
B
Behdad Esfahbod 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * Permission is hereby granted, without written agreement and without
 * license or royalty fees, to use, copy, modify, and distribute this
 * software and its documentation for any purpose, provided that the
 * above copyright notice and the following two paragraphs appear in
 * all copies of this software.
 *
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Red Hat Author(s): Behdad Esfahbod
B
Behdad Esfahbod 已提交
28
 * Google Author(s): Behdad Esfahbod
B
Behdad Esfahbod 已提交
29 30
 */

31 32 33 34
#include "hb-open-type.hh"
#include "hb-ot-layout.hh"
#include "hb-ot-map.hh"
#include "hb-map.hh"
35

36 37 38
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
39 40 41 42

// Just so we compile them; unused otherwise:
#include "hb-ot-layout-base-table.hh"
#include "hb-ot-layout-jstf-table.hh"
43 44
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
45 46 47
#include "hb-ot-color-sbix-table.hh"
#include "hb-ot-color-svg-table.hh"
#include "hb-ot-name-table.hh"
B
Behdad Esfahbod 已提交
48

B
Behdad Esfahbod 已提交
49

50 51 52
// static inline const OT::BASE&
// _get_base (hb_face_t *face)
// {
B
Behdad Esfahbod 已提交
53
//   if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
54 55
//   hb_ot_face_data_t *data = hb_ot_face_data (face);
//   return *(data->base.get ());
56
// }
B
Behdad Esfahbod 已提交
57

58
static inline const OT::GDEF&
59 60
_get_gdef (hb_face_t *face)
{
B
Behdad Esfahbod 已提交
61
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
62
  return *hb_ot_face_data (face)->table.GDEF;
63
}
64
static inline const OT::GSUB&
65
_get_gsub (hb_face_t *face)
B
Behdad Esfahbod 已提交
66
{
B
Behdad Esfahbod 已提交
67
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
68
  return *hb_ot_face_data (face)->table.GSUB;
B
Behdad Esfahbod 已提交
69
}
70
static inline const OT::GPOS&
71
_get_gpos (hb_face_t *face)
B
Behdad Esfahbod 已提交
72
{
B
Behdad Esfahbod 已提交
73
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
74
  return *hb_ot_face_data (face)->table.GPOS;
B
Behdad Esfahbod 已提交
75 76
}

B
Behdad Esfahbod 已提交
77 78 79 80 81
/*
 * GDEF
 */

hb_bool_t
82
hb_ot_layout_has_glyph_classes (hb_face_t *face)
B
Behdad Esfahbod 已提交
83
{
84
  return _get_gdef (face).has_glyph_classes ();
B
Behdad Esfahbod 已提交
85 86
}

S
Sascha Brawer 已提交
87
/**
B
Behdad Esfahbod 已提交
88 89
 * hb_ot_layout_get_glyph_class:
 *
S
Sascha Brawer 已提交
90 91
 * Since: 0.9.7
 **/
92 93 94 95 96 97
hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class (hb_face_t      *face,
			      hb_codepoint_t  glyph)
{
  return (hb_ot_layout_glyph_class_t) _get_gdef (face).get_glyph_class (glyph);
}
B
Behdad Esfahbod 已提交
98

S
Sascha Brawer 已提交
99
/**
B
Behdad Esfahbod 已提交
100 101
 * hb_ot_layout_get_glyphs_in_class:
 *
S
Sascha Brawer 已提交
102 103
 * Since: 0.9.7
 **/
104 105 106 107 108 109 110 111
void
hb_ot_layout_get_glyphs_in_class (hb_face_t                  *face,
				  hb_ot_layout_glyph_class_t  klass,
				  hb_set_t                   *glyphs /* OUT */)
{
  return _get_gdef (face).get_glyphs_in_class (klass, glyphs);
}

B
Behdad Esfahbod 已提交
112
unsigned int
113
hb_ot_layout_get_attach_points (hb_face_t      *face,
B
Behdad Esfahbod 已提交
114
				hb_codepoint_t  glyph,
B
Behdad Esfahbod 已提交
115
				unsigned int    start_offset,
B
Behdad Esfahbod 已提交
116 117 118
				unsigned int   *point_count /* IN/OUT */,
				unsigned int   *point_array /* OUT */)
{
B
Behdad Esfahbod 已提交
119
  return _get_gdef (face).get_attach_points (glyph, start_offset, point_count, point_array);
B
Behdad Esfahbod 已提交
120 121
}

B
Behdad Esfahbod 已提交
122
unsigned int
123 124 125 126 127
hb_ot_layout_get_ligature_carets (hb_font_t      *font,
				  hb_direction_t  direction,
				  hb_codepoint_t  glyph,
				  unsigned int    start_offset,
				  unsigned int   *caret_count /* IN/OUT */,
128
				  hb_position_t  *caret_array /* OUT */)
B
Behdad Esfahbod 已提交
129
{
130
  return _get_gdef (font->face).get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
B
Behdad Esfahbod 已提交
131 132
}

133

134 135 136 137
/*
 * GSUB/GPOS
 */

138
static const OT::GSUBGPOS&
139 140
get_gsubgpos_table (hb_face_t *face,
		    hb_tag_t   table_tag)
141
{
142
  switch (table_tag) {
143 144
    case HB_OT_TAG_GSUB: return _get_gsub (face);
    case HB_OT_TAG_GPOS: return _get_gpos (face);
B
Behdad Esfahbod 已提交
145
    default:             return Null(OT::GSUBGPOS);
146 147 148 149
  }
}


B
Behdad Esfahbod 已提交
150
unsigned int
151 152
hb_ot_layout_table_get_script_tags (hb_face_t    *face,
				    hb_tag_t      table_tag,
B
Behdad Esfahbod 已提交
153
				    unsigned int  start_offset,
154 155
				    unsigned int *script_count /* IN/OUT */,
				    hb_tag_t     *script_tags /* OUT */)
156
{
157
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
158

B
Behdad Esfahbod 已提交
159
  return g.get_script_tags (start_offset, script_count, script_tags);
160 161
}

B
Minor  
Behdad Esfahbod 已提交
162 163
#define HB_OT_TAG_LATIN_SCRIPT		HB_TAG ('l', 'a', 't', 'n')

164
hb_bool_t
165 166 167 168
hb_ot_layout_table_find_script (hb_face_t    *face,
				hb_tag_t      table_tag,
				hb_tag_t      script_tag,
				unsigned int *script_index)
169
{
170
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), "");
171
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
172 173

  if (g.find_script_index (script_tag, script_index))
174
    return true;
175 176

  /* try finding 'DFLT' */
177
  if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index))
178
    return false;
179

180 181
  /* try with 'dflt'; MS site has had typos and many fonts use it now :(.
   * including many versions of DejaVu Sans Mono! */
182
  if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index))
183
    return false;
B
Behdad Esfahbod 已提交
184

B
Minor  
Behdad Esfahbod 已提交
185 186 187 188 189
  /* try with 'latn'; some old fonts put their features there even though
     they're really trying to support Thai, for example :( */
  if (g.find_script_index (HB_OT_TAG_LATIN_SCRIPT, script_index))
    return false;

B
Behdad Esfahbod 已提交
190
  if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
191
  return false;
B
Behdad Esfahbod 已提交
192 193 194 195 196 197
}

hb_bool_t
hb_ot_layout_table_choose_script (hb_face_t      *face,
				  hb_tag_t        table_tag,
				  const hb_tag_t *script_tags,
B
Behdad Esfahbod 已提交
198 199
				  unsigned int   *script_index,
				  hb_tag_t       *chosen_script)
B
Behdad Esfahbod 已提交
200
{
201
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), "");
202
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
B
Behdad Esfahbod 已提交
203 204 205

  while (*script_tags)
  {
B
Behdad Esfahbod 已提交
206 207 208
    if (g.find_script_index (*script_tags, script_index)) {
      if (chosen_script)
        *chosen_script = *script_tags;
209
      return true;
B
Behdad Esfahbod 已提交
210
    }
B
Behdad Esfahbod 已提交
211 212 213 214
    script_tags++;
  }

  /* try finding 'DFLT' */
B
Behdad Esfahbod 已提交
215 216 217
  if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index)) {
    if (chosen_script)
      *chosen_script = HB_OT_TAG_DEFAULT_SCRIPT;
218
    return false;
B
Behdad Esfahbod 已提交
219
  }
B
Behdad Esfahbod 已提交
220 221

  /* try with 'dflt'; MS site has had typos and many fonts use it now :( */
B
Behdad Esfahbod 已提交
222 223 224
  if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index)) {
    if (chosen_script)
      *chosen_script = HB_OT_TAG_DEFAULT_LANGUAGE;
225
    return false;
B
Behdad Esfahbod 已提交
226
  }
227

228 229 230 231 232
  /* try with 'latn'; some old fonts put their features there even though
     they're really trying to support Thai, for example :( */
  if (g.find_script_index (HB_OT_TAG_LATIN_SCRIPT, script_index)) {
    if (chosen_script)
      *chosen_script = HB_OT_TAG_LATIN_SCRIPT;
233
    return false;
234 235
  }

236
  if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
B
Behdad Esfahbod 已提交
237 238
  if (chosen_script)
    *chosen_script = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
239
  return false;
240 241
}

B
Behdad Esfahbod 已提交
242
unsigned int
243 244
hb_ot_layout_table_get_feature_tags (hb_face_t    *face,
				     hb_tag_t      table_tag,
B
Behdad Esfahbod 已提交
245
				     unsigned int  start_offset,
246 247
				     unsigned int *feature_count /* IN/OUT */,
				     hb_tag_t     *feature_tags /* OUT */)
248
{
249
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
250

B
Behdad Esfahbod 已提交
251
  return g.get_feature_tags (start_offset, feature_count, feature_tags);
252 253
}

254 255 256 257 258 259
hb_bool_t
hb_ot_layout_table_find_feature (hb_face_t    *face,
				 hb_tag_t      table_tag,
				 hb_tag_t      feature_tag,
				 unsigned int *feature_index)
{
260
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), "");
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);

  unsigned int num_features = g.get_feature_count ();
  for (unsigned int i = 0; i < num_features; i++)
  {
    if (feature_tag == g.get_feature_tag (i)) {
      if (feature_index) *feature_index = i;
      return true;
    }
  }

  if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX;
  return false;
}

276

B
Behdad Esfahbod 已提交
277
unsigned int
278 279 280
hb_ot_layout_script_get_language_tags (hb_face_t    *face,
				       hb_tag_t      table_tag,
				       unsigned int  script_index,
B
Behdad Esfahbod 已提交
281
				       unsigned int  start_offset,
282 283
				       unsigned int *language_count /* IN/OUT */,
				       hb_tag_t     *language_tags /* OUT */)
284
{
285
  const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
286

B
Behdad Esfahbod 已提交
287
  return s.get_lang_sys_tags (start_offset, language_count, language_tags);
288 289 290
}

hb_bool_t
291 292 293 294 295
hb_ot_layout_script_find_language (hb_face_t    *face,
				   hb_tag_t      table_tag,
				   unsigned int  script_index,
				   hb_tag_t      language_tag,
				   unsigned int *language_index)
296
{
297
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX), "");
298
  const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
299

300
  if (s.find_lang_sys_index (language_tag, language_index))
301
    return true;
302 303

  /* try with 'dflt'; MS site has had typos and many fonts use it now :( */
304
  if (s.find_lang_sys_index (HB_OT_TAG_DEFAULT_LANGUAGE, language_index))
305
    return false;
306

307
  if (language_index) *language_index = HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX;
308
  return false;
309
}
310

B
Behdad Esfahbod 已提交
311 312 313 314 315 316 317 318 319 320 321 322
hb_bool_t
hb_ot_layout_language_get_required_feature_index (hb_face_t    *face,
						  hb_tag_t      table_tag,
						  unsigned int  script_index,
						  unsigned int  language_index,
						  unsigned int *feature_index)
{
  return hb_ot_layout_language_get_required_feature (face,
						     table_tag,
						     script_index,
						     language_index,
						     feature_index,
B
Behdad Esfahbod 已提交
323
						     nullptr);
B
Behdad Esfahbod 已提交
324 325
}

S
Sascha Brawer 已提交
326
/**
B
Behdad Esfahbod 已提交
327 328
 * hb_ot_layout_language_get_required_feature:
 *
S
Sascha Brawer 已提交
329 330
 * Since: 0.9.30
 **/
331
hb_bool_t
332 333 334 335 336 337
hb_ot_layout_language_get_required_feature (hb_face_t    *face,
					    hb_tag_t      table_tag,
					    unsigned int  script_index,
					    unsigned int  language_index,
					    unsigned int *feature_index,
					    hb_tag_t     *feature_tag)
338
{
339 340
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
341

342 343 344
  unsigned int index = l.get_required_feature_index ();
  if (feature_index) *feature_index = index;
  if (feature_tag) *feature_tag = g.get_feature_tag (index);
345

346 347
  return l.has_required_feature ();
}
348

349 350 351 352 353 354 355 356 357 358 359 360 361
static void
_hb_ot_layout_language_add_feature_indexes_to (hb_face_t    *face,
                                               hb_tag_t      table_tag,
                                               unsigned int  script_index,
                                               unsigned int  language_index,
                                               hb_set_t     *feature_indexes /* OUT */)
{
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
  l.add_feature_indexes_to (feature_indexes);
}


B
Behdad Esfahbod 已提交
362
unsigned int
363 364 365 366
hb_ot_layout_language_get_feature_indexes (hb_face_t    *face,
					   hb_tag_t      table_tag,
					   unsigned int  script_index,
					   unsigned int  language_index,
B
Behdad Esfahbod 已提交
367
					   unsigned int  start_offset,
368 369
					   unsigned int *feature_count /* IN/OUT */,
					   unsigned int *feature_indexes /* OUT */)
370
{
371 372
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
373

B
Behdad Esfahbod 已提交
374
  return l.get_feature_indexes (start_offset, feature_count, feature_indexes);
375 376
}

B
Behdad Esfahbod 已提交
377
unsigned int
378 379 380 381
hb_ot_layout_language_get_feature_tags (hb_face_t    *face,
					hb_tag_t      table_tag,
					unsigned int  script_index,
					unsigned int  language_index,
B
Behdad Esfahbod 已提交
382
					unsigned int  start_offset,
383 384
					unsigned int *feature_count /* IN/OUT */,
					hb_tag_t     *feature_tags /* OUT */)
385
{
386 387
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
388

389
  static_assert ((sizeof (unsigned int) == sizeof (hb_tag_t)), "");
B
Behdad Esfahbod 已提交
390
  unsigned int ret = l.get_feature_indexes (start_offset, feature_count, (unsigned int *) feature_tags);
391

B
Behdad Esfahbod 已提交
392 393 394 395 396
  if (feature_tags) {
    unsigned int count = *feature_count;
    for (unsigned int i = 0; i < count; i++)
      feature_tags[i] = g.get_feature_tag ((unsigned int) feature_tags[i]);
  }
397 398

  return ret;
399 400 401 402
}


hb_bool_t
403 404 405 406 407 408
hb_ot_layout_language_find_feature (hb_face_t    *face,
				    hb_tag_t      table_tag,
				    unsigned int  script_index,
				    unsigned int  language_index,
				    hb_tag_t      feature_tag,
				    unsigned int *feature_index)
409
{
410
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), "");
411 412
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
413

B
Behdad Esfahbod 已提交
414 415
  unsigned int num_features = l.get_feature_count ();
  for (unsigned int i = 0; i < num_features; i++) {
416 417 418 419
    unsigned int f_index = l.get_feature_index (i);

    if (feature_tag == g.get_feature_tag (f_index)) {
      if (feature_index) *feature_index = f_index;
420
      return true;
421 422
    }
  }
423

424
  if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX;
425
  return false;
426
}
427

S
Sascha Brawer 已提交
428
/**
K
Khaled Hosny 已提交
429 430
 * hb_ot_layout_feature_get_lookups:
 *
S
Sascha Brawer 已提交
431 432
 * Since: 0.9.7
 **/
B
Behdad Esfahbod 已提交
433
unsigned int
434 435 436 437 438 439
hb_ot_layout_feature_get_lookups (hb_face_t    *face,
				  hb_tag_t      table_tag,
				  unsigned int  feature_index,
				  unsigned int  start_offset,
				  unsigned int *lookup_count /* IN/OUT */,
				  unsigned int *lookup_indexes /* OUT */)
440
{
441 442 443 444 445 446 447
  return hb_ot_layout_feature_with_variations_get_lookups (face,
							   table_tag,
							   feature_index,
							   HB_OT_LAYOUT_NO_VARIATIONS_INDEX,
							   start_offset,
							   lookup_count,
							   lookup_indexes);
448 449
}

S
Sascha Brawer 已提交
450
/**
K
Khaled Hosny 已提交
451 452
 * hb_ot_layout_table_get_lookup_count:
 *
S
Sascha Brawer 已提交
453 454
 * Since: 0.9.22
 **/
455 456 457 458
unsigned int
hb_ot_layout_table_get_lookup_count (hb_face_t    *face,
				     hb_tag_t      table_tag)
{
459
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return 0;
460 461 462 463
  switch (table_tag)
  {
    case HB_OT_TAG_GSUB:
    {
464
      return hb_ot_face_data (face)->gsub_lookup_count;
465 466 467
    }
    case HB_OT_TAG_GPOS:
    {
468
      return hb_ot_face_data (face)->gpos_lookup_count;
469 470
    }
  }
B
Behdad Esfahbod 已提交
471
  return 0;
472 473
}

474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
static void
_hb_ot_layout_collect_lookups_lookups (hb_face_t      *face,
				       hb_tag_t        table_tag,
				       unsigned int    feature_index,
				       hb_set_t       *lookup_indexes /* OUT */)
{
  unsigned int lookup_indices[32];
  unsigned int offset, len;

  offset = 0;
  do {
    len = ARRAY_LENGTH (lookup_indices);
    hb_ot_layout_feature_get_lookups (face,
				      table_tag,
				      feature_index,
				      offset, &len,
				      lookup_indices);

    for (unsigned int i = 0; i < len; i++)
      lookup_indexes->add (lookup_indices[i]);

    offset += len;
  } while (len == ARRAY_LENGTH (lookup_indices));
}

static void
500 501 502 503 504 505
_hb_ot_layout_collect_features_features (hb_face_t      *face,
                                         hb_tag_t        table_tag,
                                         unsigned int    script_index,
                                         unsigned int    language_index,
                                         const hb_tag_t *features,
                                         hb_set_t       *feature_indexes /* OUT */)
506 507 508
{
  if (!features)
  {
509
    unsigned int required_feature_index;
510 511 512 513 514
    if (hb_ot_layout_language_get_required_feature (face,
						    table_tag,
						    script_index,
						    language_index,
						    &required_feature_index,
515 516
						    nullptr))
      feature_indexes->add (required_feature_index);
517

518
    /* All features */
519 520 521 522 523
    _hb_ot_layout_language_add_feature_indexes_to (face,
                                                   table_tag,
                                                   script_index,
                                                   language_index,
                                                   feature_indexes);
524 525 526
  }
  else
  {
527 528 529
    for (; *features; features++)
    {
      unsigned int feature_index;
B
Behdad Esfahbod 已提交
530 531 532 533 534 535
      if (hb_ot_layout_language_find_feature (face,
					      table_tag,
					      script_index,
					      language_index,
					      *features,
					      &feature_index))
536
        feature_indexes->add (feature_index);
537 538 539 540 541
    }
  }
}

static void
542 543 544 545 546 547
_hb_ot_layout_collect_features_languages (hb_face_t      *face,
                                          hb_tag_t        table_tag,
                                          unsigned int    script_index,
                                          const hb_tag_t *languages,
                                          const hb_tag_t *features,
                                          hb_set_t       *feature_indexes /* OUT */)
548
{
549 550 551 552 553 554
  _hb_ot_layout_collect_features_features (face,
                                           table_tag,
                                           script_index,
                                           HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
                                           features,
                                           feature_indexes);
555

556 557 558
  if (!languages)
  {
    /* All languages */
B
Behdad Esfahbod 已提交
559 560 561
    unsigned int count = hb_ot_layout_script_get_language_tags (face,
								table_tag,
								script_index,
B
Behdad Esfahbod 已提交
562
								0, nullptr, nullptr);
563
    for (unsigned int language_index = 0; language_index < count; language_index++)
564 565 566 567 568 569
      _hb_ot_layout_collect_features_features (face,
                                               table_tag,
                                               script_index,
                                               language_index,
                                               features,
                                               feature_indexes);
570 571 572
  }
  else
  {
573 574 575
    for (; *languages; languages++)
    {
      unsigned int language_index;
B
Behdad Esfahbod 已提交
576 577 578 579 580
      if (hb_ot_layout_script_find_language (face,
					     table_tag,
					     script_index,
					     *languages,
					     &language_index))
581 582 583 584 585 586
        _hb_ot_layout_collect_features_features (face,
                                                 table_tag,
                                                 script_index,
                                                 language_index,
                                                 features,
                                                 feature_indexes);
587 588 589 590
    }
  }
}

S
Sascha Brawer 已提交
591
/**
592
 * hb_ot_layout_collect_features:
K
Khaled Hosny 已提交
593
 *
B
1.8.5  
Behdad Esfahbod 已提交
594
 * Since: 1.8.5
S
Sascha Brawer 已提交
595
 **/
596
void
597 598 599 600 601 602
hb_ot_layout_collect_features (hb_face_t      *face,
                               hb_tag_t        table_tag,
                               const hb_tag_t *scripts,
                               const hb_tag_t *languages,
                               const hb_tag_t *features,
                               hb_set_t       *feature_indexes /* OUT */)
603 604 605 606
{
  if (!scripts)
  {
    /* All scripts */
B
Behdad Esfahbod 已提交
607 608
    unsigned int count = hb_ot_layout_table_get_script_tags (face,
							     table_tag,
B
Behdad Esfahbod 已提交
609
							     0, nullptr, nullptr);
610
    for (unsigned int script_index = 0; script_index < count; script_index++)
611 612 613 614 615 616
      _hb_ot_layout_collect_features_languages (face,
                                                table_tag,
                                                script_index,
                                                languages,
                                                features,
                                                feature_indexes);
617 618 619
  }
  else
  {
620 621 622
    for (; *scripts; scripts++)
    {
      unsigned int script_index;
B
Behdad Esfahbod 已提交
623 624 625 626
      if (hb_ot_layout_table_find_script (face,
					  table_tag,
					  *scripts,
					  &script_index))
627 628 629 630 631 632
        _hb_ot_layout_collect_features_languages (face,
                                                  table_tag,
                                                  script_index,
                                                  languages,
                                                  features,
                                                  feature_indexes);
633 634 635 636
    }
  }
}

637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
/**
 * hb_ot_layout_collect_lookups:
 *
 * Since: 0.9.8
 **/
void
hb_ot_layout_collect_lookups (hb_face_t      *face,
			      hb_tag_t        table_tag,
			      const hb_tag_t *scripts,
			      const hb_tag_t *languages,
			      const hb_tag_t *features,
			      hb_set_t       *lookup_indexes /* OUT */)
{
  hb_auto_t<hb_set_t> feature_indexes;
  hb_ot_layout_collect_features (face, table_tag, scripts, languages, features, &feature_indexes);
  for (hb_codepoint_t feature_index = HB_SET_VALUE_INVALID; hb_set_next (&feature_indexes, &feature_index);)
    _hb_ot_layout_collect_lookups_lookups (face, table_tag, feature_index, lookup_indexes);
}

S
Sascha Brawer 已提交
656
/**
K
Khaled Hosny 已提交
657 658
 * hb_ot_layout_lookup_collect_glyphs:
 *
S
Sascha Brawer 已提交
659 660
 * Since: 0.9.7
 **/
661 662 663 664
void
hb_ot_layout_lookup_collect_glyphs (hb_face_t    *face,
				    hb_tag_t      table_tag,
				    unsigned int  lookup_index,
B
Behdad Esfahbod 已提交
665 666 667 668
				    hb_set_t     *glyphs_before, /* OUT. May be nullptr */
				    hb_set_t     *glyphs_input,  /* OUT. May be nullptr */
				    hb_set_t     *glyphs_after,  /* OUT. May be nullptr */
				    hb_set_t     *glyphs_output  /* OUT. May be nullptr */)
669 670 671
{
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;

B
Behdad Esfahbod 已提交
672 673 674 675 676
  OT::hb_collect_glyphs_context_t c (face,
				     glyphs_before,
				     glyphs_input,
				     glyphs_after,
				     glyphs_output);
677

678 679
  switch (table_tag)
  {
680 681
    case HB_OT_TAG_GSUB:
    {
682
      const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->get_lookup (lookup_index);
B
Behdad Esfahbod 已提交
683
      l.collect_glyphs (&c);
684 685 686 687
      return;
    }
    case HB_OT_TAG_GPOS:
    {
688
      const OT::PosLookup& l = hb_ot_face_data (face)->table.GPOS->get_lookup (lookup_index);
B
Behdad Esfahbod 已提交
689
      l.collect_glyphs (&c);
690 691 692 693 694
      return;
    }
  }
}

B
Behdad Esfahbod 已提交
695

696 697 698 699 700 701 702 703 704 705 706 707 708 709
/* Variations support */

hb_bool_t
hb_ot_layout_table_find_feature_variations (hb_face_t    *face,
					    hb_tag_t      table_tag,
					    const int    *coords,
					    unsigned int  num_coords,
					    unsigned int *variations_index /* out */)
{
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);

  return g.find_variations_index (coords, num_coords, variations_index);
}

710 711 712 713 714 715 716 717 718
unsigned int
hb_ot_layout_feature_with_variations_get_lookups (hb_face_t    *face,
						  hb_tag_t      table_tag,
						  unsigned int  feature_index,
						  unsigned int  variations_index,
						  unsigned int  start_offset,
						  unsigned int *lookup_count /* IN/OUT */,
						  unsigned int *lookup_indexes /* OUT */)
{
719
  static_assert ((OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX), "");
720 721 722 723 724 725 726
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);

  const OT::Feature &f = g.get_feature_variation (feature_index, variations_index);

  return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
}

727

B
Behdad Esfahbod 已提交
728
/*
729
 * OT::GSUB
B
Behdad Esfahbod 已提交
730 731 732
 */

hb_bool_t
733 734
hb_ot_layout_has_substitution (hb_face_t *face)
{
735
  return _get_gsub (face).has_data ();
736 737
}

S
Sascha Brawer 已提交
738
/**
K
Khaled Hosny 已提交
739 740
 * hb_ot_layout_lookup_would_substitute:
 *
S
Sascha Brawer 已提交
741 742
 * Since: 0.9.7
 **/
743
hb_bool_t
744
hb_ot_layout_lookup_would_substitute (hb_face_t            *face,
745
				      unsigned int          lookup_index,
746 747
				      const hb_codepoint_t *glyphs,
				      unsigned int          glyphs_length,
748
				      hb_bool_t             zero_context)
749
{
750
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
751
  return hb_ot_layout_lookup_would_substitute_fast (face, lookup_index, glyphs, glyphs_length, zero_context);
752 753
}

B
Behdad Esfahbod 已提交
754
hb_bool_t
755
hb_ot_layout_lookup_would_substitute_fast (hb_face_t            *face,
756
					   unsigned int          lookup_index,
B
Behdad Esfahbod 已提交
757 758
					   const hb_codepoint_t *glyphs,
					   unsigned int          glyphs_length,
759
					   hb_bool_t             zero_context)
B
Behdad Esfahbod 已提交
760
{
761
  if (unlikely (lookup_index >= hb_ot_face_data (face)->gsub_lookup_count)) return false;
762
  OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
B
Behdad Esfahbod 已提交
763

764
  const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->get_lookup (lookup_index);
B
Behdad Esfahbod 已提交
765

766
  return l.would_apply (&c, &hb_ot_face_data (face)->gsub_accels[lookup_index]);
B
Behdad Esfahbod 已提交
767 768
}

769
void
770
hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer)
771
{
772
  OT::GSUB::substitute_start (font, buffer);
773 774
}

S
Sascha Brawer 已提交
775
/**
K
Khaled Hosny 已提交
776 777
 * hb_ot_layout_lookup_substitute_closure:
 *
S
Sascha Brawer 已提交
778 779
 * Since: 0.9.7
 **/
B
Behdad Esfahbod 已提交
780
void
781
hb_ot_layout_lookup_substitute_closure (hb_face_t    *face,
782 783
				        unsigned int  lookup_index,
				        hb_set_t     *glyphs)
784
{
785 786
  hb_auto_t<hb_map_t> done_lookups;
  OT::hb_closure_context_t c (face, glyphs, &done_lookups);
787 788 789

  const OT::SubstLookup& l = _get_gsub (face).get_lookup (lookup_index);

790
  l.closure (&c, lookup_index);
791
}
792

793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
/**
 * hb_ot_layout_lookups_substitute_closure:
 *
 * Compute the transitive closure of glyphs needed for all of the
 * provided lookups.
 *
 * Since: 1.8.1
 **/
void
hb_ot_layout_lookups_substitute_closure (hb_face_t      *face,
                                         const hb_set_t *lookups,
                                         hb_set_t       *glyphs)
{
  hb_auto_t<hb_map_t> done_lookups;
  OT::hb_closure_context_t c (face, glyphs, &done_lookups);
  const OT::GSUB& gsub = _get_gsub (face);

810
  unsigned int iteration_count = 0;
811 812 813 814
  unsigned int glyphs_length;
  do
  {
    glyphs_length = glyphs->get_population ();
815 816 817 818
    if (lookups != nullptr)
    {
      for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);)
        gsub.get_lookup (lookup_index).closure (&c, lookup_index);
B
Style  
Behdad Esfahbod 已提交
819 820 821
    }
    else
    {
822 823 824
      for (unsigned int i = 0; i < gsub.get_lookup_count (); i++)
        gsub.get_lookup (i).closure (&c, i);
    }
825 826 827
    iteration_count++;
  } while (iteration_count <= HB_CLOSURE_MAX_STAGES
           && glyphs_length != glyphs->get_population ());
828 829
}

830
/*
831
 * OT::GPOS
832 833 834
 */

hb_bool_t
835 836
hb_ot_layout_has_positioning (hb_face_t *face)
{
837
  return _get_gpos (face).has_data ();
838 839
}

840
void
841
hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer)
842
{
843
  OT::GPOS::position_start (font, buffer);
844 845
}

846
void
847 848 849 850 851 852 853
hb_ot_layout_position_finish_advances (hb_font_t *font, hb_buffer_t *buffer)
{
  OT::GPOS::position_finish_advances (font, buffer);
}

void
hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer)
854
{
855
  OT::GPOS::position_finish_offsets (font, buffer);
856
}
857

S
Sascha Brawer 已提交
858
/**
K
Khaled Hosny 已提交
859 860
 * hb_ot_layout_get_size_params:
 *
B
Behdad Esfahbod 已提交
861
 * Since: 0.9.10
S
Sascha Brawer 已提交
862
 **/
863
hb_bool_t
864
hb_ot_layout_get_size_params (hb_face_t    *face,
B
Behdad Esfahbod 已提交
865 866 867 868 869
			      unsigned int *design_size,       /* OUT.  May be nullptr */
			      unsigned int *subfamily_id,      /* OUT.  May be nullptr */
			      unsigned int *subfamily_name_id, /* OUT.  May be nullptr */
			      unsigned int *range_start,       /* OUT.  May be nullptr */
			      unsigned int *range_end          /* OUT.  May be nullptr */)
870 871
{
  const OT::GPOS &gpos = _get_gpos (face);
872
  const hb_tag_t tag = HB_TAG ('s','i','z','e');
873

874 875 876
  unsigned int num_features = gpos.get_feature_count ();
  for (unsigned int i = 0; i < num_features; i++)
  {
877
    if (tag == gpos.get_feature_tag (i))
878
    {
879
      const OT::Feature &f = gpos.get_feature (i);
880
      const OT::FeatureParamsSize &params = f.get_feature_params ().get_size_params (tag);
881

882
      if (params.designSize)
883
      {
884
#define PARAM(a, A) if (a) *a = params.A
885 886 887 888 889 890
	PARAM (design_size, designSize);
	PARAM (subfamily_id, subfamilyID);
	PARAM (subfamily_name_id, subfamilyNameID);
	PARAM (range_start, rangeStart);
	PARAM (range_end, rangeEnd);
#undef PARAM
891 892 893

	return true;
      }
894 895 896
    }
  }

897
#define PARAM(a, A) if (a) *a = 0
898 899 900 901 902
  PARAM (design_size, designSize);
  PARAM (subfamily_id, subfamilyID);
  PARAM (subfamily_name_id, subfamilyNameID);
  PARAM (range_start, rangeStart);
  PARAM (range_end, rangeEnd);
903
#undef PARAM
904

905
  return false;
906
}
B
Behdad Esfahbod 已提交
907 908 909


/*
B
Behdad Esfahbod 已提交
910
 * Parts of different types are implemented here such that they have direct
B
Behdad Esfahbod 已提交
911 912 913 914
 * access to GSUB/GPOS lookups.
 */


B
Behdad Esfahbod 已提交
915 916 917
struct GSUBProxy
{
  static const unsigned int table_index = 0;
B
Behdad Esfahbod 已提交
918
  static const bool inplace = false;
B
Behdad Esfahbod 已提交
919 920 921
  typedef OT::SubstLookup Lookup;

  GSUBProxy (hb_face_t *face) :
922 923
    table (*hb_ot_face_data (face)->table.GSUB),
    accels (hb_ot_face_data (face)->gsub_accels) {}
B
Behdad Esfahbod 已提交
924 925 926 927 928 929 930 931

  const OT::GSUB &table;
  const hb_ot_layout_lookup_accelerator_t *accels;
};

struct GPOSProxy
{
  static const unsigned int table_index = 1;
B
Behdad Esfahbod 已提交
932
  static const bool inplace = true;
B
Behdad Esfahbod 已提交
933 934 935
  typedef OT::PosLookup Lookup;

  GPOSProxy (hb_face_t *face) :
936 937
    table (*hb_ot_face_data (face)->table.GPOS),
    accels (hb_ot_face_data (face)->gpos_accels) {}
B
Behdad Esfahbod 已提交
938 939 940 941 942 943

  const OT::GPOS &table;
  const hb_ot_layout_lookup_accelerator_t *accels;
};


944
struct hb_get_subtables_context_t :
945
       hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
946 947
{
  template <typename Type>
948
  static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
949 950 951 952 953
  {
    const Type *typed_obj = (const Type *) obj;
    return typed_obj->apply (c);
  }

954
  typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
955 956 957 958 959 960 961 962 963

  struct hb_applicable_t
  {
    inline void init (const void *obj_, hb_apply_func_t apply_func_)
    {
      obj = obj_;
      apply_func = apply_func_;
    }

964
    inline bool apply (OT::hb_ot_apply_context_t *c) const { return apply_func (obj, c); }
965 966 967 968 969 970

    private:
    const void *obj;
    hb_apply_func_t apply_func;
  };

B
Behdad Esfahbod 已提交
971
  typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
972 973 974 975 976 977 978

  /* Dispatch interface. */
  inline const char *get_name (void) { return "GET_SUBTABLES"; }
  template <typename T>
  inline return_t dispatch (const T &obj)
  {
    hb_applicable_t *entry = array.push();
979
    entry->init (&obj, apply_to<T>);
980 981 982 983 984 985 986 987 988 989 990 991 992
    return HB_VOID;
  }
  static return_t default_return_value (void) { return HB_VOID; }
  bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }

  hb_get_subtables_context_t (array_t &array_) :
			      array (array_),
			      debug_depth (0) {}

  array_t &array;
  unsigned int debug_depth;
};

993
static inline bool
994
apply_forward (OT::hb_ot_apply_context_t *c,
995 996
	       const hb_ot_layout_lookup_accelerator_t &accel,
	       const hb_get_subtables_context_t::array_t &subtables)
997 998 999
{
  bool ret = false;
  hb_buffer_t *buffer = c->buffer;
B
Behdad Esfahbod 已提交
1000
  while (buffer->idx < buffer->len && buffer->successful)
1001
  {
1002
    bool applied = false;
1003 1004
    if (accel.may_have (buffer->cur().codepoint) &&
	(buffer->cur().mask & c->lookup_mask) &&
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
	c->check_glyph_property (&buffer->cur(), c->lookup_props))
     {
       for (unsigned int i = 0; i < subtables.len; i++)
         if (subtables[i].apply (c))
	 {
	   applied = true;
	   break;
	 }
     }

    if (applied)
1016 1017 1018 1019 1020 1021 1022 1023
      ret = true;
    else
      buffer->next_glyph ();
  }
  return ret;
}

static inline bool
1024
apply_backward (OT::hb_ot_apply_context_t *c,
1025 1026
	       const hb_ot_layout_lookup_accelerator_t &accel,
	       const hb_get_subtables_context_t::array_t &subtables)
1027 1028 1029 1030 1031 1032 1033
{
  bool ret = false;
  hb_buffer_t *buffer = c->buffer;
  do
  {
    if (accel.may_have (buffer->cur().codepoint) &&
	(buffer->cur().mask & c->lookup_mask) &&
1034 1035 1036 1037 1038 1039 1040 1041 1042
	c->check_glyph_property (&buffer->cur(), c->lookup_props))
    {
     for (unsigned int i = 0; i < subtables.len; i++)
       if (subtables[i].apply (c))
       {
	 ret = true;
	 break;
       }
    }
1043 1044 1045 1046 1047 1048 1049 1050
    /* The reverse lookup doesn't "advance" cursor (for good reason). */
    buffer->idx--;

  }
  while ((int) buffer->idx >= 0);
  return ret;
}

1051
template <typename Proxy>
1052
static inline void
1053
apply_string (OT::hb_ot_apply_context_t *c,
1054 1055 1056
	      const typename Proxy::Lookup &lookup,
	      const hb_ot_layout_lookup_accelerator_t &accel)
{
B
Behdad Esfahbod 已提交
1057
  hb_buffer_t *buffer = c->buffer;
1058

1059
  if (unlikely (!buffer->len || !c->lookup_mask))
1060
    return;
1061

1062
  c->set_lookup_props (lookup.get_props ());
1063

1064 1065 1066 1067
  hb_get_subtables_context_t::array_t subtables;
  hb_get_subtables_context_t c_get_subtables (subtables);
  lookup.dispatch (&c_get_subtables);

1068 1069 1070 1071
  if (likely (!lookup.is_reverse ()))
  {
    /* in/out forward substitution/positioning */
    if (Proxy::table_index == 0)
B
Behdad Esfahbod 已提交
1072 1073
      buffer->clear_output ();
    buffer->idx = 0;
1074

1075
    bool ret;
1076
    ret = apply_forward (c, accel, subtables);
1077
    if (ret)
1078
    {
B
Behdad Esfahbod 已提交
1079
      if (!Proxy::inplace)
B
Behdad Esfahbod 已提交
1080
	buffer->swap_buffers ();
1081
      else
1082
	assert (!buffer->has_separate_output ());
1083
    }
1084 1085 1086 1087 1088
  }
  else
  {
    /* in-place backward substitution/positioning */
    if (Proxy::table_index == 0)
B
Behdad Esfahbod 已提交
1089 1090
      buffer->remove_output ();
    buffer->idx = buffer->len - 1;
1091

1092
    apply_backward (c, accel, subtables);
1093 1094 1095
  }
}

B
Behdad Esfahbod 已提交
1096 1097
template <typename Proxy>
inline void hb_ot_map_t::apply (const Proxy &proxy,
B
Behdad Esfahbod 已提交
1098 1099 1100 1101
				const hb_ot_shape_plan_t *plan,
				hb_font_t *font,
				hb_buffer_t *buffer) const
{
B
Behdad Esfahbod 已提交
1102
  const unsigned int table_index = proxy.table_index;
B
Behdad Esfahbod 已提交
1103
  unsigned int i = 0;
1104
  OT::hb_ot_apply_context_t c (table_index, font, buffer);
1105
  c.set_recurse_func (Proxy::Lookup::apply_recurse_func);
B
Behdad Esfahbod 已提交
1106 1107 1108 1109

  for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stage_index++) {
    const stage_map_t *stage = &stages[table_index][stage_index];
    for (; i < stage->last_lookup; i++)
B
Behdad Esfahbod 已提交
1110 1111
    {
      unsigned int lookup_index = lookups[table_index][i].index;
1112
      if (!buffer->message (font, "start lookup %d", lookup_index)) continue;
1113
      c.set_lookup_index (lookup_index);
B
Behdad Esfahbod 已提交
1114 1115
      c.set_lookup_mask (lookups[table_index][i].mask);
      c.set_auto_zwj (lookups[table_index][i].auto_zwj);
1116
      c.set_auto_zwnj (lookups[table_index][i].auto_zwnj);
1117 1118 1119
      apply_string<Proxy> (&c,
			   proxy.table.get_lookup (lookup_index),
			   proxy.accels[lookup_index]);
1120
      (void) buffer->message (font, "end lookup %d", lookup_index);
B
Behdad Esfahbod 已提交
1121
    }
B
Behdad Esfahbod 已提交
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132

    if (stage->pause_func)
    {
      buffer->clear_output ();
      stage->pause_func (plan, font, buffer);
    }
  }
}

void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
B
Behdad Esfahbod 已提交
1133 1134
  GSUBProxy proxy (font->face);
  apply (proxy, plan, font, buffer);
B
Behdad Esfahbod 已提交
1135 1136 1137 1138
}

void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
B
Behdad Esfahbod 已提交
1139 1140 1141 1142
  GPOSProxy proxy (font->face);
  apply (proxy, plan, font, buffer);
}

B
Minor  
Behdad Esfahbod 已提交
1143
void
1144
hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
B
Behdad Esfahbod 已提交
1145 1146 1147
				const OT::SubstLookup &lookup,
				const hb_ot_layout_lookup_accelerator_t &accel)
{
1148
  apply_string<GSUBProxy> (c, lookup, accel);
B
Behdad Esfahbod 已提交
1149
}
B
Behdad Esfahbod 已提交
1150 1151 1152 1153 1154 1155 1156 1157




/*
 * OT::BASE
 */

1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
// /**
//  * hb_ot_base_has_data:
//  * @face: #hb_face_t to test
//  *
//  * This function allows to verify the presence of an OpenType BASE table on the
//  * face.
//  *
//  * Return value: true if face has a BASE table, false otherwise
//  *
//  * Since: XXX
//  **/
// hb_bool_t
// hb_ot_base_has_data (hb_face_t *face)
// {
1172
//   return _get_base (face).has_data ();
1173
// }