1 /* tagloadr.h */
2 
3 /*
4  * Copyright (C) 2011-2021 by Werner Lemberg.
5  *
6  * This file is part of the ttfautohint library, and may only be used,
7  * modified, and distributed under the terms given in `COPYING'.  By
8  * continuing to use, modify, or distribute this file you indicate that you
9  * have read `COPYING' and understand and accept it fully.
10  *
11  * The file `COPYING' mentioned in the previous paragraph is distributed
12  * with the ttfautohint library.
13  */
14 
15 
16 /* originally file `ftgloadr.h' (2011-Mar-28) from FreeType */
17 
18 /* heavily modified 2011 by Werner Lemberg <wl@gnu.org> */
19 
20 #ifndef TAGLOADR_H_
21 #define TAGLOADR_H_
22 
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 typedef struct TA_SubGlyphRec_
32 {
33   FT_Int index;
34   FT_UShort flags;
35 
36   FT_Int arg1;
37   FT_Int arg2;
38 
39   FT_Matrix transform;
40 } TA_SubGlyphRec, *TA_SubGlyph;
41 
42 
43 typedef struct TA_GlyphLoadRec_
44 {
45   FT_Outline outline; /* outline */
46 
47   FT_Vector* extra_points; /* extra points table */
48   FT_Vector* extra_points2; /* second extra points table */
49 
50   FT_UInt num_subglyphs; /* number of subglyphs */
51   TA_SubGlyph subglyphs; /* subglyphs */
52 } TA_GlyphLoadRec, *TA_GlyphLoad;
53 
54 
55 typedef struct TA_GlyphLoaderRec_
56 {
57   FT_UInt max_points;
58   FT_UInt max_contours;
59   FT_UInt max_subglyphs;
60   FT_Bool use_extra;
61 
62   TA_GlyphLoadRec base;
63   TA_GlyphLoadRec current;
64 } TA_GlyphLoaderRec, *TA_GlyphLoader;
65 
66 
67 /* create new empty glyph loader */
68 FT_Error
69 TA_GlyphLoader_New(TA_GlyphLoader *aloader);
70 
71 /* add an extra points table to a glyph loader */
72 FT_Error
73 TA_GlyphLoader_CreateExtra(TA_GlyphLoader loader);
74 
75 /* destroy a glyph loader */
76 void
77 TA_GlyphLoader_Done(TA_GlyphLoader loader);
78 
79 /* reset a glyph loader (frees everything int it) */
80 void
81 TA_GlyphLoader_Reset(TA_GlyphLoader loader);
82 
83 /* rewind a glyph loader */
84 void
85 TA_GlyphLoader_Rewind(TA_GlyphLoader loader);
86 
87 /* check that there is enough space to add */
88 /* `n_points' and `n_contours' to the glyph loader */
89 FT_Error
90 TA_GlyphLoader_CheckPoints(TA_GlyphLoader loader,
91                            FT_UInt n_points,
92                            FT_UInt n_contours);
93 
94 
95 #define TA_GLYPHLOADER_CHECK_P(_loader, _count) \
96    ((_count) == 0 \
97     || ((FT_UInt)(_loader)->base.outline.n_points \
98         + (FT_UInt)(_loader)->current.outline.n_points \
99         + (FT_UInt)(_count)) <= (_loader)->max_points)
100 
101 #define TA_GLYPHLOADER_CHECK_C(_loader, _count) \
102    ((_count) == 0 \
103     || ((FT_UInt)(_loader)->base.outline.n_contours \
104         + (FT_UInt)(_loader)->current.outline.n_contours \
105         + (FT_UInt)(_count)) <= (_loader)->max_contours)
106 
107 #define TA_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours) \
108    ((TA_GLYPHLOADER_CHECK_P(_loader, _points) \
109      && TA_GLYPHLOADER_CHECK_C(_loader, _contours)) \
110     ? 0 \
111     : TA_GlyphLoader_CheckPoints((_loader), \
112                                  (FT_UInt)(_points), \
113                                  (FT_UInt)(_contours)))
114 
115 
116 /* check that there is enough space to add */
117 /* `n_subs' sub-glyphs to a glyph loader */
118 FT_Error
119 TA_GlyphLoader_CheckSubGlyphs(TA_GlyphLoader loader,
120                               FT_UInt n_subs);
121 
122 /* prepare a glyph loader, i.e. empty the current glyph */
123 void
124 TA_GlyphLoader_Prepare(TA_GlyphLoader loader);
125 
126 /* add the current glyph to the base glyph */
127 void
128 TA_GlyphLoader_Add(TA_GlyphLoader loader);
129 
130 /* copy points from one glyph loader to another */
131 FT_Error
132 TA_GlyphLoader_CopyPoints(TA_GlyphLoader target,
133                           TA_GlyphLoader source);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* TAGLOADR_H_ */
140 
141 /* end of tagloadr.h */
142