ReactOS 0.4.16-dev-1067-ge98bba2
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 90 of file ttgload.c.

94 {
95 ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
96
97 FT_TRACE5(( " advance width (font units): %d\n", *aw ));
98 FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
99 }
unsigned int idx
Definition: utils.c:41
#define FT_TRACE5(varformat)
Definition: ftdebug.h:190
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 108 of file ttgload.c.

113 {
114 if ( face->vertical_info )
115 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
116
117 else if ( face->os2.version != 0xFFFFU )
118 {
119 *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
120 *ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
121 face->os2.sTypoDescender );
122 }
123
124 else
125 {
126 *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
127 *ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
128 face->horizontal.Descender );
129 }
130
131 FT_TRACE5(( " advance height (font units): %d\n", *ah ));
132 FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
133 }
#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 761 of file ttgload.c.

762 {
763 face->access_glyph_frame = TT_Access_Glyph_Frame;
764 face->read_glyph_header = TT_Load_Glyph_Header;
765 face->read_simple_glyph = TT_Load_Simple_Glyph;
766 face->read_composite_glyph = TT_Load_Composite_Glyph;
767 face->forget_glyph_frame = TT_Forget_Glyph_Frame;
768 }
TT_Access_Glyph_Frame(TT_Loader loader, FT_UInt glyph_index, FT_ULong offset, FT_UInt byte_count)
Definition: ttgload.c:277
TT_Load_Simple_Glyph(TT_Loader load)
Definition: ttgload.c:338
TT_Load_Glyph_Header(TT_Loader loader)
Definition: ttgload.c:310
TT_Forget_Glyph_Frame(TT_Loader loader)
Definition: ttgload.c:300
TT_Load_Composite_Glyph(TT_Loader loader)
Definition: ttgload.c:572

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

2717 {
2719 TT_LoaderRec loader;
2720
2721#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
2722#define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \
2723 FT_IS_VARIATION( glyph->face ) ) )
2724#else
2725#define IS_DEFAULT_INSTANCE 1
2726#endif
2727
2728
2729 FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
2730
2731#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
2732
2733 /* try to load embedded bitmap (if any) */
2734 if ( size->strike_index != 0xFFFFFFFFUL &&
2735 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
2737 {
2738 FT_Fixed x_scale = size->root.metrics.x_scale;
2739 FT_Fixed y_scale = size->root.metrics.y_scale;
2740
2741
2742 error = load_sbit_image( size, glyph, glyph_index, load_flags );
2743 if ( FT_ERR_EQ( error, Missing_Bitmap ) )
2744 {
2745 /* the bitmap strike is incomplete and misses the requested glyph; */
2746 /* if we have a bitmap-only font, return an empty glyph */
2747 if ( !FT_IS_SCALABLE( glyph->face ) )
2748 {
2749 TT_Face face = (TT_Face)glyph->face;
2750
2751 FT_Short left_bearing = 0;
2752 FT_Short top_bearing = 0;
2753
2754 FT_UShort advance_width = 0;
2755 FT_UShort advance_height = 0;
2756
2757
2758 /* to return an empty glyph, however, we need metrics data */
2759 /* from the `hmtx' (or `vmtx') table; the assumption is that */
2760 /* empty glyphs are missing intentionally, representing */
2761 /* whitespace - not having at least horizontal metrics is */
2762 /* thus considered an error */
2763 if ( !face->horz_metrics_size )
2764 return error;
2765
2766 /* we now construct an empty bitmap glyph */
2767 TT_Get_HMetrics( face, glyph_index,
2768 &left_bearing,
2769 &advance_width );
2770 TT_Get_VMetrics( face, glyph_index,
2771 0,
2772 &top_bearing,
2773 &advance_height );
2774
2775 glyph->outline.n_points = 0;
2776 glyph->outline.n_contours = 0;
2777
2778 glyph->metrics.width = 0;
2779 glyph->metrics.height = 0;
2780
2781 glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
2782 glyph->metrics.horiBearingY = 0;
2783 glyph->metrics.horiAdvance = FT_MulFix( advance_width, x_scale );
2784
2785 glyph->metrics.vertBearingX = 0;
2786 glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
2787 glyph->metrics.vertAdvance = FT_MulFix( advance_height, y_scale );
2788
2789 glyph->format = FT_GLYPH_FORMAT_BITMAP;
2791
2792 glyph->bitmap_left = 0;
2793 glyph->bitmap_top = 0;
2794
2795 return FT_Err_Ok;
2796 }
2797 }
2798 else if ( error )
2799 {
2800 /* return error if font is not scalable */
2801 if ( !FT_IS_SCALABLE( glyph->face ) )
2802 return error;
2803 }
2804 else
2805 {
2806 if ( FT_IS_SCALABLE( glyph->face ) )
2807 {
2808 /* for the bbox we need the header only */
2809 (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
2810 (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
2811 tt_loader_done( &loader );
2812 glyph->linearHoriAdvance = loader.linear;
2813 glyph->linearVertAdvance = loader.vadvance;
2814
2815 /* sanity checks: if `xxxAdvance' in the sbit metric */
2816 /* structure isn't set, use `linearXXXAdvance' */
2817 if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
2818 glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance,
2819 x_scale );
2820 if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
2821 glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance,
2822 y_scale );
2823 }
2824
2825 return FT_Err_Ok;
2826 }
2827 }
2828
2829#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
2830
2831 /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
2832 if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
2833 {
2834 error = FT_THROW( Invalid_Size_Handle );
2835 goto Exit;
2836 }
2837
2838 if ( load_flags & FT_LOAD_SBITS_ONLY )
2839 {
2840 error = FT_THROW( Invalid_Argument );
2841 goto Exit;
2842 }
2843
2844 error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
2845 if ( error )
2846 goto Exit;
2847
2849 glyph->num_subglyphs = 0;
2850 glyph->outline.flags = 0;
2851
2852 /* main loading loop */
2853 error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
2854 if ( !error )
2855 {
2856 if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
2857 {
2858 glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
2859 glyph->subglyphs = loader.gloader->base.subglyphs;
2860 }
2861 else
2862 {
2863 glyph->outline = loader.gloader->base.outline;
2864 glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
2865
2866 /* Translate array so that (0,0) is the glyph's origin. Note */
2867 /* that this behaviour is independent on the value of bit 1 of */
2868 /* the `flags' field in the `head' table -- at least major */
2869 /* applications like Acroread indicate that. */
2870 if ( loader.pp1.x )
2871 FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
2872 }
2873
2874#ifdef TT_USE_BYTECODE_INTERPRETER
2875
2876 if ( IS_HINTED( load_flags ) )
2877 {
2878 if ( loader.exec->GS.scan_control )
2879 {
2880 /* convert scan conversion mode to FT_OUTLINE_XXX flags */
2881 switch ( loader.exec->GS.scan_type )
2882 {
2883 case 0: /* simple drop-outs including stubs */
2885 break;
2886 case 1: /* simple drop-outs excluding stubs */
2887 /* nothing; it's the default rendering mode */
2888 break;
2889 case 4: /* smart drop-outs including stubs */
2892 break;
2893 case 5: /* smart drop-outs excluding stubs */
2895 break;
2896
2897 default: /* no drop-out control */
2899 break;
2900 }
2901 }
2902 else
2904 }
2905
2906#endif /* TT_USE_BYTECODE_INTERPRETER */
2907
2908 error = compute_glyph_metrics( &loader, glyph_index );
2909 }
2910
2911 tt_loader_done( &loader );
2912
2913 /* Set the `high precision' bit flag. */
2914 /* This is _critical_ to get correct output for monochrome */
2915 /* TrueType glyphs at all sizes using the bytecode interpreter. */
2916 /* */
2917 if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
2918 size->metrics->y_ppem < 24 )
2920
2921 Exit:
2922#ifdef FT_DEBUG_LEVEL_TRACE
2923 if ( error )
2924 FT_TRACE1(( " failed (error code 0x%x)\n",
2925 error ));
2926#endif
2927
2928 return error;
2929 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FT_LOAD_SBITS_ONLY
Definition: freetype.h:3050
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3030
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3027
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1284
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_TRACE1(varformat)
Definition: ftdebug.h:186
#define FT_OUTLINE_SMART_DROPOUTS
Definition: ftimage.h:433
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:184
#define FT_OUTLINE_IGNORE_DROPOUTS
Definition: ftimage.h:432
#define FT_OUTLINE_INCLUDE_STUBS
Definition: ftimage.h:434
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:436
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:509
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
Definition: ftsmooth.c:465
#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:268
FT_SubGlyph subglyphs
Definition: ftgloadr.h:56
FT_UInt num_subglyphs
Definition: ftgloadr.h:55
FT_Outline outline
Definition: ftgloadr.h:52
FT_GlyphLoadRec base
Definition: ftgloadr.h:69
FT_Int bitmap_top
Definition: freetype.h:1894
FT_SubGlyph subglyphs
Definition: freetype.h:1899
FT_UInt num_subglyphs
Definition: freetype.h:1898
FT_Int bitmap_left
Definition: freetype.h:1893
FT_Bitmap bitmap
Definition: freetype.h:1892
FT_Outline outline
Definition: freetype.h:1896
FT_Fixed linearHoriAdvance
Definition: freetype.h:1886
FT_Fixed linearVertAdvance
Definition: freetype.h:1887
FT_Glyph_Metrics metrics
Definition: freetype.h:1885
FT_Glyph_Format format
Definition: freetype.h:1890
short n_contours
Definition: ftimage.h:339
int flags
Definition: ftimage.h:346
short n_points
Definition: ftimage.h:340
FT_Pos x
Definition: ftimage.h:78
TT_GraphicsState GS
Definition: ttinterp.h:177
FT_Bool scan_control
Definition: ttobjs.h:91
FT_Int scan_type
Definition: ttobjs.h:92
TT_ExecContext exec
Definition: tttypes.h:1826
FT_GlyphLoader gloader
Definition: tttypes.h:1805
FT_Vector pp1
Definition: tttypes.h:1819
FT_Int linear
Definition: tttypes.h:1817
FT_Int vadvance
Definition: tttypes.h:1835
static void tt_loader_done(TT_Loader loader)
Definition: ttgload.c:2672
static FT_Error load_truetype_glyph(TT_Loader loader, FT_UInt glyph_index, FT_UInt recurse_count, FT_Bool header_only)
Definition: ttgload.c:1523
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:2374
#define IS_DEFAULT_INSTANCE
TT_Get_HMetrics(TT_Face face, FT_UInt idx, FT_Short *lsb, FT_UShort *aw)
Definition: ttgload.c:90
static FT_Error compute_glyph_metrics(TT_Loader loader, FT_UInt glyph_index)
Definition: ttgload.c:2127
TT_Get_VMetrics(TT_Face face, FT_UInt idx, FT_Pos yMax, FT_Short *tsb, FT_UShort *ah)
Definition: ttgload.c:108
#define IS_HINTED(flags)
Definition: ttobjs.h:417
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:1064

Referenced by tt_glyph_load().