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
#include "hb-open-type.hh"
#include "hb-ot-layout.hh"
33
#include "hb-ot-face.hh"
34 35
#include "hb-ot-map.hh"
#include "hb-map.hh"
36

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

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

B
Behdad Esfahbod 已提交
50

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

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

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

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

S
Sascha Brawer 已提交
88
/**
B
Behdad Esfahbod 已提交
89 90
 * hb_ot_layout_get_glyph_class:
 *
S
Sascha Brawer 已提交
91 92
 * Since: 0.9.7
 **/
93 94 95 96 97 98
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 已提交
99

S
Sascha Brawer 已提交
100
/**
B
Behdad Esfahbod 已提交
101 102
 * hb_ot_layout_get_glyphs_in_class:
 *
S
Sascha Brawer 已提交
103 104
 * Since: 0.9.7
 **/
105 106 107 108 109 110 111 112
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 已提交
113
unsigned int
114
hb_ot_layout_get_attach_points (hb_face_t      *face,
B
Behdad Esfahbod 已提交
115
				hb_codepoint_t  glyph,
B
Behdad Esfahbod 已提交
116
				unsigned int    start_offset,
B
Behdad Esfahbod 已提交
117 118 119
				unsigned int   *point_count /* IN/OUT */,
				unsigned int   *point_array /* OUT */)
{
B
Behdad Esfahbod 已提交
120
  return _get_gdef (face).get_attach_points (glyph, start_offset, point_count, point_array);
B
Behdad Esfahbod 已提交
121 122
}

B
Behdad Esfahbod 已提交
123
unsigned int
124 125 126 127 128
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 */,
129
				  hb_position_t  *caret_array /* OUT */)
B
Behdad Esfahbod 已提交
130
{
131
  return _get_gdef (font->face).get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
B
Behdad Esfahbod 已提交
132 133
}

134

135 136 137 138
/*
 * GSUB/GPOS
 */

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


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

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

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

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

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

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

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

B
Minor  
Behdad Esfahbod 已提交
186 187 188 189 190
  /* 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 已提交
191
  if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
192
  return false;
B
Behdad Esfahbod 已提交
193 194 195 196 197 198
}

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 已提交
199 200
				  unsigned int   *script_index,
				  hb_tag_t       *chosen_script)
B
Behdad Esfahbod 已提交
201
{
202
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), "");
203
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
B
Behdad Esfahbod 已提交
204 205 206

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

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

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

229 230 231 232 233
  /* 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;
234
    return false;
235 236
  }

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

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

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

255 256 257 258 259 260
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)
{
261
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), "");
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
  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;
}

277

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

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

hb_bool_t
292 293 294 295 296
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)
297
{
298
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX), "");
299
  const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
300

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

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

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

B
Behdad Esfahbod 已提交
312 313 314 315 316 317 318 319 320 321 322 323
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 已提交
324
						     nullptr);
B
Behdad Esfahbod 已提交
325 326
}

S
Sascha Brawer 已提交
327
/**
B
Behdad Esfahbod 已提交
328 329
 * hb_ot_layout_language_get_required_feature:
 *
S
Sascha Brawer 已提交
330 331
 * Since: 0.9.30
 **/
332
hb_bool_t
333 334 335 336 337 338
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)
339
{
340 341
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
342

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

347 348
  return l.has_required_feature ();
}
349

350 351 352 353 354 355 356 357 358 359 360 361 362
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 已提交
363
unsigned int
364 365 366 367
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 已提交
368
					   unsigned int  start_offset,
369 370
					   unsigned int *feature_count /* IN/OUT */,
					   unsigned int *feature_indexes /* OUT */)
371
{
372 373
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
374

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

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

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

B
Behdad Esfahbod 已提交
393 394 395 396 397
  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]);
  }
398 399

  return ret;
400 401 402 403
}


hb_bool_t
404 405 406 407 408 409
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)
410
{
411
  static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), "");
412 413
  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
  const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
414

B
Behdad Esfahbod 已提交
415 416
  unsigned int num_features = l.get_feature_count ();
  for (unsigned int i = 0; i < num_features; i++) {
417 418 419 420
    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;
421
      return true;
422 423
    }
  }
424

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

S
Sascha Brawer 已提交
429
/**
K
Khaled Hosny 已提交
430 431
 * hb_ot_layout_feature_get_lookups:
 *
S
Sascha Brawer 已提交
432 433
 * Since: 0.9.7
 **/
B
Behdad Esfahbod 已提交
434
unsigned int
435 436 437 438 439 440
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 */)
441
{
442 443 444 445 446 447 448
  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);
449 450
}

S
Sascha Brawer 已提交
451
/**
K
Khaled Hosny 已提交
452 453
 * hb_ot_layout_table_get_lookup_count:
 *
S
Sascha Brawer 已提交
454 455
 * Since: 0.9.22
 **/
456 457 458 459
unsigned int
hb_ot_layout_table_get_lookup_count (hb_face_t    *face,
				     hb_tag_t      table_tag)
{
460
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return 0;
461 462 463 464
  switch (table_tag)
  {
    case HB_OT_TAG_GSUB:
    {
465
      return hb_ot_face_data (face)->table.GSUB->lookup_count;
466 467 468
    }
    case HB_OT_TAG_GPOS:
    {
469
      return hb_ot_face_data (face)->table.GPOS->lookup_count;
470 471
    }
  }
B
Behdad Esfahbod 已提交
472
  return 0;
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 500
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
501 502 503 504 505 506
_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 */)
507 508 509
{
  if (!features)
  {
510
    unsigned int required_feature_index;
511 512 513 514 515
    if (hb_ot_layout_language_get_required_feature (face,
						    table_tag,
						    script_index,
						    language_index,
						    &required_feature_index,
516 517
						    nullptr))
      feature_indexes->add (required_feature_index);
518

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

static void
543 544 545 546 547 548
_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 */)
549
{
550 551 552 553 554 555
  _hb_ot_layout_collect_features_features (face,
                                           table_tag,
                                           script_index,
                                           HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
                                           features,
                                           feature_indexes);
556

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

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

638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
/**
 * 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 已提交
657
/**
K
Khaled Hosny 已提交
658 659
 * hb_ot_layout_lookup_collect_glyphs:
 *
S
Sascha Brawer 已提交
660 661
 * Since: 0.9.7
 **/
662 663 664 665
void
hb_ot_layout_lookup_collect_glyphs (hb_face_t    *face,
				    hb_tag_t      table_tag,
				    unsigned int  lookup_index,
B
Behdad Esfahbod 已提交
666 667 668 669
				    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 */)
670 671 672
{
  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;

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

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

B
Behdad Esfahbod 已提交
696

697 698 699 700 701 702 703 704 705 706 707 708 709 710
/* 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);
}

711 712 713 714 715 716 717 718 719
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 */)
{
720
  static_assert ((OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX), "");
721 722 723 724 725 726 727
  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);
}

728

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

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

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

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

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

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

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

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

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

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

794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
/**
 * 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);

811
  unsigned int iteration_count = 0;
812 813 814 815
  unsigned int glyphs_length;
  do
  {
    glyphs_length = glyphs->get_population ();
816 817 818 819
    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 已提交
820 821 822
    }
    else
    {
823 824 825
      for (unsigned int i = 0; i < gsub.get_lookup_count (); i++)
        gsub.get_lookup (i).closure (&c, i);
    }
826 827 828
    iteration_count++;
  } while (iteration_count <= HB_CLOSURE_MAX_STAGES
           && glyphs_length != glyphs->get_population ());
829 830
}

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

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

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

847
void
848 849 850 851 852 853 854
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)
855
{
856
  OT::GPOS::position_finish_offsets (font, buffer);
857
}
858

S
Sascha Brawer 已提交
859
/**
K
Khaled Hosny 已提交
860 861
 * hb_ot_layout_get_size_params:
 *
B
Behdad Esfahbod 已提交
862
 * Since: 0.9.10
S
Sascha Brawer 已提交
863
 **/
864
hb_bool_t
865
hb_ot_layout_get_size_params (hb_face_t    *face,
B
Behdad Esfahbod 已提交
866 867 868 869 870
			      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 */)
871 872
{
  const OT::GPOS &gpos = _get_gpos (face);
873
  const hb_tag_t tag = HB_TAG ('s','i','z','e');
874

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

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

	return true;
      }
895 896 897
    }
  }

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

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


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


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

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

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

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

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

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


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

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

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

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

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

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

  /* 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();
980
    entry->init (&obj, apply_to<T>);
981 982 983 984 985 986 987 988 989 990 991 992 993
    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;
};

994
static inline bool
995
apply_forward (OT::hb_ot_apply_context_t *c,
996 997
	       const hb_ot_layout_lookup_accelerator_t &accel,
	       const hb_get_subtables_context_t::array_t &subtables)
998 999 1000
{
  bool ret = false;
  hb_buffer_t *buffer = c->buffer;
B
Behdad Esfahbod 已提交
1001
  while (buffer->idx < buffer->len && buffer->successful)
1002
  {
1003
    bool applied = false;
1004 1005
    if (accel.may_have (buffer->cur().codepoint) &&
	(buffer->cur().mask & c->lookup_mask) &&
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
	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)
1017 1018 1019 1020 1021 1022 1023 1024
      ret = true;
    else
      buffer->next_glyph ();
  }
  return ret;
}

static inline bool
1025
apply_backward (OT::hb_ot_apply_context_t *c,
1026 1027
	       const hb_ot_layout_lookup_accelerator_t &accel,
	       const hb_get_subtables_context_t::array_t &subtables)
1028 1029 1030 1031 1032 1033 1034
{
  bool ret = false;
  hb_buffer_t *buffer = c->buffer;
  do
  {
    if (accel.may_have (buffer->cur().codepoint) &&
	(buffer->cur().mask & c->lookup_mask) &&
1035 1036 1037 1038 1039 1040 1041 1042 1043
	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;
       }
    }
1044 1045 1046 1047 1048 1049 1050 1051
    /* The reverse lookup doesn't "advance" cursor (for good reason). */
    buffer->idx--;

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

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

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

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

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

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

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

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

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

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

    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 已提交
1134 1135
  GSUBProxy proxy (font->face);
  apply (proxy, plan, font, buffer);
B
Behdad Esfahbod 已提交
1136 1137 1138 1139
}

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 已提交
1140 1141 1142 1143
  GPOSProxy proxy (font->face);
  apply (proxy, plan, font, buffer);
}

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




/*
 * OT::BASE
 */

1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
// /**
//  * 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)
// {
1173
//   return _get_base (face).has_data ();
1174
// }