ReactOS 0.4.16-dev-2358-g0df3463
ttgload.h File Reference
#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 99 of file ttgload.c.

103 {
104 ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
105
106 FT_TRACE5(( " advance width (font units): %d\n", *aw ));
107 FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
108 }
unsigned int idx
Definition: utils.c:41
#define FT_TRACE5(varformat)
Definition: ftdebug.h:192
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
SFNT_Interface * SFNT_Service
Definition: sfnt.h:784

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 117 of file ttgload.c.

122 {
123 if ( face->vertical_info )
124 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
125
126 else if ( face->os2.version != 0xFFFFU )
127 {
128 *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
129 *ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
130 face->os2.sTypoDescender );
131 }
132
133 else
134 {
135 *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
136 *ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
137 face->horizontal.Descender );
138 }
139
140#ifdef FT_DEBUG_LEVEL_TRACE
141 if ( !face->vertical_info )
142 FT_TRACE5(( " [vertical metrics missing, computing values]\n" ));
143#endif
144
145 FT_TRACE5(( " advance height (font units): %d\n", *ah ));
146 FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
147 }
#define FT_ABS(a)
Definition: ftobjs.h:73
unsigned short FT_UShort
Definition: fttypes.h:209
signed short FT_Short
Definition: fttypes.h:198

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 779 of file ttgload.c.

780 {
781 face->access_glyph_frame = TT_Access_Glyph_Frame;
782 face->read_glyph_header = TT_Load_Glyph_Header;
783 face->read_simple_glyph = TT_Load_Simple_Glyph;
784 face->read_composite_glyph = TT_Load_Composite_Glyph;
785 face->forget_glyph_frame = TT_Forget_Glyph_Frame;
786 }
TT_Access_Glyph_Frame(TT_Loader loader, FT_UInt glyph_index, FT_ULong offset, FT_UInt byte_count)
Definition: ttgload.c:291
TT_Load_Simple_Glyph(TT_Loader load)
Definition: ttgload.c:352
TT_Load_Glyph_Header(TT_Loader loader)
Definition: ttgload.c:324
TT_Forget_Glyph_Frame(TT_Loader loader)
Definition: ttgload.c:314
TT_Load_Composite_Glyph(TT_Loader loader)
Definition: ttgload.c:590

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 2807 of file ttgload.c.

2811 {
2813 TT_LoaderRec loader;
2814
2815
2816 FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
2817
2818#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
2819
2820 /* try to load embedded bitmap (if any) */
2821 if ( size->strike_index != 0xFFFFFFFFUL &&
2822 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
2823 IS_DEFAULT_INSTANCE( glyph->face ) )
2824 {
2825 FT_Fixed x_scale = size->root.metrics.x_scale;
2826 FT_Fixed y_scale = size->root.metrics.y_scale;
2827
2828
2829 error = load_sbit_image( size, glyph, glyph_index, load_flags );
2830 if ( FT_ERR_EQ( error, Missing_Bitmap ) )
2831 {
2832 /* the bitmap strike is incomplete and misses the requested glyph; */
2833 /* if we have a bitmap-only font, return an empty glyph */
2834 if ( !FT_IS_SCALABLE( glyph->face ) )
2835 {
2836 TT_Face face = (TT_Face)glyph->face;
2837
2838 FT_Short left_bearing = 0;
2839 FT_Short top_bearing = 0;
2840
2841 FT_UShort advance_width = 0;
2842 FT_UShort advance_height = 0;
2843
2844
2845 /* to return an empty glyph, however, we need metrics data */
2846 /* from the `hmtx' (or `vmtx') table; the assumption is that */
2847 /* empty glyphs are missing intentionally, representing */
2848 /* whitespace - not having at least horizontal metrics is */
2849 /* thus considered an error */
2850 if ( !face->horz_metrics_size )
2851 return error;
2852
2853 /* we now construct an empty bitmap glyph */
2854 TT_Get_HMetrics( face, glyph_index,
2855 &left_bearing,
2856 &advance_width );
2857 TT_Get_VMetrics( face, glyph_index,
2858 0,
2859 &top_bearing,
2860 &advance_height );
2861
2862 glyph->outline.n_points = 0;
2863 glyph->outline.n_contours = 0;
2864
2865 glyph->metrics.width = 0;
2866 glyph->metrics.height = 0;
2867
2868 glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
2869 glyph->metrics.horiBearingY = 0;
2870 glyph->metrics.horiAdvance = FT_MulFix( advance_width, x_scale );
2871
2872 glyph->metrics.vertBearingX = 0;
2873 glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
2874 glyph->metrics.vertAdvance = FT_MulFix( advance_height, y_scale );
2875
2876 glyph->format = FT_GLYPH_FORMAT_BITMAP;
2878
2879 glyph->bitmap_left = 0;
2880 glyph->bitmap_top = 0;
2881
2882 return FT_Err_Ok;
2883 }
2884 }
2885 else if ( error )
2886 {
2887 /* return error if font is not scalable */
2888 if ( !FT_IS_SCALABLE( glyph->face ) )
2889 return error;
2890 }
2891 else
2892 {
2893 if ( FT_IS_SCALABLE( glyph->face ) )
2894 {
2895 /* for the bbox we need the header only */
2896 (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
2897 (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
2898 tt_loader_done( &loader );
2899 glyph->linearHoriAdvance = loader.linear;
2900 glyph->linearVertAdvance = loader.vadvance;
2901
2902 /* sanity checks: if `xxxAdvance' in the sbit metric */
2903 /* structure isn't set, use `linearXXXAdvance' */
2904 if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
2905 glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance,
2906 x_scale );
2907 if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
2908 glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance,
2909 y_scale );
2910 }
2911
2912 return FT_Err_Ok;
2913 }
2914 }
2915
2916#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
2917
2918 /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
2919 if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
2920 {
2921 error = FT_THROW( Invalid_Size_Handle );
2922 goto Exit;
2923 }
2924
2925 if ( load_flags & FT_LOAD_SBITS_ONLY )
2926 {
2927 error = FT_THROW( Invalid_Argument );
2928 goto Exit;
2929 }
2930
2931 error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
2932 if ( error )
2933 goto Exit;
2934
2935 glyph->format = FT_GLYPH_FORMAT_OUTLINE;
2936 glyph->num_subglyphs = 0;
2937 glyph->outline.flags = 0;
2938
2939 /* main loading loop */
2940 error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
2941 if ( !error )
2942 {
2943 if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
2944 {
2945 glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
2946 glyph->subglyphs = loader.gloader->base.subglyphs;
2947 }
2948 else
2949 {
2950 glyph->outline = loader.gloader->base.outline;
2951 glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
2952
2953 /* Translate array so that (0,0) is the glyph's origin. Note */
2954 /* that this behaviour is independent on the value of bit 1 of */
2955 /* the `flags' field in the `head' table -- at least major */
2956 /* applications like Acroread indicate that. */
2957 if ( loader.pp1.x )
2958 FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
2959 }
2960
2961#ifdef TT_USE_BYTECODE_INTERPRETER
2962
2963 if ( IS_HINTED( load_flags ) )
2964 {
2965 if ( loader.exec->GS.scan_control )
2966 {
2967 /* convert scan conversion mode to FT_OUTLINE_XXX flags */
2968 switch ( loader.exec->GS.scan_type )
2969 {
2970 case 0: /* simple drop-outs including stubs */
2972 break;
2973 case 1: /* simple drop-outs excluding stubs */
2974 /* nothing; it's the default rendering mode */
2975 break;
2976 case 4: /* smart drop-outs including stubs */
2979 break;
2980 case 5: /* smart drop-outs excluding stubs */
2982 break;
2983
2984 default: /* no drop-out control */
2986 break;
2987 }
2988 }
2989 else
2991 }
2992
2993#endif /* TT_USE_BYTECODE_INTERPRETER */
2994
2995 error = compute_glyph_metrics( &loader, glyph_index );
2996 }
2997
2998 /* Set the `high precision' bit flag. */
2999 /* This is _critical_ to get correct output for monochrome */
3000 /* TrueType glyphs at all sizes using the bytecode interpreter. */
3001 /* */
3002 if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
3003 size->metrics->y_ppem < 24 )
3005
3006 FT_TRACE1(( " subglyphs = %u, contours = %hd, points = %hd,"
3007 " flags = 0x%.3x\n",
3008 loader.gloader->base.num_subglyphs,
3009 glyph->outline.n_contours,
3010 glyph->outline.n_points,
3011 glyph->outline.flags ));
3012
3013 tt_loader_done( &loader );
3014
3015 Exit:
3016#ifdef FT_DEBUG_LEVEL_TRACE
3017 if ( error )
3018 FT_TRACE1(( " failed (error code 0x%x)\n",
3019 error ));
3020#endif
3021
3022 return error;
3023 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FT_LOAD_SBITS_ONLY
Definition: freetype.h:3045
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3025
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3022
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1271
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:508
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE1(varformat)
Definition: ftdebug.h:188
#define FT_OUTLINE_SMART_DROPOUTS
Definition: ftimage.h:439
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:183
#define FT_OUTLINE_IGNORE_DROPOUTS
Definition: ftimage.h:438
#define FT_OUTLINE_INCLUDE_STUBS
Definition: ftimage.h:440
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:443
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:507
#define FT_ERR_EQ(x, e)
Definition: fttypes.h:604
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
GLsizeiptr size
Definition: glext.h:5919
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
unsigned char pixel_mode
Definition: ftimage.h:267
FT_SubGlyph subglyphs
Definition: ftgloadr.h:55
FT_UInt num_subglyphs
Definition: ftgloadr.h:54
FT_Outline outline
Definition: ftgloadr.h:51
FT_GlyphLoadRec base
Definition: ftgloadr.h:68
FT_Int bitmap_top
Definition: freetype.h:1888
FT_SubGlyph subglyphs
Definition: freetype.h:1893
FT_UInt num_subglyphs
Definition: freetype.h:1892
FT_Int bitmap_left
Definition: freetype.h:1887
FT_Bitmap bitmap
Definition: freetype.h:1886
FT_Outline outline
Definition: freetype.h:1890
FT_Fixed linearHoriAdvance
Definition: freetype.h:1880
FT_Fixed linearVertAdvance
Definition: freetype.h:1881
FT_Glyph_Metrics metrics
Definition: freetype.h:1879
FT_Glyph_Format format
Definition: freetype.h:1884
short n_contours
Definition: ftimage.h:338
int flags
Definition: ftimage.h:345
short n_points
Definition: ftimage.h:339
FT_Pos x
Definition: ftimage.h:77
TT_GraphicsState GS
Definition: ttinterp.h:176
FT_Bool scan_control
Definition: ttobjs.h:90
FT_Int scan_type
Definition: ttobjs.h:91
TT_ExecContext exec
Definition: tttypes.h:1752
FT_GlyphLoader gloader
Definition: tttypes.h:1731
FT_Vector pp1
Definition: tttypes.h:1745
FT_Int linear
Definition: tttypes.h:1743
FT_Int vadvance
Definition: tttypes.h:1761
static void tt_loader_done(TT_Loader loader)
Definition: ttgload.c:2766
static FT_Error load_truetype_glyph(TT_Loader loader, FT_UInt glyph_index, FT_UInt recurse_count, FT_Bool header_only)
Definition: ttgload.c:1601
#define IS_DEFAULT_INSTANCE(_face)
Definition: ttgload.c:90
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:2473
TT_Get_HMetrics(TT_Face face, FT_UInt idx, FT_Short *lsb, FT_UShort *aw)
Definition: ttgload.c:99
static FT_Error compute_glyph_metrics(TT_Loader loader, FT_UInt glyph_index)
Definition: ttgload.c:2225
TT_Get_VMetrics(TT_Face face, FT_UInt idx, FT_Pos yMax, FT_Short *tsb, FT_UShort *ah)
Definition: ttgload.c:117
#define IS_HINTED(flags)
Definition: ttobjs.h:416
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:988

Referenced by tt_glyph_load().