ReactOS  0.4.14-dev-552-g2fad488
ttgload.h File Reference
#include <ft2build.h>
#include "ttobjs.h"
Include dependency graph for ttgload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER TT_Init_Glyph_Loading (TT_Face face)
 
 TT_Get_HMetrics (TT_Face face, FT_UInt idx, FT_Short *lsb, FT_UShort *aw)
 
 TT_Get_VMetrics (TT_Face face, FT_UInt idx, FT_Pos yMax, FT_Short *tsb, FT_UShort *ah)
 
 TT_Load_Glyph (TT_Size size, TT_GlyphSlot glyph, FT_UInt glyph_index, FT_Int32 load_flags)
 

Function Documentation

◆ TT_Get_HMetrics()

TT_Get_HMetrics ( TT_Face  face,
FT_UInt  idx,
FT_Short lsb,
FT_UShort aw 
)

Definition at line 75 of file ttgload.c.

79  {
80  ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
81 
82  FT_TRACE5(( " advance width (font units): %d\n", *aw ));
83  FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
84  }
SFNT_Interface * SFNT_Service
Definition: sfnt.h:628
unsigned int idx
Definition: utils.c:41
#define FT_TRACE5(varformat)
Definition: ftdebug.h:162
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by tt_get_metrics(), and TT_Load_Glyph().

◆ TT_Get_VMetrics()

TT_Get_VMetrics ( TT_Face  face,
FT_UInt  idx,
FT_Pos  yMax,
FT_Short tsb,
FT_UShort ah 
)

Definition at line 93 of file ttgload.c.

98  {
99  if ( face->vertical_info )
100  ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
101 
102  else if ( face->os2.version != 0xFFFFU )
103  {
104  *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
105  *ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
106  face->os2.sTypoDescender );
107  }
108 
109  else
110  {
111  *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
112  *ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
113  face->horizontal.Descender );
114  }
115 
116  FT_TRACE5(( " advance height (font units): %d\n", *ah ));
117  FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
118  }
SFNT_Interface * SFNT_Service
Definition: sfnt.h:628
#define FT_ABS(a)
Definition: ftobjs.h:74
unsigned int idx
Definition: utils.c:41
signed short FT_Short
Definition: fttypes.h:198
#define FT_TRACE5(varformat)
Definition: ftdebug.h:162
unsigned short FT_UShort
Definition: fttypes.h:209
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by tt_get_metrics(), and TT_Load_Glyph().

◆ TT_Init_Glyph_Loading()

FT_BEGIN_HEADER TT_Init_Glyph_Loading ( TT_Face  face)

Definition at line 742 of file ttgload.c.

743  {
744  face->access_glyph_frame = TT_Access_Glyph_Frame;
745  face->read_glyph_header = TT_Load_Glyph_Header;
746  face->read_simple_glyph = TT_Load_Simple_Glyph;
747  face->read_composite_glyph = TT_Load_Composite_Glyph;
748  face->forget_glyph_frame = TT_Forget_Glyph_Frame;
749  }
TT_Load_Glyph_Header(TT_Loader loader)
Definition: ttgload.c:298
TT_Forget_Glyph_Frame(TT_Loader loader)
Definition: ttgload.c:288
TT_Load_Composite_Glyph(TT_Loader loader)
Definition: ttgload.c:559
TT_Load_Simple_Glyph(TT_Loader load)
Definition: ttgload.c:326
TT_Access_Glyph_Frame(TT_Loader loader, FT_UInt glyph_index, FT_ULong offset, FT_UInt byte_count)
Definition: ttgload.c:262
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by tt_face_init().

◆ TT_Load_Glyph()

TT_Load_Glyph ( TT_Size  size,
TT_GlyphSlot  glyph,
FT_UInt  glyph_index,
FT_Int32  load_flags 
)

Definition at line 2687 of file ttgload.c.

2691  {
2692  FT_Error error;
2693  TT_LoaderRec loader;
2694 
2695 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
2696 #define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \
2697  FT_IS_VARIATION( glyph->face ) ) )
2698 #else
2699 #define IS_DEFAULT_INSTANCE 1
2700 #endif
2701 
2702 
2703  FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
2704 
2705 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
2706 
2707  /* try to load embedded bitmap (if any) */
2708  if ( size->strike_index != 0xFFFFFFFFUL &&
2709  ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
2711  {
2712  error = load_sbit_image( size, glyph, glyph_index, load_flags );
2713  if ( FT_ERR_EQ( error, Missing_Bitmap ) )
2714  {
2715  /* the bitmap strike is incomplete and misses the requested glyph; */
2716  /* if we have a bitmap-only font, return an empty glyph */
2717  if ( !FT_IS_SCALABLE( glyph->face ) )
2718  {
2719  TT_Face face = (TT_Face)glyph->face;
2720  FT_Short left_bearing = 0, top_bearing = 0;
2721  FT_UShort advance_width = 0, advance_height = 0;
2722 
2723 
2724  /* to return an empty glyph, however, we need metrics data */
2725  /* from the `hmtx' (or `vmtx') table; the assumption is that */
2726  /* empty glyphs are missing intentionally, representing */
2727  /* whitespace - not having at least horizontal metrics is */
2728  /* thus considered an error */
2729  if ( !face->horz_metrics_size )
2730  return error;
2731 
2732  /* we now construct an empty bitmap glyph */
2733  TT_Get_HMetrics( face, glyph_index,
2734  &left_bearing,
2735  &advance_width );
2736  TT_Get_VMetrics( face, glyph_index,
2737  0,
2738  &top_bearing,
2739  &advance_height );
2740 
2741  glyph->outline.n_points = 0;
2742  glyph->outline.n_contours = 0;
2743 
2744  glyph->metrics.width = 0;
2745  glyph->metrics.height = 0;
2746 
2747  glyph->metrics.horiBearingX = left_bearing;
2748  glyph->metrics.horiBearingY = 0;
2749  glyph->metrics.horiAdvance = advance_width;
2750 
2751  glyph->metrics.vertBearingX = 0;
2752  glyph->metrics.vertBearingY = top_bearing;
2753  glyph->metrics.vertAdvance = advance_height;
2754 
2755  glyph->format = FT_GLYPH_FORMAT_BITMAP;
2757 
2758  glyph->bitmap_left = 0;
2759  glyph->bitmap_top = 0;
2760 
2761  return FT_Err_Ok;
2762  }
2763  }
2764  else if ( error )
2765  {
2766  /* return error if font is not scalable */
2767  if ( !FT_IS_SCALABLE( glyph->face ) )
2768  return error;
2769  }
2770  else
2771  {
2772  if ( FT_IS_SCALABLE( glyph->face ) )
2773  {
2774  /* for the bbox we need the header only */
2775  (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
2776  (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
2777  tt_loader_done( &loader );
2778  glyph->linearHoriAdvance = loader.linear;
2779  glyph->linearVertAdvance = loader.vadvance;
2780 
2781  /* sanity checks: if `xxxAdvance' in the sbit metric */
2782  /* structure isn't set, use `linearXXXAdvance' */
2783  if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
2784  glyph->metrics.horiAdvance =
2785  FT_MulFix( glyph->linearHoriAdvance,
2786  size->metrics->x_scale );
2787  if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
2788  glyph->metrics.vertAdvance =
2789  FT_MulFix( glyph->linearVertAdvance,
2790  size->metrics->y_scale );
2791  }
2792 
2793  return FT_Err_Ok;
2794  }
2795  }
2796 
2797 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
2798 
2799  /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
2800  if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
2801  {
2802  error = FT_THROW( Invalid_Size_Handle );
2803  goto Exit;
2804  }
2805 
2806  if ( load_flags & FT_LOAD_SBITS_ONLY )
2807  {
2808  error = FT_THROW( Invalid_Argument );
2809  goto Exit;
2810  }
2811 
2812  error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
2813  if ( error )
2814  goto Exit;
2815 
2817  glyph->num_subglyphs = 0;
2818  glyph->outline.flags = 0;
2819 
2820  /* main loading loop */
2821  error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
2822  if ( !error )
2823  {
2824  if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
2825  {
2826  glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
2827  glyph->subglyphs = loader.gloader->base.subglyphs;
2828  }
2829  else
2830  {
2831  glyph->outline = loader.gloader->base.outline;
2833 
2834  /* Translate array so that (0,0) is the glyph's origin. Note */
2835  /* that this behaviour is independent on the value of bit 1 of */
2836  /* the `flags' field in the `head' table -- at least major */
2837  /* applications like Acroread indicate that. */
2838  if ( loader.pp1.x )
2839  FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
2840  }
2841 
2842 #ifdef TT_USE_BYTECODE_INTERPRETER
2843 
2844  if ( IS_HINTED( load_flags ) )
2845  {
2846  if ( loader.exec->GS.scan_control )
2847  {
2848  /* convert scan conversion mode to FT_OUTLINE_XXX flags */
2849  switch ( loader.exec->GS.scan_type )
2850  {
2851  case 0: /* simple drop-outs including stubs */
2853  break;
2854  case 1: /* simple drop-outs excluding stubs */
2855  /* nothing; it's the default rendering mode */
2856  break;
2857  case 4: /* smart drop-outs including stubs */
2860  break;
2861  case 5: /* smart drop-outs excluding stubs */
2863  break;
2864 
2865  default: /* no drop-out control */
2867  break;
2868  }
2869  }
2870  else
2872  }
2873 
2874 #endif /* TT_USE_BYTECODE_INTERPRETER */
2875 
2876  error = compute_glyph_metrics( &loader, glyph_index );
2877  }
2878 
2879  tt_loader_done( &loader );
2880 
2881  /* Set the `high precision' bit flag. */
2882  /* This is _critical_ to get correct output for monochrome */
2883  /* TrueType glyphs at all sizes using the bytecode interpreter. */
2884  /* */
2885  if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
2886  size->metrics->y_ppem < 24 )
2888 
2889  Exit:
2890 #ifdef FT_DEBUG_LEVEL_TRACE
2891  if ( error )
2892  FT_TRACE1(( " failed (error code 0x%x)\n",
2893  error ));
2894 #endif
2895 
2896  return error;
2897  }
#define FT_OUTLINE_SINGLE_PASS
Definition: ftimage.h:436
FT_Int vadvance
Definition: tttypes.h:1670
int FT_Error
Definition: fttypes.h:300
FT_Int scan_type
Definition: ttobjs.h:92
#define TRUE
Definition: types.h:120
#define FT_LOAD_SBITS_ONLY
Definition: freetype.h:3032
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
unsigned char pixel_mode
Definition: ftimage.h:268
#define error(str)
Definition: mkdosfs.c:1605
#define IS_DEFAULT_INSTANCE
FT_Pos x
Definition: ftimage.h:76
#define FT_OUTLINE_IGNORE_DROPOUTS
Definition: ftimage.h:431
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
FT_Fixed linearHoriAdvance
Definition: freetype.h:1917
FT_SubGlyph subglyphs
Definition: ftgloadr.h:56
FT_Int linear
Definition: tttypes.h:1652
FT_Fixed linearVertAdvance
Definition: freetype.h:1918
static void tt_loader_done(TT_Loader loader)
Definition: ttgload.c:2650
return FT_Err_Ok
Definition: ftbbox.c:511
FT_GlyphLoadRec base
Definition: ftgloadr.h:69
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3009
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
FT_Outline outline
Definition: ftgloadr.h:52
#define FT_THROW(e)
Definition: ftdebug.h:213
TT_Get_VMetrics(TT_Face face, FT_UInt idx, FT_Pos yMax, FT_Short *tsb, FT_UShort *ah)
Definition: ttgload.c:93
TT_ExecContext exec
Definition: tttypes.h:1661
FT_Int bitmap_left
Definition: freetype.h:1924
FT_Bool scan_control
Definition: ttobjs.h:91
FT_UInt num_subglyphs
Definition: ftgloadr.h:55
FT_Int bitmap_top
Definition: freetype.h:1925
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:973
TT_Get_HMetrics(TT_Face face, FT_UInt idx, FT_Short *lsb, FT_UShort *aw)
Definition: ttgload.c:75
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:435
GLsizeiptr size
Definition: glext.h:5919
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void Exit(void)
Definition: sock.c:1331
#define FT_ERR_EQ(x, e)
Definition: fttypes.h:591
FT_UInt num_subglyphs
Definition: freetype.h:1929
int flags
Definition: ftimage.h:343
signed short FT_Short
Definition: fttypes.h:198
FT_Outline outline
Definition: freetype.h:1927
static FT_Error compute_glyph_metrics(TT_Loader loader, FT_UInt glyph_index)
Definition: ttgload.c:2105
FT_Bitmap bitmap
Definition: freetype.h:1923
#define FT_OUTLINE_INCLUDE_STUBS
Definition: ftimage.h:433
TT_GraphicsState GS
Definition: ttinterp.h:177
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
FT_Glyph_Format format
Definition: freetype.h:1921
short n_points
Definition: ftimage.h:337
static FT_Error load_truetype_glyph(TT_Loader loader, FT_UInt glyph_index, FT_UInt recurse_count, FT_Bool header_only)
Definition: ttgload.c:1510
#define FT_OUTLINE_SMART_DROPOUTS
Definition: ftimage.h:432
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
unsigned short FT_UShort
Definition: fttypes.h:209
static FT_Error tt_loader_init(TT_Loader loader, TT_Size size, TT_GlyphSlot glyph, FT_Int32 load_flags, FT_Bool glyf_table_only)
Definition: ttgload.c:2352
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
FT_SubGlyph subglyphs
Definition: freetype.h:1930
short n_contours
Definition: ftimage.h:336
FT_Vector pp1
Definition: tttypes.h:1654
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define IS_HINTED(flags)
Definition: ttobjs.h:417
FT_GlyphLoader gloader
Definition: tttypes.h:1640

Referenced by tt_glyph_load().