2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / cairo / src / cairo-truetype-subset-private.h
blob397a9f38920795715d3fbae756adae61a6692eb7
1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2006 Red Hat, Inc
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
32 * Contributor(s):
33 * Kristian Høgsberg <krh@redhat.com>
34 * Adrian Johnson <ajohnson@redneon.com>
37 #ifndef CAIRO_TRUETYPE_SUBSET_PRIVATE_H
38 #define CAIRO_TRUETYPE_SUBSET_PRIVATE_H
40 #include "cairoint.h"
42 #if CAIRO_HAS_FONT_SUBSET
44 /* The structs defined here should strictly follow the TrueType
45 * specification and not be padded. We use only 16-bit integer
46 * in their definition to guarantee that. The fields of type
47 * "FIXED" in the TT spec are broken into two *_1 and *_2 16-bit
48 * parts, and 64-bit members are broken into four.
50 * The test truetype-tables in the test suite makes sure that
51 * these tables have the right size. Please update that test
52 * if you add new tables/structs that should be packed.
55 #define MAKE_TT_TAG(a, b, c, d) (a<<24 | b<<16 | c<<8 | d)
56 #define TT_TAG_CFF MAKE_TT_TAG('C','F','F',' ')
57 #define TT_TAG_cmap MAKE_TT_TAG('c','m','a','p')
58 #define TT_TAG_cvt MAKE_TT_TAG('c','v','t',' ')
59 #define TT_TAG_fpgm MAKE_TT_TAG('f','p','g','m')
60 #define TT_TAG_glyf MAKE_TT_TAG('g','l','y','f')
61 #define TT_TAG_head MAKE_TT_TAG('h','e','a','d')
62 #define TT_TAG_hhea MAKE_TT_TAG('h','h','e','a')
63 #define TT_TAG_hmtx MAKE_TT_TAG('h','m','t','x')
64 #define TT_TAG_loca MAKE_TT_TAG('l','o','c','a')
65 #define TT_TAG_maxp MAKE_TT_TAG('m','a','x','p')
66 #define TT_TAG_name MAKE_TT_TAG('n','a','m','e')
67 #define TT_TAG_post MAKE_TT_TAG('p','o','s','t')
68 #define TT_TAG_prep MAKE_TT_TAG('p','r','e','p')
70 /* All tt_* structs are big-endian */
71 typedef struct _tt_cmap_index {
72 uint16_t platform;
73 uint16_t encoding;
74 uint32_t offset;
75 } tt_cmap_index_t;
77 typedef struct _tt_cmap {
78 uint16_t version;
79 uint16_t num_tables;
80 tt_cmap_index_t index[1];
81 } tt_cmap_t;
83 typedef struct _segment_map {
84 uint16_t format;
85 uint16_t length;
86 uint16_t version;
87 uint16_t segCountX2;
88 uint16_t searchRange;
89 uint16_t entrySelector;
90 uint16_t rangeShift;
91 uint16_t endCount[1];
92 } tt_segment_map_t;
94 typedef struct _tt_head {
95 int16_t version_1;
96 int16_t version_2;
97 int16_t revision_1;
98 int16_t revision_2;
99 uint16_t checksum_1;
100 uint16_t checksum_2;
101 uint16_t magic_1;
102 uint16_t magic_2;
103 uint16_t flags;
104 uint16_t units_per_em;
105 int16_t created_1;
106 int16_t created_2;
107 int16_t created_3;
108 int16_t created_4;
109 int16_t modified_1;
110 int16_t modified_2;
111 int16_t modified_3;
112 int16_t modified_4;
113 int16_t x_min; /* FWORD */
114 int16_t y_min; /* FWORD */
115 int16_t x_max; /* FWORD */
116 int16_t y_max; /* FWORD */
117 uint16_t mac_style;
118 uint16_t lowest_rec_pppem;
119 int16_t font_direction_hint;
120 int16_t index_to_loc_format;
121 int16_t glyph_data_format;
122 } tt_head_t;
124 typedef struct _tt_hhea {
125 int16_t version_1;
126 int16_t version_2;
127 int16_t ascender; /* FWORD */
128 int16_t descender; /* FWORD */
129 int16_t line_gap; /* FWORD */
130 uint16_t advance_max_width; /* UFWORD */
131 int16_t min_left_side_bearing; /* FWORD */
132 int16_t min_right_side_bearing; /* FWORD */
133 int16_t x_max_extent; /* FWORD */
134 int16_t caret_slope_rise;
135 int16_t caret_slope_run;
136 int16_t reserved[5];
137 int16_t metric_data_format;
138 uint16_t num_hmetrics;
139 } tt_hhea_t;
141 typedef struct _tt_maxp {
142 int16_t version_1;
143 int16_t version_2;
144 uint16_t num_glyphs;
145 uint16_t max_points;
146 uint16_t max_contours;
147 uint16_t max_composite_points;
148 uint16_t max_composite_contours;
149 uint16_t max_zones;
150 uint16_t max_twilight_points;
151 uint16_t max_storage;
152 uint16_t max_function_defs;
153 uint16_t max_instruction_defs;
154 uint16_t max_stack_elements;
155 uint16_t max_size_of_instructions;
156 uint16_t max_component_elements;
157 uint16_t max_component_depth;
158 } tt_maxp_t;
160 typedef struct _tt_name_record {
161 uint16_t platform;
162 uint16_t encoding;
163 uint16_t language;
164 uint16_t name;
165 uint16_t length;
166 uint16_t offset;
167 } tt_name_record_t;
169 typedef struct _tt_name {
170 uint16_t format;
171 uint16_t num_records;
172 uint16_t strings_offset;
173 tt_name_record_t records[1];
174 } tt_name_t;
178 /* composite_glyph_t flags */
179 #define TT_ARG_1_AND_2_ARE_WORDS 0x0001
180 #define TT_WE_HAVE_A_SCALE 0x0008
181 #define TT_MORE_COMPONENTS 0x0020
182 #define TT_WE_HAVE_AN_X_AND_Y_SCALE 0x0040
183 #define TT_WE_HAVE_A_TWO_BY_TWO 0x0080
185 typedef struct _tt_composite_glyph {
186 uint16_t flags;
187 uint16_t index;
188 uint16_t args[7]; /* 1 to 7 arguments depending on value of flags */
189 } tt_composite_glyph_t;
191 typedef struct _tt_glyph_data {
192 int16_t num_contours;
193 int8_t data[8];
194 tt_composite_glyph_t glyph;
195 } tt_glyph_data_t;
197 #endif /* CAIRO_HAS_FONT_SUBSET */
199 #endif /* CAIRO_TRUETYPE_SUBSET_PRIVATE_H */