various hacks to the TrueType driver that I cannot explain now, but they'll be very useful in the near future :-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 8ad78e4..7b209f4 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1053,6 +1053,8 @@
/* a function type used for the truetype bytecode interpreter hooks */
typedef FT_Error (*TT_Interpreter)( void* exec_context );
+ /* forward declaration */
+ typedef struct TT_Loader_ TT_Loader;
/*************************************************************************/
/* */
@@ -1084,6 +1086,70 @@
/*************************************************************************/
/* */
+ /* <FuncType> */
+ /* TT_Access_Glyph_Frame */
+ /* */
+ /* <Description> */
+ /* Seeks a stream to the start of a given glyph element, and */
+ /* opens a frame for it.. */
+ /* */
+ /* <Input> */
+ /* loader :: the current TrueType glyph loader object */
+ /* glyph index :: index of glyph to access */
+ /* offset :: offset of glyph according to locations table */
+ /* byte_count :: size of frame in bytes */
+ /* */
+ /* <Return> */
+ /* TrueType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function is normally equivalent to FILE_Seek(offset) */
+ /* followed by ACCESS_Frame(byte_count) with the loader's stream */
+ /* but alternative formats (compressed ones) might use something */
+ /* different.. */
+ /* */
+ typedef
+ FT_Error (*TT_Access_Glyph_Frame_Func)( TT_Loader* loader,
+ FT_UInt glyph_index,
+ FT_ULong offset,
+ FT_UInt byte_count );
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* TT_Load_Glyph_Element */
+ /* */
+ /* <Description> */
+ /* Reads one glyph element (its header, a simple glyph, or a */
+ /* composite) from the loader's current stream frame.. */
+ /* */
+ /* <Input> */
+ /* loader :: the current TrueType glyph loader object */
+ /* */
+ /* <Return> */
+ /* TrueType error code. 0 means success. */
+ /* */
+ typedef
+ FT_Error (*TT_Load_Glyph_Element_Func)( TT_Loader* loader );
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* TT_Forget_Frame_Element */
+ /* */
+ /* <Description> */
+ /* Closes the current loader stream frame for the glyph.. */
+ /* */
+ /* <Input> */
+ /* loader :: the current TrueType glyph loader object */
+ /* */
+ typedef
+ void (*TT_Forget_Glyph_Frame_Func)( TT_Loader* loader );
+
+
+
+ /*************************************************************************/
+ /* */
/* TrueType Face Type */
/* */
/* <Struct> */
@@ -1276,6 +1342,12 @@
/* might need something different, e.g. Type 42 fonts */
TT_Goto_Table_Func goto_table;
+ TT_Access_Glyph_Frame_Func access_glyph_frame;
+ TT_Load_Glyph_Element_Func read_glyph_header;
+ TT_Load_Glyph_Element_Func read_simple_glyph;
+ TT_Load_Glyph_Element_Func read_composite_glyph;
+ TT_Forget_Glyph_Frame_Func forget_glyph_frame;
+
/* a typeless pointer to the SFNT_Interface table used to load */
/* the basic TrueType tables in the face object */
void* sfnt;
@@ -1347,7 +1419,7 @@
/* */
/***********************************************************************/
- void* other;
+ FT_Generic extra;
} TT_FaceRec;
@@ -1397,7 +1469,7 @@
typedef struct TT_ExecContextRec_* TT_ExecContext;
/* glyph loader structure */
- typedef struct TT_Loader_
+ struct TT_Loader_
{
FT_Face face;
FT_Size size;
@@ -1427,8 +1499,11 @@
TT_ExecContext exec;
FT_Byte* instructions;
FT_ULong ins_pos;
+
+ /* for possible extensibility in other formats */
+ void* other;
- } TT_Loader;
+ };
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index 31b7c93..b877eae 100644
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -333,7 +333,7 @@
T2_Size size,
T2_GlyphSlot slot )
{
- CFF_Font* cff = (CFF_Font*)face->other;
+ CFF_Font* cff = (CFF_Font*)face->extra.data;
/* clear everything */
@@ -1608,7 +1608,7 @@
T2_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting;
- CFF_Font* cff = (CFF_Font*)face->other;
+ CFF_Font* cff = (CFF_Font*)face->extra.data;
if ( load_flags & FT_LOAD_NO_RECURSE )
diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c
index e59952d..14a880d 100644
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -122,7 +122,7 @@
if ( ALLOC( cff, sizeof ( *cff ) ) )
goto Exit;
- face->other = cff;
+ face->extra.data = cff;
error = T2_Load_CFF_Font( stream, face_index, cff );
if ( error )
goto Exit;
@@ -164,13 +164,13 @@
sfnt->done_face( face );
{
- CFF_Font* cff = (CFF_Font*)face->other;
+ CFF_Font* cff = (CFF_Font*)face->extra.data;
if ( cff )
{
T2_Done_CFF_Font( cff );
- FREE( face->other );
+ FREE( face->extra.data );
}
}
}
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 15d7183..f671a7a 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -250,12 +250,12 @@
static
- FT_Error TT_Load_Simple_Glyph( TT_Loader* load,
- FT_Int n_contours )
+ FT_Error TT_Load_Simple_Glyph( TT_Loader* load )
{
FT_Error error;
- FT_Stream stream = load->stream;
- FT_GlyphLoader* gloader = load->gloader;
+ FT_Stream stream = load->stream;
+ FT_GlyphLoader* gloader = load->gloader;
+ FT_Int n_contours = load->n_contours;
FT_Outline* outline;
TT_Face face = (TT_Face)load->face;
TT_GlyphSlot slot = (TT_GlyphSlot)load->glyph;
@@ -405,8 +405,7 @@
static
- FT_Error TT_Load_Composite_Glyph( TT_Loader* loader,
- FT_UInt byte_count )
+ FT_Error TT_Load_Composite_Glyph( TT_Loader* loader )
{
FT_Error error;
FT_Stream stream = loader->stream;
@@ -490,6 +489,16 @@
}
+ LOCAL_FUNC
+ void TT_Init_Glyph_Loading( TT_Face face )
+ {
+ face->access_glyph_frame = TT_Access_Glyph_Frame;
+ face->read_glyph_header = TT_Load_Glyph_Header;
+ face->read_simple_glyph = TT_Load_Simple_Glyph;
+ face->read_composite_glyph = TT_Load_Composite_Glyph;
+ face->forget_glyph_frame = TT_Forget_Glyph_Frame;
+ }
+
/*************************************************************************/
/* */
@@ -708,13 +717,13 @@
offset = loader->glyf_offset + offset;
/* access glyph frame */
- error = TT_Access_Glyph_Frame( loader, glyph_index, offset, count );
+ error = face->access_glyph_frame( loader, glyph_index, offset, count );
if (error) goto Exit;
opened_frame = 1;
/* read first glyph header */
- error = TT_Load_Glyph_Header( loader );
+ error = face->read_glyph_header( loader );
if (error) goto Fail;
contours_count = loader->n_contours;
@@ -744,7 +753,7 @@
error = FT_GlyphLoader_Check_Points( gloader, 0, contours_count );
if (error) goto Fail;
- error = TT_Load_Simple_Glyph( loader, contours_count );
+ error = face->read_simple_glyph( loader );
if (error) goto Fail;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
@@ -779,10 +788,10 @@
start_contour = gloader->base.outline.n_contours;
- error = TT_Load_Composite_Glyph( loader, count );
+ error = face->read_composite_glyph( loader );
if (error) goto Fail;
- TT_Forget_Glyph_Frame( loader );
+ face->forget_glyph_frame( loader );
opened_frame = 0;
/* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
@@ -1031,7 +1040,7 @@
Fail:
if (opened_frame)
- TT_Forget_Glyph_Frame( loader );
+ face->forget_glyph_frame( loader );
Exit:
return error;
diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h
index a559f87..d703921 100644
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -36,6 +36,10 @@
FT_Short* bearing,
FT_UShort* advance );
+
+ LOCAL_DEF
+ void TT_Init_Glyph_Loading( TT_Face face );
+
LOCAL_DEF
FT_Error TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index f160fd2..f167ec4 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -27,6 +27,7 @@
#include <ttobjs.h>
#include <ttpload.h>
+#include <ttgload.h>
#include <freetype/internal/tterrors.h>
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
@@ -189,6 +190,9 @@
TT_Load_CVT ( face, stream ) ||
TT_Load_Programs ( face, stream );
+ /* initialise standard glyph loading routines */
+ TT_Init_Glyph_Loading( face );
+
Exit:
return error;
@@ -217,6 +221,9 @@
SFNT_Interface* sfnt = face->sfnt;
+ /* for "extended TrueType formats" (i.e. compressed versions) */
+ if (face->extra.finalizer)
+ face->extra.finalizer( face->extra.data );
if ( sfnt )
sfnt->done_face( face );