HPGS - HPGl Script
hpgsfont.h
1 /***********************************************************************
2  * *
3  * $Id: hpgsfont.h 489 2009-02-11 14:10:30Z softadm $
4  * *
5  * hpgs - HPGl Script, a hpgl/2 interpreter, which uses a Postscript *
6  * API for rendering a scene and thus renders to a variety of *
7  * devices and fileformats. *
8  * *
9  * (C) 2004-2009 ev-i Informationstechnologie GmbH http://www.ev-i.at *
10  * *
11  * Author: Wolfgang Glas *
12  * *
13  * hpgs is free software; you can redistribute it and/or *
14  * modify it under the terms of the GNU Lesser General Public *
15  * License as published by the Free Software Foundation; either *
16  * version 2.1 of the License, or (at your option) any later version. *
17  * *
18  * hpgs is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
21  * Lesser General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU Lesser General Public *
24  * License along with this library; if not, write to the *
25  * Free Software Foundation, Inc., 59 Temple Place, Suite 330, *
26  * Boston, MA 02111-1307 USA *
27  * *
28  ***********************************************************************
29  * *
30  * Private header file for ttf font support. *
31  * *
32  ***********************************************************************/
33 
34 #ifndef __HPGS_FONT_H__
35 #define __HPGS_FONT_H__
36 
37 #include<hpgsmutex.h>
38 #include<stdint.h>
39 
40 HPGS_INTERNAL_API void hpgs_font_init();
41 HPGS_INTERNAL_API void hpgs_font_cleanup();
42 
43 // The max. number of ttf tables to store.
44 #define HPGS_FONT_MAX_TTF_TABLES 32
45 
60 
61 
63 {
64  uint32_t tag; /* Table name */
65  uint32_t checksum; /* for table */
66  uint32_t offset; /* to start of table in input file */
67  uint32_t length; /* length of table */
68 };
69 
71  uint32_t version;
72  uint32_t fontRevision;
73  uint32_t checkSumAdjustment;
74  uint32_t magicNumber;
75  uint16_t flags;
76  uint16_t unitsPerEm;
77  //int64_t created;
78  //int64_t modified;
79  int32_t created_low;
80  int32_t created_high;
81  int32_t modified_low;
82  int32_t modified_high;
83  int16_t xMin;
84  int16_t yMin;
85  int16_t xMax;
86  int16_t yMax;
87  uint16_t macStyle;
88  int16_t lowestRecPPEM;
89  int16_t fontDirectionHint;
90  int16_t indexToLocFormat;
91  int16_t glyphDataFormat;
92 };
93 
95  uint32_t version;
96  int16_t ascent;
97  int16_t descent;
98  int16_t lineGap;
99  uint16_t advanceWidthMax;
100  int16_t minLeftSideBearing;
101  int16_t minRightSideBearing;
102  int16_t xMaxExtent;
103  int16_t caretSlopeRise;
104  int16_t caretSlopeRun;
105  int16_t caretOffset;
106  int16_t reserved1;
107  int16_t reserved2;
108  int16_t reserved3;
109  int16_t reserved4;
110  int16_t metricDataFormat;
111  uint16_t numOfLongHorMetrics;
112 };
113 
115  uint32_t version;
116  uint16_t numGlyphs;
117  uint16_t maxPoints;
118  uint16_t maxContours;
119  uint16_t maxComponentPoints;
120  uint16_t maxComponentContours;
121  uint16_t maxZones;
122  uint16_t maxTwilightPoints;
123  uint16_t maxStorage;
124  uint16_t maxFunctionDefs;
125  uint16_t maxInstructionDefs;
126  uint16_t maxStackElements;
127  uint16_t maxSizeOfInstructions;
128  uint16_t maxComponentElements;
129  uint16_t maxComponentDepth;
130 };
131 
133 {
134  uint16_t advanceWidth;
135  int16_t leftSideBearing;
136 };
137 
139 {
140  uint16_t startCode;
141  uint16_t endCode;
142  uint16_t idDelta;
143  uint16_t idRangeOffset;
144 };
145 
147 {
148  size_t ranges_sz;
150 
151  size_t glyphIndexArray_sz;
152  uint16_t *glyphIndexArray;
153 };
154 
156 {
157  int32_t version; // 0x00020000 for version 2.0
158  int32_t italicAngle; // Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).
159  int16_t underlinePosition; // This is the suggested distance of the top of the underline from the baseline (negative values indicate below baseline).
160  int16_t underlineThickness; // Suggested values for the underline thickness.
161  uint32_t isFixedPitch; // Set to 0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced (i.e. monospaced).
162  uint32_t minMemType42; // Minimum memory usage when an OpenType font is downloaded.
163  uint32_t maxMemType42; // Maximum memory usage when an OpenType font is downloaded.
164  uint32_t minMemType1; // Minimum memory usage when an OpenType font is downloaded as a Type 1 font.
165  uint32_t maxMemType1; // Maximum memory usage when an OpenType font is downloaded as a Type 1 font.
166  uint16_t numberOfGlyphs; // Number of glyphs (this should be the same as numGlyphs in 'maxp' table).
167 
168  const char **names; // pointer to the glyph names.
169  const char *name_data; // the buffer holding the actual data.
170 };
171 
172 #define HPGS_FONT_GLYPH_POINT_START 1
173 #define HPGS_FONT_GLYPH_POINT_ONCURVE 2
174 #define HPGS_FONT_GLYPH_POINT_CONTROL 3
175 
177 {
178  hpgs_point p;
179  int flags; // HPGS_FONT_GLYPH_POINT_*
180 };
181 
183 {
184  hpgs_matrix matrix; // transformation matrix
185  uint16_t gid; // the references glyph id.
186 };
187 
189 {
190  hpgs_bbox bbox;
191 
192  size_t points_sz;
193  hpgs_font_glyph_point *points;
194 
195  size_t refs_sz;
196  size_t refs_alloc_sz;
197  hpgs_font_glyph_ref *refs;
198 
201 };
202 
207 {
208  uint16_t left_gid;
209  uint16_t right_gid;
211  double value;
212 };
213 
214 
222 {
223  int32_t version;
224  uint16_t numtab;
225  uint16_t searchRange;
226  uint16_t entrySel;
227  uint16_t rangeShift;
229  hpgs_font_table_entry tables[HPGS_FONT_MAX_TTF_TABLES];
241 };
242 
250 {
253  // the file header.
254  hpgs_font_header header;
255 
263  uint32_t *loca_data;
264  size_t loca_data_sz;
269  hpgs_font_kern_pair *kern_data;
270  size_t kern_data_sz;
280  hpgs_mutex_t mutex;
281  size_t nref;
282 };
283 
289 
290  char *font_name;
291  char *filename;
294 };
295 
296 #endif
A bounding box.
Definition: hpgs.h:297
Definition: hpgsfont.h:139
Definition: hpgsfont.h:147
A truetype font directory entry.
Definition: hpgsfont.h:288
hpgs_font * font
Definition: hpgsfont.h:293
char * font_name
Definition: hpgsfont.h:290
char * filename
Definition: hpgsfont.h:291
Definition: hpgsfont.h:189
size_t begin_kern_pair
Definition: hpgsfont.h:199
size_t end_kern_pair
Definition: hpgsfont.h:200
Definition: hpgsfont.h:177
Definition: hpgsfont.h:183
Definition: hpgsfont.h:70
A truetype font header.
Definition: hpgsfont.h:222
int loca_table
Definition: hpgsfont.h:236
int name_table
Definition: hpgsfont.h:231
int maxp_table
Definition: hpgsfont.h:234
uint16_t entrySel
Definition: hpgsfont.h:226
int hmtx_table
Definition: hpgsfont.h:235
uint16_t searchRange
Definition: hpgsfont.h:225
uint16_t numtab
Definition: hpgsfont.h:224
int hhea_table
Definition: hpgsfont.h:233
int glyf_table
Definition: hpgsfont.h:239
int head_table
Definition: hpgsfont.h:232
uint16_t rangeShift
Definition: hpgsfont.h:227
int post_table
Definition: hpgsfont.h:238
int kern_table
Definition: hpgsfont.h:240
int32_t version
Definition: hpgsfont.h:223
int cmap_table
Definition: hpgsfont.h:237
hpgs_font_table_entry tables[HPGS_FONT_MAX_TTF_TABLES]
Definition: hpgsfont.h:229
Definition: hpgsfont.h:94
A ttf kerning pair.
Definition: hpgsfont.h:207
double value
Definition: hpgsfont.h:211
uint16_t right_gid
Definition: hpgsfont.h:209
uint16_t left_gid
Definition: hpgsfont.h:208
Definition: hpgsfont.h:133
Definition: hpgsfont.h:114
Definition: hpgsfont.h:156
A truetype font.
Definition: hpgsfont.h:250
int * glyph_cache_positions
Definition: hpgsfont.h:272
size_t n_cached_glyphs
Definition: hpgsfont.h:277
size_t nref
Definition: hpgsfont.h:281
hpgs_istream * is
Definition: hpgsfont.h:251
hpgs_font_maxp_data maxp_data
Definition: hpgsfont.h:258
hpgs_font_longHorMetrics * hmtx_data
Definition: hpgsfont.h:260
hpgs_font_glyph_data * glyph_cache
Definition: hpgsfont.h:278
size_t loca_data_sz
Definition: hpgsfont.h:264
hpgs_font_cmap_data cmap_data
Definition: hpgsfont.h:266
hpgs_mutex_t mutex
Definition: hpgsfont.h:280
uint32_t * loca_data
Definition: hpgsfont.h:263
hpgs_font_hhea_data hhea_data
Definition: hpgsfont.h:257
hpgs_font_head_data head_data
Definition: hpgsfont.h:256
hpgs_font_post_data post_data
Definition: hpgsfont.h:267
size_t kern_data_sz
Definition: hpgsfont.h:270
Definition: hpgsfont.h:63
A virtual input stream for the HPGL reader.
Definition: hpgs.h:427
A transformation matrix for 2D points.
Definition: hpgs.h:341
A 2D point.
Definition: hpgs.h:227