ref: 7fa51b5535dc05a91b96aac57835bf1473a24339
parent: e1075ceabb1c0740162e7f6173cf6600116223c4
author: Werner Lemberg <[email protected]>
date: Sat Jul 8 15:51:42 EDT 2000
Formatting. Adding some trivial error checking. Adding/Fixing tracing levels.
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -78,11 +78,19 @@
trace_ttpload, /* TT data/program loader (ttpload.c) */
/* Type 1 driver components */
- trace_t1objs,
- trace_t1load,
+ trace_t1driver,
trace_t1gload,
trace_t1hint,
- trace_t1driver,
+ trace_t1load,
+ trace_t1objs,
+
+ /* experimental Type 1 driver components */
+ trace_z1driver,
+ trace_z1gload,
+ trace_z1hint,
+ trace_z1load,
+ trace_z1objs,
+ trace_z1parse,
/* Type 2 driver components */
trace_t2driver,
--- a/src/base/ftbase.c
+++ b/src/base/ftbase.c
@@ -17,6 +17,7 @@
#ifdef FT_FLAT_COMPILE
+
#include "ftcalc.c"
#include "ftobjs.c"
#include "ftstream.c"
@@ -23,7 +24,9 @@
#include "ftlist.c"
#include "ftoutln.c"
#include "ftextend.c"
+
#else
+
#include <ftcalc.c>
#include <ftobjs.c>
#include <ftstream.c>
@@ -30,6 +33,8 @@
#include <ftlist.c>
#include <ftoutln.c>
#include <ftextend.c>
+
#endif
+
/* END */
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2014,7 +2014,7 @@
metrics->y_scale = FT_DivFix( metrics->y_ppem << 6,
face->units_per_EM );
-
+
ft_recompute_scaled_metrics( face, metrics );
}
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -270,15 +270,16 @@
}
- FT_EXPORT_FUNC( FT_Error ) FT_Outline_New_Internal( FT_Memory memory,
- FT_UInt numPoints,
- FT_Int numContours,
- FT_Outline* outline )
+ FT_EXPORT_FUNC( FT_Error ) FT_Outline_New_Internal(
+ FT_Memory memory,
+ FT_UInt numPoints,
+ FT_Int numContours,
+ FT_Outline* outline )
{
- FT_Error error;
+ FT_Error error;
- if ( !outline )
+ if ( !outline || !memory )
return FT_Err_Invalid_Argument;
*outline = null_outline;
@@ -302,7 +303,6 @@
}
-
/*************************************************************************/
/* */
/* <Function> */
@@ -340,12 +340,14 @@
FT_Int numContours,
FT_Outline* outline )
{
+ if ( !library )
+ return FT_Err_Invalid_Library_Handle;
+
return FT_Outline_New_Internal( library->memory, numPoints,
numContours, outline );
-
}
-
+
/*************************************************************************/
/* */
/* <Function> */
@@ -396,7 +398,26 @@
}
+ FT_EXPORT_FUNC( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory,
+ FT_Outline* outline )
+ {
+ if ( outline )
+ {
+ if ( outline->flags & ft_outline_owner )
+ {
+ FREE( outline->points );
+ FREE( outline->tags );
+ FREE( outline->contours );
+ }
+ *outline = null_outline;
+ return FT_Err_Ok;
+ }
+ else
+ return FT_Err_Invalid_Argument;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -424,33 +445,17 @@
/* The reason why this function takes an `outline' parameter is */
/* simply to use FT_Free(). */
/* */
-
- FT_EXPORT_FUNC( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory,
- FT_Outline* outline )
- {
- if ( outline )
- {
- if ( outline->flags & ft_outline_owner )
- {
- FREE( outline->points );
- FREE( outline->tags );
- FREE( outline->contours );
- }
- *outline = null_outline;
-
- return FT_Err_Ok;
- }
- else
- return FT_Err_Invalid_Argument;
- }
-
-
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Done( FT_Library library,
FT_Outline* outline )
-
{
+ /* check for valid `outline' in FT_Outline_Done_Internal() */
+
+ if ( !library )
+ return FT_Err_Invalid_Library_Handle;
+
return FT_Outline_Done_Internal( library->memory, outline );
}
+
/*************************************************************************/
/* */
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -636,8 +636,6 @@
}
-
-
BASE_FUNC( FT_Error ) FT_Read_Fields( FT_Stream stream,
const FT_Frame_Field* fields,
void* structure )
--- a/src/cff/cff.c
+++ b/src/cff/cff.c
@@ -19,19 +19,22 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
+
#include "t2driver.c" /* driver interface */
#include "t2parse.c" /* token parser */
#include "t2load.c" /* tables loader */
#include "t2objs.c" /* object management */
#include "t2gload.c" /* glyph loader */
+
#else
+
#include <cff/t2driver.c> /* driver interface */
#include <cff/t2parse.c> /* token parser */
#include <cff/t2load.c> /* tables loader */
#include <cff/t2objs.c> /* object management */
#include <cff/t2gload.c> /* glyph loader */
-#endif
+#endif
/* END */
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -24,14 +24,18 @@
#include <freetype/internal/t2errors.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t2driver.h"
#include "t2gload.h"
+
#else
+
#include <cff/t2driver.h>
#include <cff/t2gload.h>
-#endif
+#endif
/*************************************************************************/
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -23,14 +23,20 @@
#include <freetype/ftoutln.h>
#include <freetype/tttags.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t2load.h"
#include "t2gload.h"
+
#else
+
#include <cff/t2load.h>
#include <cff/t2gload.h>
+
#endif
+
#include <freetype/internal/t2errors.h>
@@ -470,7 +476,8 @@
FT_Pos y )
{
FT_Error error = 0;
-
+
+
/* test whether we are building a new contour */
if ( !builder->path_begun )
{
@@ -1155,7 +1162,6 @@
}
break;
-
case t2_op_rcurveline:
{
FT_Int num_curves = ( num_args - 2 ) / 6;
@@ -1196,128 +1202,131 @@
}
break;
-
-
case t2_op_hflex1:
{
FT_Pos start_y;
-
+
+
FT_TRACE4(( " hflex1" ));
-
+
args = stack;
-
- /* Adding five more points; 4 control points, 1 on curve point. */
- if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+
+ /* adding five more points; 4 control points, 1 on-curve point */
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 5 ) )
goto Memory_Error;
-
+
/* Record the starting point's y postion for later use */
start_y = y;
-
+
/* first control point */
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
-
+
/* second control point */
x += args[2];
y += args[3];
add_point( builder, x, y, 0 );
-
+
/* join point; on curve, with y-value the same as the last */
/* control point's y-value */
x += args[4];
add_point( builder, x, y, 1 );
-
+
/* third control point, with y-value the same as the join */
/* point's y-value */
x += args[5];
add_point( builder, x, y, 0 );
-
+
/* fourth control point */
x += args[6];
y += args[7];
add_point( builder, x, y, 0 );
-
- /* ending point, with y-value the same as the start */
- /* point's y-value. we don't add this point, though. */
+
+ /* ending point, with y-value the same as the start */
+ /* point's y-value -- we don't add this point, though */
x += args[8];
y = start_y;
-
+
args = stack;
break;
}
-
case t2_op_hflex:
{
FT_Pos start_y;
-
+
+
FT_TRACE4(( " hflex" ));
-
+
args = stack;
-
- /* Adding five more points; 4 control points, 1 on curve point. */
- if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
-
+
+ /* adding five more points; 4 control points, 1 on-curve point */
+ if ( start_point( builder, x, y ) ||
+ check_points ( builder, 5 ) )
goto Memory_Error;
-
- /* Record the starting point's y postion for later use */
+
+ /* record the starting point's y-position for later use */
start_y = y;
-
+
/* first control point */
x += args[0];
add_point( builder, x, y, 0 );
-
+
/* second control point */
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
-
+
/* join point; on curve, with y-value the same as the last */
/* control point's y-value */
x += args[3];
add_point( builder, x, y, 1 );
-
+
/* third control point, with y-value the same as the join */
/* point's y-value */
x += args[4];
add_point( builder, x, y, 0 );
-
+
/* fourth control point */
x += args[5];
y = start_y;
add_point( builder, x, y, 0 );
-
+
/* ending point, with y-value the same as the start point's */
- /* y-value we don't add this point, though. */
+ /* y-value -- we don't add this point, though */
x += args[6];
-
+
args = stack;
break;
}
-
case t2_op_flex1:
{
- FT_Pos start_x, start_y; /* record start x,y values for alter use */
- FT_Int dx = 0, dy = 0; /* used in hort./vert. algorithm below */
- FT_Int horizontal, count;
+ FT_Pos start_x, start_y; /* record start x, y values for alter */
+ /* use */
+ FT_Int dx = 0, dy = 0; /* used in horizontal/vertical */
+ /* algorithm below */
+ FT_Int horizontal, count;
+
FT_TRACE4(( " flex1" ));
-
- /* Adding five more points; 4 control points, 1 on curve point. */
- if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+
+ /* adding five more points; 4 control points, 1 on-curve point */
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 5 ) )
goto Memory_Error;
-
- /* Record the starting point's x,y postion for later use */
+
+ /* record the starting point's x, y postion for later use */
start_x = x;
start_y = y;
-
- /* XXXX: figure out if this is supposed to be a horizontal or */
- /* vertical flex. The Type 2 specification is vague... */
-
+
+ /* XXX: figure out whether this is supposed to be a horizontal */
+ /* or vertical flex; the Type 2 specification is vague... */
+
args = stack;
-
+
/* grab up to the last argument */
for ( count = 5; count > 0; count-- )
{
@@ -1325,25 +1334,25 @@
dy += args[1];
args += 2;
}
-
+
/* rewind */
args = stack;
-
+
if ( dx < 0 ) dx = -dx;
if ( dy < 0 ) dy = -dy;
-
+
/* strange test, but here it is... */
- horizontal = (dx > dy);
+ horizontal = ( dx > dy );
for ( count = 5; count > 0; count-- )
{
x += args[0];
y += args[1];
- add_point( builder, x, y, (FT_Bool)(count == 3) );
+ add_point( builder, x, y, (FT_Bool)( count == 3 ) );
args += 2;
}
- if (horizontal)
+ if ( horizontal )
{
x += args[0];
y = start_y;
@@ -1353,40 +1362,37 @@
x = start_x;
y += args[0];
}
-
+
args = stack;
break;
}
-
case t2_op_flex:
{
- FT_UInt count;
-
+ FT_UInt count;
+
+
FT_TRACE4(( " flex" ));
-
- if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
- goto Memory_Error;
-
+
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 5 ) )
+ goto Memory_Error;
+
args = stack;
for ( count = 5; count > 0; count-- )
{
x += args[0];
y += args[1];
- add_point( builder, x, y, (FT_Bool)(count == 3) );
+ add_point( builder, x, y, (FT_Bool)( count == 3 ) );
args += 2;
}
-
+
x += args[0];
y += args[1];
-
+
args = stack;
}
break;
-
-
-
-
case t2_op_endchar:
FT_TRACE4(( " endchar" ));
--- a/src/cff/t2gload.h
+++ b/src/cff/t2gload.h
@@ -21,11 +21,17 @@
#include <freetype/freetype.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t2objs.h"
+
#else
+
#include <cff/t2objs.h>
+
#endif
+
#ifdef __cplusplus
extern "C" {
--- a/src/cff/t2load.c
+++ b/src/cff/t2load.c
@@ -24,12 +24,17 @@
#include <freetype/internal/t2errors.h>
#include <freetype/tttags.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t2load.h"
#include "t2parse.h"
+
#else
+
#include <cff/t2load.h>
#include <cff/t2parse.h>
+
#endif
@@ -322,7 +327,6 @@
return name;
}
}
-
/*************************************************************************/
--- a/src/cff/t2load.h
+++ b/src/cff/t2load.h
@@ -34,7 +34,6 @@
FT_UInt sid,
PSNames_Interface* interface );
-
LOCAL_DEF
FT_Error T2_Access_Element( CFF_Index* index,
FT_UInt element,
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -26,17 +26,25 @@
#include <freetype/internal/sfnt.h>
#include <freetype/internal/psnames.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t2objs.h"
#include "t2load.h"
+
#else
+
#include <cff/t2objs.h>
#include <cff/t2load.h>
+
#endif
+
#include <freetype/internal/t2errors.h>
+#include <string.h> /* for strlen() */
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -54,13 +62,15 @@
/*************************************************************************/
static
- FT_String* T2_StrCopy( FT_Memory memory, const FT_String* source )
+ FT_String* T2_StrCopy( FT_Memory memory,
+ const FT_String* source )
{
- FT_Error error;
- FT_String* result = 0;
- FT_Int len = (FT_Int)strlen(source);
-
- if ( !ALLOC( result, len+1 ) )
+ FT_Error error;
+ FT_String* result = 0;
+ FT_Int len = (FT_Int)strlen( source );
+
+
+ if ( !ALLOC( result, len + 1 ) )
{
MEM_Copy( result, source, len );
result[len] = 0;
@@ -70,12 +80,13 @@
#if 0
+
/* this function is used to build a Unicode charmap from the glyph names */
- /* in a file.. */
+ /* in a file */
static
- FT_Error CFF_Build_Unicode_Charmap( T2_Face face,
- FT_ULong base_offset,
- PSNames_Interface* psnames )
+ FT_Error CFF_Build_Unicode_Charmap( T2_Face face,
+ FT_ULong base_offset,
+ PSNames_Interface* psnames )
{
CFF_Font* font = (CFF_Font*)face->extra.data;
FT_Memory memory = FT_FACE_MEMORY(face);
@@ -87,8 +98,9 @@
FT_Byte format;
FT_Stream stream = face->root.stream;
+
charset_offset = dict->charset_offset;
- if (!charset_offset)
+ if ( !charset_offset )
{
FT_ERROR(( "CFF.Build_Unicode_Charmap: charset table is missing\n" ));
error = FT_Err_Invalid_File_Format;
@@ -96,7 +108,7 @@
}
/* allocate the charmap */
- if ( ALLOC( face->charmap,
+ if ( ALLOC( face->charmap, ...
/* seek to charset table and allocate glyph names table */
if ( FILE_Seek( base_offset + charset_offset ) ||
@@ -104,19 +116,19 @@
goto Exit;
/* now, read each glyph name and store it in the glyph name table */
- if ( READ_Byte(format) )
+ if ( READ_Byte( format ) )
goto Fail;
-
- switch (format)
+
+ switch ( format )
{
case 0: /* format 0 - one SID per glyph */
{
const char** gname = glyph_names;
const char** limit = gname + num_glyphs;
-
+
if ( ACCESS_Frame( num_glyphs*2 ) )
goto Fail;
-
+
for ( ; gname < limit; gname++ )
gname[0] = T2_Get_String( &font->string_index,
GET_UShort(),
@@ -124,7 +136,7 @@
FORGET_Frame();
break;
}
-
+
case 1: /* format 1 - sequential ranges */
case 2: /* format 2 - sequential ranges with 16-bit counts */
{
@@ -131,15 +143,15 @@
const char** gname = glyph_names;
const char** limit = gname + num_glyphs;
FT_UInt len = 3;
-
+
if (format == 2)
len++;
-
+
while (gname < limit)
{
FT_UInt first;
FT_UInt count;
-
+
if ( ACCESS_Frame( len ) )
goto Fail;
@@ -150,7 +162,7 @@
count = GET_Byte();
FORGET_Frame();
-
+
for ( ; count > 0; count-- )
{
gname[0] = T2_Get_String( &font->string_index,
@@ -162,7 +174,7 @@
}
break;
}
-
+
default: /* unknown charset format !! */
FT_ERROR(( "CFF: unknown charset format !!\n" ));
error = FT_Err_Invalid_File_Format;
@@ -175,14 +187,14 @@
Fail:
for ( n = 0; n < num_glyphs; n++ )
FREE( glyph_names[n] );
-
+
FREE( glyph_names );
-
+
Exit:
return error;
}
-#endif
+#endif /* 0 */
static
@@ -233,7 +245,7 @@
return ft_encoding_none;
}
-
+
/*************************************************************************/
/* */
/* <Function> */
@@ -270,6 +282,7 @@
FT_Bool pure_cff = 1;
FT_Bool sfnt_format = 0;
+
sfnt = (SFNT_Interface*)FT_Get_Module_Interface(
face->root.driver->root.library, "sfnt" );
if ( !sfnt )
@@ -276,7 +289,7 @@
goto Bad_Format;
psnames = (PSNames_Interface*)FT_Get_Module_Interface(
- face->root.driver->root.library, "psnames" );
+ face->root.driver->root.library, "psnames" );
/* create input stream from resource */
if ( FILE_Seek( 0 ) )
@@ -296,27 +309,28 @@
if ( face_index < 0 )
return T2_Err_Ok;
- sfnt_format = 1;
+ sfnt_format = 1;
- /* now, the font can be either an OpenType/CFF font, or a SVG CEF font */
- /* in the later case, it doesn't have a "head" table.. */
+ /* now, the font can be either an OpenType/CFF font, or a SVG CEF */
+ /* font in the later case; it doesn't have a `head' table */
error = face->goto_table( face, TTAG_head, stream, 0 );
- if (!error)
+ if ( !error )
{
pure_cff = 0;
/* Load font directory */
- error = sfnt->load_face( stream, face, face_index, num_params, params );
+ error = sfnt->load_face( stream, face,
+ face_index, num_params, params );
if ( error )
goto Exit;
}
else
{
- /* load the "cmap" table by hand */
+ /* load the `cmap' table by hand */
error = sfnt->load_charmaps( face, stream );
- if (error)
+ if ( error )
goto Exit;
-
+
/* XXX: for now, we don't load the GPOS table, as OpenType Layout */
/* support will be added later to FreeType 2 as a separate module */
}
@@ -328,12 +342,11 @@
}
else
{
- /* rewind to start of file, we're going to load a pure-CFF font */
- (void)FILE_Seek(0);
+ /* rewind to start of file; we are going to load a pure-CFF font */
+ (void)FILE_Seek( 0 );
error = FT_Err_Ok;
}
-
/* now load and parse the CFF table in the file */
{
CFF_Font* cff;
@@ -347,7 +360,7 @@
goto Exit;
base_offset = FILE_Pos();
-
+
face->extra.data = cff;
error = T2_Load_CFF_Font( stream, face_index, cff );
if ( error )
@@ -355,125 +368,131 @@
/* Complement the root flags with some interesting information. */
/* Note that this is only necessary for pure CFF and CEF fonts */
-
+
root = &face->root;
- if (pure_cff)
+ if ( pure_cff )
{
CFF_Font_Dict* dict = &cff->top_font.font_dict;
-
- /* we need the psnames module for pure-CFF and CEF formats */
- if (!psnames)
+
+
+ /* we need the `PSNames' module for pure-CFF and CEF formats */
+ if ( !psnames )
{
- FT_ERROR(( "cannot open CFF & CEF fonts without the 'psnames' module\n" ));
+ FT_ERROR(( "T2_Init_Face:" ));
+ FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
+ FT_ERROR(( " " ));
+ FT_ERROR(( " without the `PSNames' module\n" ));
goto Bad_Format;
}
-
+
/* compute number of glyphs */
- if (dict->cid_registry)
+ if ( dict->cid_registry )
root->num_glyphs = dict->cid_count;
else
root->num_glyphs = cff->charstrings_index.count;
-
+
/* set global bbox, as well as EM size */
- root->units_per_EM = FT_DivFix( 1000L << 16, dict->font_matrix.yy ) >> 16;
- root->bbox = dict->font_bbox;
- root->ascender = root->bbox.yMax;
- root->descender = root->bbox.yMin;
-
+ root->units_per_EM = FT_DivFix( 1000L << 16,
+ dict->font_matrix.yy ) >> 16;
+ root->bbox = dict->font_bbox;
+ root->ascender = root->bbox.yMax;
+ root->descender = root->bbox.yMin;
+
/* retrieve font family & style name */
root->family_name = T2_Get_Name( &cff->name_index, face_index );
- if (dict->cid_registry)
+ if ( dict->cid_registry )
{
- root->style_name = T2_StrCopy( memory, "Regular" ); /* XXXX */
+ root->style_name = T2_StrCopy( memory, "Regular" ); /* XXXX */
}
else
{
- root->style_name = T2_Get_String( &cff->string_index,
- dict->weight,
- psnames );
+ root->style_name = T2_Get_String( &cff->string_index,
+ dict->weight,
+ psnames );
}
-
- /*********************************************************************/
- /* */
- /* Compute face flags. */
- /* */
- flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
- if (sfnt_format)
- flags |= FT_FACE_FLAG_SFNT;
-
- /* fixed width font? */
- if ( dict->is_fixed_pitch )
- flags |= FT_FACE_FLAG_FIXED_WIDTH;
+ /*******************************************************************/
+ /* */
+ /* Compute face flags. */
+ /* */
+ flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
+ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
+ if ( sfnt_format )
+ flags |= FT_FACE_FLAG_SFNT;
+
+ /* fixed width font? */
+ if ( dict->is_fixed_pitch )
+ flags |= FT_FACE_FLAG_FIXED_WIDTH;
+
/* XXXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
#if 0
- /* kerning available ? */
- if ( face->kern_pairs )
- flags |= FT_FACE_FLAG_KERNING;
+ /* kerning available? */
+ if ( face->kern_pairs )
+ flags |= FT_FACE_FLAG_KERNING;
#endif
- root->face_flags = flags;
-
- /*********************************************************************/
- /* */
- /* Compute style flags. */
- /* */
- flags = 0;
-
- if ( dict->italic_angle )
- flags |= FT_STYLE_FLAG_ITALIC;
-
- /* XXXX : may not be correct .. */
- if ( cff->top_font.private_dict.force_bold )
- flags |= FT_STYLE_FLAG_BOLD;
-
- root->style_flags = flags;
-
- /* set the charmaps if any */
- if (sfnt_format)
+ root->face_flags = flags;
+
+ /*******************************************************************/
+ /* */
+ /* Compute style flags. */
+ /* */
+ flags = 0;
+
+ if ( dict->italic_angle )
+ flags |= FT_STYLE_FLAG_ITALIC;
+
+ /* XXX: may not be correct */
+ if ( cff->top_font.private_dict.force_bold )
+ flags |= FT_STYLE_FLAG_BOLD;
+
+ root->style_flags = flags;
+
+ /* set the charmaps if any */
+ if ( sfnt_format )
+ {
+ /*****************************************************************/
+ /* */
+ /* Polish the charmaps. */
+ /* */
+ /* Try to set the charmap encoding according to the platform & */
+ /* encoding ID of each charmap. */
+ /* */
+ TT_CharMap charmap;
+ FT_Int n;
+
+
+ charmap = face->charmaps;
+ root->num_charmaps = face->num_charmaps;
+
+ /* allocate table of pointers */
+ if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
+ goto Exit;
+
+ for ( n = 0; n < root->num_charmaps; n++, charmap++ )
{
- /*********************************************************************/
- /* */
- /* Polish the charmaps. */
- /* */
- /* Try to set the charmap encoding according to the platform & */
- /* encoding ID of each charmap. */
- /* */
- TT_CharMap charmap;
- FT_Int n;
+ FT_Int platform = charmap->cmap.platformID;
+ FT_Int encoding = charmap->cmap.platformEncodingID;
- charmap = face->charmaps;
- root->num_charmaps = face->num_charmaps;
-
- /* allocate table of pointers */
- if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
- goto Exit;
-
- for ( n = 0; n < root->num_charmaps; n++, charmap++ )
- {
- FT_Int platform = charmap->cmap.platformID;
- FT_Int encoding = charmap->cmap.platformEncodingID;
-
-
- charmap->root.face = (FT_Face)face;
- charmap->root.platform_id = platform;
- charmap->root.encoding_id = encoding;
- charmap->root.encoding = find_encoding( platform, encoding );
-
- /* now, set root->charmap with a unicode charmap */
- /* wherever available */
- if ( !root->charmap &&
- charmap->root.encoding == ft_encoding_unicode )
- root->charmap = (FT_CharMap)charmap;
-
- root->charmaps[n] = (FT_CharMap)charmap;
- }
+
+ charmap->root.face = (FT_Face)face;
+ charmap->root.platform_id = platform;
+ charmap->root.encoding_id = encoding;
+ charmap->root.encoding = find_encoding( platform, encoding );
+
+ /* now, set root->charmap with a unicode charmap */
+ /* wherever available */
+ if ( !root->charmap &&
+ charmap->root.encoding == ft_encoding_unicode )
+ root->charmap = (FT_CharMap)charmap;
+
+ root->charmaps[n] = (FT_CharMap)charmap;
}
+ }
}
}
-
+
Exit:
return error;
--- a/src/cff/t2objs.h
+++ b/src/cff/t2objs.h
@@ -89,8 +89,8 @@
} T2_Transform;
- /* this is only used in the case of a pure CFF font with no charmap */
- typedef struct T2_CharMapRec_
+ /* this is only used in the case of a pure CFF font with no charmap */
+ typedef struct T2_CharMapRec_
{
TT_CharMapRec root;
PS_Unicodes unicodes;
--- a/src/cff/t2parse.c
+++ b/src/cff/t2parse.c
@@ -17,11 +17,16 @@
#ifdef FT_FLAT_COMPILE
+
#include "t2parse.h"
+
#else
+
#include <cff/t2parse.h>
+
#endif
+
#include <freetype/internal/t2errors.h>
@@ -422,11 +427,17 @@
static const T2_Field_Handler t2_field_handlers[] =
{
+
#ifdef FT_FLAT_COMPILE
+
#include "t2tokens.h"
+
#else
+
#include <cff/t2tokens.h>
+
#endif
+
{ 0, 0, 0, 0, 0, 0, 0 }
};
--- a/src/cid/cidafm.c
+++ b/src/cid/cidafm.c
@@ -15,11 +15,17 @@
/* */
/***************************************************************************/
+
#ifdef FT_FLAT_COMPILE
+
#include "cidafm.h"
+
#else
+
#include <cid/cidafm.h>
+
#endif
+
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
--- a/src/cid/cidafm.h
+++ b/src/cid/cidafm.h
@@ -19,10 +19,15 @@
#ifndef CIDAFM_H
#define CIDAFM_H
+
#ifdef FT_FLAT_COMPILE
+
#include "cidobjs.h"
+
#else
+
#include <cid/cidobjs.h>
+
#endif
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -17,12 +17,17 @@
#ifdef FT_FLAT_COMPILE
+
#include "cidload.h"
#include "cidgload.h"
+
#else
+
#include <cid/cidload.h>
#include <cid/cidgload.h>
+
#endif
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
--- a/src/cid/cidgload.h
+++ b/src/cid/cidgload.h
@@ -19,11 +19,17 @@
#ifndef CIDGLOAD_H
#define CIDGLOAD_H
+
#ifdef FT_FLAT_COMPILE
+
#include "cidobjs.h"
+
#else
+
#include <cid/cidobjs.h>
+
#endif
+
#ifdef __cplusplus
extern "C" {
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -23,12 +23,18 @@
#include <freetype/internal/t1types.h>
#include <freetype/internal/t1errors.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "cidload.h"
+
#else
+
#include <cid/cidload.h>
+
#endif
+
#include <stdio.h>
#include <ctype.h> /* for isspace(), isalnum() */
@@ -243,11 +249,17 @@
static
const CID_Field_Rec t1_field_records[] =
{
+
#ifdef FT_FLAT_COMPILE
+
#include "cidtokens.h"
+
#else
+
#include <cid/cidtokens.h>
+
#endif
+
{ 0, 0, 0, 0, 0, 0, 0, 0 }
};
--- a/src/cid/cidload.h
+++ b/src/cid/cidload.h
@@ -21,11 +21,17 @@
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "cidparse.h"
+
#else
+
#include <cid/cidparse.h>
+
#endif
+
#ifdef __cplusplus
extern "C" {
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -19,13 +19,19 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "cidgload.h"
#include "cidload.h"
+
#else
+
#include <cid/cidgload.h>
#include <cid/cidload.h>
+
#endif
+
#include <freetype/internal/psnames.h>
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -22,11 +22,17 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1errors.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "cidparse.h"
+
#else
+
#include <cid/cidparse.h>
+
#endif
+
#include <string.h> /* for strncmp() */
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -17,12 +17,17 @@
#ifdef FT_FLAT_COMPILE
+
#include "cidriver.h"
#include "cidgload.h"
+
#else
+
#include <cid/cidriver.h>
#include <cid/cidgload.h>
+
#endif
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
--- a/src/cid/type1cid.c
+++ b/src/cid/type1cid.c
@@ -19,17 +19,21 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
+
#include "cidparse.c"
#include "cidload.c"
#include "cidobjs.c"
#include "cidriver.c"
#include "cidgload.c"
+
#else
+
#include <cid/cidparse.c>
#include <cid/cidload.c>
#include <cid/cidobjs.c>
#include <cid/cidriver.c>
#include <cid/cidgload.c>
+
#endif
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -19,13 +19,19 @@
#include <freetype/internal/psnames.h>
#include <freetype/internal/ftobjs.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "psmodule.h"
#include "pstables.h"
+
#else
+
#include <psnames/psmodule.h>
#include <psnames/pstables.h>
+
#endif
+
#include <stdlib.h> /* for qsort() */
#include <string.h> /* for strcmp(), strncpy() */
--- a/src/raster1/ftrend1.c
+++ b/src/raster1/ftrend1.c
@@ -19,12 +19,17 @@
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ftrend1.h"
#include "ftraster.h"
+
#else
+
#include <raster1/ftrend1.h>
#include <raster1/ftraster.h>
+
#endif
--- a/src/raster1/raster1.c
+++ b/src/raster1/raster1.c
@@ -18,12 +18,17 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
+
#include "ftraster.c"
#include "ftrend1.c"
+
#else
+
#include <raster1/ftraster.c>
#include <raster1/ftrend1.c>
+
#endif
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -19,7 +19,9 @@
#include <freetype/internal/sfnt.h>
#include <freetype/internal/ftobjs.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "sfdriver.h"
#include "ttload.h"
#include "ttsbit.h"
@@ -26,7 +28,9 @@
#include "ttpost.h"
#include "ttcmap.h"
#include "sfobjs.h"
+
#else
+
#include <sfnt/sfdriver.h>
#include <sfnt/ttload.h>
#include <sfnt/ttsbit.h>
@@ -33,6 +37,7 @@
#include <sfnt/ttpost.h>
#include <sfnt/ttcmap.h>
#include <sfnt/sfobjs.h>
+
#endif
--- a/src/sfnt/sfnt.c
+++ b/src/sfnt/sfnt.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
#include "ttload.c"
@@ -31,9 +32,9 @@
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.c"
#endif
+
#include "sfdriver.c"
-
#else /* FT_FLAT_COMPILE */
#include <sfnt/ttload.c>
@@ -47,12 +48,10 @@
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include <sfnt/ttpost.c>
#endif
+
#include <sfnt/sfdriver.c>
#endif /* FT_FLAT_COMPILE */
-
-
-
/* END */
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -17,10 +17,15 @@
#ifdef FT_FLAT_COMPILE
+
#include "sfobjs.h"
+
#else
+
#include <sfnt/sfobjs.h>
+
#endif
+
#include <freetype/internal/sfnt.h>
#include <freetype/internal/psnames.h>
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -19,15 +19,18 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/tterrors.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttload.h"
#include "ttcmap.h"
+
#else
+
#include <sfnt/ttload.h>
#include <sfnt/ttcmap.h>
-#endif
-
+#endif
/*************************************************************************/
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -21,15 +21,18 @@
#include <freetype/internal/tterrors.h>
#include <freetype/tttags.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttload.h"
#include "ttcmap.h"
+
#else
+
#include <sfnt/ttload.h>
#include <sfnt/ttcmap.h>
-#endif
-
+#endif
/*************************************************************************/
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -29,14 +29,18 @@
#include <freetype/internal/tterrors.h>
#include <freetype/tttags.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttpost.h"
#include "ttload.h"
+
#else
+
#include <sfnt/ttpost.h>
#include <sfnt/ttload.h>
-#endif
+#endif
/*************************************************************************/
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -20,12 +20,16 @@
#include <freetype/internal/tterrors.h>
#include <freetype/tttags.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttsbit.h"
+
#else
+
#include <sfnt/ttsbit.h>
-#endif
+#endif
/*************************************************************************/
--- a/src/sfnt/ttsbit.h
+++ b/src/sfnt/ttsbit.h
@@ -19,12 +19,16 @@
#ifndef TTSBIT_H
#define TTSBIT_H
+
#ifdef FT_FLAT_COMPILE
+
#include "ttload.h"
+
#else
+
#include <sfnt/ttload.h>
-#endif
+#endif
#ifdef __cplusplus
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -123,10 +123,15 @@
#else /* _STANDALONE_ */
+
#ifdef FT_FLAT_COMPILE
+
#include "ftgrays.h"
+
#else
+
#include <smooth/ftgrays.h>
+
#endif
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -19,15 +19,18 @@
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ftsmooth.h"
#include "ftgrays.h"
+
#else
+
#include <smooth/ftsmooth.h>
#include <smooth/ftgrays.h>
-#endif
-
+#endif
/* initialize renderer -- init its raster */
--- a/src/smooth/smooth.c
+++ b/src/smooth/smooth.c
@@ -18,15 +18,18 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
+
#include "ftgrays.c"
#include "ftsmooth.c"
+
#else
+
#include <smooth/ftgrays.c>
#include <smooth/ftsmooth.c>
-#endif
-
+#endif
/* END */
--- a/src/truetype/truetype.c
+++ b/src/truetype/truetype.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
#include "ttdriver.c" /* driver interface */
@@ -24,21 +25,23 @@
#include "ttpload.c" /* tables loader */
#include "ttgload.c" /* glyph loader */
#include "ttobjs.c" /* object manager */
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.c" /* bytecode interpreter */
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <truetype/ttdriver.c> /* driver interface */
#include <truetype/ttpload.c> /* tables loader */
#include <truetype/ttgload.c> /* glyph loader */
#include <truetype/ttobjs.c> /* object manager */
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.c> /* bytecode interpreter */
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
/* END */
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -21,14 +21,18 @@
#include <freetype/internal/sfnt.h>
#include <freetype/ttnameid.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttdriver.h"
#include "ttgload.h"
+
#else
+
#include <truetype/ttdriver.h>
#include <truetype/ttgload.h>
-#endif
+#endif
/*************************************************************************/
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -23,14 +23,18 @@
#include <freetype/tttags.h>
#include <freetype/ftoutln.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttgload.h"
+
#else
+
#include <truetype/ttgload.h>
+
#endif
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -1048,7 +1052,7 @@
pts->tags[k] &= FT_Curve_Tag_On;
}
- cur_to_org( num_points+2, pts );
+ cur_to_org( num_points + 2, pts );
/* now consider hinting */
if ( IS_HINTED( loader->load_flags ) && n_ins > 0 )
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -19,21 +19,24 @@
#ifndef TTGLOAD_H
#define TTGLOAD_H
+
#ifdef FT_FLAT_COMPILE
#include "ttobjs.h"
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <truetype/ttobjs.h>
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.h>
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
#ifdef __cplusplus
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -20,10 +20,15 @@
#include <freetype/internal/ftcalc.h>
#include <freetype/ftsystem.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "ttinterp.h"
+
#else
+
#include <truetype/ttinterp.h>
+
#endif
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -19,12 +19,16 @@
#ifndef TTINTERP_H
#define TTINTERP_H
+
#ifdef FT_FLAT_COMPILE
+
#include "ttobjs.h"
+
#else
+
#include <truetype/ttobjs.h>
-#endif
+#endif
#ifdef __cplusplus
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -25,23 +25,27 @@
#include <freetype/internal/sfnt.h>
#include <freetype/internal/psnames.h>
+
#ifdef FT_FLAT_COMPILE
#include "ttgload.h"
#include "ttpload.h"
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <truetype/ttgload.h>
#include <truetype/ttpload.h>
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.h>
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
+
#include <freetype/internal/tterrors.h>
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -17,10 +17,15 @@
#ifdef FT_FLAT_COMPILE
+
#include "t1afm.h"
+
#else
+
#include <type1/t1afm.h>
+
#endif
+
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -17,15 +17,20 @@
#ifdef FT_FLAT_COMPILE
+
#include "t1driver.h"
#include "t1gload.h"
#include "t1afm.h"
+
#else
+
#include <type1/t1driver.h>
#include <type1/t1gload.h>
#include <type1/t1afm.h>
+
#endif
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/psnames.h>
@@ -217,8 +222,8 @@
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
- /* the function returns 0xFFFF when the Unicode charcode has */
- /* no corresponding glyph. */
+ /* the function returns 0xFFFF if the Unicode charcode has */
+ /* no corresponding glyph */
if ( result == 0xFFFF )
result = 0;
goto Exit;
@@ -264,7 +269,7 @@
if ( gname && gname[0] == glyph_name[0] &&
- strcmp( gname, glyph_name ) == 0 )
+ strcmp( gname, glyph_name ) == 0 )
{
result = n;
break;
@@ -316,7 +321,7 @@
#ifdef T1_CONFIG_OPTION_NO_AFM
(FTDriver_getKerning) 0,
- (FTDriver_getAdvances) 0,
+ (FTDriver_attachFile) 0,
#else
(FTDriver_getKerning) Get_Kerning,
(FTDriver_attachFile) T1_Read_AFM,
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -19,24 +19,26 @@
#ifdef FT_FLAT_COMPILE
#include <type1/t1gload.h>
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.h>
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <type1/t1gload.h>
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.h>
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ftoutln.h>
-
#include <string.h> /* for strcmp() */
@@ -181,6 +183,7 @@
/* */
/* <Input> */
/* funcs :: The hinting functions interface. */
+ /* */
LOCAL_FUNC
void T1_Init_Decoder( T1_Decoder* decoder,
const T1_Hinter_Funcs* funcs )
--- a/src/type1/t1gload.h
+++ b/src/type1/t1gload.h
@@ -19,10 +19,15 @@
#ifndef T1GLOAD_H
#define T1GLOAD_H
+
#ifdef FT_FLAT_COMPILE
+
#include "t1objs.h"
+
#else
+
#include <type1/t1objs.h>
+
#endif
--- a/src/type1/t1hinter.c
+++ b/src/type1/t1hinter.c
@@ -26,14 +26,19 @@
#include <freetype/internal/ftdebug.h>
+
+
#ifdef FT_FLAT_COMPILE
+
#include "t1objs.h"
#include "t1hinter.h"
+
#else
+
#include <type1/t1objs.h>
#include <type1/t1hinter.h>
-#endif
+#endif
/*************************************************************************/
--- a/src/type1/t1hinter.h
+++ b/src/type1/t1hinter.h
@@ -19,13 +19,19 @@
#ifndef T1HINTER_H
#define T1HINTER_H
+
#ifdef FT_FLAT_COMPILE
+
#include "t1objs.h"
#include "t1gload.h"
+
#else
+
#include <type1/t1objs.h>
#include <type1/t1gload.h>
+
#endif
+
#ifdef __cplusplus
extern "C" {
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -20,12 +20,17 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/t1types.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t1tokens.h"
#include "t1parse.h"
+
#else
+
#include <type1/t1tokens.h>
#include <type1/t1parse.h>
+
#endif
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -21,10 +21,15 @@
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t1parse.h"
+
#else
+
#include <type1/t1parse.h>
+
#endif
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -19,32 +19,33 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
#include "t1gload.h"
#include "t1load.h"
#include "t1afm.h"
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include "t1hinter.h"
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <type1/t1gload.h>
#include <type1/t1load.h>
#include <type1/t1afm.h>
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.h>
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
-
#include <freetype/internal/psnames.h>
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -174,7 +175,6 @@
/* */
/* FACE FUNCTIONS */
/* */
- /* */
/*************************************************************************/
@@ -245,7 +245,8 @@
/*************************************************************************/
/* */
- /* <Function> T1_Init_Face */
+ /* <Function> */
+ /* T1_Init_Face */
/* */
/* <Description> */
/* The face object constructor. */
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -19,10 +19,15 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/t1types.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t1parse.h"
+
#else
+
#include <type1/t1parse.h>
+
#endif
--- a/src/type1/t1parse.h
+++ b/src/type1/t1parse.h
@@ -32,10 +32,15 @@
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t1tokens.h"
+
#else
+
#include <type1/t1tokens.h>
+
#endif
--- a/src/type1/t1tokens.c
+++ b/src/type1/t1tokens.c
@@ -32,12 +32,17 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "t1tokens.h"
#include "t1load.h"
+
#else
+
#include <type1/t1tokens.h>
#include <type1/t1load.h>
+
#endif
--- a/src/type1/t1tokens.h
+++ b/src/type1/t1tokens.h
@@ -19,12 +19,16 @@
#ifndef T1TOKENS_H
#define T1TOKENS_H
+
#ifdef FT_FLAT_COMPILE
+
#include "t1objs.h"
+
#else
+
#include <type1/t1objs.h>
-#endif
+#endif
#ifdef __cplusplus
--- a/src/type1/type1.c
+++ b/src/type1/type1.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
#include "t1driver.c"
@@ -26,9 +27,11 @@
#include "t1gload.c"
#include "t1tokens.c"
#include "t1parse.c"
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include "t1hinter.c"
#endif
+
#ifndef T1_CONFIG_OPTION_NO_AFM
#include "t1afm.c"
#endif
@@ -41,16 +44,16 @@
#include <type1/t1gload.c>
#include <type1/t1tokens.c>
#include <type1/t1parse.c>
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.c>
#endif
+
#ifndef T1_CONFIG_OPTION_NO_AFM
#include <type1/t1afm.c>
#endif
-#endif
-
-
+#endif /* FT_FLAT_COMPILE */
/* END */
--- a/src/type1z/type1z.c
+++ b/src/type1z/type1z.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#ifdef FT_FLAT_COMPILE
#include "z1parse.c"
@@ -25,11 +26,12 @@
#include "z1objs.c"
#include "z1driver.c"
#include "z1gload.c"
+
#ifndef Z1_CONFIG_OPTION_NO_AFM
#include "z1afm.c"
#endif
-#else
+#else /* FT_FLAT_COMPILE */
#include <type1z/z1parse.c>
#include <type1z/z1load.c>
@@ -36,11 +38,12 @@
#include <type1z/z1objs.c>
#include <type1z/z1driver.c>
#include <type1z/z1gload.c>
+
#ifndef Z1_CONFIG_OPTION_NO_AFM
#include <type1z/z1afm.c>
#endif
-#endif
+#endif /* FT_FLAT_COMPILE */
/* END */
--- a/src/type1z/z1afm.c
+++ b/src/type1z/z1afm.c
@@ -17,10 +17,15 @@
#ifdef FT_FLAT_COMPILE
+
#include "z1afm.h"
+
#else
+
#include <type1z/z1afm.h>
+
#endif
+
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
--- a/src/type1z/z1afm.h
+++ b/src/type1z/z1afm.h
@@ -19,12 +19,16 @@
#ifndef Z1AFM_H
#define Z1AFM_H
+
#ifdef FT_FLAT_COMPILE
+
#include "z1objs.h"
+
#else
+
#include <type1z/z1objs.h>
-#endif
+#endif
#ifdef __cplusplus
--- a/src/type1z/z1driver.c
+++ b/src/type1z/z1driver.c
@@ -1,30 +1,35 @@
-/*******************************************************************
- *
- * t1driver.c
- *
- * High-level Type1 driver interface for FreeType 2.0
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1driver.c */
+/* */
+/* Experimental Type 1 driver interface (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifdef FT_FLAT_COMPILE
+
#include "z1driver.h"
#include "z1gload.h"
#include "z1load.h"
#include "z1afm.h"
+
#else
+
#include <type1z/z1driver.h>
#include <type1z/z1gload.h>
#include <type1z/z1load.h>
#include <type1z/z1afm.h>
+
#endif
@@ -32,9 +37,19 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/psnames.h>
+#include <string.h> /* for strcmp() */
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1driver
+#define FT_COMPONENT trace_z1driver
+
/*************************************************************************/
/* */
/* <Function> */
@@ -66,8 +81,8 @@
FT_Module_Interface Get_Interface( FT_Driver driver,
const FT_String* interface )
{
- FT_UNUSED(driver);
- FT_UNUSED(interface);
+ FT_UNUSED( driver );
+ FT_UNUSED( interface );
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
if ( strcmp( (const char*)interface, "get_mm" ) == 0 )
@@ -84,6 +99,8 @@
#ifndef Z1_CONFIG_OPTION_NO_AFM
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -124,17 +141,21 @@
{
Z1_AFM* afm;
+
kerning->x = 0;
kerning->y = 0;
afm = (Z1_AFM*)face->afm_data;
- if (afm)
+ if ( afm )
Z1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return T1_Err_Ok;
}
-#endif
+
+#endif /* T1_CONFIG_OPTION_NO_AFM */
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -158,73 +179,75 @@
FT_UInt result = 0;
PSNames_Interface* psnames;
- face = (T1_Face)charmap->face;
+
+ face = (T1_Face)charmap->face;
psnames = (PSNames_Interface*)face->psnames;
- if (psnames)
- switch (charmap->encoding)
+ if ( psnames )
+ switch ( charmap->encoding )
{
- /********************************************************************/
- /* */
- /* Unicode encoding support */
- /* */
- case ft_encoding_unicode:
- {
- /* use the "psnames" module to synthetize the Unicode charmap */
- result = psnames->lookup_unicode( &face->unicode_map,
- (FT_ULong)charcode );
+ /*******************************************************************/
+ /* */
+ /* Unicode encoding support */
+ /* */
+ case ft_encoding_unicode:
+ /* use the `PSNames' module to synthetize the Unicode charmap */
+ result = psnames->lookup_unicode( &face->unicode_map,
+ (FT_ULong)charcode );
- /* the function returns 0xFFFF when the Unicode charcode has */
- /* no corresponding glyph.. */
- if (result == 0xFFFF)
- result = 0;
- goto Exit;
- }
+ /* the function returns 0xFFFF if the Unicode charcode has */
+ /* no corresponding glyph */
+ if ( result == 0xFFFF )
+ result = 0;
+ goto Exit;
- /********************************************************************/
- /* */
- /* Custom Type 1 encoding */
- /* */
- case ft_encoding_adobe_custom:
- {
- T1_Encoding* encoding = &face->type1.encoding;
- if (charcode >= encoding->code_first &&
- charcode <= encoding->code_last)
- {
- result = encoding->char_index[charcode];
- }
- goto Exit;
- }
+ /*******************************************************************/
+ /* */
+ /* Custom Type 1 encoding */
+ /* */
+ case ft_encoding_adobe_custom:
+ {
+ T1_Encoding* encoding = &face->type1.encoding;
- /********************************************************************/
- /* */
- /* Adobe Standard & Expert encoding support */
- /* */
- default:
- if (charcode < 256)
- {
- FT_UInt code;
- FT_Int n;
- const char* glyph_name;
- code = psnames->adobe_std_encoding[charcode];
- if (charmap->encoding == ft_encoding_adobe_expert)
- code = psnames->adobe_expert_encoding[charcode];
+ if ( charcode >= encoding->code_first &&
+ charcode <= encoding->code_last )
+ result = encoding->char_index[charcode];
+ goto Exit;
+ }
- glyph_name = psnames->adobe_std_strings(code);
- if (!glyph_name) break;
+ /*******************************************************************/
+ /* */
+ /* Adobe Standard & Expert encoding support */
+ /* */
+ default:
+ if ( charcode < 256 )
+ {
+ FT_UInt code;
+ FT_Int n;
+ const char* glyph_name;
- for ( n = 0; n < face->type1.num_glyphs; n++ )
- {
- const char* gname = face->type1.glyph_names[n];
- if ( gname && gname[0] == glyph_name[0] &&
- strcmp( gname, glyph_name ) == 0 )
- {
- result = n;
- break;
- }
- }
- }
+ code = psnames->adobe_std_encoding[charcode];
+ if ( charmap->encoding == ft_encoding_adobe_expert )
+ code = psnames->adobe_expert_encoding[charcode];
+
+ glyph_name = psnames->adobe_std_strings( code );
+ if ( !glyph_name )
+ break;
+
+ for ( n = 0; n < face->type1.num_glyphs; n++ )
+ {
+ const char* gname = face->type1.glyph_names[n];
+
+
+ if ( gname && gname[0] == glyph_name[0] &&
+ strcmp( gname, glyph_name ) == 0 )
+ {
+ result = n;
+ break;
+ }
+ }
+ }
}
Exit:
return result;
@@ -231,7 +254,7 @@
}
- const FT_Driver_Class t1z_driver_class =
+ const FT_Driver_Class t1z_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
@@ -238,14 +261,14 @@
sizeof( FT_DriverRec ),
"type1z",
- 0x10000,
- 0x20000,
+ 0x10000L,
+ 0x20000L,
0, /* format interface */
- (FT_Module_Constructor) Z1_Init_Driver,
- (FT_Module_Destructor) Z1_Done_Driver,
- (FT_Module_Requester) Get_Interface,
+ (FT_Module_Constructor)Z1_Init_Driver,
+ (FT_Module_Destructor) Z1_Done_Driver,
+ (FT_Module_Requester) Get_Interface,
},
sizeof( T1_FaceRec ),
@@ -252,53 +275,32 @@
sizeof( Z1_SizeRec ),
sizeof( Z1_GlyphSlotRec ),
- (FTDriver_initFace) Z1_Init_Face,
- (FTDriver_doneFace) Z1_Done_Face,
- (FTDriver_initSize) 0,
- (FTDriver_doneSize) 0,
- (FTDriver_initGlyphSlot) 0,
- (FTDriver_doneGlyphSlot) 0,
+ (FTDriver_initFace) Z1_Init_Face,
+ (FTDriver_doneFace) Z1_Done_Face,
+ (FTDriver_initSize) 0,
+ (FTDriver_doneSize) 0,
+ (FTDriver_initGlyphSlot)0,
+ (FTDriver_doneGlyphSlot)0,
- (FTDriver_setCharSizes) 0,
- (FTDriver_setPixelSizes) 0,
- (FTDriver_loadGlyph) Z1_Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_setCharSizes) 0,
+ (FTDriver_setPixelSizes)0,
+ (FTDriver_loadGlyph) Z1_Load_Glyph,
+ (FTDriver_getCharIndex) Get_Char_Index,
#ifdef Z1_CONFIG_OPTION_NO_AFM
- (FTDriver_getKerning) 0,
- (FTDriver_attachFile) 0,
+ (FTDriver_getKerning) 0,
+ (FTDriver_attachFile) 0,
#else
- (FTDriver_getKerning) Get_Kerning,
- (FTDriver_attachFile) Z1_Read_AFM,
+ (FTDriver_getKerning) Get_Kerning,
+ (FTDriver_attachFile) Z1_Read_AFM,
#endif
- (FTDriver_getAdvances) 0
-
+ (FTDriver_getAdvances) 0
};
- /******************************************************************/
- /* */
- /* <Function> Get_FreeType_Driver_Interface */
- /* */
- /* <Description> */
- /* This function is used when compiling the TrueType driver */
- /* as a shared library (.DLL or .so). It will be used by the */
- /* high-level library of FreeType to retrieve the address of */
- /* the driver's generic interface. */
- /* */
- /* It shouldn't be implemented in a static build, as each */
- /* driver must have the same function as an exported entry */
- /* point. */
- /* */
- /* <Return> */
- /* address of TrueType's driver generic interface. The */
- /* forma-specific interface can then be retrieved through */
- /* the method interface->get_format_interface.. */
- /* */
-
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
- EXPORT_FUNC(const FT_Driver_Class*) getDriverClass( void )
+ EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
{
return &t1z_driver_class;
}
@@ -306,3 +308,4 @@
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
+/* END */
--- a/src/type1z/z1driver.h
+++ b/src/type1z/z1driver.h
@@ -1,26 +1,29 @@
-/*******************************************************************
- *
- * t1driver.h
- *
- * High-level Type1 driver interface for FreeType 2.0
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1driver.h */
+/* */
+/* High-level experimental Type 1 driver interface (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef Z1DRIVER_H
#define Z1DRIVER_H
#include <freetype/internal/ftdriver.h>
- FT_EXPORT_VAR(const FT_Driver_Class) t1z_driver_class;
+ FT_EXPORT_VAR( const FT_Driver_Class ) t1z_driver_class;
#endif /* Z1DRIVER_H */
+
+/* END */
--- a/src/type1z/z1gload.c
+++ b/src/type1z/z1gload.c
@@ -1,34 +1,50 @@
-/*******************************************************************
- *
- * t1gload.c 1.0
- *
- * Type1 Glyph Loader.
- *
- * Copyright 1996-1999 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1gload.c */
+/* */
+/* Experimental Type 1 Glyph Loader (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifdef FT_FLAT_COMPILE
+
#include "z1gload.h"
+
#else
+
#include <type1z/z1gload.h>
+
#endif
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ftoutln.h>
+#include <string.h> /* for strcmp() */
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1gload
+#define FT_COMPONENT trace_z1gload
- typedef enum Z1_Operator_
+
+ typedef enum Z1_Operator_
{
op_none = 0,
op_endchar,
@@ -61,7 +77,8 @@
} Z1_Operator;
- static const FT_Int t1_args_count[ op_max ] =
+ static
+ const FT_Int t1_args_count[op_max] =
{
0, /* none */
0, /* endchar */
@@ -92,34 +109,37 @@
};
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** GENERIC CHARSTRINGS PARSING *********/
- /********** *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** *********/
+ /********** GENERIC CHARSTRING PARSING *********/
+ /********** *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
-/*********************************************************************
- *
- * <Function>
- * Z1_Init_Builder
- *
- * <Description>
- * Initialise a given glyph builder.
- *
- * <Input>
- * builder :: glyph builder to initialise
- * face :: current face object
- * size :: current size object
- * glyph :: current glyph object
- *
- *********************************************************************/
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Init_Builder */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph builder. */
+ /* */
+ /* <InOut> */
+ /* builder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* glyph :: The current glyph object. */
+ /* */
LOCAL_FUNC
void Z1_Init_Builder( Z1_Builder* builder,
T1_Face face,
@@ -133,18 +153,19 @@
builder->glyph = glyph;
builder->memory = face->root.memory;
- if (glyph)
+ if ( glyph )
{
FT_GlyphLoader* loader = glyph->root.loader;
- builder->loader = loader;
+
+ builder->loader = loader;
builder->current = &loader->current.outline;
builder->base = &loader->base.outline;
- FT_GlyphLoader_Rewind(loader);
+ FT_GlyphLoader_Rewind( loader );
}
- if (size)
+ if ( size )
{
builder->scale_x = size->root.metrics.x_scale;
builder->scale_y = size->root.metrics.y_scale;
@@ -160,46 +181,41 @@
}
-/*********************************************************************
- *
- * <Function>
- * Z1_Done_Builder
- *
- * <Description>
- * Finalise a given glyph builder. Its content can still be
- * used after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * <Input>
- * builder :: glyph builder to initialise
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Done_Builder */
+ /* */
+ /* <Description> */
+ /* Finalizes a given glyph builder. Its contents can still be used */
+ /* after the call, but the function saves important information */
+ /* within the corresponding glyph slot. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder to finalize. */
+ /* */
LOCAL_FUNC
void Z1_Done_Builder( Z1_Builder* builder )
{
Z1_GlyphSlot glyph = builder->glyph;
- if (glyph)
+
+ if ( glyph )
glyph->root.outline = *builder->base;
}
-
-/*********************************************************************
- *
- * <Function>
- * Z1_Init_Decoder
- *
- * <Description>
- * Initialise a given Type 1 decoder for parsing
- *
- * <Input>
- * decoder :: Type 1 decoder to initialise
- * funcs :: hinter functions interface
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Init_Decoder */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph decoder. */
+ /* */
+ /* <InOut> */
+ /* decoder :: A pointer to the glyph builder to initialize. */
+ /* */
LOCAL_FUNC
void Z1_Init_Decoder( Z1_Decoder* decoder )
{
@@ -210,11 +226,11 @@
decoder->blend = 0;
/* Clear loader */
- MEM_Set( &decoder->builder, 0, sizeof(decoder->builder) );
+ MEM_Set( &decoder->builder, 0, sizeof ( decoder->builder ) );
}
- /* check that there is enough room for "count" more points */
+ /* check that there is enough space for `count' more points */
static
FT_Error check_points( Z1_Builder* builder,
FT_Int count )
@@ -223,7 +239,7 @@
}
- /* add a new point, do not check room */
+ /* add a new point; do not check space */
static
void add_point( Z1_Builder* builder,
FT_Pos x,
@@ -232,14 +248,16 @@
{
FT_Outline* outline = builder->current;
- if (builder->load_points)
+
+ if ( builder->load_points )
{
FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
+
point->x = x;
point->y = y;
- *control = ( flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic );
+ *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic;
builder->last = *point;
}
@@ -248,7 +266,7 @@
}
- /* check room for a new on-curve point, then add it */
+ /* check space for a new on-curve point, then add it */
static
FT_Error add_point1( Z1_Builder* builder,
FT_Pos x,
@@ -256,8 +274,9 @@
{
FT_Error error;
- error = check_points(builder,1);
- if (!error)
+
+ error = check_points( builder, 1 );
+ if ( !error )
add_point( builder, x, y, 1 );
return error;
@@ -264,7 +283,7 @@
}
- /* check room for a new contour, then add it */
+ /* check space for a new contour, then add it */
static
FT_Error add_contour( Z1_Builder* builder )
{
@@ -271,24 +290,27 @@
FT_Outline* outline = builder->current;
FT_Error error;
- if (!builder->load_points)
+
+ if ( !builder->load_points )
{
outline->n_contours++;
return FT_Err_Ok;
}
- /* realloc contours array if necessary */
+ /* reallocate contours array if necessary */
error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
- if (!error)
+ if ( !error )
{
- if (outline->n_contours > 0)
- outline->contours[ outline->n_contours-1 ] = outline->n_points-1;
+ if ( outline->n_contours > 0 )
+ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
outline->n_contours++;
}
+
return error;
}
+
/* if a path was begun, add its first on-curve point */
static
FT_Error start_point( Z1_Builder* builder,
@@ -295,14 +317,16 @@
FT_Pos x,
FT_Pos y )
{
- /* test wether we're building a new contour */
- if (!builder->path_begun)
+ /* test whether we are building a new contour */
+ if ( !builder->path_begun )
{
FT_Error error;
+
builder->path_begun = 1;
error = add_contour( builder );
- if (error) return error;
+ if ( error )
+ return error;
}
return add_point1( builder, x, y );
}
@@ -314,17 +338,19 @@
{
FT_Outline* outline = builder->current;
- /* XXXX : we must not include the last point in the path if it */
- /* is located on the first point.. */
- if (outline->n_points > 1)
+
+ /* XXX: we must not include the last point in the path if it */
+ /* is located on the first point */
+ if ( outline->n_points > 1 )
{
FT_Int first = 0;
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points-1;
- if (outline->n_contours > 1)
+
+ if ( outline->n_contours > 1 )
{
- first = outline->contours[outline->n_contours-2]+1;
+ first = outline->contours[outline->n_contours - 2] + 1;
p1 = outline->points + first;
}
@@ -333,49 +359,50 @@
}
if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours-1] = outline->n_points-1;
+ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
}
-/*********************************************************************
- *
- * <Function>
- * lookup_glyph_by_stdcharcode
- *
- * <Description>
- * Lookup a given glyph by its StandardEncoding charcode. Used
- * to implement the SEAC Type 1 operator.
- *
- * <Input>
- * face :: current face object
- * charcode :: charcode to look for
- *
- * <Return>
- * glyph index in font face. Returns -1 if the corresponding
- * glyph wasn't found.
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* lookup_glyph_by_stdcharcode */
+ /* */
+ /* <Description> */
+ /* Looks up a given glyph by its StandardEncoding charcode. Used */
+ /* to implement the SEAC Type 1 operator. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* charcode :: The character code to look for. */
+ /* */
+ /* <Return> */
+ /* A glyph index in the font face. Returns -1 if the corresponding */
+ /* glyph wasn't found. */
+ /* */
static
- FT_Int lookup_glyph_by_stdcharcode( T1_Face face,
- FT_Int charcode )
+ FT_Int lookup_glyph_by_stdcharcode( T1_Face face,
+ FT_Int charcode )
{
FT_Int n;
const FT_String* glyph_name;
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
+
/* check range of standard char code */
- if (charcode < 0 || charcode > 255)
+ if ( charcode < 0 || charcode > 255 )
return -1;
glyph_name = psnames->adobe_std_strings(
- psnames->adobe_std_encoding[charcode]);
+ psnames->adobe_std_encoding[charcode]);
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
FT_String* name = (FT_String*)face->type1.glyph_names[n];
- if ( name && strcmp(name,glyph_name) == 0 )
+
+ if ( name && strcmp( name,glyph_name ) == 0 )
return n;
}
@@ -383,28 +410,30 @@
}
-
-/*********************************************************************
- *
- * <Function>
- * t1operator_seac
- *
- * <Description>
- * Implements the "seac" Type 1 operator for a Type 1 decoder
- *
- * <Input>
- * decoder :: current Type 1 decoder
- * asb :: accent's side bearing
- * adx :: horizontal position of accent
- * ady :: vertical position of accent
- * bchar :: base character's StandardEncoding charcode
- * achar :: accent character's StandardEncoding charcode
- *
- * <Return>
- * Error code. 0 means success.
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1operator_seac */
+ /* */
+ /* <Description> */
+ /* Implements the `seac' Type 1 operator for a Type 1 decoder. */
+ /* */
+ /* <Input> */
+ /* decoder :: The current CID decoder. */
+ /* */
+ /* asb :: The accent's side bearing. */
+ /* */
+ /* adx :: The horizontal offset of the accent. */
+ /* */
+ /* ady :: The vertical offset of the accent. */
+ /* */
+ /* bchar :: The base character's StandardEncoding charcode. */
+ /* */
+ /* achar :: The accent character's StandardEncoding charcode. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
static
FT_Error t1operator_seac( Z1_Decoder* decoder,
FT_Pos asb,
@@ -421,12 +450,14 @@
T1_Face face = decoder->builder.face;
T1_Font* type1 = &face->type1;
+
bchar_index = lookup_glyph_by_stdcharcode( face, bchar );
achar_index = lookup_glyph_by_stdcharcode( face, achar );
if ( bchar_index < 0 || achar_index < 0 )
{
- FT_ERROR(( "t1operator_seac: invalid seac character code arguments\n" ));
+ FT_ERROR(( "t1operator_seac:" ));
+ FT_ERROR(( " invalid seac character code arguments\n" ));
return T1_Err_Syntax_Error;
}
@@ -434,14 +465,15 @@
/* accent character and return the array of subglyphs. */
if ( decoder->builder.no_recurse )
{
-
- FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
+ FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
FT_GlyphLoader* loader = glyph->loader;
FT_SubGlyph* subg;
+
/* reallocate subglyph array if necessary */
error = FT_GlyphLoader_Check_Subglyphs( loader, 2 );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
subg = loader->current.subglyphs;
@@ -478,91 +510,103 @@
type1->num_subrs,
type1->subrs,
type1->subrs_len );
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
n_base_points = cur->n_points;
- {
- /* save the left bearing and width of the base character */
- /* as they will be erased by the next load. */
+ /* save the left bearing and width of the base character */
+ /* as they will be erased by the next load. */
- left_bearing = decoder->builder.left_bearing;
- advance = decoder->builder.advance;
+ left_bearing = decoder->builder.left_bearing;
+ advance = decoder->builder.advance;
- decoder->builder.left_bearing.x = 0;
- decoder->builder.left_bearing.y = 0;
+ decoder->builder.left_bearing.x = 0;
+ decoder->builder.left_bearing.y = 0;
- /* Now load `achar' on top of */
- /* the base outline */
- error = Z1_Parse_CharStrings( decoder,
- type1->charstrings [achar_index],
- type1->charstrings_len[achar_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- if ( error ) return error;
+ /* Now load `achar' on top of */
+ /* the base outline */
+ error = Z1_Parse_CharStrings( decoder,
+ type1->charstrings [achar_index],
+ type1->charstrings_len[achar_index],
+ type1->num_subrs,
+ type1->subrs,
+ type1->subrs_len );
+ if ( error )
+ return error;
- /* restore the left side bearing and */
- /* advance width of the base character */
+ /* restore the left side bearing and */
+ /* advance width of the base character */
- decoder->builder.left_bearing = left_bearing;
- decoder->builder.advance = advance;
+ decoder->builder.left_bearing = left_bearing;
+ decoder->builder.advance = advance;
- /* Finally, move the accent */
- if ( decoder->builder.load_points )
- {
- FT_Outline dummy;
+ /* Finally, move the accent */
+ if ( decoder->builder.load_points )
+ {
+ FT_Outline dummy;
+
- dummy.n_points = base->n_points - n_base_points;
- dummy.points = base->points + n_base_points;
- FT_Outline_Translate( &dummy, adx - asb, ady );
- }
+ dummy.n_points = base->n_points - n_base_points;
+ dummy.points = base->points + n_base_points;
+ FT_Outline_Translate( &dummy, adx - asb, ady );
}
+
Exit:
return error;
}
-/*********************************************************************
- *
- * <Function>
- * Z1_Parse_CharStrings
- *
- * <Description>
- * Parses a given Type 1 charstrings program
- *
- * <Input>
- * decoder :: current Type 1 decoder
- * charstring_base :: base of the charstring stream
- * charstring_len :: length in bytes of the charstring stream
- * num_subrs :: number of sub-routines
- * subrs_base :: array of sub-routines addresses
- * subrs_len :: array of sub-routines lengths
- *
- * <Return>
- * Error code. 0 means success.
- *
- *********************************************************************/
+#define USE_ARGS( n ) do \
+ { \
+ top -= n; \
+ if ( top < decoder->stack ) \
+ goto Stack_Underflow; \
+ } while ( 0 )
-#define USE_ARGS(n) top -= n; if (top < decoder->stack) goto Stack_Underflow
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Parse_CharStrings */
+ /* */
+ /* <Description> */
+ /* Parses a given Type 1 charstrings program. */
+ /* */
+ /* <Input> */
+ /* decoder :: The current Type 1 decoder. */
+ /* */
+ /* charstring_base :: The base address of the charstring stream. */
+ /* */
+ /* charstring_len :: The length in bytes of the charstring stream. */
+ /* */
+ /* num_subrs :: The number of sub-routines. */
+ /* */
+ /* subrs_base :: An array of sub-routines addresses. */
+ /* */
+ /* subrs_len :: An array of sub-routines lengths. */
+ /* */
+ /* <Return> */
+ /* Free error code. 0 means success. */
+ /* */
LOCAL_FUNC
- FT_Error Z1_Parse_CharStrings( Z1_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_Int charstring_len,
- FT_Int num_subrs,
- FT_Byte** subrs_base,
- FT_Int* subrs_len )
+ FT_Error Z1_Parse_CharStrings( Z1_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_Int charstring_len,
+ FT_Int num_subrs,
+ FT_Byte** subrs_base,
+ FT_Int* subrs_len )
{
- FT_Error error;
- Z1_Decoder_Zone* zone;
- FT_Byte* ip;
- FT_Byte* limit;
- Z1_Builder* builder = &decoder->builder;
- FT_Outline* outline;
- FT_Pos x, y;
+ FT_Error error;
+ Z1_Decoder_Zone* zone;
+ FT_Byte* ip;
+ FT_Byte* limit;
+ Z1_Builder* builder = &decoder->builder;
+ FT_Outline* outline;
+ FT_Pos x, y;
- /* First of all, initialise the decoder */
+
+ /* First of all, initialize the decoder */
decoder->top = decoder->stack;
decoder->zone = decoder->zones;
zone = decoder->zones;
@@ -582,125 +626,174 @@
/* now, execute loop */
while ( ip < limit )
{
- FT_Int* top = decoder->top;
- Z1_Operator op = op_none;
- FT_Long value = 0;
+ FT_Int* top = decoder->top;
+ Z1_Operator op = op_none;
+ FT_Long value = 0;
- /********************************************************************/
- /* */
- /* Decode operator or operand */
- /* */
- /* */
- /* First of all, decompress operator or value */
- switch (*ip++)
+ /*********************************************************************/
+ /* */
+ /* Decode operator or operand */
+ /* */
+ /* */
+
+ /* first of all, decompress operator or value */
+ switch ( *ip++ )
{
- case 1: op = op_hstem; break;
+ case 1:
+ op = op_hstem;
+ break;
- case 3: op = op_vstem; break;
- case 4: op = op_vmoveto; break;
- case 5: op = op_rlineto; break;
- case 6: op = op_hlineto; break;
- case 7: op = op_vlineto; break;
- case 8: op = op_rrcurveto; break;
- case 9: op = op_closepath; break;
- case 10: op = op_callsubr; break;
- case 11: op = op_return; break;
+ case 3:
+ op = op_vstem;
+ break;
+ case 4:
+ op = op_vmoveto;
+ break;
+ case 5:
+ op = op_rlineto;
+ break;
+ case 6:
+ op = op_hlineto;
+ break;
+ case 7:
+ op = op_vlineto;
+ break;
+ case 8:
+ op = op_rrcurveto;
+ break;
+ case 9:
+ op = op_closepath;
+ break;
+ case 10:
+ op = op_callsubr;
+ break;
+ case 11:
+ op = op_return;
+ break;
- case 13: op = op_hsbw; break;
- case 14: op = op_endchar; break;
+ case 13:
+ op = op_hsbw;
+ break;
+ case 14:
+ op = op_endchar;
+ break;
- case 21: op = op_rmoveto; break;
- case 22: op = op_hmoveto; break;
+ case 21:
+ op = op_rmoveto;
+ break;
+ case 22:
+ op = op_hmoveto;
+ break;
- case 30: op = op_vhcurveto; break;
- case 31: op = op_hvcurveto; break;
+ case 30:
+ op = op_vhcurveto;
+ break;
+ case 31:
+ op = op_hvcurveto;
+ break;
- case 12:
- {
- if (ip > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+EOF)\n" ));
- goto Syntax_Error;
- }
+ case 12:
+ if ( ip > limit )
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid escape (12+EOF)\n" ));
+ goto Syntax_Error;
+ }
- switch (*ip++)
- {
- case 0: op = op_dotsection; break;
- case 1: op = op_vstem3; break;
- case 2: op = op_hstem3; break;
- case 6: op = op_seac; break;
- case 7: op = op_sbw; break;
- case 12: op = op_div; break;
- case 16: op = op_callothersubr; break;
- case 17: op = op_pop; break;
- case 33: op = op_setcurrentpoint; break;
-
- default:
- FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
- }
+ switch ( *ip++ )
+ {
+ case 0:
+ op = op_dotsection;
break;
+ case 1:
+ op = op_vstem3;
+ break;
+ case 2:
+ op = op_hstem3;
+ break;
+ case 6:
+ op = op_seac;
+ break;
+ case 7:
+ op = op_sbw;
+ break;
+ case 12:
+ op = op_div;
+ break;
+ case 16:
+ op = op_callothersubr;
+ break;
+ case 17:
+ op = op_pop;
+ break;
+ case 33:
+ op = op_setcurrentpoint;
+ break;
- case 255: /* four bytes integer */
- {
- if (ip+4 > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
+ default:
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid escape (12+%d)\n",
+ ip[-1] ));
+ goto Syntax_Error;
+ }
+ break;
- value = ((long)ip[0] << 24) |
- ((long)ip[1] << 16) |
- ((long)ip[2] << 8) |
+ case 255: /* four bytes integer */
+ if ( ip + 4 > limit )
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: unexpected EOF in integer\n" ));
+ goto Syntax_Error;
+ }
+
+ value = ( (FT_Long)ip[0] << 24 ) |
+ ( (FT_Long)ip[1] << 16 ) |
+ ( (FT_Long)ip[2] << 8 ) |
ip[3];
- ip += 4;
- }
- break;
+ ip += 4;
+ break;
- default:
- if (ip[-1] >= 32)
+ default:
+ if ( ip[-1] >= 32 )
+ {
+ if ( ip[-1] < 247 )
+ value = (FT_Long)ip[-1] - 139;
+ else
{
- if (ip[-1] < 247)
- value = (long)ip[-1] - 139;
- else
+ if ( ++ip > limit )
{
- if (++ip > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- if (ip[-2] < 251)
- value = ((long)(ip[-2]-247) << 8) + ip[-1] + 108;
- else
- value = -((((long)ip[-2]-251) << 8) + ip[-1] + 108 );
+ FT_ERROR(( "Z1_Parse_CharStrings:" ));
+ FT_ERROR(( " unexpected EOF in integer\n" ));
+ goto Syntax_Error;
}
- }
+
+ if ( ip[-2] < 251 )
+ value = ( (FT_Long)( ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
else
- {
- FT_ERROR(( "T1.Parse_CharStrings : invalid byte (%d)\n",
- ip[-1] ));
- goto Syntax_Error;
+ value = -( ( ( (FT_Long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
}
+ }
+ else
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid byte (%d)\n",
+ ip[-1] ));
+ goto Syntax_Error;
+ }
}
- /********************************************************************/
- /* */
- /* Push value on stack, or process operator */
- /* */
- /* */
+ /*********************************************************************/
+ /* */
+ /* Push value on stack, or process operator */
+ /* */
+ /* */
if ( op == op_none )
{
if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
{
- FT_ERROR(( "T1.Parse_CharStrings : Stack overflow !!\n" ));
+ FT_ERROR(( "Z1_Parse_CharStrings: stack overflow!\n" ));
goto Syntax_Error;
}
FT_TRACE4(( " %ld", value ));
+
*top++ = value;
decoder->top = top;
}
@@ -707,6 +800,7 @@
else if ( op == op_callothersubr ) /* callothersubr */
{
FT_TRACE4(( " callothersubr" ));
+
if ( top - decoder->stack < 2 )
goto Stack_Underflow;
@@ -713,154 +807,156 @@
top -= 2;
switch ( top[1] )
{
- case 1: /* start flex feature ---------------------- */
- {
- if ( top[0] != 0 ) goto Unexpected_OtherSubr;
+ case 1: /* start flex feature */
+ if ( top[0] != 0 )
+ goto Unexpected_OtherSubr;
- decoder->flex_state = 1;
- decoder->num_flex_vectors = 0;
- if ( start_point(builder, x, y) ||
- check_points(builder,6) ) goto Memory_Error;
- }
- break;
+ decoder->flex_state = 1;
+ decoder->num_flex_vectors = 0;
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 6 ) )
+ goto Memory_Error;
+ break;
- case 2: /* add flex vectors ------------------------ */
- {
- FT_Int index;
+ case 2: /* add flex vectors */
+ {
+ FT_Int index;
- if ( top[0] != 0 ) goto Unexpected_OtherSubr;
+ if ( top[0] != 0 )
+ goto Unexpected_OtherSubr;
- /* note that we should not add a point for index 0 */
- /* this will move our current position to the flex */
- /* point without adding any point to the outline */
- index = decoder->num_flex_vectors++;
- if (index > 0 && index < 7)
- add_point( builder,
- x,
- y,
- (FT_Byte)( index==3 || index==6 ) );
- }
- break;
+ /* note that we should not add a point for index 0; */
+ /* this will move our current position to the flex */
+ /* point without adding any point to the outline */
+ index = decoder->num_flex_vectors++;
+ if ( index > 0 && index < 7 )
+ add_point( builder,
+ x,
+ y,
+ (FT_Byte)( index == 3 || index == 6 ) );
+ }
+ break;
- case 0: /* end flex feature ------------------------- */
- {
- if ( top[0] != 3 ) goto Unexpected_OtherSubr;
+ case 0: /* end flex feature */
+ if ( top[0] != 3 )
+ goto Unexpected_OtherSubr;
- if ( decoder->flex_state == 0 ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "T1.Parse_CharStrings: unexpected flex end\n" ));
- goto Syntax_Error;
- }
+ if ( decoder->flex_state == 0 ||
+ decoder->num_flex_vectors != 7 )
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: unexpected flex end\n" ));
+ goto Syntax_Error;
+ }
- /* now consume the remaining "pop pop setcurpoint" */
- if ( ip+6 > limit ||
- ip[0] != 12 || ip[1] != 17 || /* pop */
- ip[2] != 12 || ip[3] != 17 || /* pop */
- ip[4] != 12 || ip[5] != 33 ) /* setcurpoint */
- {
- FT_ERROR(( "T1.Parse_CharStrings: invalid flex charstring\n" ));
- goto Syntax_Error;
- }
+ /* now consume the remaining `pop pop setcurpoint' */
+ if ( ip + 6 > limit ||
+ ip[0] != 12 || ip[1] != 17 || /* pop */
+ ip[2] != 12 || ip[3] != 17 || /* pop */
+ ip[4] != 12 || ip[5] != 33 ) /* setcurpoint */
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid flex charstring\n" ));
+ goto Syntax_Error;
+ }
- ip += 6;
- decoder->flex_state = 0;
- break;
- }
+ ip += 6;
+ decoder->flex_state = 0;
+ break;
- case 3: /* change hints ---------------------------- */
- {
- if ( top[0] != 1 ) goto Unexpected_OtherSubr;
+ case 3: /* change hints */
+ if ( top[0] != 1 )
+ goto Unexpected_OtherSubr;
- /* eat the following "pop" */
- if (ip+2 > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings: invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
+ /* eat the following `pop' */
+ if ( ip + 2 > limit )
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid escape (12+%d)\n",
+ ip[-1] ));
+ goto Syntax_Error;
+ }
- if (ip[0] != 12 || ip[1] != 17)
- {
- FT_ERROR(( "T1.Parse_CharStrings: 'pop' expected, found (%d %d)\n",
- ip[0], ip[1] ));
- goto Syntax_Error;
- }
- ip += 2;
- break;;
- }
+ if ( ip[0] != 12 || ip[1] != 17 )
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings:" ));
+ FT_ERROR(( " `pop' expected, found (%d %d)\n",
+ ip[0], ip[1] ));
+ goto Syntax_Error;
+ }
+ ip += 2;
+ break;
- case 12:
- case 13:
+ case 12:
+ case 13:
+ /* counter control hints, clear stack */
+ top = decoder->stack;
+ break;
+
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18: /* multiple masters */
+ {
+ T1_Blend* blend = decoder->blend;
+ FT_UInt num_points, nn, mm;
+ FT_Int* delta;
+ FT_Int* values;
+
+
+ if ( !blend )
{
- /* counter control hints, clear stack */
- top = decoder->stack;
- break;
+ FT_ERROR(( "Z1_Parse_CharStrings:" ));
+ FT_ERROR(( " unexpected multiple masters operator!\n" ));
+ goto Syntax_Error;
}
-
- case 14:
- case 15:
- case 16:
- case 17:
- case 18: /* multiple masters */
+
+ num_points = top[1] - 13 + ( top[1] == 18 );
+ if ( top[0] != (FT_Int)( num_points * blend->num_designs ) )
{
- T1_Blend* blend = decoder->blend;
- FT_UInt num_points, nn, mm;
- FT_Int* delta;
- FT_Int* values;
+ FT_ERROR(( "Z1_Parse_CharStrings:" ));
+ FT_ERROR(( " incorrect number of mm arguments\n" ));
+ goto Syntax_Error;
+ }
- if (!blend)
- {
- FT_ERROR(( "T1.Parse_CharStrings: unexpected multiple masters operator !!\n" ));
- goto Syntax_Error;
- }
-
- num_points = top[1] - 13 + (top[1] == 18);
- if (top[0] != (FT_Int)(num_points*blend->num_designs))
- {
- FT_ERROR(( "T1.Parse_CharStrings: incorrect number of mm arguments\n" ));
- goto Syntax_Error;
- }
-
- top -= blend->num_designs*num_points;
- if (top < decoder->stack)
- goto Stack_Underflow;
+ top -= blend->num_designs*num_points;
+ if ( top < decoder->stack )
+ goto Stack_Underflow;
- /* we want to compute: */
- /* */
- /* a0*w0 + a1*w1 + ... + ak*wk */
- /* */
- /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */
- /* however, given that w0 + w1 + ... + wk == 1, we can */
- /* rewrite it easily as: */
- /* */
- /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */
- /* */
- /* where k == num_designs-1 */
- /* */
- /* I guess that's why it's written in this "compact" */
- /* form.. */
- /* */
- /* */
- delta = top + num_points;
- values = top;
- for ( nn = 0; nn < num_points; nn++ )
- {
- FT_Int x = values[0];
- for ( mm = 1; mm < blend->num_designs; mm++ )
- x += FT_MulFix( *delta++, blend->weight_vector[mm] );
+ /* we want to compute: */
+ /* */
+ /* a0*w0 + a1*w1 + ... + ak*wk */
+ /* */
+ /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */
+ /* however, given that w0 + w1 + ... + wk == 1, we can */
+ /* rewrite it easily as: */
+ /* */
+ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */
+ /* */
+ /* where k == num_designs-1 */
+ /* */
+ /* I guess that's why it's written in this `compact' */
+ /* form. */
+ /* */
+ delta = top + num_points;
+ values = top;
+ for ( nn = 0; nn < num_points; nn++ )
+ {
+ FT_Int x = values[0];
- *values++ = x;
- }
- /* note that "top" will be incremented later by calls to "pop" */
- break;
+
+ for ( mm = 1; mm < blend->num_designs; mm++ )
+ x += FT_MulFix( *delta++, blend->weight_vector[mm] );
+
+ *values++ = x;
}
+ /* note that `top' will be incremented later by calls to `pop' */
+ break;
+ }
- default:
- Unexpected_OtherSubr:
- FT_ERROR(( "T1.Parse_CharStrings: invalid othersubr [%d %d]!!\n",
- top[0], top[1] ));
- goto Syntax_Error;
+ default:
+ Unexpected_OtherSubr:
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid othersubr [%d %d]!\n",
+ top[0], top[1] ));
+ goto Syntax_Error;
}
decoder->top = top;
}
@@ -868,226 +964,210 @@
{
FT_Int num_args = t1_args_count[op];
+
if ( top - decoder->stack < num_args )
goto Stack_Underflow;
top -= num_args;
- switch (op)
+ switch ( op )
{
- case op_endchar: /*************************************************/
- {
- FT_TRACE4(( " endchar" ));
- close_contour( builder );
+ case op_endchar:
+ FT_TRACE4(( " endchar" ));
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
+ close_contour( builder );
- /* return now !! */
- FT_TRACE4(( "\n\n" ));
- return T1_Err_Ok;
- }
+ /* add current outline to the glyph slot */
+ FT_GlyphLoader_Add( builder->loader );
+ /* return now! */
+ FT_TRACE4(( "\n\n" ));
+ return T1_Err_Ok;
- case op_hsbw: /****************************************************/
- {
- FT_TRACE4(( " hsbw" ));
- builder->left_bearing.x += top[0];
- builder->advance.x = top[1];
- builder->advance.y = 0;
+ case op_hsbw:
+ FT_TRACE4(( " hsbw" ));
- builder->last.x = x = top[0];
- builder->last.y = y = 0;
+ builder->left_bearing.x += top[0];
+ builder->advance.x = top[1];
+ builder->advance.y = 0;
- /* the "metrics_only" indicates that we only want to compute */
- /* the glyph's metrics (lsb + advance width), not load the */
- /* rest of it.. so exit immediately */
- if (builder->metrics_only)
- return T1_Err_Ok;
+ builder->last.x = x = top[0];
+ builder->last.y = y = 0;
- break;
- }
+ /* the `metrics_only' indicates that we only want to compute */
+ /* the glyph's metrics (lsb + advance width), not load the */
+ /* rest of it; so exit immediately */
+ if ( builder->metrics_only )
+ return T1_Err_Ok;
+ break;
- case op_seac: /****************************************************/
- /* return immediately after the processing */
- return t1operator_seac( decoder, top[0], top[1],
- top[2], top[3], top[4] );
+ case op_seac:
+ /* return immediately after the processing */
+ return t1operator_seac( decoder, top[0], top[1],
+ top[2], top[3], top[4] );
- case op_sbw: /****************************************************/
- {
- FT_TRACE4(( " sbw" ));
- builder->left_bearing.x += top[0];
- builder->left_bearing.y += top[1];
- builder->advance.x = top[2];
- builder->advance.y = top[3];
+ case op_sbw:
+ FT_TRACE4(( " sbw" ));
- builder->last.x = x = top[0];
- builder->last.y = y = top[1];
+ builder->left_bearing.x += top[0];
+ builder->left_bearing.y += top[1];
+ builder->advance.x = top[2];
+ builder->advance.y = top[3];
- /* the "metrics_only" indicates that we only want to compute */
- /* the glyph's metrics (lsb + advance width), not load the */
- /* rest of it.. so exit immediately */
- if (builder->metrics_only)
- return T1_Err_Ok;
+ builder->last.x = x = top[0];
+ builder->last.y = y = top[1];
- break;
- }
+ /* the `metrics_only' indicates that we only want to compute */
+ /* the glyph's metrics (lsb + advance width), not load the */
+ /* rest of it; so exit immediately */
+ if ( builder->metrics_only )
+ return T1_Err_Ok;
+ break;
- case op_closepath: /**********************************************/
- {
- FT_TRACE4(( " closepath" ));
- close_contour( builder );
- builder->path_begun = 0;
- }
+ case op_closepath:
+ FT_TRACE4(( " closepath" ));
+
+ close_contour( builder );
+ builder->path_begun = 0;
break;
+ case op_hlineto:
+ FT_TRACE4(( " hlineto" ));
- case op_hlineto: /************************************************/
- {
- FT_TRACE4(( " hlineto" ));
- if ( start_point( builder, x, y ) ) goto Memory_Error;
+ if ( start_point( builder, x, y ) )
+ goto Memory_Error;
- x += top[0];
- goto Add_Line;
- }
+ x += top[0];
+ goto Add_Line;
+ case op_hmoveto:
+ FT_TRACE4(( " hmoveto" ));
- case op_hmoveto: /************************************************/
- {
- FT_TRACE4(( " hmoveto" ));
- x += top[0];
- break;
- }
+ x += top[0];
+ break;
+ case op_hvcurveto:
+ FT_TRACE4(( " hvcurveto" ));
- case op_hvcurveto: /**********************************************/
- {
- FT_TRACE4(( " hvcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) ) goto Memory_Error;
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 3 ) )
+ goto Memory_Error;
- x += top[0];
- add_point( builder, x, y, 0 );
- x += top[1];
- y += top[2];
- add_point( builder, x, y, 0 );
- y += top[3];
- add_point( builder, x, y, 1 );
- break;
- }
+ x += top[0];
+ add_point( builder, x, y, 0 );
+ x += top[1];
+ y += top[2];
+ add_point( builder, x, y, 0 );
+ y += top[3];
+ add_point( builder, x, y, 1 );
+ break;
+ case op_rlineto:
+ FT_TRACE4(( " rlineto" ));
- case op_rlineto: /*************************************************/
- {
- FT_TRACE4(( " rlineto" ));
- if ( start_point( builder, x, y ) ) goto Memory_Error;
+ if ( start_point( builder, x, y ) )
+ goto Memory_Error;
- x += top[0];
- y += top[1];
- Add_Line:
- if (add_point1( builder, x, y )) goto Memory_Error;
- break;
- }
+ x += top[0];
+ y += top[1];
+ Add_Line:
+ if ( add_point1( builder, x, y ) )
+ goto Memory_Error;
+ break;
- case op_rmoveto: /*************************************************/
- {
- FT_TRACE4(( " rmoveto" ));
- x += top[0];
- y += top[1];
- break;
- }
+ case op_rmoveto:
+ FT_TRACE4(( " rmoveto" ));
- case op_rrcurveto: /***********************************************/
- {
- FT_TRACE4(( " rcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) ) goto Memory_Error;
+ x += top[0];
+ y += top[1];
+ break;
- x += top[0];
- y += top[1];
- add_point( builder, x, y, 0 );
+ case op_rrcurveto:
+ FT_TRACE4(( " rcurveto" ));
- x += top[2];
- y += top[3];
- add_point( builder, x, y, 0 );
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 3 ) )
+ goto Memory_Error;
- x += top[4];
- y += top[5];
- add_point( builder, x, y, 1 );
- break;
- }
+ x += top[0];
+ y += top[1];
+ add_point( builder, x, y, 0 );
+ x += top[2];
+ y += top[3];
+ add_point( builder, x, y, 0 );
- case op_vhcurveto: /**********************************************/
- {
- FT_TRACE4(( " vhcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) ) goto Memory_Error;
+ x += top[4];
+ y += top[5];
+ add_point( builder, x, y, 1 );
+ break;
- y += top[0];
- add_point( builder, x, y, 0 );
- x += top[1];
- y += top[2];
- add_point( builder, x, y, 0 );
- x += top[3];
- add_point( builder, x, y, 1 );
- break;
- }
+ case op_vhcurveto:
+ FT_TRACE4(( " vhcurveto" ));
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, 3 ) )
+ goto Memory_Error;
- case op_vlineto: /************************************************/
- {
- FT_TRACE4(( " vlineto" ));
- if ( start_point( builder, x, y ) ) goto Memory_Error;
+ y += top[0];
+ add_point( builder, x, y, 0 );
+ x += top[1];
+ y += top[2];
+ add_point( builder, x, y, 0 );
+ x += top[3];
+ add_point( builder, x, y, 1 );
+ break;
- y += top[0];
- goto Add_Line;
- }
+ case op_vlineto:
+ FT_TRACE4(( " vlineto" ));
+ if ( start_point( builder, x, y ) )
+ goto Memory_Error;
- case op_vmoveto: /************************************************/
- {
- FT_TRACE4(( " vmoveto" ));
- y += top[0];
- break;
- }
+ y += top[0];
+ goto Add_Line;
+ case op_vmoveto:
+ FT_TRACE4(( " vmoveto" ));
- case op_div: /****************************************************/
+ y += top[0];
+ break;
+
+ case op_div:
+ FT_TRACE4(( " div" ));
+
+ if ( top[1] )
{
- FT_TRACE4(( " div" ));
- if (top[1])
- {
- *top = top[0] / top[1];
- ++top;
- }
- else
- {
- FT_ERROR(( "T1.Parse_CharStrings : division by 0\n" ));
- goto Syntax_Error;
- }
- break;
+ *top = top[0] / top[1];
+ ++top;
}
+ else
+ {
+ FT_ERROR(( "Z1_Parse_CharStrings: division by 0\n" ));
+ goto Syntax_Error;
+ }
+ break;
-
- case op_callsubr: /***********************************************/
+ case op_callsubr:
{
FT_Int index;
+
FT_TRACE4(( " callsubr" ));
+
index = top[0];
if ( index < 0 || index >= num_subrs )
{
- FT_ERROR(( "T1.Parse_CharStrings : invalid subrs index\n" ));
+ FT_ERROR(( "Z1_Parse_CharStrings: invalid subrs index\n" ));
goto Syntax_Error;
}
if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
{
- FT_ERROR(( "T1.Parse_CharStrings : too many nested subrs\n" ));
+ FT_ERROR(( "Z1_Parse_CharStrings: too many nested subrs\n" ));
goto Syntax_Error;
}
@@ -1094,13 +1174,13 @@
zone->cursor = ip; /* save current instruction pointer */
zone++;
- zone->base = subrs_base[index];
- zone->limit = zone->base + subrs_len[index];
- zone->cursor = zone->base;
+ zone->base = subrs_base[index];
+ zone->limit = zone->base + subrs_len[index];
+ zone->cursor = zone->base;
- if (!zone->base)
+ if ( !zone->base )
{
- FT_ERROR(( "T1.Parse_CharStrings : invoking empty subrs !!\n" ));
+ FT_ERROR(( "Z1_Parse_CharStrings: invoking empty subrs!\n" ));
goto Syntax_Error;
}
@@ -1110,72 +1190,63 @@
break;
}
+ case op_pop:
+ FT_TRACE4(( " pop" ));
- case op_pop: /****************************************************/
+ /* theorically, the arguments are already on the stack */
+ top++;
+ break;
+
+ case op_return:
+ FT_TRACE4(( " return" ));
+
+ if ( zone <= decoder->zones )
{
- FT_TRACE4(( " pop" ));
- /* theorically, the arguments are already on the stack */
- top++;
- break;
+ FT_ERROR(( "Z1_Parse_CharStrings: unexpected return\n" ));
+ goto Syntax_Error;
}
+ zone--;
+ ip = zone->cursor;
+ limit = zone->limit;
+ decoder->zone = zone;
+ break;
- case op_return: /************************************************/
- {
- FT_TRACE4(( " return" ));
- if ( zone <= decoder->zones )
- {
- FT_ERROR(( "T1.Parse_CharStrings : unexpected return\n" ));
- goto Syntax_Error;
- }
+ case op_dotsection:
+ FT_TRACE4(( " dotsection" ));
- zone--;
- ip = zone->cursor;
- limit = zone->limit;
- decoder->zone = zone;
- break;
- }
+ break;
- case op_dotsection: /*********************************************/
- {
- FT_TRACE4(( " dotsection" ));
- break;
- }
+ case op_hstem:
+ FT_TRACE4(( " hstem" ));
- case op_hstem: /**************************************************/
- {
- FT_TRACE4(( " hstem" ));
- break;
- }
+ break;
- case op_hstem3: /*************************************************/
- {
- FT_TRACE4(( " hstem3" ));
- break;
- }
+ case op_hstem3:
+ FT_TRACE4(( " hstem3" ));
- case op_vstem: /**************************************************/
- {
- FT_TRACE4(( " vstem" ));
- break;
- }
+ break;
- case op_vstem3: /*************************************************/
- {
- FT_TRACE4(( " vstem3" ));
- break;
- }
+ case op_vstem:
+ FT_TRACE4(( " vstem" ));
- case op_setcurrentpoint: /*****************************************/
- {
- FT_TRACE4(( " setcurrentpoint" ));
- FT_ERROR(( "T1.Parse_CharStrings : unexpected SETCURRENTPOINT\n" ));
- goto Syntax_Error;
- }
+ break;
- default:
- FT_ERROR(( "T1.Parse_CharStrings : unhandled opcode %d\n", op ));
- goto Syntax_Error;
+ case op_vstem3:
+ FT_TRACE4(( " vstem3" ));
+
+ break;
+
+ case op_setcurrentpoint:
+ FT_TRACE4(( " setcurrentpoint" ));
+
+ FT_ERROR(( "Z1_Parse_CharStrings:" ));
+ FT_ERROR(( " unexpected `setcurrentpoint'\n" ));
+ goto Syntax_Error;
+
+ default:
+ FT_ERROR(( "Z1_Parse_CharStrings: unhandled opcode %d\n", op ));
+ goto Syntax_Error;
}
decoder->top = top;
@@ -1182,8 +1253,8 @@
} /* general operator processing */
-
} /* while ip < limit */
+
FT_TRACE4(( "..end..\n\n" ));
return error;
@@ -1198,27 +1269,26 @@
}
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
+ /********** *********/
+ /********** The following code is in charge of computing *********/
+ /********** the maximum advance width of the font. It *********/
+ /********** quickly processes each glyph charstring to *********/
+ /********** extract the value from either a `sbw' or `seac' *********/
+ /********** operator. *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly process each glyph charstring to *********/
- /********** extract the value from either a "sbw" or "seac" *********/
- /********** operator. *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
LOCAL_FUNC
FT_Error Z1_Compute_Max_Advance( T1_Face face,
- FT_Int *max_advance )
+ FT_Int* max_advance )
{
FT_Error error;
Z1_Decoder decoder;
@@ -1225,9 +1295,10 @@
FT_Int glyph_index;
T1_Font* type1 = &face->type1;
+
*max_advance = 0;
- /* Initialise load decoder */
+ /* Initialize load decoder */
Z1_Init_Decoder( &decoder );
Z1_Init_Builder( &decoder.builder, face, 0, 0 );
@@ -1235,8 +1306,8 @@
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
- /* For each glyph, parse the glyph charstring and extract */
- /* the advance width.. */
+ /* for each glyph, parse the glyph charstring and extract */
+ /* the advance width */
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
{
/* now get load the unscaled outline */
@@ -1254,20 +1325,21 @@
}
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** UNHINTED GLYPH LOADER *********/
- /********** *********/
- /********** The following code is in charge of loading a *********/
- /********** single outline. It completely ignores hinting *********/
- /********** and is used when FT_LOAD_NO_HINTING is set. *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** UNHINTED GLYPH LOADER *********/
+ /********** *********/
+ /********** The following code is in charge of loading a *********/
+ /********** single outline. It completely ignores hinting *********/
+ /********** and is used when FT_LOAD_NO_HINTING is set. *********/
+ /********** *********/
+ /********** The Type 1 hinter is located in `t1hint.c' *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
LOCAL_FUNC
@@ -1276,13 +1348,14 @@
FT_Int glyph_index,
FT_Int load_flags )
{
- FT_Error error;
- Z1_Decoder decoder;
- T1_Face face = (T1_Face)glyph->root.face;
- FT_Bool hinting;
- T1_Font* type1 = &face->type1;
+ FT_Error error;
+ Z1_Decoder decoder;
+ T1_Face face = (T1_Face)glyph->root.face;
+ FT_Bool hinting;
+ T1_Font* type1 = &face->type1;
- if (load_flags & FT_LOAD_NO_RECURSE)
+
+ if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
glyph->x_scale = size->root.metrics.x_scale;
@@ -1296,32 +1369,30 @@
glyph->root.format = ft_glyph_format_outline;
- {
- Z1_Init_Decoder( &decoder );
- Z1_Init_Builder( &decoder.builder, face, size, glyph );
+ Z1_Init_Decoder( &decoder );
+ Z1_Init_Builder( &decoder.builder, face, size, glyph );
- decoder.blend = ((T1_Face)glyph->root.face)->blend;
- decoder.builder.no_recurse = (FT_Bool)!!(load_flags & FT_LOAD_NO_RECURSE);
+ decoder.blend = ((T1_Face)glyph->root.face)->blend;
+ decoder.builder.no_recurse = ( load_flags & FT_LOAD_NO_RECURSE ) != 0;
- /* now load the unscaled outline */
- error = Z1_Parse_CharStrings( &decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
+ /* now load the unscaled outline */
+ error = Z1_Parse_CharStrings( &decoder,
+ type1->charstrings [glyph_index],
+ type1->charstrings_len[glyph_index],
+ type1->num_subrs,
+ type1->subrs,
+ type1->subrs_len );
- /* save new glyph tables */
- Z1_Done_Builder( &decoder.builder );
- }
+ /* save new glyph tables */
+ Z1_Done_Builder( &decoder.builder );
- /* Now, set the metrics.. - this is rather simple, as : */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax.. */
- if (!error)
+ /* now, set the metrics -- this is rather simple, as */
+ /* the left side bearing is the xMin, and the top side */
+ /* bearing the yMax */
+ if ( !error )
{
- /* for composite glyphs, return only the left side bearing and the */
- /* advance width.. */
+ /* for composite glyphs, return only left side bearing and */
+ /* advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
@@ -1332,8 +1403,9 @@
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+
/* copy the _unscaled_ advance width */
- metrics->horiAdvance = decoder.builder.advance.x;
+ metrics->horiAdvance = decoder.builder.advance.x;
/* make up vertical metrics */
metrics->vertBearingX = 0;
@@ -1348,13 +1420,13 @@
glyph->root.outline.flags |= ft_outline_reverse_fill;
- /*
+#if 0
glyph->root.outline.second_pass = TRUE;
- glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
+ glyph->root.outline.high_precision = size->root.metrics.y_ppem < 24;
glyph->root.outline.dropout_mode = 2;
- */
+#endif /* 0 */
- if ( (load_flags & FT_LOAD_NO_SCALE) == 0 )
+ if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
/* scale the outline and the metrics */
FT_Int n;
@@ -1363,6 +1435,7 @@
FT_Fixed x_scale = glyph->x_scale;
FT_Fixed y_scale = glyph->y_scale;
+
/* First of all, scale the points */
for ( n = cur->n_points; n > 0; n--, vec++ )
{
@@ -1381,18 +1454,19 @@
}
/* apply the font matrix */
- FT_Outline_Transform( &glyph->root.outline, &face->type1.font_matrix );
+ FT_Outline_Transform( &glyph->root.outline,
+ &face->type1.font_matrix );
/* compute the other metrics */
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
/* grid fit the bounding box if necessary */
- if (hinting)
+ if ( hinting )
{
cbox.xMin &= -64;
cbox.yMin &= -64;
- cbox.xMax = ( cbox.xMax+63 ) & -64;
- cbox.yMax = ( cbox.yMax+63 ) & -64;
+ cbox.xMax = ( cbox.xMax+63 ) & -64;
+ cbox.yMax = ( cbox.yMax+63 ) & -64;
}
metrics->width = cbox.xMax - cbox.xMin;
@@ -1405,3 +1479,5 @@
return error;
}
+
+/* END */
--- a/src/type1z/z1gload.h
+++ b/src/type1z/z1gload.h
@@ -1,44 +1,33 @@
-/*******************************************************************
- *
- * t1gload.h 1.0
- *
- * Type1 Glyph Loader.
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- *
- * The Type 1 glyph loader uses three distinct objects to build
- * scaled and hinted outlines from a charstrings program. These are :
- *
- * - a glyph builder, Z1_Builder, used to store the built outline
- *
- * - a glyph hinter, Z1_Hinter, used to record and apply the stem
- * hints
- *
- * - a charstrings interpreter, Z1_Decoder, used to parse the
- * Type 1 charstrings stream, manage a stack and call the builder
- * and/or hinter depending on the opcodes.
- *
- * Ideally, a Type 2 glyph loader would only need to have its own
- * T2_Decoder object (assuming the hinter is able to manage all
- * kinds of hints).
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1gload.h */
+/* */
+/* Experimental Type 1 Glyph Loader (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef Z1GLOAD_H
#define Z1GLOAD_H
+
#ifdef FT_FLAT_COMPILE
+
#include "z1objs.h"
+
#else
+
#include <type1z/z1objs.h>
+
#endif
@@ -47,46 +36,55 @@
#endif
-/*************************************************************************/
-/* */
-/* <Structure> Z1_Builder */
-/* */
-/* <Description> */
-/* a structure used during glyph loading to store its outline. */
-/* */
-/* <Fields> */
-/* system :: current system object */
-/* face :: current face object */
-/* glyph :: current glyph slot */
-/* */
-/* current :: current glyph outline */
-/* base :: base glyph outline */
-/* */
-/* max_points :: maximum points in builder outline */
-/* max_contours :: maximum contours in builder outline */
-/* */
-/* last :: last point position */
-/* */
-/* scale_x :: horizontal scale ( FUnits to sub-pixels ) */
-/* scale_y :: vertical scale ( FUnits to sub-pixels ) */
-/* pos_x :: horizontal translation (composite glyphs) */
-/* pos_y :: vertical translation (composite glyph) */
-/* */
-/* left_bearing :: left side bearing point */
-/* advance :: horizontal advance vector */
-/* */
-/* path_begun :: flag, indicates that a new path has begun */
-/* load_points :: flag, if not set, no points are loaded */
-/* */
-/* error :: an error code that is only used to report */
-/* memory allocation problems.. */
-/* */
-/* metrics_only :: a boolean indicating that we only want to */
-/* compute the metrics of a given glyph, not load */
-/* all of its points.. */
-/* */
-
- typedef struct Z1_Builder_
+ /*************************************************************************/
+ /* */
+ /* <Structure> */
+ /* Z1_Builder */
+ /* */
+ /* <Description> */
+ /* A structure used during glyph loading to store its outline. */
+ /* */
+ /* <Fields> */
+ /* memory :: The current memory object. */
+ /* */
+ /* face :: The current face object. */
+ /* */
+ /* glyph :: The current glyph slot. */
+ /* */
+ /* loader :: The current glyph loader. */
+ /* */
+ /* current :: The current glyph outline. */
+ /* */
+ /* base :: The base glyph outline. */
+ /* */
+ /* last :: The last point position. */
+ /* */
+ /* scale_x :: The horizontal scale (FUnits to sub-pixels). */
+ /* */
+ /* scale_y :: The vertical scale (FUnits to sub-pixels). */
+ /* */
+ /* pos_x :: The horizontal translation (for composite glyphs). */
+ /* */
+ /* pos_y :: The vertical translation (for composite glyphs). */
+ /* */
+ /* left_bearing :: The left side bearing point. */
+ /* */
+ /* advance :: The horizontal advance vector. */
+ /* */
+ /* no_recurse :: */
+ /* */
+ /* bbox :: The glyph's bounding box. */
+ /* */
+ /* path_begun :: A flag which indicates that a new path has begun. */
+ /* */
+ /* load_points :: A flag which indicates, if not set, that no points */
+ /* are loaded. */
+ /* */
+ /* error :: The current error code. */
+ /* */
+ /* metrics_only :: A flag whether to compute metrics only. */
+ /* */
+ typedef struct Z1_Builder_
{
FT_Memory memory;
T1_Face face;
@@ -119,7 +117,7 @@
/* execution context charstring zone */
- typedef struct Z1_Decoder_Zone_
+ typedef struct Z1_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
@@ -128,47 +126,41 @@
} Z1_Decoder_Zone;
- typedef struct Z1_Decoder_
+ typedef struct Z1_Decoder_
{
- Z1_Builder builder;
+ Z1_Builder builder;
- FT_Int stack[ T1_MAX_CHARSTRINGS_OPERANDS ];
- FT_Int* top;
+ FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
+ FT_Int* top;
- Z1_Decoder_Zone zones[ T1_MAX_SUBRS_CALLS+1 ];
- Z1_Decoder_Zone* zone;
+ Z1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
+ Z1_Decoder_Zone* zone;
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
+ FT_Int flex_state;
+ FT_Int num_flex_vectors;
+ FT_Vector flex_vectors[7];
- T1_Blend* blend; /* for multiple masters */
+ T1_Blend* blend; /* for multiple masters */
} Z1_Decoder;
-
LOCAL_DEF
- void Z1_Init_Builder( Z1_Builder* builder,
- T1_Face face,
- Z1_Size size,
- Z1_GlyphSlot glyph );
+ void Z1_Init_Builder( Z1_Builder* builder,
+ T1_Face face,
+ Z1_Size size,
+ Z1_GlyphSlot glyph );
LOCAL_DEF
- void Z1_Done_Builder( Z1_Builder* builder );
+ void Z1_Done_Builder( Z1_Builder* builder );
-
LOCAL_DEF
- void Z1_Init_Decoder( Z1_Decoder* decoder );
+ void Z1_Init_Decoder( Z1_Decoder* decoder );
-
- /* Compute the maximum advance width of a font through quick parsing */
LOCAL_DEF
FT_Error Z1_Compute_Max_Advance( T1_Face face,
- FT_Int *max_advance );
+ FT_Int* max_advance );
-
- /* This function is exported, because it is used by the T1Dump utility */
LOCAL_DEF
FT_Error Z1_Parse_CharStrings( Z1_Decoder* decoder,
FT_Byte* charstring_base,
@@ -177,8 +169,6 @@
FT_Byte** subrs_base,
FT_Int* subrs_len );
-
-
LOCAL_DEF
FT_Error Z1_Load_Glyph( Z1_GlyphSlot glyph,
Z1_Size size,
@@ -190,4 +180,8 @@
}
#endif
+
#endif /* Z1GLOAD_H */
+
+
+/* END */
--- a/src/type1z/z1load.h
+++ b/src/type1z/z1load.h
@@ -1,20 +1,21 @@
-/*******************************************************************
- *
- * t1load.h 2.0
- *
- * Type1 Loader.
- *
- * Copyright 1996-2000 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1load.h */
+/* */
+/* Experimental Type 1 font loader (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef Z1LOAD_H
#define Z1LOAD_H
@@ -22,40 +23,46 @@
#include <freetype/internal/t1types.h>
#include <freetype/ftmm.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "z1parse.h"
+
#else
+
#include <type1z/z1parse.h>
+
#endif
-
#ifdef __cplusplus
extern "C" {
#endif
- typedef struct Z1_Loader_
+ typedef struct Z1_Loader_
{
- Z1_Parser parser; /* parser used to read the stream */
+ Z1_Parser parser; /* parser used to read the stream */
- FT_Int num_chars; /* number of characters in encoding */
- Z1_Table encoding_table; /* Z1_Table used to store the */
+ FT_Int num_chars; /* number of characters in encoding */
+ Z1_Table encoding_table; /* Z1_Table used to store the */
/* encoding character names */
- FT_Int num_glyphs;
- Z1_Table glyph_names;
- Z1_Table charstrings;
+ FT_Int num_glyphs;
+ Z1_Table glyph_names;
+ Z1_Table charstrings;
- FT_Int num_subrs;
- Z1_Table subrs;
- FT_Bool fontdata;
+ FT_Int num_subrs;
+ Z1_Table subrs;
+ FT_Bool fontdata;
} Z1_Loader;
+
LOCAL_DEF
FT_Error Z1_Open_Face( T1_Face face );
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
+
LOCAL_DEF
FT_Error Z1_Get_Multi_Master( T1_Face face,
FT_Multi_Master* master );
@@ -72,7 +79,9 @@
LOCAL_DEF
void Z1_Done_Blend( T1_Face face );
-#endif
+
+#endif /* !Z1_CONFIG_OPTION_NO_MM_SUPPORT */
+
#ifdef __cplusplus
}
--- a/src/type1z/z1objs.c
+++ b/src/type1z/z1objs.c
@@ -1,62 +1,71 @@
-/*******************************************************************
- *
- * t1objs.c 1.0
- *
- * Type1 Objects manager.
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1objs.c */
+/* */
+/* Experimental Type 1 objects manager (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "z1gload.h"
#include "z1load.h"
#include "z1afm.h"
+
#else
+
#include <type1z/z1gload.h>
#include <type1z/z1load.h>
#include <type1z/z1afm.h>
+
#endif
#include <freetype/internal/psnames.h>
-/* Required by tracing mode */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1objs
-/*******************************************************************
- * *
- * FACE FUNCTIONS *
- * *
- * *
- *******************************************************************/
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_z1objs
-/*******************************************************************
- *
- * <Function> Z1_Done_Face
- *
- * <Description>
- * The face object destructor.
- *
- * <Input>
- * face :: typeless pointer to the face object to destroy
- *
- * <Return>
- * Error code.
- *
- ******************************************************************/
+ /*************************************************************************/
+ /* */
+ /* FACE FUNCTIONS */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Done_Face */
+ /* */
+ /* <Description> */
+ /* The face object destructor. */
+ /* */
+ /* <Input> */
+ /* face :: A typeless pointer to the face object to destroy. */
+ /* */
LOCAL_FUNC
void Z1_Done_Face( T1_Face face )
{
@@ -63,7 +72,8 @@
FT_Memory memory;
T1_Font* type1 = &face->type1;
- if (face)
+
+ if ( face )
{
memory = face->root.memory;
@@ -77,6 +87,7 @@
{
T1_FontInfo* info = &type1->font_info;
+
FREE( info->version );
FREE( info->notice );
FREE( info->full_name );
@@ -101,7 +112,7 @@
#ifndef Z1_CONFIG_OPTION_NO_AFM
/* release afm data if present */
- if ( face->afm_data)
+ if ( face->afm_data )
Z1_Done_AFM( memory, (Z1_AFM*)face->afm_data );
#endif
@@ -114,22 +125,30 @@
}
}
-/*******************************************************************
- *
- * <Function> Z1_Init_Face
- *
- * <Description>
- * The face object constructor.
- *
- * <Input>
- * face :: face record to build
- * Input :: input stream where to load font data
- *
- * <Return>
- * Error code.
- *
- ******************************************************************/
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Init_Face */
+ /* */
+ /* <Description> */
+ /* The face object constructor. */
+ /* */
+ /* <Input> */
+ /* stream :: input stream where to load font data. */
+ /* */
+ /* face_index :: The index of the font face in the resource. */
+ /* */
+ /* num_params :: Number of additional generic parameters. Ignored. */
+ /* */
+ /* params :: Additional generic parameters. Ignored. */
+ /* */
+ /* <InOut> */
+ /* face :: The face record to build. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error Z1_Init_Face( FT_Stream stream,
T1_Face face,
@@ -137,21 +156,22 @@
FT_Int num_params,
FT_Parameter* params )
{
- FT_Error error;
+ FT_Error error;
PSNames_Interface* psnames;
- FT_UNUSED(num_params);
- FT_UNUSED(params);
- FT_UNUSED(face_index);
- FT_UNUSED(stream);
+ FT_UNUSED( num_params );
+ FT_UNUSED( params );
+ FT_UNUSED( face_index );
+ FT_UNUSED( stream );
+
face->root.num_faces = 1;
psnames = (PSNames_Interface*)face->psnames;
- if (!psnames)
+ if ( !psnames )
{
psnames = (PSNames_Interface*)
- FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psnames" );
+ FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psnames" );
face->psnames = psnames;
}
@@ -158,125 +178,132 @@
/* open the tokenizer, this will also check the font format */
error = Z1_Open_Face( face );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
/* if we just wanted to check the format, leave successfully now */
- if (face_index < 0)
+ if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( face_index != 0 )
{
- FT_ERROR(( "T1.Init_Face : invalid face index\n" ));
+ FT_ERROR(( "Z1_Init_Face: invalid face index\n" ));
error = T1_Err_Invalid_Argument;
goto Exit;
}
/* Now, load the font program into the face object */
+
+ /* Init the face object fields */
+ /* Now set up root face fields */
{
- /* Init the face object fields */
- /* Now set up root face fields */
- {
- FT_Face root = (FT_Face)&face->root;
+ FT_Face root = (FT_Face)&face->root;
- root->num_glyphs = face->type1.num_glyphs;
- root->num_charmaps = 1;
- root->face_index = face_index;
- root->face_flags = FT_FACE_FLAG_SCALABLE;
+ root->num_glyphs = face->type1.num_glyphs;
+ root->num_charmaps = 1;
- root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+ root->face_index = face_index;
+ root->face_flags = FT_FACE_FLAG_SCALABLE;
- if ( face->type1.font_info.is_fixed_pitch )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+ root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
- if ( face->blend )
- root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
+ if ( face->type1.font_info.is_fixed_pitch )
+ root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
- /* XXX : TO DO - add kerning with .afm support */
+ if ( face->blend )
+ root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
- /* get style name - be careful, some broken fonts only */
- /* have a /FontName dictionary entry .. !! */
- root->family_name = face->type1.font_info.family_name;
- if (root->family_name)
- {
- char* full = face->type1.font_info.full_name;
- char* family = root->family_name;
+ /* XXX: TODO -- add kerning with .afm support */
- while ( *family && *full == *family )
- {
- family++;
- full++;
- }
+ /* get style name -- be careful, some broken fonts only */
+ /* have a `/FontName' dictionary entry! */
+ root->family_name = face->type1.font_info.family_name;
+ if ( root->family_name )
+ {
+ char* full = face->type1.font_info.full_name;
+ char* family = root->family_name;
- root->style_name = ( *full == ' ' ? full + 1
- : (char *)"Regular" );
+
+ while ( *family && *full == *family )
+ {
+ family++;
+ full++;
}
- else
+
+ root->style_name = ( *full == ' ' ? full + 1
+ : (char *)"Regular" );
+ }
+ else
+ {
+ /* do we have a `/FontName'? */
+ if ( face->type1.font_name )
{
- /* do we have a /FontName ?? */
- if (face->type1.font_name)
- {
- root->family_name = face->type1.font_name;
- root->style_name = "Regular";
- }
+ root->family_name = face->type1.font_name;
+ root->style_name = "Regular";
}
+ }
- /* no embedded bitmap support */
- root->num_fixed_sizes = 0;
- root->available_sizes = 0;
+ /* no embedded bitmap support */
+ root->num_fixed_sizes = 0;
+ root->available_sizes = 0;
- root->bbox = face->type1.font_bbox;
- root->units_per_EM = 1000;
- root->ascender = (FT_Short)face->type1.font_bbox.yMax;
- root->descender = -(FT_Short)face->type1.font_bbox.yMin;
- root->height = ((root->ascender + root->descender)*12)/10;
+ root->bbox = face->type1.font_bbox;
+ root->units_per_EM = 1000;
+ root->ascender = (FT_Short)face->type1.font_bbox.yMax;
+ root->descender = -(FT_Short)face->type1.font_bbox.yMin;
+ root->height = ( ( root->ascender + root->descender ) * 12 ) / 10;
- /* now compute the maximum advance width */
+ /* now compute the maximum advance width */
- root->max_advance_width = face->type1.private_dict.standard_width[0];
+ root->max_advance_width = face->type1.private_dict.standard_width[0];
- /* compute max advance width for proportional fonts */
- if (!face->type1.font_info.is_fixed_pitch)
- {
- FT_Int max_advance;
+ /* compute max advance width for proportional fonts */
+ if ( !face->type1.font_info.is_fixed_pitch )
+ {
+ FT_Int max_advance;
- error = Z1_Compute_Max_Advance( face, &max_advance );
- /* in case of error, keep the standard width */
- if (!error)
- root->max_advance_width = max_advance;
- else
- error = 0; /* clear error */
- }
+ error = Z1_Compute_Max_Advance( face, &max_advance );
- root->max_advance_height = root->height;
+ /* in case of error, keep the standard width */
+ if ( !error )
+ root->max_advance_width = max_advance;
+ else
+ error = 0; /* clear error */
+ }
- root->underline_position = face->type1.font_info.underline_position;
- root->underline_thickness = face->type1.font_info.underline_thickness;
+ root->max_advance_height = root->height;
- root->max_points = 0;
- root->max_contours = 0;
- }
+ root->underline_position = face->type1.font_info.underline_position;
+ root->underline_thickness = face->type1.font_info.underline_thickness;
+
+ root->max_points = 0;
+ root->max_contours = 0;
}
- /* charmap support - synthetize unicode charmap when possible */
+ /* charmap support -- synthetize unicode charmap if possible */
{
- FT_Face root = &face->root;
- FT_CharMap charmap = face->charmaprecs;
+ FT_Face root = &face->root;
+ FT_CharMap charmap = face->charmaprecs;
- /* synthesize a Unicode charmap if there is support in the "psnames" */
- /* module.. */
- if (face->psnames)
+
+ /* synthesize a Unicode charmap if there is support in the `PSNames' */
+ /* module */
+ if ( face->psnames )
{
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
- if (psnames->unicode_value)
+
+
+ if ( psnames->unicode_value )
{
- error = psnames->build_unicodes( root->memory,
- face->type1.num_glyphs,
- (const char**)face->type1.glyph_names,
- &face->unicode_map );
- if (!error)
+ error = psnames->build_unicodes(
+ root->memory,
+ face->type1.num_glyphs,
+ (const char**)face->type1.glyph_names,
+ &face->unicode_map );
+ if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
@@ -288,82 +315,81 @@
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
- error = 0;
+ error = FT_Err_Ok;
}
}
- /* now, support either the standard, expert, or custom encodings */
+ /* now, support either the standard, expert, or custom encoding */
charmap->face = (FT_Face)face;
- charmap->platform_id = 7; /* a new platform id for Adobe fonts ?? */
+ charmap->platform_id = 7; /* a new platform id for Adobe fonts? */
- switch (face->type1.encoding_type)
+ switch ( face->type1.encoding_type )
{
- case t1_encoding_standard:
- charmap->encoding = ft_encoding_adobe_standard;
- charmap->encoding_id = 0;
- break;
+ case t1_encoding_standard:
+ charmap->encoding = ft_encoding_adobe_standard;
+ charmap->encoding_id = 0;
+ break;
- case t1_encoding_expert:
- charmap->encoding = ft_encoding_adobe_expert;
- charmap->encoding_id = 1;
- break;
+ case t1_encoding_expert:
+ charmap->encoding = ft_encoding_adobe_expert;
+ charmap->encoding_id = 1;
+ break;
- default:
- charmap->encoding = ft_encoding_adobe_custom;
- charmap->encoding_id = 2;
- break;
+ default:
+ charmap->encoding = ft_encoding_adobe_custom;
+ charmap->encoding_id = 2;
+ break;
}
- root->charmaps = face->charmaps;
+ root->charmaps = face->charmaps;
root->num_charmaps = charmap - face->charmaprecs + 1;
- face->charmaps[0] = &face->charmaprecs[0];
- face->charmaps[1] = &face->charmaprecs[1];
+ face->charmaps[0] = &face->charmaprecs[0];
+ face->charmaps[1] = &face->charmaprecs[1];
}
+
Exit:
return error;
}
-/*******************************************************************
- *
- * <Function> Z1_Init_Driver
- *
- * <Description>
- * Initialise a given Type 1 driver object
- *
- * <Input>
- * driver :: handle to target driver object
- *
- * <Return>
- * Error code.
- *
- ******************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Init_Driver */
+ /* */
+ /* <Description> */
+ /* Initializes a given Type 1 driver object. */
+ /* */
+ /* <Input> */
+ /* driver :: A handle to the target driver object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error Z1_Init_Driver( Z1_Driver driver )
{
- FT_UNUSED(driver);
+ FT_UNUSED( driver );
+
return T1_Err_Ok;
}
-
-/*******************************************************************
- *
- * <Function> Z1_Done_Driver
- *
- * <Description>
- * finalise a given Type 1 driver
- *
- * <Input>
- * driver :: handle to target Type 1 driver
- *
- ******************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Done_Driver */
+ /* */
+ /* <Description> */
+ /* Finalizes a given Type 1 driver. */
+ /* */
+ /* <Input> */
+ /* driver :: A handle to the target Type 1 driver. */
+ /* */
LOCAL_DEF
void Z1_Done_Driver( Z1_Driver driver )
{
- FT_UNUSED(driver);
+ FT_UNUSED( driver );
}
--- a/src/type1z/z1objs.h
+++ b/src/type1z/z1objs.h
@@ -1,20 +1,21 @@
-/*******************************************************************
- *
- * t1objs.h 1.0
- *
- * Type1 objects definition.
- *
- * Copyright 1996-1999 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1objs.h */
+/* */
+/* Experimental Type 1 objects manager (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef Z1OBJS_H
#define Z1OBJS_H
@@ -31,67 +32,72 @@
typedef struct Z1_Size_Hints_ Z1_Size_Hints;
typedef struct Z1_Glyph_Hints_ Z1_Glyph_Hints;
- /***********************************************************************/
- /* */
- /* <Type> Z1_Driver */
- /* */
- /* <Description> */
- /* A handle to a Type 1 driver object. */
- /* */
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_Driver */
+ /* */
+ /* <Description> */
+ /* A handle to a Type 1 driver object. */
+ /* */
typedef struct Z1_DriverRec_ *Z1_Driver;
- /***********************************************************************/
- /* */
- /* <Type> Z1_Size */
- /* */
- /* <Description> */
- /* A handle to a Type 1 size object. */
- /* */
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_Size */
+ /* */
+ /* <Description> */
+ /* A handle to a Type 1 size object. */
+ /* */
typedef struct Z1_SizeRec_* Z1_Size;
- /***********************************************************************/
- /* */
- /* <Type> Z1_GlyphSlot */
- /* */
- /* <Description> */
- /* A handle to a Type 1 glyph slot object. */
- /* */
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_GlyphSlot */
+ /* */
+ /* <Description> */
+ /* A handle to a Type 1 glyph slot object. */
+ /* */
typedef struct Z1_GlyphSlotRec_* Z1_GlyphSlot;
- /***********************************************************************/
- /* */
- /* <Type> Z1_CharMap */
- /* */
- /* <Description> */
- /* A handle to a Type 1 character mapping object. */
- /* */
- /* <Note> */
- /* The Type 1 format doesn't use a charmap but an encoding table. */
- /* The driver is responsible for making up charmap objects */
- /* corresponding to these tables.. */
- /* */
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_CharMap */
+ /* */
+ /* <Description> */
+ /* A handle to a Type 1 character mapping object. */
+ /* */
+ /* <Note> */
+ /* The Type 1 format doesn't use a charmap but an encoding table. */
+ /* The driver is responsible for making up charmap objects */
+ /* corresponding to these tables. */
+ /* */
typedef struct Z1_CharMapRec_* Z1_CharMap;
+ /*************************************************************************/
+ /* */
+ /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
+ /* */
+ /*************************************************************************/
- /**************************************************************************/
- /* */
- /* NOW BEGINS THE TYPE1 SPECIFIC STUFF .............................. */
- /* */
- /**************************************************************************/
-
- /***************************************************/
- /* */
- /* Z1_Size : */
- /* */
- /* Type 1 size record.. */
- /* */
-
- typedef struct Z1_SizeRec_
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_SizeRec */
+ /* */
+ /* <Description> */
+ /* Type 1 size record. */
+ /* */
+ typedef struct Z1_SizeRec_
{
FT_SizeRec root;
FT_Bool valid;
@@ -98,19 +104,19 @@
Z1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
- /* change 't1objs' each time.. */
+ /* change `z1objs' each time. */
} Z1_SizeRec;
-
- /***************************************************/
- /* */
- /* Z1_GlyphSlot : */
- /* */
- /* TrueDoc glyph record.. */
- /* */
-
- typedef struct Z1_GlyphSlotRec_
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* Z1_GlyphSlotRec */
+ /* */
+ /* <Description> */
+ /* Type 1 glyph slot record. */
+ /* */
+ typedef struct Z1_GlyphSlotRec_
{
FT_GlyphSlotRec root;
@@ -128,82 +134,22 @@
} Z1_GlyphSlotRec;
-/*******************************************************************
- *
- * <Function> Z1_Init_Face
- *
- * <Description>
- * Initialise a given Type 1 face object
- *
- * <Input>
- * face_index :: index of font face in resource
- * resource :: source font resource
- * face :: face record to build
- *
- * <Return>
- * Error code.
- *
- ******************************************************************/
-
LOCAL_DEF
- FT_Error Z1_Init_Face( FT_Stream stream,
- T1_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
+ FT_Error Z1_Init_Face( FT_Stream stream,
+ T1_Face face,
+ FT_Int face_index,
+ FT_Int num_params,
+ FT_Parameter* params );
-
-
-/*******************************************************************
- *
- * <Function> Z1_Done_Face
- *
- * <Description>
- * Finalise a given face object
- *
- * <Input>
- * face :: handle to the face object to destroy
- *
- ******************************************************************/
-
LOCAL_DEF
void Z1_Done_Face( T1_Face face );
-
-/*******************************************************************
- *
- * <Function> Z1_Init_Driver
- *
- * <Description>
- * Initialise a given Type 1 driver object
- *
- * <Input>
- * driver :: handle to target driver object
- *
- * <Return>
- * Error code.
- *
- ******************************************************************/
-
LOCAL_DEF
FT_Error Z1_Init_Driver( Z1_Driver driver );
-
-
-/*******************************************************************
- *
- * <Function> Z1_Done_Driver
- *
- * <Description>
- * finalise a given Type 1 driver
- *
- * <Input>
- * driver :: handle to target Type 1 driver
- *
- ******************************************************************/
-
LOCAL_DEF
void Z1_Done_Driver( Z1_Driver driver );
+
#ifdef __cplusplus
}
--- a/src/type1z/z1parse.c
+++ b/src/type1z/z1parse.c
@@ -1,33 +1,38 @@
-/*******************************************************************
- *
- * t1parse.c 2.0
- *
- * Type1 parser.
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- * The Type 1 parser is in charge of the following:
- *
- * - provide an implementation of a growing sequence of
- * objects called a Z1_Table (used to build various tables
- * needed by the loader).
- *
- * - opening .pfb and .pfa files to extract their top-level
- * and private dictionaries
- *
- * - read numbers, arrays & strings from any dictionary
- *
- * See "t1load.c" to see how data is loaded from the font file
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1parse.c */
+/* */
+/* Experimental Type 1 parser (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* The Type 1 parser is in charge of the following: */
+ /* */
+ /* - provide an implementation of a growing sequence of objects called */
+ /* a `Z1_Table' (used to build various tables needed by the loader). */
+ /* */
+ /* - opening .pfb and .pfa files to extract their top-level and private */
+ /* dictionaries. */
+ /* */
+ /* - read numbers, arrays & strings from any dictionary. */
+ /* */
+ /* See `z1load.c' to see how data is loaded from the font file. */
+ /* */
+ /*************************************************************************/
+
+
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftobjs.h>
@@ -34,127 +39,153 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1errors.h>
+
#ifdef FT_FLAT_COMPILE
+
#include "z1parse.h"
+
#else
+
#include <type1z/z1parse.h>
+
#endif
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1load
+#include <string.h> /* for strncmp() */
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-/***** *****/
-/***** IMPLEMENTATION OF Z1_TABLE OBJECT *****/
-/***** *****/
-/***** *****/
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_z1parse
-/*************************************************************************/
-/* */
-/* <Function> Z1_New_Table */
-/* */
-/* <Description> */
-/* Initialise a Z1_Table. */
-/* */
-/* <Input> */
-/* table :: address of target table */
-/* count :: table size = maximum number of elements */
-/* memory :: memory object to use for all subsequent reallocations */
-/* */
-/* <Return> */
-/* Error code. 0 means success */
-/* */
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** IMPLEMENTATION OF Z1_TABLE OBJECT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_New_Table */
+ /* */
+ /* <Description> */
+ /* Initialises a Z1_Table. */
+ /* */
+ /* <InOut> */
+ /* table :: The address of the target table. */
+ /* */
+ /* <Input> */
+ /* count :: The table size = the maximum number of elements. */
+ /* */
+ /* memory :: The memory object to use for all subsequent */
+ /* reallocations. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error Z1_New_Table( Z1_Table* table,
FT_Int count,
FT_Memory memory )
{
- FT_Error error;
+ FT_Error error;
- table->memory = memory;
- if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) ||
- ALLOC_ARRAY( table->lengths, count, FT_Byte* ) )
- goto Exit;
- table->max_elems = count;
+ table->memory = memory;
+ if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) ||
+ ALLOC_ARRAY( table->lengths, count, FT_Byte* ) )
+ goto Exit;
+
+ table->max_elems = count;
table->init = 0xdeadbeef;
- table->num_elems = 0;
- table->block = 0;
- table->capacity = 0;
- table->cursor = 0;
+ table->num_elems = 0;
+ table->block = 0;
+ table->capacity = 0;
+ table->cursor = 0;
Exit:
- if (error) FREE(table->elements);
+ if ( error )
+ FREE( table->elements );
- return error;
+ return error;
}
+ static
+ void shift_elements( Z1_Table* table,
+ FT_Byte* old_base )
+ {
+ FT_Long delta = table->block - old_base;
+ FT_Byte** offset = table->elements;
+ FT_Byte** limit = offset + table->max_elems;
-/*************************************************************************/
-/* */
-/* <Function> Z1_Add_Table */
-/* */
-/* <Description> */
-/* Adds an object to a Z1_Table, possibly growing its memory block */
-/* */
-/* <Input> */
-/* table :: target table */
-/* index :: index of object in table */
-/* object :: address of object to copy in memory */
-/* length :: length in bytes of source object */
-/* */
-/* <Return> */
-/* Error code. 0 means success. An error is returned when a */
-/* realloc failed.. */
-/* */
-
- static void shift_elements( Z1_Table* table, FT_Byte* old_base )
+ if ( delta )
+ for ( ; offset < limit; offset++ )
{
- FT_Long delta = table->block - old_base;
- FT_Byte** offset = table->elements;
- FT_Byte** limit = offset + table->max_elems;
-
- if (delta)
- for ( ; offset < limit; offset++ )
- {
- if (offset[0])
- offset[0] += delta;
- }
+ if ( offset[0] )
+ offset[0] += delta;
}
+ }
- static
- FT_Error reallocate_t1_table( Z1_Table* table,
- FT_Int new_size )
- {
- FT_Memory memory = table->memory;
- FT_Byte* old_base = table->block;
- FT_Error error;
- /* realloc the base block */
- if ( REALLOC( table->block, table->capacity, new_size ) )
- return error;
+ static
+ FT_Error reallocate_t1_table( Z1_Table* table,
+ FT_Int new_size )
+ {
+ FT_Memory memory = table->memory;
+ FT_Byte* old_base = table->block;
+ FT_Error error;
- table->capacity = new_size;
- /* shift all offsets when needed */
- if (old_base)
- shift_elements( table, old_base );
+ /* reallocate the base block */
+ if ( REALLOC( table->block, table->capacity, new_size ) )
+ return error;
- return T1_Err_Ok;
- }
+ table->capacity = new_size;
+ /* shift all offsets if necessary */
+ if ( old_base )
+ shift_elements( table, old_base );
+ return T1_Err_Ok;
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Add_Table */
+ /* */
+ /* <Description> */
+ /* Adds an object to a Z1_Table, possibly growing its memory block. */
+ /* */
+ /* <InOut> */
+ /* table :: The target table. */
+ /* */
+ /* <Input> */
+ /* index :: The index of the object in the table. */
+ /* */
+ /* object :: The address of the object to copy in memory. */
+ /* */
+ /* length :: The length in bytes of the source object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. An error is returned if a */
+ /* reallocation fails. */
+ /* */
LOCAL_FUNC
FT_Error Z1_Add_Table( Z1_Table* table,
FT_Int index,
@@ -161,10 +192,10 @@
void* object,
FT_Int length )
{
- if (index < 0 || index > table->max_elems)
+ if ( index < 0 || index > table->max_elems )
{
- FT_ERROR(( "T1.Add_Table: invalid index\n" ));
- return T1_Err_Syntax_Error;
+ FT_ERROR(( "Z1_Add_Table: invalid index\n" ));
+ return T1_Err_Syntax_Error;
}
/* grow the base block if needed */
@@ -173,16 +204,18 @@
FT_Error error;
FT_Int new_size = table->capacity;
- while ( new_size < table->cursor+length )
+
+ while ( new_size < table->cursor + length )
new_size += 1024;
error = reallocate_t1_table( table, new_size );
- if (error) return error;
+ if ( error )
+ return error;
}
/* add the object to the base block and adjust offset */
- table->elements[ index ] = table->block + table->cursor;
- table->lengths [ index ] = length;
+ table->elements[index] = table->block + table->cursor;
+ table->lengths [index] = length;
MEM_Copy( table->block + table->cursor, object, length );
table->cursor += length;
@@ -190,21 +223,23 @@
}
-/*************************************************************************/
-/* */
-/* <Function> Z1_Done_Table */
-/* */
-/* <Description> */
-/* Finalise a Z1_Table. (realloc it to its current cursor). */
-/* */
-/* <Input> */
-/* table :: target table */
-/* */
-/* <Note> */
-/* This function does NOT release the heap's memory block. It is up */
-/* to the caller to clean it, or reference it in its own structures. */
-/* */
#if 0
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Z1_Done_Table */
+ /* */
+ /* <Description> */
+ /* Finalizes a Z1_Table (i.e., reallocate it to its current cursor). */
+ /* */
+ /* <InOut> */
+ /* table :: The target table. */
+ /* */
+ /* <Note> */
+ /* This function does NOT release the heap's memory block. It is up */
+ /* to the caller to clean it, or reference it in its own structures. */
+ /* */
LOCAL_FUNC
void Z1_Done_Table( Z1_Table* table )
{
@@ -212,25 +247,29 @@
FT_Error error;
FT_Byte* old_base;
+
/* should never fail, as rec.cursor <= rec.size */
old_base = table->block;
- if (!old_base)
+ if ( !old_base )
return;
(void)REALLOC( table->block, table->capacity, table->cursor );
table->capacity = table->cursor;
- if (old_base != table->block)
+ if ( old_base != table->block )
shift_elements( table, old_base );
}
-#endif
+#endif /* 0 */
+
+
LOCAL_FUNC
void Z1_Release_Table( Z1_Table* table )
{
FT_Memory memory = table->memory;
- if (table->init == (FT_Long)0xdeadbeef)
+
+ if ( table->init == (FT_Long)0xDEADBEEF )
{
FREE( table->block );
FREE( table->elements );
@@ -239,32 +278,37 @@
}
}
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-/***** *****/
-/***** INPUT STREAM PARSER *****/
-/***** *****/
-/***** *****/
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-#define IS_Z1_WHITESPACE(c) ( (c) == ' ' || (c) == '\t' )
-#define IS_Z1_LINESPACE(c) ( (c) == '\r' || (c) == '\n' )
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** INPUT STREAM PARSER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
-#define IS_Z1_SPACE(c) ( IS_Z1_WHITESPACE(c) || IS_Z1_LINESPACE(c) )
+#define IS_Z1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' )
+#define IS_Z1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' )
+
+#define IS_Z1_SPACE( c ) ( IS_Z1_WHITESPACE( c ) || IS_Z1_LINESPACE( c ) )
+
+
LOCAL_FUNC
- void Z1_Skip_Spaces( Z1_Parser* parser )
+ void Z1_Skip_Spaces( Z1_Parser* parser )
{
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
- while (cur < limit)
+
+ while ( cur < limit )
{
FT_Byte c = *cur;
- if (!IS_Z1_SPACE(c))
+
+
+ if ( !IS_Z1_SPACE( c ) )
break;
cur++;
}
@@ -271,6 +315,7 @@
parser->cursor = cur;
}
+
LOCAL_FUNC
void Z1_ToToken( Z1_Parser* parser,
Z1_Token_Rec* token )
@@ -280,12 +325,13 @@
FT_Byte starter, ender;
FT_Int embed;
+
token->type = t1_token_none;
token->start = 0;
token->limit = 0;
/* first of all, skip space */
- Z1_Skip_Spaces(parser);
+ Z1_Skip_Spaces( parser );
cur = parser->cursor;
limit = parser->limit;
@@ -292,57 +338,57 @@
if ( cur < limit )
{
- switch (*cur)
+ switch ( *cur )
{
/************* check for strings ***********************/
- case '(':
- token->type = t1_token_string;
- ender = ')';
- goto Lookup_Ender;
+ case '(':
+ token->type = t1_token_string;
+ ender = ')';
+ goto Lookup_Ender;
/************* check for programs/array ****************/
- case '{':
- token->type = t1_token_array;
- ender = '}';
- goto Lookup_Ender;
+ case '{':
+ token->type = t1_token_array;
+ ender = '}';
+ goto Lookup_Ender;
/************* check for table/array ******************/
- case '[':
- token->type = t1_token_array;
- ender = ']';
+ case '[':
+ token->type = t1_token_array;
+ ender = ']';
- Lookup_Ender:
- embed = 1;
- starter = *cur++;
- token->start = cur;
- while (cur < limit)
+ Lookup_Ender:
+ embed = 1;
+ starter = *cur++;
+ token->start = cur;
+ while ( cur < limit )
+ {
+ if ( *cur == starter )
+ embed++;
+ else if ( *cur == ender )
{
- if (*cur == starter)
- embed++;
- else if (*cur == ender)
+ embed--;
+ if ( embed <= 0 )
{
- embed--;
- if (embed <= 0)
- {
- token->limit = cur++;
- break;
- }
+ token->limit = cur++;
+ break;
}
- cur++;
}
- break;
+ cur++;
+ }
+ break;
/* **************** otherwise, it's any token **********/
- default:
- token->start = cur++;
- token->type = t1_token_any;
- while (cur < limit && !IS_Z1_SPACE(*cur))
- cur++;
+ default:
+ token->start = cur++;
+ token->type = t1_token_any;
+ while ( cur < limit && !IS_Z1_SPACE( *cur ) )
+ cur++;
- token->limit = cur;
+ token->limit = cur;
}
- if (!token->limit)
+ if ( !token->limit )
{
token->start = 0;
token->type = t1_token_none;
@@ -357,14 +403,15 @@
void Z1_ToTokenArray( Z1_Parser* parser,
Z1_Token_Rec* tokens,
FT_UInt max_tokens,
- FT_Int *pnum_tokens )
+ FT_Int* pnum_tokens )
{
Z1_Token_Rec master;
+
*pnum_tokens = -1;
Z1_ToToken( parser, &master );
- if (master.type == t1_token_array)
+ if ( master.type == t1_token_array )
{
FT_Byte* old_cursor = parser->cursor;
FT_Byte* old_limit = parser->limit;
@@ -371,18 +418,20 @@
Z1_Token_Rec* cur = tokens;
Z1_Token_Rec* limit = cur + max_tokens;
+
parser->cursor = master.start;
parser->limit = master.limit;
- while (parser->cursor < parser->limit)
+ while ( parser->cursor < parser->limit )
{
Z1_Token_Rec token;
+
Z1_ToToken( parser, &token );
- if (!token.type)
+ if ( !token.type )
break;
- if (cur < limit)
+ if ( cur < limit )
*cur = token;
cur++;
@@ -397,20 +446,22 @@
static
- FT_Long t1_toint( FT_Byte* *cursor,
- FT_Byte* limit )
+ FT_Long t1_toint( FT_Byte** cursor,
+ FT_Byte* limit )
{
- FT_Long result = 0;
- FT_Byte* cur = *cursor;
- FT_Byte c, d;
+ FT_Long result = 0;
+ FT_Byte* cur = *cursor;
+ FT_Byte c, d;
- for (; cur < limit; cur++)
+
+ for ( ; cur < limit; cur++ )
{
c = *cur;
- d = (FT_Byte)(c - '0');
- if (d < 10) break;
+ d = (FT_Byte)( c - '0' );
+ if ( d < 10 )
+ break;
- if ( c=='-' )
+ if ( c == '-' )
{
cur++;
break;
@@ -417,20 +468,20 @@
}
}
- if (cur < limit)
+ if ( cur < limit )
{
do
{
- d = (FT_Byte)(cur[0] - '0');
- if (d >= 10)
+ d = (FT_Byte)( cur[0] - '0' );
+ if ( d >= 10 )
break;
- result = result*10 + d;
+ result = result * 10 + d;
cur++;
- } while (cur < limit);
+ } while ( cur < limit );
- if (c == '-')
+ if ( c == '-' )
result = -result;
}
@@ -440,51 +491,58 @@
static
- FT_Long t1_tofixed( FT_Byte* *cursor,
- FT_Byte* limit,
- FT_Long power_ten )
+ FT_Long t1_tofixed( FT_Byte** cursor,
+ FT_Byte* limit,
+ FT_Long power_ten )
{
- FT_Byte* cur = *cursor;
+ FT_Byte* cur = *cursor;
FT_Long num, divider, result;
- FT_Int sign = 0;
+ FT_Int sign = 0;
FT_Byte d;
- if (cur >= limit) return 0;
+ if ( cur >= limit )
+ return 0;
+
/* first of all, read the integer part */
result = t1_toint( &cur, limit ) << 16;
num = 0;
divider = 1;
- if (result < 0)
+ if ( result < 0 )
{
sign = 1;
result = -result;
}
- if (cur >= limit) goto Exit;
+ if ( cur >= limit )
+ goto Exit;
+
/* read decimal part, if any */
- if (*cur == '.' && cur+1 < limit)
+ if ( *cur == '.' && cur + 1 < limit )
{
cur++;
for (;;)
{
- d = (FT_Byte)(*cur - '0');
- if (d >= 10) break;
+ d = (FT_Byte)( *cur - '0' );
+ if ( d >= 10 )
+ break;
- if (divider < 10000000L)
+ if ( divider < 10000000L )
{
- num = num*10 + d;
+ num = num * 10 + d;
divider *= 10;
}
+
cur++;
- if (cur >= limit) break;
+ if ( cur >= limit )
+ break;
}
}
/* read exponent, if any */
- if ( cur+1 < limit && (*cur == 'e' || *cur == 'E'))
+ if ( cur + 1 < limit && ( *cur == 'e' || *cur == 'E' ) )
{
cur++;
power_ten += t1_toint( &cur, limit );
@@ -492,24 +550,24 @@
Exit:
/* raise to power of ten if needed */
- while (power_ten > 0)
+ while ( power_ten > 0 )
{
- result = result*10;
- num = num*10;
+ result = result * 10;
+ num = num * 10;
power_ten--;
}
- while (power_ten < 0)
+ while ( power_ten < 0 )
{
- result = result/10;
- divider = divider*10;
+ result = result / 10;
+ divider = divider * 10;
power_ten++;
}
- if (num)
+ if ( num )
result += FT_DivFix( num, divider );
- if (sign)
+ if ( sign )
result = -result;
*cursor = cur;
@@ -518,7 +576,7 @@
static
- FT_Int t1_tocoordarray( FT_Byte* *cursor,
+ FT_Int t1_tocoordarray( FT_Byte** cursor,
FT_Byte* limit,
FT_Int max_coords,
FT_Short* coords )
@@ -527,19 +585,22 @@
FT_Int count = 0;
FT_Byte c, ender;
- if (cur >= limit) goto Exit;
- /* check for the beginning of an array. If not, only one number will be read */
+ if ( cur >= limit )
+ goto Exit;
+
+ /* check for the beginning of an array. If not, only one number will */
+ /* be read */
c = *cur;
ender = 0;
- if (c == '[')
+ if ( c == '[' )
ender = ']';
- if (c == '{')
+ if ( c == '{' )
ender = '}';
- if (ender)
+ if ( ender )
cur++;
/* now, read the coordinates */
@@ -549,19 +610,21 @@
for (;;)
{
c = *cur;
- if ( c != ' ' && c != '\t' ) break;
+ if ( c != ' ' && c != '\t' )
+ break;
cur++;
- if (cur >= limit) goto Exit;
+ if ( cur >= limit )
+ goto Exit;
}
- if (count >= max_coords || c == ender)
+ if ( count >= max_coords || c == ender )
break;
- coords[count] = (FT_Short)(t1_tofixed(&cur,limit,0) >> 16);
+ coords[count] = (FT_Short)( t1_tofixed( &cur, limit, 0 ) >> 16 );
count++;
- if (!ender)
+ if ( !ender )
break;
}
@@ -571,9 +634,8 @@
}
-
static
- FT_Int t1_tofixedarray( FT_Byte* *cursor,
+ FT_Int t1_tofixedarray( FT_Byte** cursor,
FT_Byte* limit,
FT_Int max_values,
FT_Fixed* values,
@@ -583,19 +645,21 @@
FT_Int count = 0;
FT_Byte c, ender;
- if (cur >= limit) goto Exit;
- /* check for the beginning of an array. If not, only one number will be read */
+ if ( cur >= limit ) goto Exit;
+
+ /* check for the beginning of an array. If not, only one number will */
+ /* be read */
c = *cur;
ender = 0;
- if (c == '[')
+ if ( c == '[' )
ender = ']';
- if (c == '{')
+ if ( c == '{' )
ender = '}';
- if (ender)
+ if ( ender )
cur++;
/* now, read the values */
@@ -605,19 +669,21 @@
for (;;)
{
c = *cur;
- if ( c != ' ' && c != '\t' ) break;
+ if ( c != ' ' && c != '\t' )
+ break;
cur++;
- if (cur >= limit) goto Exit;
+ if ( cur >= limit )
+ goto Exit;
}
- if (count >= max_values || c == ender)
+ if ( count >= max_values || c == ender )
break;
- values[count] = t1_tofixed(&cur,limit,power_ten);
+ values[count] = t1_tofixed( &cur, limit, power_ten );
count++;
- if (!ender)
+ if ( !ender )
break;
}
@@ -628,8 +694,11 @@
#if 0
+
static
- FT_String* t1_tostring( FT_Byte* *cursor, FT_Byte* limit, FT_Memory memory )
+ FT_String* t1_tostring( FT_Byte** cursor,
+ FT_Byte* limit,
+ FT_Memory memory )
{
FT_Byte* cur = *cursor;
FT_Int len = 0;
@@ -637,20 +706,24 @@
FT_String* result;
FT_Error error;
- /* XXX : some stupid fonts have a "Notice" or "Copyright" string */
- /* that simply doesn't begin with an opening parenthesis, even */
- /* though they have a closing one !!! E.g. "amuncial.pfb" */
- /* */
- /* We must deal with these ill-fated cases there. Note that */
- /* these fonts didn't work with the old Type 1 driver as the */
- /* notice/copyright was not recognized as a valid string token */
- /* and made the old token parser commit errors.. */
- while ( cur < limit && (*cur == ' ' || *cur == '\t')) cur++;
- if (cur+1 >= limit) return 0;
+ /* XXX: some stupid fonts have a `Notice' or `Copyright' string */
+ /* that simply doesn't begin with an opening parenthesis, even */
+ /* though they have a closing one! E.g. "amuncial.pfb" */
+ /* */
+ /* We must deal with these ill-fated cases there. Note that */
+ /* these fonts didn't work with the old Type 1 driver as the */
+ /* notice/copyright was not recognized as a valid string token */
+ /* and made the old token parser commit errors. */
- if (*cur == '(') cur++; /* skip the opening parenthesis, if there is one */
+ while ( cur < limit && ( *cur == ' ' || *cur == '\t' ) )
+ cur++;
+ if ( cur + 1 >= limit )
+ return 0;
+ if ( *cur == '(' )
+ cur++; /* skip the opening parenthesis, if there is one */
+
*cursor = cur;
count = 0;
@@ -657,19 +730,20 @@
/* then, count its length */
for ( ; cur < limit; cur++ )
{
- if (*cur == '(')
+ if ( *cur == '(' )
count++;
- else if (*cur == ')')
+ else if ( *cur == ')' )
{
count--;
- if (count < 0)
+ if ( count < 0 )
break;
}
}
len = cur - *cursor;
- if (cur >= limit || ALLOC(result,len+1)) return 0;
+ if ( cur >= limit || ALLOC( result, len + 1 ) )
+ return 0;
/* now copy the string */
MEM_Copy( result, *cursor, len );
@@ -677,16 +751,20 @@
*cursor = cur;
return result;
}
-#endif
+#endif /* 0 */
+
+
static
- int t1_tobool( FT_Byte* *cursor, FT_Byte* limit )
+ int t1_tobool( FT_Byte** cursor,
+ FT_Byte* limit )
{
FT_Byte* cur = *cursor;
FT_Bool result = 0;
- /* return 1 if we find a "true", 0 otherwise */
- if ( cur+3 < limit &&
+
+ /* return 1 if we find `true', 0 otherwise */
+ if ( cur + 3 < limit &&
cur[0] == 't' &&
cur[1] == 'r' &&
cur[2] == 'u' &&
@@ -695,7 +773,7 @@
result = 1;
cur += 5;
}
- else if ( cur+4 < limit &&
+ else if ( cur + 4 < limit &&
cur[0] == 'f' &&
cur[1] == 'a' &&
cur[2] == 'l' &&
@@ -705,13 +783,13 @@
result = 0;
cur += 6;
}
+
*cursor = cur;
return result;
}
-
- /* Loads a simple field (i.e. non-table) into the current list of objects */
+ /* Load a simple field (i.e. non-table) into the current list of objects */
LOCAL_FUNC
FT_Error Z1_Load_Field( Z1_Parser* parser,
const Z1_Field_Rec* field,
@@ -726,8 +804,9 @@
FT_UInt index;
FT_Error error;
+
Z1_ToToken( parser, &token );
- if (!token.type)
+ if ( !token.type )
goto Fail;
count = 1;
@@ -735,10 +814,10 @@
cur = token.start;
limit = token.limit;
- if (token.type == t1_token_array)
+ if ( token.type == t1_token_array )
{
/* if this is an array, and we have no blend, an error occurs */
- if (max_objects == 0)
+ if ( max_objects == 0 )
goto Fail;
count = max_objects;
@@ -747,73 +826,72 @@
for ( ; count > 0; count--, index++ )
{
- FT_Byte* q = (FT_Byte*)objects[index] + field->offset;
- FT_Long val;
- FT_String* string;
+ FT_Byte* q = (FT_Byte*)objects[index] + field->offset;
+ FT_Long val;
+ FT_String* string;
- switch (field->type)
+ switch ( field->type )
{
- case t1_field_bool:
- {
- val = t1_tobool( &cur, limit );
- goto Store_Integer;
- }
+ case t1_field_bool:
+ val = t1_tobool( &cur, limit );
+ goto Store_Integer;
- case t1_field_fixed:
- {
- val = t1_tofixed( &cur, limit, 3 );
- goto Store_Integer;
- }
+ case t1_field_fixed:
+ val = t1_tofixed( &cur, limit, 3 );
+ goto Store_Integer;
- case t1_field_integer:
- {
- val = t1_toint( &cur, limit );
- Store_Integer:
- switch (field->size)
- {
- case 1:
- *(FT_Byte*)q = (FT_Byte)val;
- break;
- case 2:
- *(FT_UShort*)q = (FT_UShort)val;
- break;
+ case t1_field_integer:
+ val = t1_toint( &cur, limit );
- case 4:
- *(FT_UInt32*)q = (FT_UInt32)val;
- break;
+ Store_Integer:
+ switch ( field->size )
+ {
+ case 1:
+ *(FT_Byte*)q = (FT_Byte)val;
+ break;
- default: /* for 64-bit systems */
- *(FT_Long*)q = val;
- }
- }
+ case 2:
+ *(FT_UShort*)q = (FT_UShort)val;
break;
- case t1_field_string:
- {
- FT_Memory memory = parser->memory;
- FT_UInt len = limit-cur;
+ case 4:
+ *(FT_UInt32*)q = (FT_UInt32)val;
+ break;
+
+ default: /* for 64-bit systems */
+ *(FT_Long*)q = val;
+ }
+ break;
+
+ case t1_field_string:
+ {
+ FT_Memory memory = parser->memory;
+ FT_UInt len = limit-cur;
- if ( ALLOC( string, len+1 ) )
- goto Exit;
+ if ( ALLOC( string, len + 1 ) )
+ goto Exit;
- MEM_Copy( string, cur, len );
- string[len] = 0;
+ MEM_Copy( string, cur, len );
+ string[len] = 0;
- *(FT_String**)q = string;
- }
- break;
+ *(FT_String**)q = string;
+ }
+ break;
- default:
- /* an error occured */
- goto Fail;
+ default:
+ /* an error occured */
+ goto Fail;
}
}
- if (pflags)
+
+ if ( pflags )
*pflags |= 1L << field->flag_bit;
- error = 0;
+ error = FT_Err_Ok;
+
Exit:
return error;
+
Fail:
error = T1_Err_Invalid_File_Format;
goto Exit;
@@ -822,6 +900,7 @@
#define T1_MAX_TABLE_ELEMENTS 32
+
LOCAL_FUNC
FT_Error Z1_Load_Field_Table( Z1_Parser* parser,
const Z1_Field_Rec* field,
@@ -829,19 +908,20 @@
FT_UInt max_objects,
FT_ULong* pflags )
{
- Z1_Token_Rec elements[T1_MAX_TABLE_ELEMENTS];
- Z1_Token_Rec* token;
- FT_Int num_elements;
- FT_Error error = 0;
- FT_Byte* old_cursor;
- FT_Byte* old_limit;
- Z1_Field_Rec fieldrec = *(Z1_Field_Rec*)field;
+ Z1_Token_Rec elements[T1_MAX_TABLE_ELEMENTS];
+ Z1_Token_Rec* token;
+ FT_Int num_elements;
+ FT_Error error = 0;
+ FT_Byte* old_cursor;
+ FT_Byte* old_limit;
+ Z1_Field_Rec fieldrec = *(Z1_Field_Rec*)field;
+
Z1_ToTokenArray( parser, elements, 32, &num_elements );
- if (num_elements < 0)
+ if ( num_elements < 0 )
goto Fail;
- if (num_elements > T1_MAX_TABLE_ELEMENTS)
+ if ( num_elements > T1_MAX_TABLE_ELEMENTS )
num_elements = T1_MAX_TABLE_ELEMENTS;
old_cursor = parser->cursor;
@@ -848,7 +928,7 @@
old_limit = parser->limit;
/* we store the elements count */
- *(FT_Byte*)((FT_Byte*)objects[0] + field->count_offset) = num_elements;
+ *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = num_elements;
/* we now load each element, adjusting the field.offset on each one */
token = elements;
@@ -860,7 +940,7 @@
fieldrec.offset += fieldrec.size;
}
- if (pflags)
+ if ( pflags )
*pflags |= 1L << field->flag_bit;
parser->cursor = old_cursor;
@@ -868,6 +948,7 @@
Exit:
return error;
+
Fail:
error = T1_Err_Invalid_File_Format;
goto Exit;
@@ -874,11 +955,6 @@
}
-
-
-
-
-
LOCAL_FUNC
FT_Long Z1_ToInt ( Z1_Parser* parser )
{
@@ -887,7 +963,8 @@
LOCAL_FUNC
- FT_Long Z1_ToFixed( Z1_Parser* parser, FT_Int power_ten )
+ FT_Long Z1_ToFixed( Z1_Parser* parser,
+ FT_Int power_ten )
{
return t1_tofixed( &parser->cursor, parser->limit, power_ten );
}
@@ -894,27 +971,30 @@
LOCAL_FUNC
- FT_Int Z1_ToCoordArray( Z1_Parser* parser,
- FT_Int max_coords,
- FT_Short* coords )
+ FT_Int Z1_ToCoordArray( Z1_Parser* parser,
+ FT_Int max_coords,
+ FT_Short* coords )
{
- return t1_tocoordarray( &parser->cursor, parser->limit, max_coords, coords );
+ return t1_tocoordarray( &parser->cursor, parser->limit,
+ max_coords, coords );
}
LOCAL_FUNC
- FT_Int Z1_ToFixedArray( Z1_Parser* parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten )
+ FT_Int Z1_ToFixedArray( Z1_Parser* parser,
+ FT_Int max_values,
+ FT_Fixed* values,
+ FT_Int power_ten )
{
- return t1_tofixedarray( &parser->cursor, parser->limit, max_values, values, power_ten );
+ return t1_tofixedarray( &parser->cursor, parser->limit,
+ max_values, values, power_ten );
}
#if 0
+
LOCAL_FUNC
- FT_String* Z1_ToString( Z1_Parser* parser )
+ FT_String* Z1_ToString( Z1_Parser* parser )
{
return t1_tostring( &parser->cursor, parser->limit, parser->memory );
}
@@ -921,30 +1001,38 @@
LOCAL_FUNC
- FT_Bool Z1_ToBool( Z1_Parser* parser )
+ FT_Bool Z1_ToBool( Z1_Parser* parser )
{
return t1_tobool( &parser->cursor, parser->limit );
}
-#endif
+#endif /* 0 */
+
static
- FT_Error read_pfb_tag( FT_Stream stream, FT_UShort *tag, FT_Long* size )
+ FT_Error read_pfb_tag( FT_Stream stream,
+ FT_UShort* tag,
+ FT_Long* size )
{
FT_Error error;
- if (READ_UShort(*tag)) goto Exit;
- if (*tag == 0x8001 || *tag == 0x8002)
+
+ if ( READ_UShort( *tag ) )
+ goto Exit;
+
+ if ( *tag == 0x8001 || *tag == 0x8002 )
{
FT_Long asize;
- if (READ_ULong(asize)) goto Exit;
+ if ( READ_ULong( asize ) )
+ goto Exit;
+
/* swap between big and little endianness */
- *size = ((asize & 0xFF000000) >> 24) |
- ((asize & 0x00FF0000) >> 8 ) |
- ((asize & 0x0000FF00) << 8 ) |
- ((asize & 0x000000FF) << 24);
+ *size = ( ( asize & 0xFF000000L ) >> 24 ) |
+ ( ( asize & 0x00FF0000L ) >> 8 ) |
+ ( ( asize & 0x0000FF00L ) << 8 ) |
+ ( ( asize & 0x000000FFL ) << 24 );
}
Exit:
@@ -952,7 +1040,6 @@
}
-
LOCAL_FUNC
FT_Error Z1_New_Parser( Z1_Parser* parser,
FT_Stream stream,
@@ -962,6 +1049,7 @@
FT_UShort tag;
FT_Long size;
+
parser->stream = stream;
parser->memory = memory;
parser->base_len = 0;
@@ -977,42 +1065,43 @@
/******************************************************************/
/* */
- /* Here's a short summary of what is going on : */
+ /* Here a short summary of what is going on: */
/* */
- /* When creating a new Type 1 parser, we try to locate and */
- /* load the base dictionary when this is possible (i.e. for */
- /* .pfb files). Otherwise, we load the whole font in memory. */
+ /* When creating a new Type 1 parser, we try to locate and load */
+ /* the base dictionary if this is possible (i.e. for PFB */
+ /* files). Otherwise, we load the whole font into memory. */
/* */
- /* When "loading" the base dictionary, we only setup pointers */
- /* in the case of a memory-based stream. Otherwise, we allocate */
- /* and load the base dict in it. */
+ /* When `loading' the base dictionary, we only setup pointers */
+ /* in the case of a memory-based stream. Otherwise, we */
+ /* allocate and load the base dictionary in it. */
/* */
- /* parser->in_pfb is set when we are in a binary (".pfb") font */
- /* parser->in_memory is set when we have a memory stream. */
+ /* parser->in_pfb is set if we are in a binary (".pfb") font. */
+ /* parser->in_memory is set if we have a memory stream. */
/* */
- /* try to compute the size of the base dictionary */
+ /* try to compute the size of the base dictionary; */
/* look for a Postscript binary file tag, i.e 0x8001 */
- if ( FILE_Seek(0L) )
+ if ( FILE_Seek( 0L ) )
goto Exit;
error = read_pfb_tag( stream, &tag, &size );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
- if (tag != 0x8001)
+ if ( tag != 0x8001 )
{
- /* assume that this is a PFA file for now, an error will */
+ /* assume that this is a PFA file for now; an error will */
/* be produced later when more things are checked */
- (void)FILE_Seek(0L);
+ (void)FILE_Seek( 0L );
size = stream->size;
}
else
parser->in_pfb = 1;
- /* now, try to load the "size" bytes of the "base" dictionary we */
- /* found previously */
+ /* now, try to load `size' bytes of the `base' dictionary we */
+ /* found previously */
- /* if it's a memory-based resource, set up pointers */
+ /* if it is a memory-based resource, set up pointers */
if ( !stream->read )
{
parser->base_dict = (FT_Byte*)stream->base + stream->pos;
@@ -1019,8 +1108,9 @@
parser->base_len = size;
parser->in_memory = 1;
- /* check that the "size" field is valid */
- if ( FILE_Skip(size) ) goto Exit;
+ /* check that the `size' field is valid */
+ if ( FILE_Skip( size ) )
+ goto Exit;
}
else
{
@@ -1031,14 +1121,16 @@
parser->base_len = size;
}
- /* Now check font format, we must see a '%!PS-AdobeFont-1' */
- /* or a '%!FontType' */
+ /* Now check font format; we must see `%!PS-AdobeFont-1' */
+ /* or `%!FontType' */
{
- if ( size <= 16 ||
- ( strncmp( (const char*)parser->base_dict, "%!PS-AdobeFont-1", 16 ) &&
- strncmp( (const char*)parser->base_dict, "%!FontType", 10 ) ) )
+ if ( size <= 16 ||
+ ( strncmp( (const char*)parser->base_dict,
+ "%!PS-AdobeFont-1", 16 ) &&
+ strncmp( (const char*)parser->base_dict,
+ "%!FontType", 10 ) ) )
{
- FT_TRACE2(( "Not a Type1 font\n" ));
+ FT_TRACE2(( "[not a Type1 font]\n" ));
error = FT_Err_Unknown_File_Format;
}
else
@@ -1049,7 +1141,7 @@
}
Exit:
- if (error && !parser->in_memory)
+ if ( error && !parser->in_memory )
FREE( parser->base_dict );
return error;
@@ -1061,34 +1153,39 @@
{
FT_Memory memory = parser->memory;
+
/* always free the private dictionary */
FREE( parser->private_dict );
/* free the base dictionary only when we have a disk stream */
- if (!parser->in_memory)
+ if ( !parser->in_memory )
FREE( parser->base_dict );
}
- /* return the value of an hexadecimal digit */
- static
- int hexa_value( char c )
- {
+ /* return the value of an hexadecimal digit */
+ static
+ int hexa_value( char c )
+ {
unsigned int d;
- d = (unsigned int)(c-'0');
- if ( d <= 9 ) return (int)d;
- d = (unsigned int)(c-'a');
- if ( d <= 5 ) return (int)(d+10);
+ d = (unsigned int)( c - '0' );
+ if ( d <= 9 )
+ return (int)d;
- d = (unsigned int)(c-'A');
- if ( d <= 5 ) return (int)(d+10);
+ d = (unsigned int)( c - 'a' );
+ if ( d <= 5 )
+ return (int)( d + 10 );
- return -1;
- }
+ d = (unsigned int)( c - 'A' );
+ if ( d <= 5 )
+ return (int)( d + 10 );
+ return -1;
+ }
+
LOCAL_FUNC
void Z1_Decrypt( FT_Byte* buffer,
FT_Int length,
@@ -1098,8 +1195,9 @@
{
FT_Byte plain;
- plain = (*buffer ^ (seed >> 8));
- seed = (*buffer+seed)*52845+22719;
+
+ plain = ( *buffer ^ ( seed >> 8 ) );
+ seed = ( *buffer + seed ) * 52845 + 22719;
*buffer++ = plain;
length--;
}
@@ -1114,28 +1212,31 @@
FT_Error error = 0;
FT_Long size;
- if (parser->in_pfb)
+
+ if ( parser->in_pfb )
{
/* in the case of the PFB format, the private dictionary can be */
- /* made of several segments. We thus first read the number of */
+ /* made of several segments. We thus first read the number of */
/* segments to compute the total size of the private dictionary */
- /* then re-read them into memory.. */
- FT_Long start_pos = FILE_Pos();
+ /* then re-read them into memory. */
+ FT_Long start_pos = FILE_Pos();
FT_UShort tag;
FT_Long size;
+
parser->private_len = 0;
for (;;)
{
- error = read_pfb_tag(stream, &tag, &size);
- if (error) goto Fail;
+ error = read_pfb_tag( stream, &tag, &size );
+ if ( error )
+ goto Fail;
- if (tag != 0x8002)
+ if ( tag != 0x8002 )
break;
parser->private_len += size;
- if ( FILE_Skip(size) )
+ if ( FILE_Skip( size ) )
goto Fail;
}
@@ -1143,7 +1244,8 @@
/* and allocate private dictionary buffer */
if ( parser->private_len == 0 )
{
- FT_ERROR(( "T1.Open_Private: invalid private dictionary section\n" ));
+ FT_ERROR(( "Z1_Get_Private_Dict:" ));
+ FT_ERROR(( " invalid private dictionary section\n" ));
error = T1_Err_Invalid_File_Format;
goto Fail;
}
@@ -1156,7 +1258,11 @@
for (;;)
{
error = read_pfb_tag( stream, &tag, &size );
- if (error || tag != 0x8002) { error = 0; break; }
+ if ( error || tag != 0x8002 )
+ {
+ error = FT_Err_Ok;
+ break;
+ }
if ( FILE_Read( parser->private_dict + parser->private_len, size ) )
goto Fail;
@@ -1166,29 +1272,31 @@
}
else
{
- /* we have already "loaded" the whole PFA font file in memory */
- /* if this is a memory resource, allocate a new block to hold */
- /* the private dict. Otherwise, simply overwrite into the */
- /* base dict block in the heap.. */
+ /* we have already `loaded' the whole PFA font file into memory; */
+ /* if this is a memory resource, allocate a new block to hold */
+ /* the private dict. Otherwise, simply overwrite into the base */
+ /* dictionary block in the heap. */
- /* first of all, look at the "eexec" keyword */
+ /* first of all, look at the `eexec' keyword */
FT_Byte* cur = parser->base_dict;
FT_Byte* limit = cur + parser->base_len;
FT_Byte c;
+
for (;;)
{
c = cur[0];
- if (c == 'e' && cur+9 < limit) /* 9 = 5 letters for 'eexec' + newline + 4 chars */
+ if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */
+ /* newline + 4 chars */
{
if ( cur[1] == 'e' && cur[2] == 'x' &&
cur[3] == 'e' && cur[4] == 'c' )
{
- cur += 6; /* we skip the newling after the "eexec" */
+ cur += 6; /* we skip the newling after the `eexec' */
- /* XXX: Some fonts use DOS-linefeeds, i.e. \r\n, we need to skip */
- /* the extra \n when we find it.. */
- if (cur[0] == '\n')
+ /* XXX: Some fonts use DOS-linefeeds, i.e. \r\n; we need to */
+ /* skip the extra \n if we find it */
+ if ( cur[0] == '\n' )
cur++;
break;
@@ -1195,24 +1303,26 @@
}
}
cur++;
- if (cur >= limit)
+ if ( cur >= limit )
{
- FT_ERROR(("T1.Open_Private: could not find 'eexec' keyword\n"));
+ FT_ERROR(( "Z1_Get_Private_Dict:" ));
+ FT_ERROR(( " could not find `eexec' keyword\n" ));
error = T1_Err_Invalid_File_Format;
goto Exit;
}
}
- /* now determine wether where to write the _encrypted_ binary private */
- /* dictionary. We overwrite the base dictionary for disk-based resources */
- /* and allocate a new block otherwise */
+ /* now determine where to write the _encrypted_ binary private */
+ /* dictionary. We overwrite the base dictionary for disk-based */
+ /* resources and allocate a new block otherwise */
- size = parser->base_len - (cur-parser->base_dict);
+ size = parser->base_len - ( cur - parser->base_dict);
if ( parser->in_memory )
{
- /* note that we allocate one more byte to put a terminating '0' */
- if (ALLOC( parser->private_dict, size+1 )) goto Fail;
+ /* note that we allocate one more byte to put a terminating `0' */
+ if ( ALLOC( parser->private_dict, size + 1 ) )
+ goto Fail;
parser->private_len = size;
}
else
@@ -1224,45 +1334,46 @@
parser->base_len = 0;
}
- /* now determine wether the private dictionary is encoded in binary */
- /* or hexadecimal ASCII format.. */
- /* and decode it accordingly */
+ /* now determine whether the private dictionary is encoded in binary */
+ /* or hexadecimal ASCII format -- decode it accordingly */
/* we need to access the next 4 bytes (after the final \r following */
- /* the 'eexec' keyword..) if they all are hexadecimal digits, then */
- /*we have a case of ASCII storage.. */
+ /* the `eexec' keyword); if they all are hexadecimal digits, then */
+ /* we have a case of ASCII storage */
if ( ( hexa_value( cur[0] ) | hexa_value( cur[1] ) |
hexa_value( cur[2] ) | hexa_value( cur[3] ) ) < 0 )
- {
- /* binary encoding - "simply" copy the private dict */
- MEM_Copy( parser->private_dict, cur, size );
- }
+
+ /* binary encoding -- `simply' copy the private dict */
+ MEM_Copy( parser->private_dict, cur, size );
+
else
{
- /* ASCII hexadecimal encoding.. This blows goats !!.. */
+ /* ASCII hexadecimal encoding */
FT_Byte* write;
FT_Int count;
+
write = parser->private_dict;
count = 0;
- for ( ;cur < limit; cur++)
+ for ( ;cur < limit; cur++ )
{
int hex1;
+
/* check for newline */
- if (cur[0] == '\r' || cur[0] == '\n')
+ if ( cur[0] == '\r' || cur[0] == '\n' )
continue;
/* exit if we have a non-hexadecimal digit that isn't a newline */
- hex1 = hexa_value(cur[0]);
- if (hex1 < 0 || cur+1 >= limit)
+ hex1 = hexa_value( cur[0] );
+ if ( hex1 < 0 || cur + 1 >= limit )
break;
/* otherwise, store byte */
- *write++ = (hex1 << 4) | hexa_value(cur[1]);
+ *write++ = ( hex1 << 4 ) | hexa_value( cur[1] );
count++;
cur++;
}
@@ -1283,3 +1394,5 @@
return error;
}
+
+/* END */
--- a/src/type1z/z1parse.h
+++ b/src/type1z/z1parse.h
@@ -1,33 +1,21 @@
-/*******************************************************************
- *
- * t1parse.h 2.0
- *
- * Type1 parser.
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- * The Type 1 parser is in charge of the following:
- *
- * - provide an implementation of a growing sequence of
- * objects called a Z1_Table (used to build various tables
- * needed by the loader).
- *
- * - opening .pfb and .pfa files to extract their top-level
- * and private dictionaries
- *
- * - read numbers, arrays & strings from any dictionary
- *
- * See "t1load.c" to see how data is loaded from the font file
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1parse.h */
+/* */
+/* Experimental Type 1 parser (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef Z1PARSE_H
#define Z1PARSE_H
@@ -39,7 +27,7 @@
/* simple enumeration type used to identify token types */
- typedef enum Z1_Token_Type_
+ typedef enum Z1_Token_Type_
{
t1_token_none = 0,
t1_token_any,
@@ -51,8 +39,9 @@
} Z1_Token_Type;
+
/* a simple structure used to identify tokens */
- typedef struct Z1_Token_Rec_
+ typedef struct Z1_Token_Rec_
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
@@ -60,8 +49,9 @@
} Z1_Token_Rec;
+
/* enumeration type used to identify object fields */
- typedef enum Z1_Field_Type_
+ typedef enum Z1_Field_Type_
{
t1_field_none = 0,
t1_field_bool,
@@ -76,8 +66,9 @@
} Z1_Field_Type;
+
/* structure type used to model object fields */
- typedef struct Z1_Field_Rec_
+ typedef struct Z1_Field_Rec_
{
Z1_Field_Type type; /* type of field */
FT_UInt offset; /* offset of field in object */
@@ -88,94 +79,114 @@
} Z1_Field_Rec;
-#define Z1_FIELD_REF(s,f) (((s*)0)->f)
-#define Z1_FIELD_BOOL( _ftype, _fname ) \
- { t1_field_bool, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)), \
- 0, 0, 0 }
+#define Z1_FIELD_REF( s, f ) ( ((s*)0)->f )
-#define Z1_FIELD_NUM( _ftype, _fname ) \
- { t1_field_integer, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)), \
- 0, 0, 0 }
+#define Z1_FIELD_BOOL( _ftype, _fname ) \
+ { \
+ t1_field_bool, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
+ 0, 0, 0 \
+ }
-#define Z1_FIELD_FIXED( _ftype, _fname, _power ) \
- { t1_field_fixed, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)), \
- 0, 0, 0 }
+#define Z1_FIELD_NUM( _ftype, _fname ) \
+ { \
+ t1_field_integer, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
+ 0, 0, 0 \
+ }
-#define Z1_FIELD_STRING( _ftype, _fname ) \
- { t1_field_string, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)), \
- 0, 0, 0 }
+#define Z1_FIELD_FIXED( _ftype, _fname, _power ) \
+ { \
+ t1_field_fixed, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
+ 0, 0, 0 \
+ }
-#define Z1_FIELD_NUM_ARRAY( _ftype, _fname, _fcount, _fmax ) \
- { t1_field_integer, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)[0]), \
- _fmax, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fcount), \
- 0 }
+#define Z1_FIELD_STRING( _ftype, _fname ) \
+ { \
+ t1_field_string, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
+ 0, 0, 0 \
+ }
+#define Z1_FIELD_NUM_ARRAY( _ftype, _fname, _fcount, _fmax ) \
+ { \
+ t1_field_integer, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
+ _fmax, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
+ 0 \
+ }
+
#define Z1_FIELD_FIXED_ARRAY( _ftype, _fname, _fcount, _fmax ) \
- { t1_field_fixed, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)[0]), \
- _fmax, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fcount), \
- 0 }
+ { \
+ t1_field_fixed, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
+ _fmax, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
+ 0 \
+ }
#define Z1_FIELD_NUM_ARRAY2( _ftype, _fname, _fmax ) \
- { t1_field_integer, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)[0]), \
- _fmax, \
- 0, 0 }
+ { \
+ t1_field_integer, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
+ _fmax, \
+ 0, 0 \
+ }
-#define Z1_FIELD_FIXED_ARRAY2( _ftype, _fname, _fmax ) \
- { t1_field_fixed, \
- (FT_UInt)(char*)&Z1_FIELD_REF(_ftype,_fname), \
- sizeof(Z1_FIELD_REF(_ftype,_fname)[0]), \
- _fmax, \
- 0, 0 }
+#define Z1_FIELD_FIXED_ARRAY2( _ftype, _fname, _fmax ) \
+ { \
+ t1_field_fixed, \
+ (FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
+ sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
+ _fmax, \
+ 0, 0 \
+ }
-
-/*************************************************************************
- *
- * <Struct> Z1_Table
- *
- * <Description>
- * A Z1_Table is a simple object used to store an array of objects
- * in a single memory block.
- *
- * <Fields>
- * block :: address in memory of the growheap's block. This
- * can change between two object adds, due to the use
- * of 'realloc'.
- *
- * cursor :: current top of the grow heap within its block
- *
- * capacity :: current size of the heap block. Increments by 1 Kb
- *
- * init :: boolean. set when the table has been initialized
- * (the table user should set this field)
- *
- * max_elems :: maximum number of elements in table
- * num_elems :: current number of elements in table
- *
- * elements :: table of element addresses within the block
- * lengths :: table of element sizes within the block
- *
- * memory :: memory object used for memory operations (alloc/realloc)
- */
-
- typedef struct Z1_Table_
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* Z1_Table */
+ /* */
+ /* <Description> */
+ /* A Z1_Table is a simple object used to store an array of objects in */
+ /* a single memory block. */
+ /* */
+ /* <Fields> */
+ /* block :: The address in memory of the growheap's block. This */
+ /* can change between two object adds, due to the use of */
+ /* reallocation. */
+ /* */
+ /* cursor :: The current top of the grow heap within its block. */
+ /* */
+ /* capacity :: The current size of the heap block. Increments in */
+ /* 1kByte blocks. */
+ /* */
+ /* init :: A boolean. Set when the table has been initialized */
+ /* (the table user should set this field). */
+ /* */
+ /* max_elems :: The maximum number of elements in the table. */
+ /* */
+ /* num_elems :: The current number of elements in the table. */
+ /* */
+ /* elements :: A table of element addresses within the block. */
+ /* */
+ /* lengths :: A table of element sizes within the block. */
+ /* */
+ /* memory :: The memory object used for memory operations */
+ /* (allocation/reallocation). */
+ /* */
+ typedef struct Z1_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
@@ -192,36 +203,44 @@
} Z1_Table;
-/*************************************************************************
- *
- * <Struct> Z1_Parser
- *
- * <Description>
- * A Z1_Parser is an object used to parse a Type 1 fonts very
- * quickly.
- *
- * <Fields>
- * stream :: current input stream
- * memory :: current memory object
- *
- * base_dict :: pointer to top-level dictionary
- * base_len :: length in bytes of top dict
- *
- * private_dict :: pointer to private dictionary
- * private_len :: length in bytes of private dict
- *
- * in_pfb :: boolean. Indicates that we're in a .pfb file
- * in_memory :: boolean. Indicates a memory-based stream
- * single_block :: boolean. Indicates that the private dict
- * is stored in lieu of the base dict
- *
- * cursor :: current parser cursor
- * limit :: current parser limit (first byte after current
- * dictionary).
- *
- * error :: current parsing error
- */
- typedef struct Z1_Parser_
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* Z1_Parser */
+ /* */
+ /* <Description> */
+ /* A Z1_Parser is an object used to parse a Type 1 fonts very */
+ /* quickly. */
+ /* */
+ /* <Fields> */
+ /* stream :: The current input stream. */
+ /* */
+ /* memory :: The current memory object. */
+ /* */
+ /* base_dict :: A pointer to the top-level dictionary. */
+ /* */
+ /* base_len :: The length in bytes of the top dictionary. */
+ /* */
+ /* private_dict :: A pointer to the private dictionary. */
+ /* */
+ /* private_len :: The length in bytes of the private dictionary. */
+ /* */
+ /* in_pfb :: A boolean. Indicates that we are handling a PFB */
+ /* file. */
+ /* */
+ /* in_memory :: A boolean. Indicates a memory-based stream. */
+ /* */
+ /* single_block :: A boolean. Indicates that the private dictionary */
+ /* is stored in lieu of the base dictionary. */
+ /* */
+ /* cursor :: The current parser cursor. */
+ /* */
+ /* limit :: The current parser limit (first byte after the */
+ /* current dictionary). */
+ /* */
+ /* error :: The current parsing error. */
+ /* */
+ typedef struct Z1_Parser_
{
FT_Stream stream;
FT_Memory memory;
@@ -264,41 +283,38 @@
void Z1_Release_Table( Z1_Table* table );
LOCAL_DEF
- FT_Long Z1_ToInt ( Z1_Parser* parser );
+ FT_Long Z1_ToInt( Z1_Parser* parser );
LOCAL_DEF
- FT_Long Z1_ToFixed( Z1_Parser* parser, FT_Int power_ten );
+ FT_Long Z1_ToFixed( Z1_Parser* parser,
+ FT_Int power_ten );
LOCAL_DEF
- FT_Int Z1_ToCoordArray( Z1_Parser* parser,
- FT_Int max_coords,
- FT_Short* coords );
+ FT_Int Z1_ToCoordArray( Z1_Parser* parser,
+ FT_Int max_coords,
+ FT_Short* coords );
LOCAL_DEF
- FT_Int Z1_ToFixedArray( Z1_Parser* parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten );
+ FT_Int Z1_ToFixedArray( Z1_Parser* parser,
+ FT_Int max_values,
+ FT_Fixed* values,
+ FT_Int power_ten );
#if 0
LOCAL_DEF
- FT_String* Z1_ToString( Z1_Parser* parser );
+ FT_String* Z1_ToString( Z1_Parser* parser );
LOCAL_DEF
- FT_Bool Z1_ToBool( Z1_Parser* parser );
+ FT_Bool Z1_ToBool( Z1_Parser* parser );
#endif
-
-
-
-
LOCAL_DEF
- void Z1_Skip_Spaces( Z1_Parser* parser );
+ void Z1_Skip_Spaces( Z1_Parser* parser );
LOCAL_DEF
- void Z1_ToToken( Z1_Parser* parser,
- Z1_Token_Rec* token );
+ void Z1_ToToken( Z1_Parser* parser,
+ Z1_Token_Rec* token );
LOCAL_FUNC
void Z1_ToTokenArray( Z1_Parser* parser,
@@ -345,4 +361,3 @@
/* END */
-
--- a/src/type1z/z1tokens.h
+++ b/src/type1z/z1tokens.h
@@ -1,22 +1,21 @@
-/*******************************************************************
- *
- * t1tokens.h
- *
- * Type 1 tokens definition
- *
- * Copyright 2000 David Turner, Robert Wilhelm and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- * This file only contains macros that are expanded when compiling
- * the "t1load.c" source file.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* z1tokens.h */
+/* */
+/* Experimental Type 1 tokenizer (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#undef T1TYPE
#define T1TYPE T1_FontInfo
@@ -26,35 +25,38 @@
Z1_FONTINFO_STRING( "FamilyName", family_name )
Z1_FONTINFO_STRING( "Weight", weight )
- Z1_FONTINFO_NUM( "ItalicAngle", italic_angle )
- Z1_FONTINFO_BOOL( "isFixedPitch", is_fixed_pitch )
- Z1_FONTINFO_NUM( "UnderlinePosition", underline_position )
- Z1_FONTINFO_NUM( "UnderlineThickness", underline_thickness )
+ Z1_FONTINFO_NUM ( "ItalicAngle", italic_angle )
+ Z1_FONTINFO_BOOL ( "isFixedPitch", is_fixed_pitch )
+ Z1_FONTINFO_NUM ( "UnderlinePosition", underline_position )
+ Z1_FONTINFO_NUM ( "UnderlineThickness", underline_thickness )
+
#undef T1TYPE
#define T1TYPE T1_Private
- Z1_PRIVATE_NUM ( "UniqueID", unique_id )
- Z1_PRIVATE_NUM ( "lenIV", lenIV )
- Z1_PRIVATE_NUM ( "LanguageGroup", language_group )
- Z1_PRIVATE_NUM ( "password", password )
-
- Z1_PRIVATE_FIXED( "BlueScale", blue_scale )
- Z1_PRIVATE_NUM ( "BlueShift", blue_shift )
- Z1_PRIVATE_NUM ( "BlueFuzz", blue_fuzz )
-
- Z1_PRIVATE_NUM_TABLE( "BlueValues", blue_values, 14, num_blue_values )
- Z1_PRIVATE_NUM_TABLE( "OtherBlues", other_blues, 10, num_other_blues )
- Z1_PRIVATE_NUM_TABLE( "FamilyBlues", family_blues, 14, num_family_blues )
- Z1_PRIVATE_NUM_TABLE( "FamilyOtherBlues", family_other_blues, 10, num_family_other_blues )
+ Z1_PRIVATE_NUM ( "UniqueID", unique_id )
+ Z1_PRIVATE_NUM ( "lenIV", lenIV )
+ Z1_PRIVATE_NUM ( "LanguageGroup", language_group )
+ Z1_PRIVATE_NUM ( "password", password )
+ Z1_PRIVATE_FIXED ( "BlueScale", blue_scale )
+ Z1_PRIVATE_NUM ( "BlueShift", blue_shift )
+ Z1_PRIVATE_NUM ( "BlueFuzz", blue_fuzz )
+
+ Z1_PRIVATE_NUM_TABLE ( "BlueValues", blue_values, 14, num_blue_values )
+ Z1_PRIVATE_NUM_TABLE ( "OtherBlues", other_blues, 10, num_other_blues )
+ Z1_PRIVATE_NUM_TABLE ( "FamilyBlues", family_blues, 14, num_family_blues )
+ Z1_PRIVATE_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10, \
+ num_family_other_blues )
+
Z1_PRIVATE_NUM_TABLE2( "StdHW", standard_width, 1 )
Z1_PRIVATE_NUM_TABLE2( "StdVW", standard_height, 1 )
Z1_PRIVATE_NUM_TABLE2( "MinFeature", min_feature, 2 )
-
+
Z1_PRIVATE_NUM_TABLE ( "StemSnapH", snap_widths, 12, num_snap_widths )
Z1_PRIVATE_NUM_TABLE ( "StemSnapV", snap_heights, 12, num_snap_heights )
+
#undef T1TYPE
#define T1TYPE T1_Font
@@ -62,64 +64,69 @@
Z1_TOPDICT_NUM( "FontType", font_type )
Z1_TOPDICT_NUM( "StrokeWidth", stroke_width )
+
#if 0
+
/* define the font info dictionary parsing callbacks */
#undef FACE
#define FACE (face->type1.font_info)
- PARSE_STRING("version",version)
- PARSE_STRING("Notice",notice)
- PARSE_STRING("FullName",full_name)
- PARSE_STRING("FamilyName",family_name)
- PARSE_STRING("Weight",weight)
+ PARSE_STRING( "version", version )
+ PARSE_STRING( "Notice", notice )
+ PARSE_STRING( "FullName", full_name )
+ PARSE_STRING( "FamilyName", family_name )
+ PARSE_STRING( "Weight", weight )
- PARSE_INT("ItalicAngle",italic_angle)
- PARSE_BOOL("isFixedPitch",is_fixed_pitch)
- PARSE_NUM("UnderlinePosition",underline_position,FT_Short)
- PARSE_NUM("UnderlineThickness",underline_thickness,FT_UShort)
+ PARSE_INT ( "ItalicAngle", italic_angle )
+ PARSE_BOOL ( "isFixedPitch", is_fixed_pitch )
+ PARSE_NUM ( "UnderlinePosition", underline_position, FT_Short )
+ PARSE_NUM ( "UnderlineThickness", underline_thickness, FT_UShort )
- /* define the private dict parsing callbacks */
+ /* define the private dict parsing callbacks */
#undef FACE
#define FACE (face->type1.private_dict)
- PARSE_INT("UniqueID",unique_id)
- PARSE_INT("lenIV",lenIV)
+ PARSE_INT ("UniqueID", unique_id )
+ PARSE_INT ("lenIV", lenIV )
- PARSE_COORDS( "BlueValues", num_blues, 14, blue_values)
- PARSE_COORDS( "OtherBlues", num_other_blues, 10, other_blues)
+ PARSE_COORDS ( "BlueValues", num_blues, 14, blue_values)
+ PARSE_COORDS ( "OtherBlues", num_other_blues, 10, other_blues)
- PARSE_COORDS( "FamilyBlues", num_family_blues, 14, family_blues)
- PARSE_COORDS( "FamilyOtherBlues", num_family_other_blues, 10, family_other_blues)
+ PARSE_COORDS ( "FamilyBlues", num_family_blues, 14, family_blues )
+ PARSE_COORDS ( "FamilyOtherBlues", num_family_other_blues, 10,
+ family_other_blues )
- PARSE_FIXED( "BlueScale", blue_scale)
- PARSE_INT( "BlueShift", blue_shift)
+ PARSE_FIXED ( "BlueScale", blue_scale )
+ PARSE_INT ( "BlueShift", blue_shift )
- PARSE_INT( "BlueFuzz", blue_fuzz)
+ PARSE_INT ( "BlueFuzz", blue_fuzz )
- PARSE_COORDS2( "StdHW", 1, standard_width )
- PARSE_COORDS2( "StdVW", 1, standard_height )
+ PARSE_COORDS2( "StdHW", 1, standard_width )
+ PARSE_COORDS2( "StdVW", 1, standard_height )
- PARSE_COORDS( "StemSnapH", num_snap_widths, 12, stem_snap_widths )
- PARSE_COORDS( "StemSnapV", num_snap_heights, 12, stem_snap_heights )
+ PARSE_COORDS ( "StemSnapH", num_snap_widths, 12, stem_snap_widths )
+ PARSE_COORDS ( "StemSnapV", num_snap_heights, 12, stem_snap_heights )
- PARSE_INT( "LanguageGroup", language_group )
- PARSE_INT( "password", password )
- PARSE_COORDS2( "MinFeature", 2, min_feature )
+ PARSE_INT ( "LanguageGroup", language_group )
+ PARSE_INT ( "password", password )
+ PARSE_COORDS2( "MinFeature", 2, min_feature )
- /* define the top-level dictionary parsing callbacks */
+ /* define the top-level dictionary parsing callbacks */
#undef FACE
#define FACE (face->type1)
+/*PARSE_STRING ( "FontName", font_name ) -- handled by special routine */
+ PARSE_NUM ( "PaintType", paint_type, FT_Byte )
+ PARSE_NUM ( "FontType", font_type, FT_Byte )
+ PARSE_FIXEDS2( "FontMatrix", 4, font_matrix )
+/*PARSE_COORDS2( "FontBBox", 4, font_bbox ) -- handled by special routine */
+ PARSE_INT ( "StrokeWidth", stroke_width )
-/* PARSE_STRING( "FontName", font_name ) -- handled by special routine */
- PARSE_NUM( "PaintType", paint_type, FT_Byte )
- PARSE_NUM( "FontType", font_type, FT_Byte )
- PARSE_FIXEDS2( "FontMatrix", 4, font_matrix )
-/* PARSE_COORDS2( "FontBBox", 4, font_bbox ) -- handled by special func */
- PARSE_INT( "StrokeWidth", stroke_width )
-
#undef FACE
-#endif
+#endif /* 0 */
+
+
+/* END */