hb-buffer.cc 15.3 KB
Newer Older
1
/*
B
Behdad Esfahbod 已提交
2 3 4
 * Copyright © 1998-2004  David Turner and Werner Lemberg
 * Copyright © 2004,2007,2009,2010  Red Hat, Inc.
 * Copyright © 2011  Google, Inc.
5
 *
6
 *  This is part of HarfBuzz, a text shaping library.
7
 *
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * 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): Owen Taylor, Behdad Esfahbod
27
 * Google Author(s): Behdad Esfahbod
28 29
 */

30
#include "hb-buffer-private.hh"
31

B
Behdad Esfahbod 已提交
32 33
#include <string.h>

B
Behdad Esfahbod 已提交
34 35
HB_BEGIN_DECLS

36

37
static hb_buffer_t _hb_buffer_nil = {
38
  HB_OBJECT_HEADER_STATIC,
B
Behdad Esfahbod 已提交
39

40 41 42 43 44 45
  &_hb_unicode_funcs_nil,  /* unicode */
  {
    HB_DIRECTION_INVALID,
    HB_SCRIPT_INVALID,
    NULL,
  },
46 47
};

48 49
/* Here is how the buffer works internally:
 *
B
Behdad Esfahbod 已提交
50 51
 * There are two info pointers: info and out_info.  They always have
 * the same allocated size, but different lengths.
52
 *
53
 * As an optimization, both info and out_info may point to the
54
 * same piece of memory, which is owned by info.  This remains the
55
 * case as long as out_len doesn't exceed i at any time.
B
Behdad Esfahbod 已提交
56 57
 * In that case, swap() is no-op and the glyph operations operate
 * mostly in-place.
58
 *
59
 * As soon as out_info gets longer than info, out_info is moved over
B
Behdad Esfahbod 已提交
60 61 62 63
 * to an alternate buffer (which we reuse the pos buffer for!), and its
 * current contents (out_len entries) are copied to the new place.
 * This should all remain transparent to the user.  swap() then
 * switches info and out_info.
64 65
 */

B
Behdad Esfahbod 已提交
66

67 68 69 70 71 72 73
static hb_bool_t
_hb_buffer_enlarge (hb_buffer_t *buffer, unsigned int size)
{
  if (unlikely (buffer->in_error))
    return FALSE;

  unsigned int new_allocated = buffer->allocated;
74 75
  hb_glyph_position_t *new_pos;
  hb_glyph_info_t *new_info;
76 77 78 79 80 81 82
  bool separate_out;

  separate_out = buffer->out_info != buffer->info;

  while (size > new_allocated)
    new_allocated += (new_allocated >> 1) + 8;

B
Behdad Esfahbod 已提交
83 84 85 86 87 88 89 90 91 92
  ASSERT_STATIC (sizeof (buffer->info[0]) == sizeof (buffer->pos[0]));
  bool overflows = new_allocated >= ((unsigned int) -1) / sizeof (buffer->info[0]);

  if (unlikely (overflows)) {
    new_pos = NULL;
    new_info = NULL;
  } else {
    new_pos = (hb_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
    new_info = (hb_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
  }
93 94 95 96 97 98 99 100 101 102

  if (unlikely (!new_pos || !new_info))
    buffer->in_error = TRUE;

  if (likely (new_pos))
    buffer->pos = new_pos;

  if (likely (new_info))
    buffer->info = new_info;

103
  buffer->out_info = separate_out ? (hb_glyph_info_t *) buffer->pos : buffer->info;
104 105 106 107 108 109 110 111 112 113 114
  if (likely (!buffer->in_error))
    buffer->allocated = new_allocated;

  return likely (!buffer->in_error);
}

static inline hb_bool_t
_hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
  return likely (size <= buffer->allocated) ? TRUE : _hb_buffer_enlarge (buffer, size);
}
115

B
Behdad Esfahbod 已提交
116
static inline hb_bool_t
117
_hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
B
Behdad Esfahbod 已提交
118
{
119
  if (unlikely (!_hb_buffer_ensure (buffer, size))) return FALSE;
120

121
  if (buffer->out_info == buffer->info)
122
  {
123
    assert (buffer->have_output);
124

125
    buffer->out_info = (hb_glyph_info_t *) buffer->pos;
126
    memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
127
  }
128 129

  return TRUE;
130 131
}

132

133 134
/* Public API */

135
hb_buffer_t *
136
hb_buffer_create (unsigned int pre_alloc_size)
137
{
138 139
  hb_buffer_t *buffer;

B
Behdad Esfahbod 已提交
140
  if (!HB_OBJECT_DO_CREATE (hb_buffer_t, buffer))
141
    return &_hb_buffer_nil;
142

143
  if (pre_alloc_size)
144
    _hb_buffer_ensure (buffer, pre_alloc_size);
145

146
  hb_buffer_reset (buffer);
B
Behdad Esfahbod 已提交
147

148 149
  return buffer;
}
B
Behdad Esfahbod 已提交
150

151 152 153 154 155
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer)
{
  HB_OBJECT_DO_REFERENCE (buffer);
}
B
Behdad Esfahbod 已提交
156

B
Behdad Esfahbod 已提交
157
void
158
hb_buffer_destroy (hb_buffer_t *buffer)
B
Behdad Esfahbod 已提交
159
{
160 161
  HB_OBJECT_DO_DESTROY (buffer);

B
Behdad Esfahbod 已提交
162 163
  hb_unicode_funcs_destroy (buffer->unicode);

164
  free (buffer->info);
165
  free (buffer->pos);
166

167
  free (buffer);
B
Behdad Esfahbod 已提交
168 169
}

B
Behdad Esfahbod 已提交
170 171 172 173 174

void
hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
			     hb_unicode_funcs_t *unicode)
{
B
Behdad Esfahbod 已提交
175 176 177
  if (!unicode)
    unicode = &_hb_unicode_funcs_nil;

B
Behdad Esfahbod 已提交
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
  hb_unicode_funcs_reference (unicode);
  hb_unicode_funcs_destroy (buffer->unicode);
  buffer->unicode = unicode;
}

hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer)
{
  return buffer->unicode;
}

void
hb_buffer_set_direction (hb_buffer_t    *buffer,
			 hb_direction_t  direction)

{
194
  buffer->props.direction = direction;
B
Behdad Esfahbod 已提交
195 196 197 198 199
}

hb_direction_t
hb_buffer_get_direction (hb_buffer_t    *buffer)
{
200
  return buffer->props.direction;
B
Behdad Esfahbod 已提交
201 202
}

203 204 205 206
void
hb_buffer_set_script (hb_buffer_t *buffer,
		      hb_script_t  script)
{
207
  buffer->props.script = script;
208 209 210 211 212
}

hb_script_t
hb_buffer_get_script (hb_buffer_t *buffer)
{
213
  return buffer->props.script;
214 215 216 217 218 219
}

void
hb_buffer_set_language (hb_buffer_t   *buffer,
			hb_language_t  language)
{
220
  buffer->props.language = language;
221 222 223 224 225
}

hb_language_t
hb_buffer_get_language (hb_buffer_t *buffer)
{
226
  return buffer->props.language;
227 228
}

B
Behdad Esfahbod 已提交
229

230 231
void
hb_buffer_reset (hb_buffer_t *buffer)
B
Behdad Esfahbod 已提交
232
{
233 234 235 236 237
  hb_unicode_funcs_destroy (buffer->unicode);
  buffer->unicode = _hb_buffer_nil.unicode;

  buffer->props = _hb_buffer_nil.props;

238
  buffer->have_output = FALSE;
239
  buffer->have_positions = FALSE;
240
  buffer->in_error = FALSE;
241 242

  buffer->i = 0;
243
  buffer->len = 0;
244
  buffer->out_len = 0;
B
Behdad Esfahbod 已提交
245

246
  buffer->serial = 0;
B
Behdad Esfahbod 已提交
247

248
  buffer->out_info = buffer->info;
B
Behdad Esfahbod 已提交
249 250
}

251
hb_bool_t
252
hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
B
Behdad Esfahbod 已提交
253
{
254
  return _hb_buffer_ensure (buffer, size);
B
Behdad Esfahbod 已提交
255 256
}

257 258 259 260 261 262
hb_bool_t
hb_buffer_allocation_successful (hb_buffer_t  *buffer)
{
  return !buffer->in_error;
}

263
void
264 265 266 267
hb_buffer_add (hb_buffer_t    *buffer,
	       hb_codepoint_t  codepoint,
	       hb_mask_t       mask,
	       unsigned int    cluster)
268
{
269
  hb_glyph_info_t *glyph;
270

271
  if (unlikely (!_hb_buffer_ensure (buffer, buffer->len + 1))) return;
272

273
  glyph = &buffer->info[buffer->len];
274 275

  memset (glyph, 0, sizeof (*glyph));
276
  glyph->codepoint = codepoint;
277
  glyph->mask = mask;
278 279
  glyph->cluster = cluster;

280
  buffer->len++;
281 282
}

283 284 285 286 287 288 289
/* HarfBuzz-Internal API */

void
_hb_buffer_clear_output (hb_buffer_t *buffer)
{
  buffer->have_output = TRUE;
  buffer->have_positions = FALSE;
290

291 292 293 294
  buffer->out_len = 0;
  buffer->out_info = buffer->info;
}

295 296 297 298 299 300 301 302 303
void
_hb_buffer_clear_positions (hb_buffer_t *buffer)
{
  buffer->have_output = FALSE;
  buffer->have_positions = TRUE;

  memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len);
}

B
Behdad Esfahbod 已提交
304
void
B
Behdad Esfahbod 已提交
305
_hb_buffer_swap (hb_buffer_t *buffer)
306
{
B
Behdad Esfahbod 已提交
307
  unsigned int tmp;
308

309 310
  assert (buffer->have_output);

311 312
  if (unlikely (buffer->in_error)) return;

313
  if (buffer->out_info != buffer->info)
314
  {
315
    hb_glyph_info_t *tmp_string;
316
    tmp_string = buffer->info;
317 318
    buffer->info = buffer->out_info;
    buffer->out_info = tmp_string;
319
    buffer->pos = (hb_glyph_position_t *) buffer->out_info;
320
  }
321

322
  tmp = buffer->len;
323 324
  buffer->len = buffer->out_len;
  buffer->out_len = tmp;
325

326
  buffer->i = 0;
327 328
}

329
void
B
Behdad Esfahbod 已提交
330 331 332 333
_hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer,
				unsigned int num_in,
				unsigned int num_out,
				const uint16_t *glyph_data_be)
334
{
335
  if (buffer->out_info != buffer->info ||
336
      buffer->out_len + num_out > buffer->i + num_in)
337
  {
338
    if (unlikely (!_hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
339
      return;
340 341
  }

342
  hb_glyph_info_t orig_info = buffer->info[buffer->i];
343

344
  for (unsigned int i = 0; i < num_out; i++)
345
  {
346
    hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
347
    *info = orig_info;
348 349 350
    info->codepoint = hb_be_uint16 (glyph_data_be[i]);
  }

351
  buffer->i  += num_in;
352
  buffer->out_len += num_out;
353
}
B
Behdad Esfahbod 已提交
354

B
Behdad Esfahbod 已提交
355
void
B
Behdad Esfahbod 已提交
356 357
_hb_buffer_replace_glyph (hb_buffer_t *buffer,
			  hb_codepoint_t glyph_index)
358
{
359
  hb_glyph_info_t *info;
B
Behdad Esfahbod 已提交
360

361
  if (buffer->out_info != buffer->info)
362
  {
363
    if (unlikely (!_hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
364
    buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
365
  }
366 367
  else if (buffer->out_len != buffer->i)
    buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
368

369
  info = &buffer->out_info[buffer->out_len];
370
  info->codepoint = glyph_index;
B
Behdad Esfahbod 已提交
371

372
  buffer->i++;
373
  buffer->out_len++;
374 375
}

B
Behdad Esfahbod 已提交
376
void
B
Behdad Esfahbod 已提交
377
_hb_buffer_next_glyph (hb_buffer_t *buffer)
B
Behdad Esfahbod 已提交
378
{
379
  if (buffer->have_output)
380
  {
381
    if (buffer->out_info != buffer->info)
382
    {
383
      if (unlikely (!_hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
384
      buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
385
    }
386 387
    else if (buffer->out_len != buffer->i)
      buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
388

389
    buffer->out_len++;
390
  }
391

392
  buffer->i++;
393 394
}

B
Behdad Esfahbod 已提交
395
void
396 397
_hb_buffer_reset_masks (hb_buffer_t *buffer,
			hb_mask_t    mask)
B
Behdad Esfahbod 已提交
398 399 400
{
  unsigned int count = buffer->len;
  for (unsigned int i = 0; i < count; i++)
B
Behdad Esfahbod 已提交
401
    buffer->info[i].mask = mask;
B
Behdad Esfahbod 已提交
402 403 404
}

void
405
_hb_buffer_add_masks (hb_buffer_t *buffer,
B
Behdad Esfahbod 已提交
406 407 408 409 410 411 412 413 414
		      hb_mask_t    mask)
{
  unsigned int count = buffer->len;
  for (unsigned int i = 0; i < count; i++)
    buffer->info[i].mask |= mask;
}

void
_hb_buffer_set_masks (hb_buffer_t *buffer,
415 416 417 418
		      hb_mask_t    value,
		      hb_mask_t    mask,
		      unsigned int cluster_start,
		      unsigned int cluster_end)
B
Behdad Esfahbod 已提交
419
{
420
  hb_mask_t not_mask = ~mask;
421
  value &= mask;
422

B
Behdad Esfahbod 已提交
423 424 425
  if (!mask)
    return;

B
Behdad Esfahbod 已提交
426 427 428
  if (cluster_start == 0 && cluster_end == (unsigned int)-1) {
    unsigned int count = buffer->len;
    for (unsigned int i = 0; i < count; i++)
429
      buffer->info[i].mask = (buffer->info[i].mask & not_mask) | value;
B
Behdad Esfahbod 已提交
430 431 432
    return;
  }

B
Behdad Esfahbod 已提交
433
  /* XXX can't bsearch since .cluster may not be sorted. */
B
Behdad Esfahbod 已提交
434 435 436 437 438 439 440 441 442 443 444 445
  /* Binary search to find the start position and go from there. */
  unsigned int min = 0, max = buffer->len;
  while (min < max)
  {
    unsigned int mid = min + ((max - min) / 2);
    if (buffer->info[mid].cluster < cluster_start)
      min = mid + 1;
    else
      max = mid;
  }
  unsigned int count = buffer->len;
  for (unsigned int i = min; i < count && buffer->info[i].cluster < cluster_end; i++)
446
    buffer->info[i].mask = (buffer->info[i].mask & not_mask) | value;
B
Behdad Esfahbod 已提交
447 448
}

449

450 451
/* Public API again */

452 453 454 455
hb_bool_t
hb_buffer_set_length (hb_buffer_t  *buffer,
		      unsigned int  length)
{
456
  if (!_hb_buffer_ensure (buffer, length))
457 458 459 460 461 462 463 464 465 466 467 468 469
    return FALSE;

  /* Wipe the new space */
  if (length > buffer->len) {
    memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len));
    if (buffer->have_positions)
      memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len));
  }

  buffer->len = length;
  return TRUE;
}

470
unsigned int
471
hb_buffer_get_length (hb_buffer_t *buffer)
472
{
473
  return buffer->len;
474 475 476 477
}

/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
478 479
hb_buffer_get_glyph_infos (hb_buffer_t  *buffer,
                           unsigned int *length)
480
{
481 482 483
  if (length)
    *length = buffer->len;

484
  return (hb_glyph_info_t *) buffer->info;
485 486 487 488
}

/* Return value valid as long as buffer not modified */
hb_glyph_position_t *
489 490
hb_buffer_get_glyph_positions (hb_buffer_t  *buffer,
                               unsigned int *length)
491
{
492
  if (!buffer->have_positions)
493
    _hb_buffer_clear_positions (buffer);
494

495 496 497
  if (length)
    *length = buffer->len;

498
  return (hb_glyph_position_t *) buffer->pos;
499
}
B
Behdad Esfahbod 已提交
500 501


502 503 504 505
static void
reverse_range (hb_buffer_t *buffer,
	       unsigned int start,
	       unsigned int end)
B
Behdad Esfahbod 已提交
506 507 508
{
  unsigned int i, j;

509
  for (i = start, j = end - 1; i < j; i++, j--) {
510
    hb_glyph_info_t t;
B
Behdad Esfahbod 已提交
511

512 513 514
    t = buffer->info[i];
    buffer->info[i] = buffer->info[j];
    buffer->info[j] = t;
B
Behdad Esfahbod 已提交
515 516
  }

517
  if (buffer->pos) {
518
    for (i = 0, j = end - 1; i < j; i++, j--) {
519
      hb_glyph_position_t t;
B
Behdad Esfahbod 已提交
520

521 522 523
      t = buffer->pos[i];
      buffer->pos[i] = buffer->pos[j];
      buffer->pos[j] = t;
B
Behdad Esfahbod 已提交
524 525 526
    }
  }
}
527

528 529 530
void
hb_buffer_reverse (hb_buffer_t *buffer)
{
531
  if (unlikely (!buffer->len))
532 533
    return;

534
  reverse_range (buffer, 0, buffer->len);
535 536 537 538 539 540 541
}

void
hb_buffer_reverse_clusters (hb_buffer_t *buffer)
{
  unsigned int i, start, count, last_cluster;

542
  if (unlikely (!buffer->len))
543 544 545 546
    return;

  hb_buffer_reverse (buffer);

547
  count = buffer->len;
548
  start = 0;
549
  last_cluster = buffer->info[0].cluster;
550
  for (i = 1; i < count; i++) {
551
    if (last_cluster != buffer->info[i].cluster) {
552 553
      reverse_range (buffer, start, i);
      start = i;
554
      last_cluster = buffer->info[i].cluster;
555 556 557 558 559
    }
  }
  reverse_range (buffer, start, i);
}

560 561 562 563 564 565 566 567 568

#define ADD_UTF(T) \
	HB_STMT_START { \
	  const T *next = (const T *) text + item_offset; \
	  const T *end = next + item_length; \
	  while (next < end) { \
	    hb_codepoint_t u; \
	    const T *old_next = next; \
	    next = UTF_NEXT (next, end, u); \
569
	    hb_buffer_add (buffer, u, 1,  old_next - (const T *) text); \
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
	  } \
	} HB_STMT_END


#define UTF8_COMPUTE(Char, Mask, Len) \
  if (Char < 128) { Len = 1; Mask = 0x7f; } \
  else if ((Char & 0xe0) == 0xc0) { Len = 2; Mask = 0x1f; } \
  else if ((Char & 0xf0) == 0xe0) { Len = 3; Mask = 0x0f; } \
  else if ((Char & 0xf8) == 0xf0) { Len = 4; Mask = 0x07; } \
  else Len = 0;

static inline const uint8_t *
hb_utf8_next (const uint8_t *text,
	      const uint8_t *end,
	      hb_codepoint_t *unicode)
{
  uint8_t c = *text;
  unsigned int mask, len;

B
Behdad Esfahbod 已提交
589 590
  /* TODO check for overlong sequences?  also: optimize? */

591
  UTF8_COMPUTE (c, mask, len);
592
  if (unlikely (!len || (unsigned int) (end - text) < len)) {
593 594 595 596 597 598 599 600
    *unicode = -1;
    return text + 1;
  } else {
    hb_codepoint_t result;
    unsigned int i;
    result = c & mask;
    for (i = 1; i < len; i++)
      {
601
	if (unlikely ((text[i] & 0xc0) != 0x80))
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
	  {
	    *unicode = -1;
	    return text + 1;
	  }
	result <<= 6;
	result |= (text[i] & 0x3f);
      }
    *unicode = result;
    return text + len;
  }
}

void
hb_buffer_add_utf8 (hb_buffer_t  *buffer,
		    const char   *text,
617
		    unsigned int  text_length HB_UNUSED,
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
		    unsigned int  item_offset,
		    unsigned int  item_length)
{
#define UTF_NEXT(S, E, U)	hb_utf8_next (S, E, &(U))
  ADD_UTF (uint8_t);
#undef UTF_NEXT
}

static inline const uint16_t *
hb_utf16_next (const uint16_t *text,
	       const uint16_t *end,
	       hb_codepoint_t *unicode)
{
  uint16_t c = *text++;

633
  if (unlikely (c >= 0xd800 && c < 0xdc00)) {
634 635
    /* high surrogate */
    uint16_t l;
B
Minor  
Behdad Esfahbod 已提交
636
    if (text < end && ((l = *text), likely (l >= 0xdc00 && l < 0xe000))) {
637 638 639 640 641 642 643 644 645 646 647 648 649 650
      /* low surrogate */
      *unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000);
       text++;
    } else
      *unicode = -1;
  } else
    *unicode = c;

  return text;
}

void
hb_buffer_add_utf16 (hb_buffer_t    *buffer,
		     const uint16_t *text,
651
		     unsigned int    text_length HB_UNUSED,
652 653 654 655 656 657 658 659 660 661 662
		     unsigned int    item_offset,
		     unsigned int    item_length)
{
#define UTF_NEXT(S, E, U)	hb_utf16_next (S, E, &(U))
  ADD_UTF (uint16_t);
#undef UTF_NEXT
}

void
hb_buffer_add_utf32 (hb_buffer_t    *buffer,
		     const uint32_t *text,
663
		     unsigned int    text_length HB_UNUSED,
664 665 666 667 668 669 670
		     unsigned int    item_offset,
		     unsigned int    item_length)
{
#define UTF_NEXT(S, E, U)	((U) = *(S), (S)+1)
  ADD_UTF (uint32_t);
#undef UTF_NEXT
}
B
Behdad Esfahbod 已提交
671 672 673


HB_END_DECLS