1 /**************************************************************************** 2 * 3 * ftgloadr.h 4 * 5 * The FreeType glyph loader (specification). 6 * 7 * Copyright 2002-2018 by 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 #ifndef FTGLOADR_H_ 20 #define FTGLOADR_H_ 21 22 23 #include <ft2build.h> 24 #include FT_FREETYPE_H 25 26 27 FT_BEGIN_HEADER 28 29 30 /************************************************************************** 31 * 32 * @struct: 33 * FT_GlyphLoader 34 * 35 * @description: 36 * The glyph loader is an internal object used to load several glyphs 37 * together (for example, in the case of composites). 38 */ 39 typedef struct FT_SubGlyphRec_ 40 { 41 FT_Int index; 42 FT_UShort flags; 43 FT_Int arg1; 44 FT_Int arg2; 45 FT_Matrix transform; 46 47 } FT_SubGlyphRec; 48 49 50 typedef struct FT_GlyphLoadRec_ 51 { 52 FT_Outline outline; /* outline */ 53 FT_Vector* extra_points; /* extra points table */ 54 FT_Vector* extra_points2; /* second extra points table */ 55 FT_UInt num_subglyphs; /* number of subglyphs */ 56 FT_SubGlyph subglyphs; /* subglyphs */ 57 58 } FT_GlyphLoadRec, *FT_GlyphLoad; 59 60 61 typedef struct FT_GlyphLoaderRec_ 62 { 63 FT_Memory memory; 64 FT_UInt max_points; 65 FT_UInt max_contours; 66 FT_UInt max_subglyphs; 67 FT_Bool use_extra; 68 69 FT_GlyphLoadRec base; 70 FT_GlyphLoadRec current; 71 72 void* other; /* for possible future extension? */ 73 74 } FT_GlyphLoaderRec, *FT_GlyphLoader; 75 76 77 /* create new empty glyph loader */ 78 FT_BASE( FT_Error ) 79 FT_GlyphLoader_New( FT_Memory memory, 80 FT_GlyphLoader *aloader ); 81 82 /* add an extra points table to a glyph loader */ 83 FT_BASE( FT_Error ) 84 FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader ); 85 86 /* destroy a glyph loader */ 87 FT_BASE( void ) 88 FT_GlyphLoader_Done( FT_GlyphLoader loader ); 89 90 /* reset a glyph loader (frees everything int it) */ 91 FT_BASE( void ) 92 FT_GlyphLoader_Reset( FT_GlyphLoader loader ); 93 94 /* rewind a glyph loader */ 95 FT_BASE( void ) 96 FT_GlyphLoader_Rewind( FT_GlyphLoader loader ); 97 98 /* check that there is enough space to add `n_points' and `n_contours' */ 99 /* to the glyph loader */ 100 FT_BASE( FT_Error ) 101 FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader, 102 FT_UInt n_points, 103 FT_UInt n_contours ); 104 105 106 #define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ 107 ( (_count) == 0 || \ 108 ( (FT_UInt)(_loader)->base.outline.n_points + \ 109 (FT_UInt)(_loader)->current.outline.n_points + \ 110 (FT_UInt)(_count) ) <= (_loader)->max_points ) 111 112 #define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ 113 ( (_count) == 0 || \ 114 ( (FT_UInt)(_loader)->base.outline.n_contours + \ 115 (FT_UInt)(_loader)->current.outline.n_contours + \ 116 (FT_UInt)(_count) ) <= (_loader)->max_contours ) 117 118 #define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \ 119 ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ 120 FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ 121 ? 0 \ 122 : FT_GlyphLoader_CheckPoints( (_loader), \ 123 (FT_UInt)(_points), \ 124 (FT_UInt)(_contours) ) ) 125 126 127 /* check that there is enough space to add `n_subs' sub-glyphs to */ 128 /* a glyph loader */ 129 FT_BASE( FT_Error ) 130 FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader, 131 FT_UInt n_subs ); 132 133 /* prepare a glyph loader, i.e. empty the current glyph */ 134 FT_BASE( void ) 135 FT_GlyphLoader_Prepare( FT_GlyphLoader loader ); 136 137 /* add the current glyph to the base glyph */ 138 FT_BASE( void ) 139 FT_GlyphLoader_Add( FT_GlyphLoader loader ); 140 141 /* copy points from one glyph loader to another */ 142 FT_BASE( FT_Error ) 143 FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, 144 FT_GlyphLoader source ); 145 146 /* */ 147 148 149 FT_END_HEADER 150 151 #endif /* FTGLOADR_H_ */ 152 153 154 /* END */ 155