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