Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ttgload.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ttgload.c */
4 /* */
5 /* TrueType Glyph Loader (body). */
6 /* */
7 /* Copyright 1996-2013 */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17 
18 
19 #include <ft2build.h>
20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_CALC_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_INTERNAL_SFNT_H
24 #include FT_TRUETYPE_TAGS_H
25 #include FT_OUTLINE_H
26 
27 #include "ttgload.h"
28 #include "ttpload.h"
29 
30 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
31 #include "ttgxvar.h"
32 #endif
33 
34 #include "tterrors.h"
35 #include "ttsubpix.h"
36 
37 
38  /*************************************************************************/
39  /* */
40  /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
41  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
42  /* messages during execution. */
43  /* */
44 #undef FT_COMPONENT
45 #define FT_COMPONENT trace_ttgload
46 
47 
48  /*************************************************************************/
49  /* */
50  /* Composite glyph flags. */
51  /* */
52 #define ARGS_ARE_WORDS 0x0001
53 #define ARGS_ARE_XY_VALUES 0x0002
54 #define ROUND_XY_TO_GRID 0x0004
55 #define WE_HAVE_A_SCALE 0x0008
56 /* reserved 0x0010 */
57 #define MORE_COMPONENTS 0x0020
58 #define WE_HAVE_AN_XY_SCALE 0x0040
59 #define WE_HAVE_A_2X2 0x0080
60 #define WE_HAVE_INSTR 0x0100
61 #define USE_MY_METRICS 0x0200
62 #define OVERLAP_COMPOUND 0x0400
63 #define SCALED_COMPONENT_OFFSET 0x0800
64 #define UNSCALED_COMPONENT_OFFSET 0x1000
65 
66 
67  /*************************************************************************/
68  /* */
69  /* Return the horizontal metrics in font units for a given glyph. */
70  /* */
71  FT_LOCAL_DEF( void )
73  FT_UInt idx,
74  FT_Short* lsb,
75  FT_UShort* aw )
76  {
77  ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
78 
79  FT_TRACE5(( " advance width (font units): %d\n", *aw ));
80  FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
81  }
82 
83 
84  /*************************************************************************/
85  /* */
86  /* Return the vertical metrics in font units for a given glyph. */
87  /* Greg Hitchcock from Microsoft told us that if there were no `vmtx' */
88  /* table, typoAscender/Descender from the `OS/2' table would be used */
89  /* instead, and if there were no `OS/2' table, use ascender/descender */
90  /* from the `hhea' table. But that is not what Microsoft's rasterizer */
91  /* apparently does: It uses the ppem value as the advance height, and */
92  /* sets the top side bearing to be zero. */
93  /* */
94  FT_LOCAL_DEF( void )
96  FT_UInt idx,
97  FT_Short* tsb,
98  FT_UShort* ah )
99  {
100  if ( face->vertical_info )
101  ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
102 
103 #if 1 /* Empirically determined, at variance with what MS said */
104 
105  else
106  {
107  *tsb = 0;
108  *ah = face->root.units_per_EM;
109  }
110 
111 #else /* This is what MS said to do. It isn't what they do, however. */
112 
113  else if ( face->os2.version != 0xFFFFU )
114  {
115  *tsb = face->os2.sTypoAscender;
116  *ah = face->os2.sTypoAscender - face->os2.sTypoDescender;
117  }
118  else
119  {
120  *tsb = face->horizontal.Ascender;
121  *ah = face->horizontal.Ascender - face->horizontal.Descender;
122  }
123 
124 #endif
125 
126  FT_TRACE5(( " advance height (font units): %d\n", *ah ));
127  FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
128  }
129 
130 
131  static void
132  tt_get_metrics( TT_Loader loader,
133  FT_UInt glyph_index )
134  {
135  TT_Face face = (TT_Face)loader->face;
136 
137  FT_Short left_bearing = 0, top_bearing = 0;
138  FT_UShort advance_width = 0, advance_height = 0;
139 
140 
141  TT_Get_HMetrics( face, glyph_index,
142  &left_bearing,
143  &advance_width );
144  TT_Get_VMetrics( face, glyph_index,
145  &top_bearing,
146  &advance_height );
147 
148  loader->left_bearing = left_bearing;
149  loader->advance = advance_width;
150  loader->top_bearing = top_bearing;
151  loader->vadvance = advance_height;
152 
153 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
154  if ( loader->exec )
155  loader->exec->sph_tweak_flags = 0;
156 
157  /* this may not be the right place for this, but it works */
158  if ( loader->exec && loader->exec->ignore_x_mode )
159  sph_set_tweaks( loader, glyph_index );
160 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
161 
162  if ( !loader->linear_def )
163  {
164  loader->linear_def = 1;
165  loader->linear = advance_width;
166  }
167  }
168 
169 
170 #ifdef FT_CONFIG_OPTION_INCREMENTAL
171 
172  static void
173  tt_get_metrics_incr_overrides( TT_Loader loader,
174  FT_UInt glyph_index )
175  {
176  TT_Face face = (TT_Face)loader->face;
177 
178  FT_Short left_bearing = 0, top_bearing = 0;
179  FT_UShort advance_width = 0, advance_height = 0;
180 
181 
182  /* If this is an incrementally loaded font check whether there are */
183  /* overriding metrics for this glyph. */
184  if ( face->root.internal->incremental_interface &&
185  face->root.internal->incremental_interface->funcs->get_glyph_metrics )
186  {
188  FT_Error error;
189 
190 
191  metrics.bearing_x = loader->left_bearing;
192  metrics.bearing_y = 0;
193  metrics.advance = loader->advance;
194  metrics.advance_v = 0;
195 
196  error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
197  face->root.internal->incremental_interface->object,
198  glyph_index, FALSE, &metrics );
199  if ( error )
200  goto Exit;
201 
202  left_bearing = (FT_Short)metrics.bearing_x;
203  advance_width = (FT_UShort)metrics.advance;
204 
205 #if 0
206 
207  /* GWW: Do I do the same for vertical metrics? */
208  metrics.bearing_x = 0;
209  metrics.bearing_y = loader->top_bearing;
210  metrics.advance = loader->vadvance;
211 
212  error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
213  face->root.internal->incremental_interface->object,
214  glyph_index, TRUE, &metrics );
215  if ( error )
216  goto Exit;
217 
218  top_bearing = (FT_Short)metrics.bearing_y;
219  advance_height = (FT_UShort)metrics.advance;
220 
221 #endif /* 0 */
222 
223  loader->left_bearing = left_bearing;
224  loader->advance = advance_width;
225  loader->top_bearing = top_bearing;
226  loader->vadvance = advance_height;
227 
228  if ( !loader->linear_def )
229  {
230  loader->linear_def = 1;
231  loader->linear = advance_width;
232  }
233  }
234 
235  Exit:
236  return;
237  }
238 
239 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
240 
241 
242  /*************************************************************************/
243  /* */
244  /* Translates an array of coordinates. */
245  /* */
246  static void
247  translate_array( FT_UInt n,
248  FT_Vector* coords,
249  FT_Pos delta_x,
250  FT_Pos delta_y )
251  {
252  FT_UInt k;
253 
254 
255  if ( delta_x )
256  for ( k = 0; k < n; k++ )
257  coords[k].x += delta_x;
258 
259  if ( delta_y )
260  for ( k = 0; k < n; k++ )
261  coords[k].y += delta_y;
262  }
263 
264 
265  /*************************************************************************/
266  /* */
267  /* The following functions are used by default with TrueType fonts. */
268  /* However, they can be replaced by alternatives if we need to support */
269  /* TrueType-compressed formats (like MicroType) in the future. */
270  /* */
271  /*************************************************************************/
272 
275  FT_UInt glyph_index,
277  FT_UInt byte_count )
278  {
279  FT_Error error;
280  FT_Stream stream = loader->stream;
281 
282  /* for non-debug mode */
283  FT_UNUSED( glyph_index );
284 
285 
286  FT_TRACE4(( "Glyph %ld\n", glyph_index ));
287 
288  /* the following line sets the `error' variable through macros! */
289  if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
290  return error;
291 
292  loader->cursor = stream->cursor;
293  loader->limit = stream->limit;
294 
295  return FT_Err_Ok;
296  }
297 
298 
299  FT_CALLBACK_DEF( void )
301  {
302  FT_Stream stream = loader->stream;
303 
304 
305  FT_FRAME_EXIT();
306  }
307 
308 
311  {
312  FT_Byte* p = loader->cursor;
313  FT_Byte* limit = loader->limit;
314 
315 
316  if ( p + 10 > limit )
317  return FT_THROW( Invalid_Outline );
318 
319  loader->n_contours = FT_NEXT_SHORT( p );
320 
321  loader->bbox.xMin = FT_NEXT_SHORT( p );
322  loader->bbox.yMin = FT_NEXT_SHORT( p );
323  loader->bbox.xMax = FT_NEXT_SHORT( p );
324  loader->bbox.yMax = FT_NEXT_SHORT( p );
325 
326  FT_TRACE5(( " # of contours: %d\n", loader->n_contours ));
327  FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
328  loader->bbox.xMax ));
329  FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
330  loader->bbox.yMax ));
331  loader->cursor = p;
332 
333  return FT_Err_Ok;
334  }
335 
336 
339  {
340  FT_Error error;
341  FT_Byte* p = load->cursor;
342  FT_Byte* limit = load->limit;
343  FT_GlyphLoader gloader = load->gloader;
344  FT_Int n_contours = load->n_contours;
345  FT_Outline* outline;
346  TT_Face face = (TT_Face)load->face;
347  FT_UShort n_ins;
348  FT_Int n_points;
349 
350  FT_Byte *flag, *flag_limit;
351  FT_Byte c, count;
352  FT_Vector *vec, *vec_limit;
353  FT_Pos x;
354  FT_Short *cont, *cont_limit, prev_cont;
355  FT_Int xy_size = 0;
356 
357 
358  /* check that we can add the contours to the glyph */
359  error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours );
360  if ( error )
361  goto Fail;
362 
363  /* reading the contours' endpoints & number of points */
364  cont = gloader->current.outline.contours;
365  cont_limit = cont + n_contours;
366 
367  /* check space for contours array + instructions count */
368  if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
369  goto Invalid_Outline;
370 
371  prev_cont = FT_NEXT_SHORT( p );
372 
373  if ( n_contours > 0 )
374  cont[0] = prev_cont;
375 
376  if ( prev_cont < 0 )
377  goto Invalid_Outline;
378 
379  for ( cont++; cont < cont_limit; cont++ )
380  {
381  cont[0] = FT_NEXT_SHORT( p );
382  if ( cont[0] <= prev_cont )
383  {
384  /* unordered contours: this is invalid */
385  goto Invalid_Outline;
386  }
387  prev_cont = cont[0];
388  }
389 
390  n_points = 0;
391  if ( n_contours > 0 )
392  {
393  n_points = cont[-1] + 1;
394  if ( n_points < 0 )
395  goto Invalid_Outline;
396  }
397 
398  /* note that we will add four phantom points later */
399  error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
400  if ( error )
401  goto Fail;
402 
403  /* reading the bytecode instructions */
404  load->glyph->control_len = 0;
405  load->glyph->control_data = 0;
406 
407  if ( p + 2 > limit )
408  goto Invalid_Outline;
409 
410  n_ins = FT_NEXT_USHORT( p );
411 
412  FT_TRACE5(( " Instructions size: %u\n", n_ins ));
413 
414  if ( n_ins > face->max_profile.maxSizeOfInstructions )
415  {
416  FT_TRACE0(( "TT_Load_Simple_Glyph: too many instructions (%d)\n",
417  n_ins ));
418  error = FT_THROW( Too_Many_Hints );
419  goto Fail;
420  }
421 
422  if ( ( limit - p ) < n_ins )
423  {
424  FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" ));
425  error = FT_THROW( Too_Many_Hints );
426  goto Fail;
427  }
428 
429 #ifdef TT_USE_BYTECODE_INTERPRETER
430 
431  if ( IS_HINTED( load->load_flags ) )
432  {
433  load->glyph->control_len = n_ins;
434  load->glyph->control_data = load->exec->glyphIns;
435 
436  FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
437  }
438 
439 #endif /* TT_USE_BYTECODE_INTERPRETER */
440 
441  p += n_ins;
442 
443  outline = &gloader->current.outline;
444 
445  /* reading the point tags */
446  flag = (FT_Byte*)outline->tags;
447  flag_limit = flag + n_points;
448 
449  FT_ASSERT( flag != NULL );
450 
451  while ( flag < flag_limit )
452  {
453  if ( p + 1 > limit )
454  goto Invalid_Outline;
455 
456  *flag++ = c = FT_NEXT_BYTE( p );
457  if ( c & 8 )
458  {
459  if ( p + 1 > limit )
460  goto Invalid_Outline;
461 
462  count = FT_NEXT_BYTE( p );
463  if ( flag + (FT_Int)count > flag_limit )
464  goto Invalid_Outline;
465 
466  for ( ; count > 0; count-- )
467  *flag++ = c;
468  }
469  }
470 
471  /* reading the X coordinates */
472 
473  vec = outline->points;
474  vec_limit = vec + n_points;
475  flag = (FT_Byte*)outline->tags;
476  x = 0;
477 
478  if ( p + xy_size > limit )
479  goto Invalid_Outline;
480 
481  for ( ; vec < vec_limit; vec++, flag++ )
482  {
483  FT_Pos y = 0;
484  FT_Byte f = *flag;
485 
486 
487  if ( f & 2 )
488  {
489  if ( p + 1 > limit )
490  goto Invalid_Outline;
491 
492  y = (FT_Pos)FT_NEXT_BYTE( p );
493  if ( ( f & 16 ) == 0 )
494  y = -y;
495  }
496  else if ( ( f & 16 ) == 0 )
497  {
498  if ( p + 2 > limit )
499  goto Invalid_Outline;
500 
501  y = (FT_Pos)FT_NEXT_SHORT( p );
502  }
503 
504  x += y;
505  vec->x = x;
506  /* the cast is for stupid compilers */
507  *flag = (FT_Byte)( f & ~( 2 | 16 ) );
508  }
509 
510  /* reading the Y coordinates */
511 
512  vec = gloader->current.outline.points;
513  vec_limit = vec + n_points;
514  flag = (FT_Byte*)outline->tags;
515  x = 0;
516 
517  for ( ; vec < vec_limit; vec++, flag++ )
518  {
519  FT_Pos y = 0;
520  FT_Byte f = *flag;
521 
522 
523  if ( f & 4 )
524  {
525  if ( p + 1 > limit )
526  goto Invalid_Outline;
527 
528  y = (FT_Pos)FT_NEXT_BYTE( p );
529  if ( ( f & 32 ) == 0 )
530  y = -y;
531  }
532  else if ( ( f & 32 ) == 0 )
533  {
534  if ( p + 2 > limit )
535  goto Invalid_Outline;
536 
537  y = (FT_Pos)FT_NEXT_SHORT( p );
538  }
539 
540  x += y;
541  vec->y = x;
542  /* the cast is for stupid compilers */
543  *flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
544  }
545 
546  outline->n_points = (FT_UShort)n_points;
547  outline->n_contours = (FT_Short) n_contours;
548 
549  load->cursor = p;
550 
551  Fail:
552  return error;
553 
554  Invalid_Outline:
555  error = FT_THROW( Invalid_Outline );
556  goto Fail;
557  }
558 
559 
562  {
563  FT_Error error;
564  FT_Byte* p = loader->cursor;
565  FT_Byte* limit = loader->limit;
566  FT_GlyphLoader gloader = loader->gloader;
567  FT_SubGlyph subglyph;
568  FT_UInt num_subglyphs;
569 
570 
571  num_subglyphs = 0;
572 
573  do
574  {
575  FT_Fixed xx, xy, yy, yx;
576  FT_UInt count;
577 
578 
579  /* check that we can load a new subglyph */
580  error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 );
581  if ( error )
582  goto Fail;
583 
584  /* check space */
585  if ( p + 4 > limit )
586  goto Invalid_Composite;
587 
588  subglyph = gloader->current.subglyphs + num_subglyphs;
589 
590  subglyph->arg1 = subglyph->arg2 = 0;
591 
592  subglyph->flags = FT_NEXT_USHORT( p );
593  subglyph->index = FT_NEXT_USHORT( p );
594 
595  /* check space */
596  count = 2;
597  if ( subglyph->flags & ARGS_ARE_WORDS )
598  count += 2;
599  if ( subglyph->flags & WE_HAVE_A_SCALE )
600  count += 2;
601  else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
602  count += 4;
603  else if ( subglyph->flags & WE_HAVE_A_2X2 )
604  count += 8;
605 
606  if ( p + count > limit )
607  goto Invalid_Composite;
608 
609  /* read arguments */
610  if ( subglyph->flags & ARGS_ARE_WORDS )
611  {
612  subglyph->arg1 = FT_NEXT_SHORT( p );
613  subglyph->arg2 = FT_NEXT_SHORT( p );
614  }
615  else
616  {
617  subglyph->arg1 = FT_NEXT_CHAR( p );
618  subglyph->arg2 = FT_NEXT_CHAR( p );
619  }
620 
621  /* read transform */
622  xx = yy = 0x10000L;
623  xy = yx = 0;
624 
625  if ( subglyph->flags & WE_HAVE_A_SCALE )
626  {
627  xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
628  yy = xx;
629  }
630  else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
631  {
632  xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
633  yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
634  }
635  else if ( subglyph->flags & WE_HAVE_A_2X2 )
636  {
637  xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
638  yx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
639  xy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
640  yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
641  }
642 
643  subglyph->transform.xx = xx;
644  subglyph->transform.xy = xy;
645  subglyph->transform.yx = yx;
646  subglyph->transform.yy = yy;
647 
648  num_subglyphs++;
649 
650  } while ( subglyph->flags & MORE_COMPONENTS );
651 
652  gloader->current.num_subglyphs = num_subglyphs;
653 
654 #ifdef TT_USE_BYTECODE_INTERPRETER
655 
656  {
657  FT_Stream stream = loader->stream;
658 
659 
660  /* we must undo the FT_FRAME_ENTER in order to point */
661  /* to the composite instructions, if we find some. */
662  /* We will process them later. */
663  /* */
664  loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
665  p - limit );
666  }
667 
668 #endif
669 
670  loader->cursor = p;
671 
672  Fail:
673  return error;
674 
675  Invalid_Composite:
676  error = FT_THROW( Invalid_Composite );
677  goto Fail;
678  }
679 
680 
681  FT_LOCAL_DEF( void )
683  {
689  }
690 
691 
692  static void
693  tt_prepare_zone( TT_GlyphZone zone,
695  FT_UInt start_point,
696  FT_UInt start_contour )
697  {
698  zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
699  zone->n_contours = (FT_Short) ( load->outline.n_contours -
700  start_contour );
701  zone->org = load->extra_points + start_point;
702  zone->cur = load->outline.points + start_point;
703  zone->orus = load->extra_points2 + start_point;
704  zone->tags = (FT_Byte*)load->outline.tags + start_point;
705  zone->contours = (FT_UShort*)load->outline.contours + start_contour;
706  zone->first_point = (FT_UShort)start_point;
707  }
708 
709 
710  /*************************************************************************/
711  /* */
712  /* <Function> */
713  /* TT_Hint_Glyph */
714  /* */
715  /* <Description> */
716  /* Hint the glyph using the zone prepared by the caller. Note that */
717  /* the zone is supposed to include four phantom points. */
718  /* */
719  static FT_Error
720  TT_Hint_Glyph( TT_Loader loader,
721  FT_Bool is_composite )
722  {
723  TT_GlyphZone zone = &loader->zone;
724  FT_Pos origin;
725 
726 #ifdef TT_USE_BYTECODE_INTERPRETER
727  FT_UInt n_ins;
728 #else
729  FT_UNUSED( is_composite );
730 #endif
731 
732 
733 #ifdef TT_USE_BYTECODE_INTERPRETER
734  if ( loader->glyph->control_len > 0xFFFFL )
735  {
736  FT_TRACE1(( "TT_Hint_Glyph: too long instructions " ));
737  FT_TRACE1(( "(0x%lx byte) is truncated\n",
738  loader->glyph->control_len ));
739  }
740  n_ins = (FT_UInt)( loader->glyph->control_len );
741 #endif
742 
743  origin = zone->cur[zone->n_points - 4].x;
744  origin = FT_PIX_ROUND( origin ) - origin;
745  if ( origin )
746  translate_array( zone->n_points, zone->cur, origin, 0 );
747 
748 #ifdef TT_USE_BYTECODE_INTERPRETER
749  /* save original point position in org */
750  if ( n_ins > 0 )
751  FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
752 
753  /* Reset graphics state. */
754  loader->exec->GS = ((TT_Size)loader->size)->GS;
755 
756  /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
757  /* completely refer to the (already) hinted subglyphs. */
758  if ( is_composite )
759  {
760  loader->exec->metrics.x_scale = 1 << 16;
761  loader->exec->metrics.y_scale = 1 << 16;
762 
763  FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
764  }
765  else
766  {
767  loader->exec->metrics.x_scale =
768  ((TT_Size)loader->size)->metrics.x_scale;
769  loader->exec->metrics.y_scale =
770  ((TT_Size)loader->size)->metrics.y_scale;
771  }
772 #endif
773 
774  /* round pp2 and pp4 */
775  zone->cur[zone->n_points - 3].x =
776  FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
777  zone->cur[zone->n_points - 1].y =
778  FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
779 
780 #ifdef TT_USE_BYTECODE_INTERPRETER
781 
782  if ( n_ins > 0 )
783  {
784  FT_Bool debug;
785  FT_Error error;
786 
787  FT_GlyphLoader gloader = loader->gloader;
788  FT_Outline current_outline = gloader->current.outline;
789 
790 
791  error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
792  loader->exec->glyphIns, n_ins );
793  if ( error )
794  return error;
795 
796  loader->exec->is_composite = is_composite;
797  loader->exec->pts = *zone;
798 
799  debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
800  ((TT_Size)loader->size)->debug );
801 
802  error = TT_Run_Context( loader->exec, debug );
803  if ( error && loader->exec->pedantic_hinting )
804  return error;
805 
806  /* store drop-out mode in bits 5-7; set bit 2 also as a marker */
807  current_outline.tags[0] |=
808  ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
809  }
810 
811 #endif
812 
813  /* save glyph phantom points */
814  if ( !loader->preserve_pps )
815  {
816  loader->pp1 = zone->cur[zone->n_points - 4];
817  loader->pp2 = zone->cur[zone->n_points - 3];
818  loader->pp3 = zone->cur[zone->n_points - 2];
819  loader->pp4 = zone->cur[zone->n_points - 1];
820  }
821 
822 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
823  if ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
824  FT_Outline_EmboldenXY( &loader->gloader->current.outline, -24, 0 );
825 
826  else if ( loader->exec->sph_tweak_flags & SPH_TWEAK_EMBOLDEN )
827  FT_Outline_EmboldenXY( &loader->gloader->current.outline, 24, 0 );
828 #endif
829  return FT_Err_Ok;
830  }
831 
832 
833  /*************************************************************************/
834  /* */
835  /* <Function> */
836  /* TT_Process_Simple_Glyph */
837  /* */
838  /* <Description> */
839  /* Once a simple glyph has been loaded, it needs to be processed. */
840  /* Usually, this means scaling and hinting through bytecode */
841  /* interpretation. */
842  /* */
843  static FT_Error
844  TT_Process_Simple_Glyph( TT_Loader loader )
845  {
846  FT_GlyphLoader gloader = loader->gloader;
848  FT_Outline* outline;
849  FT_Int n_points;
850 
851 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
852  TT_Face face = (TT_Face)loader->face;
853  FT_String* family = face->root.family_name;
854  FT_Int ppem = loader->size->metrics.x_ppem;
855  FT_String* style = face->root.style_name;
856  FT_Int x_scale_factor = 1000;
857 #endif
858 
859 
860  outline = &gloader->current.outline;
861  n_points = outline->n_points;
862 
863  /* set phantom points */
864 
865  outline->points[n_points ] = loader->pp1;
866  outline->points[n_points + 1] = loader->pp2;
867  outline->points[n_points + 2] = loader->pp3;
868  outline->points[n_points + 3] = loader->pp4;
869 
870  outline->tags[n_points ] = 0;
871  outline->tags[n_points + 1] = 0;
872  outline->tags[n_points + 2] = 0;
873  outline->tags[n_points + 3] = 0;
874 
875  n_points += 4;
876 
878 
879  if ( ((TT_Face)loader->face)->doblend )
880  {
881  /* Deltas apply to the unscaled data. */
882  FT_Vector* deltas;
883  FT_Memory memory = loader->face->memory;
884  FT_Int i;
885 
886 
887  error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
888  loader->glyph_index,
889  &deltas,
890  n_points );
891  if ( error )
892  return error;
893 
894  for ( i = 0; i < n_points; ++i )
895  {
896  outline->points[i].x += deltas[i].x;
897  outline->points[i].y += deltas[i].y;
898  }
899 
900  FT_FREE( deltas );
901  }
902 
903 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
904 
905  if ( IS_HINTED( loader->load_flags ) )
906  {
907  tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
908 
909  FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
910  loader->zone.n_points + 4 );
911  }
912 
913 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
914  /* scale, but only if enabled and only if TT hinting is being used */
915  if ( IS_HINTED( loader->load_flags ) )
916  x_scale_factor = sph_test_tweak_x_scaling( face,
917  family,
918  ppem,
919  style,
920  loader->glyph_index );
921  /* scale the glyph */
922  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ||
923  x_scale_factor != 1000 )
924  {
925  FT_Vector* vec = outline->points;
926  FT_Vector* limit = outline->points + n_points;
927  FT_Fixed x_scale = FT_MulDiv(
928  ((TT_Size)loader->size)->metrics.x_scale,
929  x_scale_factor, 1000 );
930  FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale;
931 
932 
933  /* compensate for any scaling by de/emboldening; */
934  /* the amount was determined via experimentation */
935  if ( x_scale_factor != 1000 && ppem > 11 )
936  FT_Outline_EmboldenXY( outline,
937  FT_MulFix( 1280 * ppem,
938  1000 - x_scale_factor ),
939  0 );
940 #else
941  /* scale the glyph */
942  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
943  {
944  FT_Vector* vec = outline->points;
945  FT_Vector* limit = outline->points + n_points;
946  FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale;
947  FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale;
948 #endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
949 
950 
951  for ( ; vec < limit; vec++ )
952  {
953  vec->x = FT_MulFix( vec->x, x_scale );
954  vec->y = FT_MulFix( vec->y, y_scale );
955  }
956 
957  loader->pp1 = outline->points[n_points - 4];
958  loader->pp2 = outline->points[n_points - 3];
959  loader->pp3 = outline->points[n_points - 2];
960  loader->pp4 = outline->points[n_points - 1];
961  }
962 
963  if ( IS_HINTED( loader->load_flags ) )
964  {
965  loader->zone.n_points += 4;
966 
967  error = TT_Hint_Glyph( loader, 0 );
968  }
969 
970  return error;
971  }
972 
973 
974  /*************************************************************************/
975  /* */
976  /* <Function> */
977  /* TT_Process_Composite_Component */
978  /* */
979  /* <Description> */
980  /* Once a composite component has been loaded, it needs to be */
981  /* processed. Usually, this means transforming and translating. */
982  /* */
983  static FT_Error
984  TT_Process_Composite_Component( TT_Loader loader,
985  FT_SubGlyph subglyph,
986  FT_UInt start_point,
987  FT_UInt num_base_points )
988  {
989  FT_GlyphLoader gloader = loader->gloader;
990  FT_Vector* base_vec = gloader->base.outline.points;
991  FT_UInt num_points = gloader->base.outline.n_points;
992  FT_Bool have_scale;
993  FT_Pos x, y;
994 
995 
996  have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE |
998  WE_HAVE_A_2X2 ) );
999 
1000  /* perform the transform required for this subglyph */
1001  if ( have_scale )
1002  {
1003  FT_UInt i;
1004 
1005 
1006  for ( i = num_base_points; i < num_points; i++ )
1007  FT_Vector_Transform( base_vec + i, &subglyph->transform );
1008  }
1009 
1010  /* get offset */
1011  if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
1012  {
1013  FT_UInt k = subglyph->arg1;
1014  FT_UInt l = subglyph->arg2;
1015  FT_Vector* p1;
1016  FT_Vector* p2;
1017 
1018 
1019  /* match l-th point of the newly loaded component to the k-th point */
1020  /* of the previously loaded components. */
1021 
1022  /* change to the point numbers used by our outline */
1023  k += start_point;
1024  l += num_base_points;
1025  if ( k >= num_base_points ||
1026  l >= num_points )
1027  return FT_THROW( Invalid_Composite );
1028 
1029  p1 = gloader->base.outline.points + k;
1030  p2 = gloader->base.outline.points + l;
1031 
1032  x = p1->x - p2->x;
1033  y = p1->y - p2->y;
1034  }
1035  else
1036  {
1037  x = subglyph->arg1;
1038  y = subglyph->arg2;
1039 
1040  if ( !x && !y )
1041  return FT_Err_Ok;
1042 
1043  /* Use a default value dependent on */
1044  /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */
1045  /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */
1046 
1047  if ( have_scale &&
1048 #ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
1049  !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) )
1050 #else
1051  ( subglyph->flags & SCALED_COMPONENT_OFFSET ) )
1052 #endif
1053  {
1054 
1055 #if 0
1056 
1057  /*************************************************************************/
1058  /* */
1059  /* This algorithm is what Apple documents. But it doesn't work. */
1060  /* */
1061  int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
1062  : -subglyph->transform.xx;
1063  int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
1064  : -subglyph->transform.yx;
1065  int c = subglyph->transform.xy > 0 ? subglyph->transform.xy
1066  : -subglyph->transform.xy;
1067  int d = subglyph->transform.yy > 0 ? subglyph->transform.yy
1068  : -subglyph->transform.yy;
1069  int m = a > b ? a : b;
1070  int n = c > d ? c : d;
1071 
1072 
1073  if ( a - b <= 33 && a - b >= -33 )
1074  m *= 2;
1075  if ( c - d <= 33 && c - d >= -33 )
1076  n *= 2;
1077  x = FT_MulFix( x, m );
1078  y = FT_MulFix( y, n );
1079 
1080 #else /* 0 */
1081 
1082  /*************************************************************************/
1083  /* */
1084  /* This algorithm is a guess and works much better than the above. */
1085  /* */
1086  FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx,
1087  subglyph->transform.xy );
1088  FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy,
1089  subglyph->transform.yx );
1090 
1091 
1092  x = FT_MulFix( x, mac_xscale );
1093  y = FT_MulFix( y, mac_yscale );
1094 
1095 #endif /* 0 */
1096 
1097  }
1098 
1099  if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
1100  {
1101  FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale;
1102  FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale;
1103 
1104 
1105  x = FT_MulFix( x, x_scale );
1106  y = FT_MulFix( y, y_scale );
1107 
1108  if ( subglyph->flags & ROUND_XY_TO_GRID )
1109  {
1110  x = FT_PIX_ROUND( x );
1111  y = FT_PIX_ROUND( y );
1112  }
1113  }
1114  }
1115 
1116  if ( x || y )
1117  translate_array( num_points - num_base_points,
1118  base_vec + num_base_points,
1119  x, y );
1120 
1121  return FT_Err_Ok;
1122  }
1123 
1124 
1125  /*************************************************************************/
1126  /* */
1127  /* <Function> */
1128  /* TT_Process_Composite_Glyph */
1129  /* */
1130  /* <Description> */
1131  /* This is slightly different from TT_Process_Simple_Glyph, in that */
1132  /* its sole purpose is to hint the glyph. Thus this function is */
1133  /* only available when bytecode interpreter is enabled. */
1134  /* */
1135  static FT_Error
1136  TT_Process_Composite_Glyph( TT_Loader loader,
1137  FT_UInt start_point,
1138  FT_UInt start_contour )
1139  {
1140  FT_Error error;
1141  FT_Outline* outline;
1142  FT_UInt i;
1143 
1144 
1145  outline = &loader->gloader->base.outline;
1146 
1147  /* make room for phantom points */
1148  error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
1149  outline->n_points + 4,
1150  0 );
1151  if ( error )
1152  return error;
1153 
1154  outline->points[outline->n_points ] = loader->pp1;
1155  outline->points[outline->n_points + 1] = loader->pp2;
1156  outline->points[outline->n_points + 2] = loader->pp3;
1157  outline->points[outline->n_points + 3] = loader->pp4;
1158 
1159  outline->tags[outline->n_points ] = 0;
1160  outline->tags[outline->n_points + 1] = 0;
1161  outline->tags[outline->n_points + 2] = 0;
1162  outline->tags[outline->n_points + 3] = 0;
1163 
1164 #ifdef TT_USE_BYTECODE_INTERPRETER
1165 
1166  {
1167  FT_Stream stream = loader->stream;
1168  FT_UShort n_ins, max_ins;
1169  FT_ULong tmp;
1170 
1171 
1172  /* TT_Load_Composite_Glyph only gives us the offset of instructions */
1173  /* so we read them here */
1174  if ( FT_STREAM_SEEK( loader->ins_pos ) ||
1175  FT_READ_USHORT( n_ins ) )
1176  return error;
1177 
1178  FT_TRACE5(( " Instructions size = %d\n", n_ins ));
1179 
1180  /* check it */
1181  max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions;
1182  if ( n_ins > max_ins )
1183  {
1184  /* acroread ignores this field, so we only do a rough safety check */
1185  if ( (FT_Int)n_ins > loader->byte_len )
1186  {
1187  FT_TRACE1(( "TT_Process_Composite_Glyph: "
1188  "too many instructions (%d) for glyph with length %d\n",
1189  n_ins, loader->byte_len ));
1190  return FT_THROW( Too_Many_Hints );
1191  }
1192 
1193  tmp = loader->exec->glyphSize;
1194  error = Update_Max( loader->exec->memory,
1195  &tmp,
1196  sizeof ( FT_Byte ),
1197  (void*)&loader->exec->glyphIns,
1198  n_ins );
1199  loader->exec->glyphSize = (FT_UShort)tmp;
1200  if ( error )
1201  return error;
1202  }
1203  else if ( n_ins == 0 )
1204  return FT_Err_Ok;
1205 
1206  if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) )
1207  return error;
1208 
1209  loader->glyph->control_data = loader->exec->glyphIns;
1210  loader->glyph->control_len = n_ins;
1211  }
1212 
1213 #endif
1214 
1215  tt_prepare_zone( &loader->zone, &loader->gloader->base,
1216  start_point, start_contour );
1217 
1218  /* Some points are likely touched during execution of */
1219  /* instructions on components. So let's untouch them. */
1220  for ( i = start_point; i < loader->zone.n_points; i++ )
1221  loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
1222 
1223  loader->zone.n_points += 4;
1224 
1225  return TT_Hint_Glyph( loader, 1 );
1226  }
1227 
1228 
1229  /* Calculate the four phantom points. */
1230  /* The first two stand for horizontal origin and advance. */
1231  /* The last two stand for vertical origin and advance. */
1232 #define TT_LOADER_SET_PP( loader ) \
1233  do { \
1234  (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
1235  (loader)->pp1.y = 0; \
1236  (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
1237  (loader)->pp2.y = 0; \
1238  (loader)->pp3.x = 0; \
1239  (loader)->pp3.y = (loader)->top_bearing + (loader)->bbox.yMax; \
1240  (loader)->pp4.x = 0; \
1241  (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
1242  } while ( 0 )
1243 
1244 
1245  /*************************************************************************/
1246  /* */
1247  /* <Function> */
1248  /* load_truetype_glyph */
1249  /* */
1250  /* <Description> */
1251  /* Loads a given truetype glyph. Handles composites and uses a */
1252  /* TT_Loader object. */
1253  /* */
1254  static FT_Error
1255  load_truetype_glyph( TT_Loader loader,
1256  FT_UInt glyph_index,
1257  FT_UInt recurse_count,
1258  FT_Bool header_only )
1259  {
1260  FT_Error error = FT_Err_Ok;
1261  FT_Fixed x_scale, y_scale;
1262  FT_ULong offset;
1263  TT_Face face = (TT_Face)loader->face;
1264  FT_GlyphLoader gloader = loader->gloader;
1265  FT_Bool opened_frame = 0;
1266 
1268  FT_Vector* deltas = NULL;
1269 #endif
1270 
1272  FT_StreamRec inc_stream;
1273  FT_Data glyph_data;
1274  FT_Bool glyph_data_loaded = 0;
1275 #endif
1276 
1277 
1278  /* some fonts have an incorrect value of `maxComponentDepth', */
1279  /* thus we allow depth 1 to catch the majority of them */
1280  if ( recurse_count > 1 &&
1281  recurse_count > face->max_profile.maxComponentDepth )
1282  {
1283  error = FT_THROW( Invalid_Composite );
1284  goto Exit;
1285  }
1286 
1287  /* check glyph index */
1288  if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
1289  {
1290  error = FT_THROW( Invalid_Glyph_Index );
1291  goto Exit;
1292  }
1293 
1294  loader->glyph_index = glyph_index;
1295 
1296  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1297  {
1298  x_scale = ((TT_Size)loader->size)->metrics.x_scale;
1299  y_scale = ((TT_Size)loader->size)->metrics.y_scale;
1300  }
1301  else
1302  {
1303  x_scale = 0x10000L;
1304  y_scale = 0x10000L;
1305  }
1306 
1307  tt_get_metrics( loader, glyph_index );
1308 
1309  /* Set `offset' to the start of the glyph relative to the start of */
1310  /* the `glyf' table, and `byte_len' to the length of the glyph in */
1311  /* bytes. */
1312 
1313 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1314 
1315  /* If we are loading glyph data via the incremental interface, set */
1316  /* the loader stream to a memory stream reading the data returned */
1317  /* by the interface. */
1318  if ( face->root.internal->incremental_interface )
1319  {
1320  error = face->root.internal->incremental_interface->funcs->get_glyph_data(
1321  face->root.internal->incremental_interface->object,
1322  glyph_index, &glyph_data );
1323  if ( error )
1324  goto Exit;
1325 
1326  glyph_data_loaded = 1;
1327  offset = 0;
1328  loader->byte_len = glyph_data.length;
1329 
1330  FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
1331  FT_Stream_OpenMemory( &inc_stream,
1332  glyph_data.pointer, glyph_data.length );
1333 
1334  loader->stream = &inc_stream;
1335  }
1336  else
1337 
1338 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
1339 
1340  offset = tt_face_get_location( face, glyph_index,
1341  (FT_UInt*)&loader->byte_len );
1342 
1343  if ( loader->byte_len > 0 )
1344  {
1345 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1346  /* for the incremental interface, `glyf_offset' is always zero */
1347  if ( !loader->glyf_offset &&
1348  !face->root.internal->incremental_interface )
1349 #else
1350  if ( !loader->glyf_offset )
1351 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
1352  {
1353  FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
1354  error = FT_THROW( Invalid_Table );
1355  goto Exit;
1356  }
1357 
1358  error = face->access_glyph_frame( loader, glyph_index,
1359  loader->glyf_offset + offset,
1360  loader->byte_len );
1361  if ( error )
1362  goto Exit;
1363 
1364  opened_frame = 1;
1365 
1366  /* read glyph header first */
1367  error = face->read_glyph_header( loader );
1368  if ( error || header_only )
1369  goto Exit;
1370  }
1371 
1372  if ( loader->byte_len == 0 || loader->n_contours == 0 )
1373  {
1374  loader->bbox.xMin = 0;
1375  loader->bbox.xMax = 0;
1376  loader->bbox.yMin = 0;
1377  loader->bbox.yMax = 0;
1378 
1379  if ( header_only )
1380  goto Exit;
1381 
1382  /* must initialize points before (possibly) overriding */
1383  /* glyph metrics from the incremental interface */
1384  TT_LOADER_SET_PP( loader );
1385 
1386 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1387  tt_get_metrics_incr_overrides( loader, glyph_index );
1388 #endif
1389 
1390 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1391 
1392  if ( ((TT_Face)(loader->face))->doblend )
1393  {
1394  /* this must be done before scaling */
1395  FT_Memory memory = loader->face->memory;
1396 
1397 
1398  error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
1399  glyph_index, &deltas, 4 );
1400  if ( error )
1401  goto Exit;
1402 
1403  loader->pp1.x += deltas[0].x; loader->pp1.y += deltas[0].y;
1404  loader->pp2.x += deltas[1].x; loader->pp2.y += deltas[1].y;
1405  loader->pp3.x += deltas[2].x; loader->pp3.y += deltas[2].y;
1406  loader->pp4.x += deltas[3].x; loader->pp4.y += deltas[3].y;
1407 
1408  FT_FREE( deltas );
1409  }
1410 
1411 #endif
1412 
1413  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1414  {
1415  loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
1416  loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
1417  loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
1418  loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
1419  }
1420 
1421  error = FT_Err_Ok;
1422  goto Exit;
1423  }
1424 
1425  /* must initialize points before (possibly) overriding */
1426  /* glyph metrics from the incremental interface */
1427  TT_LOADER_SET_PP( loader );
1428 
1429 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1430  tt_get_metrics_incr_overrides( loader, glyph_index );
1431 #endif
1432 
1433  /***********************************************************************/
1434  /***********************************************************************/
1435  /***********************************************************************/
1436 
1437  /* if it is a simple glyph, load it */
1438 
1439  if ( loader->n_contours > 0 )
1440  {
1441  error = face->read_simple_glyph( loader );
1442  if ( error )
1443  goto Exit;
1444 
1445  /* all data have been read */
1446  face->forget_glyph_frame( loader );
1447  opened_frame = 0;
1448 
1449  error = TT_Process_Simple_Glyph( loader );
1450  if ( error )
1451  goto Exit;
1452 
1453  FT_GlyphLoader_Add( gloader );
1454  }
1455 
1456  /***********************************************************************/
1457  /***********************************************************************/
1458  /***********************************************************************/
1459 
1460  /* otherwise, load a composite! */
1461  else if ( loader->n_contours == -1 )
1462  {
1463  FT_UInt start_point;
1464  FT_UInt start_contour;
1465  FT_ULong ins_pos; /* position of composite instructions, if any */
1466 
1467 
1468  start_point = gloader->base.outline.n_points;
1469  start_contour = gloader->base.outline.n_contours;
1470 
1471  /* for each subglyph, read composite header */
1472  error = face->read_composite_glyph( loader );
1473  if ( error )
1474  goto Exit;
1475 
1476  /* store the offset of instructions */
1477  ins_pos = loader->ins_pos;
1478 
1479  /* all data we need are read */
1480  face->forget_glyph_frame( loader );
1481  opened_frame = 0;
1482 
1483 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1484 
1485  if ( face->doblend )
1486  {
1487  FT_Int i, limit;
1488  FT_SubGlyph subglyph;
1489  FT_Memory memory = face->root.memory;
1490 
1491 
1492  /* this provides additional offsets */
1493  /* for each component's translation */
1494 
1495  if ( ( error = TT_Vary_Get_Glyph_Deltas(
1496  face,
1497  glyph_index,
1498  &deltas,
1499  gloader->current.num_subglyphs + 4 )) != 0 )
1500  goto Exit;
1501 
1502  subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
1503  limit = gloader->current.num_subglyphs;
1504 
1505  for ( i = 0; i < limit; ++i, ++subglyph )
1506  {
1507  if ( subglyph->flags & ARGS_ARE_XY_VALUES )
1508  {
1509  /* XXX: overflow check for subglyph->{arg1,arg2}. */
1510  /* deltas[i].{x,y} must be within signed 16-bit, */
1511  /* but the restriction of summed delta is not clear */
1512  subglyph->arg1 += (FT_Int16)deltas[i].x;
1513  subglyph->arg2 += (FT_Int16)deltas[i].y;
1514  }
1515  }
1516 
1517  loader->pp1.x += deltas[i + 0].x; loader->pp1.y += deltas[i + 0].y;
1518  loader->pp2.x += deltas[i + 1].x; loader->pp2.y += deltas[i + 1].y;
1519  loader->pp3.x += deltas[i + 2].x; loader->pp3.y += deltas[i + 2].y;
1520  loader->pp4.x += deltas[i + 3].x; loader->pp4.y += deltas[i + 3].y;
1521 
1522  FT_FREE( deltas );
1523  }
1524 
1525 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
1526 
1527  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1528  {
1529  loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
1530  loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
1531  loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
1532  loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
1533  }
1534 
1535  /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
1536  /* `as is' in the glyph slot (the client application will be */
1537  /* responsible for interpreting these data)... */
1538  if ( loader->load_flags & FT_LOAD_NO_RECURSE )
1539  {
1540  FT_GlyphLoader_Add( gloader );
1541  loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
1542 
1543  goto Exit;
1544  }
1545 
1546  /*********************************************************************/
1547  /*********************************************************************/
1548  /*********************************************************************/
1549 
1550  {
1551  FT_UInt n, num_base_points;
1552  FT_SubGlyph subglyph = 0;
1553 
1554  FT_UInt num_points = start_point;
1555  FT_UInt num_subglyphs = gloader->current.num_subglyphs;
1556  FT_UInt num_base_subgs = gloader->base.num_subglyphs;
1557 
1558  FT_Stream old_stream = loader->stream;
1559  FT_Int old_byte_len = loader->byte_len;
1560 
1561 
1562  FT_GlyphLoader_Add( gloader );
1563 
1564  /* read each subglyph independently */
1565  for ( n = 0; n < num_subglyphs; n++ )
1566  {
1567  FT_Vector pp[4];
1568 
1569 
1570  /* Each time we call load_truetype_glyph in this loop, the */
1571  /* value of `gloader.base.subglyphs' can change due to table */
1572  /* reallocations. We thus need to recompute the subglyph */
1573  /* pointer on each iteration. */
1574  subglyph = gloader->base.subglyphs + num_base_subgs + n;
1575 
1576  pp[0] = loader->pp1;
1577  pp[1] = loader->pp2;
1578  pp[2] = loader->pp3;
1579  pp[3] = loader->pp4;
1580 
1581  num_base_points = gloader->base.outline.n_points;
1582 
1583  error = load_truetype_glyph( loader, subglyph->index,
1584  recurse_count + 1, FALSE );
1585  if ( error )
1586  goto Exit;
1587 
1588  /* restore subglyph pointer */
1589  subglyph = gloader->base.subglyphs + num_base_subgs + n;
1590 
1591  if ( !( subglyph->flags & USE_MY_METRICS ) )
1592  {
1593  loader->pp1 = pp[0];
1594  loader->pp2 = pp[1];
1595  loader->pp3 = pp[2];
1596  loader->pp4 = pp[3];
1597  }
1598 
1599  num_points = gloader->base.outline.n_points;
1600 
1601  if ( num_points == num_base_points )
1602  continue;
1603 
1604  /* gloader->base.outline consists of three parts: */
1605  /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
1606  /* */
1607  /* (1): exists from the beginning */
1608  /* (2): components that have been loaded so far */
1609  /* (3): the newly loaded component */
1610  TT_Process_Composite_Component( loader, subglyph, start_point,
1611  num_base_points );
1612  }
1613 
1614  loader->stream = old_stream;
1615  loader->byte_len = old_byte_len;
1616 
1617  /* process the glyph */
1618  loader->ins_pos = ins_pos;
1619  if ( IS_HINTED( loader->load_flags ) &&
1620 
1622 
1623  subglyph->flags & WE_HAVE_INSTR &&
1624 
1625 #endif
1626 
1627  num_points > start_point )
1628  TT_Process_Composite_Glyph( loader, start_point, start_contour );
1629 
1630  }
1631  }
1632  else
1633  {
1634  /* invalid composite count (negative but not -1) */
1635  error = FT_THROW( Invalid_Outline );
1636  goto Exit;
1637  }
1638 
1639  /***********************************************************************/
1640  /***********************************************************************/
1641  /***********************************************************************/
1642 
1643  Exit:
1644 
1645  if ( opened_frame )
1646  face->forget_glyph_frame( loader );
1647 
1648 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1649 
1650  if ( glyph_data_loaded )
1651  face->root.internal->incremental_interface->funcs->free_glyph_data(
1652  face->root.internal->incremental_interface->object,
1653  &glyph_data );
1654 
1655 #endif
1656 
1657  return error;
1658  }
1659 
1660 
1661  static FT_Error
1662  compute_glyph_metrics( TT_Loader loader,
1663  FT_UInt glyph_index )
1664  {
1665  FT_BBox bbox;
1666  TT_Face face = (TT_Face)loader->face;
1667  FT_Fixed y_scale;
1668  TT_GlyphSlot glyph = loader->glyph;
1669  TT_Size size = (TT_Size)loader->size;
1670 
1671 
1672  y_scale = 0x10000L;
1673  if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1674  y_scale = size->root.metrics.y_scale;
1675 
1676  if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE )
1677  FT_Outline_Get_CBox( &glyph->outline, &bbox );
1678  else
1679  bbox = loader->bbox;
1680 
1681  /* get the device-independent horizontal advance; it is scaled later */
1682  /* by the base layer. */
1683  glyph->linearHoriAdvance = loader->linear;
1684 
1685  glyph->metrics.horiBearingX = bbox.xMin;
1686  glyph->metrics.horiBearingY = bbox.yMax;
1687  glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
1688 
1689  /* adjust advance width to the value contained in the hdmx table */
1690  if ( !face->postscript.isFixedPitch &&
1691  IS_HINTED( loader->load_flags ) )
1692  {
1693  FT_Byte* widthp;
1694 
1695 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1696  FT_Bool ignore_x_mode;
1697 
1698 
1699  ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
1701 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1702 
1703  widthp = tt_face_get_device_metrics( face,
1704  size->root.metrics.x_ppem,
1705  glyph_index );
1706 
1707 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1708  if ( widthp &&
1709  ( ( ignore_x_mode && loader->exec->compatible_widths ) ||
1710  !ignore_x_mode ||
1711  SPH_OPTION_BITMAP_WIDTHS ) )
1712 #else
1713  if ( widthp )
1714 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1715  glyph->metrics.horiAdvance = *widthp << 6;
1716  }
1717 
1718  /* set glyph dimensions */
1719  glyph->metrics.width = bbox.xMax - bbox.xMin;
1720  glyph->metrics.height = bbox.yMax - bbox.yMin;
1721 
1722  /* Now take care of vertical metrics. In the case where there is */
1723  /* no vertical information within the font (relatively common), */
1724  /* create some metrics manually */
1725  {
1726  FT_Pos top; /* scaled vertical top side bearing */
1727  FT_Pos advance; /* scaled vertical advance height */
1728 
1729 
1730  /* Get the unscaled top bearing and advance height. */
1731  if ( face->vertical_info &&
1732  face->vertical.number_Of_VMetrics > 0 )
1733  {
1734  top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
1735  y_scale );
1736 
1737  if ( loader->pp3.y <= loader->pp4.y )
1738  advance = 0;
1739  else
1740  advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
1741  y_scale );
1742  }
1743  else
1744  {
1745  FT_Pos height;
1746 
1747 
1748  /* XXX Compute top side bearing and advance height in */
1749  /* Get_VMetrics instead of here. */
1750 
1751  /* NOTE: The OS/2 values are the only `portable' ones, */
1752  /* which is why we use them, if there is an OS/2 */
1753  /* table in the font. Otherwise, we use the */
1754  /* values defined in the horizontal header. */
1755 
1756  height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin,
1757  y_scale );
1758  if ( face->os2.version != 0xFFFFU )
1759  advance = (FT_Pos)( face->os2.sTypoAscender -
1760  face->os2.sTypoDescender );
1761  else
1762  advance = (FT_Pos)( face->horizontal.Ascender -
1763  face->horizontal.Descender );
1764 
1765  top = ( advance - height ) / 2;
1766  }
1767 
1768 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1769  {
1772  FT_Error error;
1773 
1774 
1775  incr = face->root.internal->incremental_interface;
1776 
1777  /* If this is an incrementally loaded font see if there are */
1778  /* overriding metrics for this glyph. */
1779  if ( incr && incr->funcs->get_glyph_metrics )
1780  {
1781  metrics.bearing_x = 0;
1782  metrics.bearing_y = top;
1783  metrics.advance = advance;
1784 
1785  error = incr->funcs->get_glyph_metrics( incr->object,
1786  glyph_index,
1787  TRUE,
1788  &metrics );
1789  if ( error )
1790  return error;
1791 
1792  top = metrics.bearing_y;
1793  advance = metrics.advance;
1794  }
1795  }
1796 
1797  /* GWW: Do vertical metrics get loaded incrementally too? */
1798 
1799 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
1800 
1801  glyph->linearVertAdvance = advance;
1802 
1803  /* scale the metrics */
1804  if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
1805  {
1806  top = FT_MulFix( top, y_scale );
1807  advance = FT_MulFix( advance, y_scale );
1808  }
1809 
1810  /* XXX: for now, we have no better algorithm for the lsb, but it */
1811  /* should work fine. */
1812  /* */
1813  glyph->metrics.vertBearingX = glyph->metrics.horiBearingX -
1814  glyph->metrics.horiAdvance / 2;
1815  glyph->metrics.vertBearingY = top;
1816  glyph->metrics.vertAdvance = advance;
1817  }
1818 
1819  return 0;
1820  }
1821 
1822 
1823 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
1824 
1825  static FT_Error
1826  load_sbit_image( TT_Size size,
1827  TT_GlyphSlot glyph,
1828  FT_UInt glyph_index,
1829  FT_Int32 load_flags )
1830  {
1831  TT_Face face;
1832  SFNT_Service sfnt;
1833  FT_Stream stream;
1834  FT_Error error;
1836 
1837 
1838  face = (TT_Face)glyph->face;
1839  sfnt = (SFNT_Service)face->sfnt;
1840  stream = face->root.stream;
1841 
1842  error = sfnt->load_sbit_image( face,
1843  size->strike_index,
1844  glyph_index,
1845  (FT_Int)load_flags,
1846  stream,
1847  &glyph->bitmap,
1848  &metrics );
1849  if ( !error )
1850  {
1851  glyph->outline.n_points = 0;
1852  glyph->outline.n_contours = 0;
1853 
1854  glyph->metrics.width = (FT_Pos)metrics.width << 6;
1855  glyph->metrics.height = (FT_Pos)metrics.height << 6;
1856 
1857  glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
1858  glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
1859  glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
1860 
1861  glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
1862  glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
1863  glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
1864 
1865  glyph->format = FT_GLYPH_FORMAT_BITMAP;
1866 
1867  if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
1868  {
1869  glyph->bitmap_left = metrics.vertBearingX;
1870  glyph->bitmap_top = metrics.vertBearingY;
1871  }
1872  else
1873  {
1874  glyph->bitmap_left = metrics.horiBearingX;
1875  glyph->bitmap_top = metrics.horiBearingY;
1876  }
1877  }
1878 
1879  return error;
1880  }
1881 
1882 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
1883 
1884 
1885  static FT_Error
1886  tt_loader_init( TT_Loader loader,
1887  TT_Size size,
1888  TT_GlyphSlot glyph,
1889  FT_Int32 load_flags,
1890  FT_Bool glyf_table_only )
1891  {
1892  TT_Face face;
1893  FT_Stream stream;
1894 #ifdef TT_USE_BYTECODE_INTERPRETER
1895  FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
1896 #endif
1897 
1898 
1899  face = (TT_Face)glyph->face;
1900  stream = face->root.stream;
1901 
1902  FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) );
1903 
1904 #ifdef TT_USE_BYTECODE_INTERPRETER
1905 
1906  /* load execution context */
1907  if ( IS_HINTED( load_flags ) && !glyf_table_only )
1908  {
1909  TT_ExecContext exec;
1910  FT_Bool grayscale;
1911 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1912  FT_Bool subpixel_hinting;
1913  FT_Bool grayscale_hinting;
1914 #if 0
1915  FT_Bool compatible_widths;
1916  FT_Bool symmetrical_smoothing;
1917  FT_Bool bgr;
1918  FT_Bool subpixel_positioned;
1919 #endif
1920 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1921 
1922 
1923  if ( !size->cvt_ready )
1924  {
1925  FT_Error error = tt_size_ready_bytecode( size, pedantic );
1926 
1927 
1928  if ( error )
1929  return error;
1930  }
1931 
1932  /* query new execution context */
1933  exec = size->debug ? size->context
1934  : ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
1935  if ( !exec )
1936  return FT_THROW( Could_Not_Find_Context );
1937 
1938 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1939 
1940  subpixel_hinting = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags )
1941  != FT_RENDER_MODE_MONO ) &&
1942  SPH_OPTION_SET_SUBPIXEL );
1943 
1944  if ( subpixel_hinting )
1945  grayscale = grayscale_hinting = FALSE;
1946  else if ( SPH_OPTION_SET_GRAYSCALE )
1947  {
1948  grayscale = grayscale_hinting = TRUE;
1949  subpixel_hinting = FALSE;
1950  }
1951  else
1952  grayscale = grayscale_hinting = FALSE;
1953 
1954  if ( FT_IS_TRICKY( glyph->face ) )
1955  subpixel_hinting = grayscale_hinting = FALSE;
1956 
1957  exec->ignore_x_mode = subpixel_hinting || grayscale_hinting;
1958  exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
1959  if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
1960  exec->rasterizer_version = 35;
1961 
1962 #if 1
1963  exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
1964  exec->symmetrical_smoothing = FALSE;
1965  exec->bgr = FALSE;
1966  exec->subpixel_positioned = TRUE;
1967 #else /* 0 */
1968  exec->compatible_widths =
1969  FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
1970  TT_LOAD_COMPATIBLE_WIDTHS );
1971  exec->symmetrical_smoothing =
1972  FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
1973  TT_LOAD_SYMMETRICAL_SMOOTHING );
1974  exec->bgr =
1975  FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
1976  TT_LOAD_BGR );
1977  exec->subpixel_positioned =
1978  FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
1979  TT_LOAD_SUBPIXEL_POSITIONED );
1980 #endif /* 0 */
1981 
1982 #else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1983 
1984  grayscale =
1985  FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
1986 
1987 #endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1988 
1989  TT_Load_Context( exec, face, size );
1990 
1991 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1992 
1993  /* a change from mono to subpixel rendering (and vice versa) */
1994  /* requires a re-execution of the CVT program */
1995  if ( subpixel_hinting != exec->subpixel_hinting )
1996  {
1997  FT_UInt i;
1998 
1999 
2000  FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
2001  " re-executing `prep' table\n" ));
2002 
2003  exec->subpixel_hinting = subpixel_hinting;
2004 
2005  for ( i = 0; i < size->cvt_size; i++ )
2006  size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
2007  tt_size_run_prep( size, pedantic );
2008  }
2009 
2010  /* a change from mono to grayscale rendering (and vice versa) */
2011  /* requires a re-execution of the CVT program */
2012  if ( grayscale != exec->grayscale_hinting )
2013  {
2014  FT_UInt i;
2015 
2016 
2017  FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
2018  " re-executing `prep' table\n" ));
2019 
2020  exec->grayscale_hinting = grayscale_hinting;
2021 
2022  for ( i = 0; i < size->cvt_size; i++ )
2023  size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
2024  tt_size_run_prep( size, pedantic );
2025  }
2026 
2027 #else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
2028 
2029  /* a change from mono to grayscale rendering (and vice versa) */
2030  /* requires a re-execution of the CVT program */
2031  if ( grayscale != exec->grayscale )
2032  {
2033  FT_UInt i;
2034 
2035 
2036  FT_TRACE4(( "tt_loader_init: grayscale change,"
2037  " re-executing `prep' table\n" ));
2038 
2039  exec->grayscale = grayscale;
2040 
2041  for ( i = 0; i < size->cvt_size; i++ )
2042  size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
2043  tt_size_run_prep( size, pedantic );
2044  }
2045 
2046 #endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
2047 
2048  /* see whether the cvt program has disabled hinting */
2049  if ( exec->GS.instruct_control & 1 )
2050  load_flags |= FT_LOAD_NO_HINTING;
2051 
2052  /* load default graphics state -- if needed */
2053  if ( exec->GS.instruct_control & 2 )
2054  exec->GS = tt_default_graphics_state;
2055 
2056  exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
2057  loader->exec = exec;
2058  loader->instructions = exec->glyphIns;
2059  }
2060 
2061 #endif /* TT_USE_BYTECODE_INTERPRETER */
2062 
2063  /* seek to the beginning of the glyph table -- for Type 42 fonts */
2064  /* the table might be accessed from a Postscript stream or something */
2065  /* else... */
2066 
2067 #ifdef FT_CONFIG_OPTION_INCREMENTAL
2068 
2069  if ( face->root.internal->incremental_interface )
2070  loader->glyf_offset = 0;
2071  else
2072 
2073 #endif
2074 
2075  {
2076  FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 );
2077 
2078 
2079  if ( FT_ERR_EQ( error, Table_Missing ) )
2080  loader->glyf_offset = 0;
2081  else if ( error )
2082  {
2083  FT_ERROR(( "tt_loader_init: could not access glyph table\n" ));
2084  return error;
2085  }
2086  else
2087  loader->glyf_offset = FT_STREAM_POS();
2088  }
2089 
2090  /* get face's glyph loader */
2091  if ( !glyf_table_only )
2092  {
2093  FT_GlyphLoader gloader = glyph->internal->loader;
2094 
2095 
2096  FT_GlyphLoader_Rewind( gloader );
2097  loader->gloader = gloader;
2098  }
2099 
2100  loader->load_flags = load_flags;
2101 
2102  loader->face = (FT_Face)face;
2103  loader->size = (FT_Size)size;
2104  loader->glyph = (FT_GlyphSlot)glyph;
2105  loader->stream = stream;
2106 
2107  return FT_Err_Ok;
2108  }
2109 
2110 
2111  /*************************************************************************/
2112  /* */
2113  /* <Function> */
2114  /* TT_Load_Glyph */
2115  /* */
2116  /* <Description> */
2117  /* A function used to load a single glyph within a given glyph slot, */
2118  /* for a given size. */
2119  /* */
2120  /* <Input> */
2121  /* glyph :: A handle to a target slot object where the glyph */
2122  /* will be loaded. */
2123  /* */
2124  /* size :: A handle to the source face size at which the glyph */
2125  /* must be scaled/loaded. */
2126  /* */
2127  /* glyph_index :: The index of the glyph in the font file. */
2128  /* */
2129  /* load_flags :: A flag indicating what to load for this glyph. The */
2130  /* FT_LOAD_XXX constants can be used to control the */
2131  /* glyph loading process (e.g., whether the outline */
2132  /* should be scaled, whether to load bitmaps or not, */
2133  /* whether to hint the outline, etc). */
2134  /* */
2135  /* <Return> */
2136  /* FreeType error code. 0 means success. */
2137  /* */
2140  TT_GlyphSlot glyph,
2141  FT_UInt glyph_index,
2142  FT_Int32 load_flags )
2143  {
2144  FT_Error error;
2145  TT_LoaderRec loader;
2146 
2147 
2148  error = FT_Err_Ok;
2149 
2150 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
2151 
2152  /* try to load embedded bitmap if any */
2153  /* */
2154  /* XXX: The convention should be emphasized in */
2155  /* the documents because it can be confusing. */
2156  if ( size->strike_index != 0xFFFFFFFFUL &&
2157  ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
2158  {
2159  error = load_sbit_image( size, glyph, glyph_index, load_flags );
2160  if ( !error )
2161  {
2162  if ( FT_IS_SCALABLE( glyph->face ) )
2163  {
2164  /* for the bbox we need the header only */
2165  (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
2166  (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
2167  glyph->linearHoriAdvance = loader.linear;
2168  glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
2169  loader.vadvance;
2170  }
2171 
2172  return FT_Err_Ok;
2173  }
2174  }
2175 
2176 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
2177 
2178  /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
2179  if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
2180  return FT_THROW( Invalid_Size_Handle );
2181 
2182  if ( load_flags & FT_LOAD_SBITS_ONLY )
2183  return FT_THROW( Invalid_Argument );
2184 
2185  error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
2186  if ( error )
2187  return error;
2188 
2189  glyph->format = FT_GLYPH_FORMAT_OUTLINE;
2190  glyph->num_subglyphs = 0;
2191  glyph->outline.flags = 0;
2192 
2193  /* main loading loop */
2194  error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
2195  if ( !error )
2196  {
2197  if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
2198  {
2199  glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
2200  glyph->subglyphs = loader.gloader->base.subglyphs;
2201  }
2202  else
2203  {
2204  glyph->outline = loader.gloader->base.outline;
2205  glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
2206 
2207  /* Translate array so that (0,0) is the glyph's origin. Note */
2208  /* that this behaviour is independent on the value of bit 1 of */
2209  /* the `flags' field in the `head' table -- at least major */
2210  /* applications like Acroread indicate that. */
2211  if ( loader.pp1.x )
2212  FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
2213  }
2214 
2215 #ifdef TT_USE_BYTECODE_INTERPRETER
2216 
2217  if ( IS_HINTED( load_flags ) )
2218  {
2219  if ( loader.exec->GS.scan_control )
2220  {
2221  /* convert scan conversion mode to FT_OUTLINE_XXX flags */
2222  switch ( loader.exec->GS.scan_type )
2223  {
2224  case 0: /* simple drop-outs including stubs */
2225  glyph->outline.flags |= FT_OUTLINE_INCLUDE_STUBS;
2226  break;
2227  case 1: /* simple drop-outs excluding stubs */
2228  /* nothing; it's the default rendering mode */
2229  break;
2230  case 4: /* smart drop-outs including stubs */
2231  glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS |
2233  break;
2234  case 5: /* smart drop-outs excluding stubs */
2235  glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS;
2236  break;
2237 
2238  default: /* no drop-out control */
2239  glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
2240  break;
2241  }
2242  }
2243  else
2244  glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
2245  }
2246 
2247 #endif /* TT_USE_BYTECODE_INTERPRETER */
2248 
2249  compute_glyph_metrics( &loader, glyph_index );
2250  }
2251 
2252  /* Set the `high precision' bit flag. */
2253  /* This is _critical_ to get correct output for monochrome */
2254  /* TrueType glyphs at all sizes using the bytecode interpreter. */
2255  /* */
2256  if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
2257  size->root.metrics.y_ppem < 24 )
2258  glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
2259 
2260  return error;
2261  }
2262 
2263 
2264 /* END */
TT_Loader_EndGlyphFunc forget_glyph_frame
Definition: tttypes.h:1291
#define UNSCALED_COMPONENT_OFFSET
Definition: ttgload.c:64
const TT_GraphicsState tt_default_graphics_state
FT_UShort n_points
Definition: tttypes.h:1477
TT_Load_Glyph_Header(TT_Loader loader)
Definition: ttgload.c:310
GLint GLint GLsizei GLsizei height
#define FT_OUTLINE_SINGLE_PASS
Definition: ftimage.h:483
FT_Byte * tags
Definition: tttypes.h:1484
int FT_Error
Definition: fttypes.h:296
FT_Vector pp4
Definition: tttypes.h:1536
FT_Byte instruct_control
Definition: ttobjs.h:101
#define FT_LOAD_VERTICAL_LAYOUT
Definition: freetype.h:2553
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:586
GLuint GLuint stream
for(n=1;n< outline->n_points;n++)
Definition: ftbbox.c:593
void * sfnt
Definition: tttypes.h:1298
signed long FT_Long
Definition: fttypes.h:238
SFNT_Interface * SFNT_Service
Definition: sfnt.h:754
TT_ExecContext exec
Definition: tttypes.h:1525
TT_OS2 os2
Definition: tttypes.h:1282
FT_GlyphSlot glyph
Definition: tttypes.h:1500
unsigned long FT_ULong
Definition: fttypes.h:249
FT_ULong isFixedPitch
Definition: tttables.h:420
FT_UInt glyphSize
Definition: ttinterp.h:199
#define FT_LOAD_SBITS_ONLY
Definition: freetype.h:2568
FT_Vector * org
Definition: tttypes.h:1480
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat p
#define TTAG_glyf
Definition: tttags.h:58
FT_UShort version
Definition: tttables.h:352
FT_Char horiBearingY
Definition: tttypes.h:441
#define FT_MEM_ZERO(dest, count)
Definition: ftmemory.h:208
FT_Byte * limit
Definition: tttypes.h:1540
#define NULL
Definition: ftobjs.h:61
GLint GLint GLint GLint GLint GLint y
FT_Short sTypoDescender
Definition: tttables.h:382
FT_Fixed xy
Definition: fttypes.h:383
#define FT_OUTLINE_IGNORE_DROPOUTS
Definition: ftimage.h:478
signed int FT_Int
Definition: fttypes.h:216
short n_contours
Definition: ftimage.h:385
#define FT_ARRAY_COPY(dest, source, count)
Definition: ftmemory.h:216
FT_UShort maxComponentDepth
Definition: tttables.h:544
FT_ULong strike_index
Definition: ttobjs.h:300
sizeof(AF_ModuleRec)
FT_BBox bbox
Definition: ftbbox.c:565
FT_Memory memory
Definition: ttinterp.h:161
#define SCALED_COMPONENT_OFFSET
Definition: ttgload.c:63
#define FT_CURVE_TAG_TOUCH_BOTH
Definition: ftimage.h:525
FT_Byte horiAdvance
Definition: tttypes.h:442
unsigned char * cursor
Definition: ftsystem.h:333
FT_BBox bbox
Definition: tttypes.h:1510
#define FT_LOAD_NO_HINTING
Definition: freetype.h:2550
TT_Loader_StartGlyphFunc access_glyph_frame
Definition: tttypes.h:1290
return FT_THROW(Missing_Property)
short * contours
Definition: ftimage.h:390
#define FT_NEXT_BYTE(buffer)
Definition: ftstream.h:220
FT_Int arg1
Definition: ftgloadr.h:61
signed short FT_Int16
Definition: ftconfig.h:127
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
char * tags
Definition: ftimage.h:389
voidpf uLong int origin
Definition: ioapi.h:142
FT_String * family_name
Definition: freetype.h:929
#define FT_LOAD_NO_RECURSE
Definition: freetype.h:2558
#define FT_LOAD_PEDANTIC
Definition: freetype.h:2556
FT_Short * cvt
Definition: tttypes.h:1357
TT_Init_Glyph_Loading(TT_Face face)
Definition: ttgload.c:682
FT_String * style_name
Definition: freetype.h:930
TT_GlyphZoneRec zone
Definition: tttypes.h:1523
FT_Outline outline
Definition: ftgloadr.h:70
GLint GLint GLint GLint GLint x
FT_Int bitmap_top
Definition: freetype.h:1629
FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics
Definition: ftincrem.h:273
FT_Vector pp3
Definition: tttypes.h:1535
#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
Definition: ftoption.h:672
typedefFT_BEGIN_HEADER struct TT_DriverRec_ * TT_Driver
Definition: ttobjs.h:39
return FT_Err_Ok
Definition: ftbbox.c:645
#define FT_READ_USHORT(var)
Definition: ftstream.h:309
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
tt_face_get_device_metrics(TT_Face face, FT_UInt ppem, FT_UInt gindex)
Definition: ttpload.c:576
FT_Byte * cursor
Definition: tttypes.h:1539
FT_Vector pp2
Definition: tttypes.h:1517
FT_Int index
Definition: ftgloadr.h:59
#define ARGS_ARE_XY_VALUES
Definition: ttgload.c:53
FT_UShort * contours
Definition: tttypes.h:1485
#define ARGS_ARE_WORDS
Definition: ttgload.c:52
GLboolean GLboolean GLboolean b
TT_Loader_GotoTableFunc goto_table
Definition: tttypes.h:1288
FT_Int left_bearing
Definition: tttypes.h:1511
FT_UShort flags
Definition: ftgloadr.h:60
png_uint_32 i
Definition: png.h:2640
FT_UInt glyph_index
Definition: tttypes.h:1504
#define FT_FACE_DRIVER(x)
Definition: ftobjs.h:561
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
#define FT_LOAD_NO_SCALE
Definition: freetype.h:2549
FT_Face_Internal internal
Definition: freetype.h:971
FT_ULong glyf_offset
Definition: tttypes.h:1519
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
GLenum GLuint GLint GLenum face
#define FT_CURVE_TAG_HAS_SCANMODE
Definition: ftimage.h:520
FT_Outline outline
Definition: freetype.h:1631
typedefFT_BEGIN_HEADER struct FT_GlyphLoaderRec_ * FT_GlyphLoader
Definition: ftgloadr.h:43
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define USE_MY_METRICS
Definition: ttgload.c:61
unsigned char FT_Byte
Definition: fttypes.h:150
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define FT_CONFIG_OPTION_INCREMENTAL
Definition: ftoption.h:346
FT_Matrix transform
Definition: ftgloadr.h:63
FT_Int linear
Definition: tttypes.h:1513
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
TT_Forget_Glyph_Frame(TT_Loader loader)
Definition: ttgload.c:300
TT_Load_SBit_Image_Func load_sbit_image
Definition: sfnt.h:715
FT_Vector * cur
Definition: tttypes.h:1481
FT_Short Descender
Definition: tttables.h:184
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:468
FT_GlyphLoader_Add(FT_GlyphLoader loader)
Definition: ftgloadr.c:324
TT_Vary_Get_Glyph_Deltas(TT_Face face, FT_UInt glyph_index, FT_Vector **deltas, FT_UInt n_points)
FT_Int byte_len
Definition: tttypes.h:1507
FT_Bitmap bitmap
Definition: freetype.h:1627
#define MORE_COMPONENTS
Definition: ttgload.c:57
TT_Load_Composite_Glyph(TT_Loader loader)
Definition: ttgload.c:561
FT_Char horiBearingX
Definition: tttypes.h:440
FT_Bool linear_def
Definition: tttypes.h:1514
#define FT_FREE(ptr)
Definition: ftmemory.h:286
FT_Short Ascender
Definition: tttables.h:183
FT_Bool preserve_pps
Definition: tttypes.h:1515
FT_Vector pp1
Definition: tttypes.h:1516
TT_Get_VMetrics(TT_Face face, FT_UInt idx, FT_Short *tsb, FT_UShort *ah)
Definition: ttgload.c:95
TT_Postscript postscript
Definition: tttypes.h:1283
FT_Pos yMax
Definition: ftimage.h:119
FT_Pos xMin
Definition: ftimage.h:118
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:951
#define WE_HAVE_AN_XY_SCALE
Definition: ttgload.c:58
TT_MaxProfile max_profile
Definition: tttypes.h:1271
FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs)
Definition: ftgloadr.c:277
FT_UInt idx
Definition: cffcmap.c:127
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:412
FT_Size_Metrics metrics
Definition: ttinterp.h:181
FT_Error error
Definition: cffdrivr.c:411
FT_Char vertBearingX
Definition: tttypes.h:444
FT_Pos x
Definition: ftimage.h:77
FT_Size size
Definition: tttypes.h:1499
TT_Get_HMetrics(TT_Face face, FT_UInt idx, FT_Short *lsb, FT_UShort *aw)
Definition: ttgload.c:72
FT_UShort number_Of_VMetrics
Definition: tttables.h:325
char FT_String
Definition: fttypes.h:183
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:482
TT_Load_Simple_Glyph(TT_Loader load)
Definition: ttgload.c:338
#define FT_IS_TRICKY(face)
Definition: freetype.h:1270
FT_ULong ins_pos
Definition: tttypes.h:1527
FT_Pos y
Definition: ftimage.h:78
FT_Vector * extra_points
Definition: ftgloadr.h:71
FT_Bool vertical_info
Definition: tttypes.h:1276
TT_Loader_ReadGlyphFunc read_composite_glyph
Definition: tttypes.h:1294
FT_Int vadvance
Definition: tttypes.h:1534
FT_Char vertBearingY
Definition: tttypes.h:445
GLdouble n
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define FT_ERR_EQ(x, e)
Definition: fttypes.h:587
FT_UShort maxSizeOfInstructions
Definition: tttables.h:542
struct FT_FaceRec_ * FT_Face
Definition: freetype.h:403
const GLubyte * c
signed int FT_Int32
Definition: ftconfig.h:132
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:323
TT_Size_Metrics ttmetrics
Definition: ttobjs.h:298
FT_GlyphLoader loader
Definition: ftobjs.h:413
#define WE_HAVE_A_2X2
Definition: ttgload.c:59
TT_VertHeader vertical
Definition: tttypes.h:1277
FT_UShort first_point
Definition: tttypes.h:1487
FT_Vector * vec
Definition: ftbbox.c:566
FT_UShort x_ppem
Definition: freetype.h:1369
GLintptr offset
FT_Int advance
Definition: tttypes.h:1512
const GLfloat * m
FT_Outline_EmboldenXY(FT_Outline *outline, FT_Pos xstrength, FT_Pos ystrength)
Definition: ftoutln.c:900
FT_Short n_contours
Definition: tttypes.h:1478
#define FALSE
Definition: ftobjs.h:57
FT_Pos xMax
Definition: ftimage.h:119
FT_GlyphLoader gloader
Definition: tttypes.h:1501
FT_Bool grayscale
Definition: ttinterp.h:261
short n_points
Definition: ftimage.h:386
signed short FT_Short
Definition: fttypes.h:194
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
FT_Bool pedantic_hinting
Definition: ttinterp.h:242
FT_Fixed xx
Definition: fttypes.h:383
#define FT_BOOL(x)
Definition: fttypes.h:574
const FT_Incremental_FuncsRec * funcs
Definition: ftincrem.h:316
#define FT_OUTLINE_INCLUDE_STUBS
Definition: ftimage.h:480
FT_FaceRec root
Definition: tttypes.h:1260
#define FT_FRAME_EXIT()
Definition: ftstream.h:514
TT_HoriHeader horizontal
Definition: tttypes.h:1269
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:485
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
if(!abbox) return FT_THROW(Invalid_Argument)
#define FT_STREAM_POS()
Definition: ftstream.h:486
FT_Fixed yx
Definition: fttypes.h:384
FT_Fixed y_scale
Definition: freetype.h:1373
GLdouble GLdouble GLdouble GLdouble top
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
Definition: ftoutln.c:680
#define ROUND_XY_TO_GRID
Definition: ttgload.c:54
signed long FT_Fixed
Definition: fttypes.h:284
TT_GraphicsState GS
Definition: ttinterp.h:184
FT_Int bitmap_left
Definition: freetype.h:1628
FT_Glyph_Format format
Definition: freetype.h:1625
FT_Long num_glyphs
Definition: freetype.h:927
local void * load(const char *name, size_t *len)
Definition: pufftest.c:60
FT_Short sTypoAscender
Definition: tttables.h:381
struct FT_SizeRec_ * FT_Size
Definition: freetype.h:433
unsigned int FT_UInt
Definition: fttypes.h:227
struct FT_GlyphSlotRec_ * FT_GlyphSlot
Definition: freetype.h:454
TT_Loader_ReadGlyphFunc read_simple_glyph
Definition: tttypes.h:1293
FT_GlyphLoader_Rewind(FT_GlyphLoader loader)
Definition: ftgloadr.c:88
#define TT_LOADER_SET_PP(loader)
Definition: ttgload.c:1232
FT_Slot_Internal internal
Definition: freetype.h:1644
unsigned char * limit
Definition: ftsystem.h:334
FT_Int scan_type
Definition: ttobjs.h:107
FT_Stream stream
Definition: tttypes.h:1506
void * control_data
Definition: freetype.h:1636
FT_Byte * instructions
Definition: tttypes.h:1526
#define FT_TRACE5(varformat)
Definition: ftdebug.h:162
FT_Bool is_composite
Definition: ttinterp.h:241
FT_Int arg2
Definition: ftgloadr.h:62
#define FT_OUTLINE_SMART_DROPOUTS
Definition: ftimage.h:479
FT_Fixed x_scale
Definition: freetype.h:1372
FT_Int top_bearing
Definition: tttypes.h:1533
#define TT_USE_BYTECODE_INTERPRETER
Definition: ftoption.h:815
FT_Glyph_Metrics metrics
Definition: freetype.h:1620
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:518
FT_Fixed scale
Definition: ttobjs.h:274
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
Definition: ftstream.c:35
GLuint GLuint GLsizei count
#define FT_CURVE_TAG_ON
Definition: ftimage.h:516
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:510
FT_Fixed yy
Definition: fttypes.h:384
FT_Bool scan_control
Definition: ttobjs.h:106
FT_Short n_contours
Definition: tttypes.h:1509
#define WE_HAVE_A_SCALE
Definition: ttgload.c:55
FT_TRACE0(("cff_property_set: missing property `%s'\, property_name))
FT_Byte * glyphIns
Definition: ttinterp.h:200
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:203
#define WE_HAVE_INSTR
Definition: ttgload.c:60
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
#define FT_NEXT_SHORT(buffer)
Definition: ftstream.h:223
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:2552
TT_Access_Glyph_Frame(TT_Loader loader, FT_UInt glyph_index, FT_ULong offset, FT_UInt byte_count)
Definition: ttgload.c:274
png_infop png_uint_32 flag
Definition: png.h:2005
TT_Load_Glyph(TT_Size size, TT_GlyphSlot glyph, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ttgload.c:2139
unsigned short FT_UShort
Definition: fttypes.h:205
#define FT_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours)
Definition: ftgloadr.h:134
FT_Pos yMin
Definition: ftimage.h:118
GLfloat f
FT_Vector * extra_points2
Definition: ftgloadr.h:72
FT_Stream stream
Definition: freetype.h:964
TT_Loader_ReadGlyphFunc read_glyph_header
Definition: tttypes.h:1292
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1148
FT_ULong load_flags
Definition: tttypes.h:1503
FT_Hypot(FT_Fixed x, FT_Fixed y)
Definition: ftcalc.c:142
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:495
GLsizeiptr size
GLuint coords
#define FT_NEXT_CHAR(buffer)
Definition: ftstream.h:217
#define TRUE
Definition: ftobjs.h:53
FT_Vector * points
Definition: ftimage.h:388
FT_Vector * orus
Definition: tttypes.h:1482
TT_GlyphZoneRec pts
Definition: ttinterp.h:175
struct TT_SizeRec_ * TT_Size
Definition: ttobjs.h:50
#define FT_PIX_ROUND(x)
Definition: ftobjs.h:81
FT_Module_Constructor FT_GLYPH_FORMAT_OUTLINE
Definition: ftrend1.c:284
GLint limit
FT_Size_Metrics metrics
Definition: freetype.h:1406
tt_face_get_location(TT_Face face, FT_UInt gindex, FT_UInt *asize)
Definition: ttpload.c:173
FT_Byte vertAdvance
Definition: tttypes.h:446
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:236
FT_Face face
Definition: tttypes.h:1498
FT_Memory memory
Definition: freetype.h:963
#define IS_HINTED(flags)
Definition: ttobjs.h:433
#define FT_LOAD_TARGET_MODE(x)
Definition: freetype.h:2655