The Type 1 experimental driver was updated

- small reduction of the code size of "t1encode.c"
- removed the hinter (not useful with the upcoming
  auto-hinter..)
- updated "t1load.c" to reduce warnings with Visual C++
- considerably changed the glyph loader (it is simpler)

Beware, this code is still experimental, and is _not_
debugged. I don't even guarantee that it works for
now

- David
This commit is contained in:
David Turner 2000-02-02 12:20:53 +00:00
parent 8f43c714a5
commit 0dd3434801
9 changed files with 603 additions and 1336 deletions

View File

@ -106,13 +106,10 @@ T1Z_COMPILE := $(FT_COMPILE) $(T1Z_INCLUDE:%=$I%)
# Type1 driver sources (i.e., C files)
#
T1Z_DRV_SRC := $(T1Z_DIR_)t1parse.c \
$(T1Z_DIR_)t1load.c
# $(T1Z_DIR_)t1parse.c \
# $(T1Z_DIR_)t1tokens.c \
# $(T1Z_DIR_)t1driver.c \
# $(T1Z_DIR_)t1encode.c \
# $(T1Z_DIR_)t1hinter.c \
# $(T1Z_DIR_)t1gload.c
$(T1Z_DIR_)t1load.c \
$(T1Z_DIR_)t1driver.c \
$(T1Z_DIR_)t1encode.c \
$(T1Z_DIR_)t1gload.c
# Type1 driver headers

View File

@ -184,14 +184,14 @@
/* */
/* t1_standard_encoding[33] == 2 */
/* */
/* which means that the glyph name for character code 32 is */
/* which means that the glyph name for character code 33 is */
/* */
/* t1_standard_strings[2] == "exclam" */
/* */
/* (this correspond to the exclamation mark `!'). */
/* */
LOCAL_FUNC
T1_Short t1_standard_encoding[256] =
T1_Byte t1_standard_encoding[256] =
{
/* 0 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -240,7 +240,7 @@
/* */
/* t1_expert_encoding[33] == 229 */
/* */
/* which means that the glyph name for character code 32 is */
/* which means that the glyph name for character code 33 is */
/* */
/* t1_standard_strings[229] == "exclamsmall" */
/* */
@ -281,52 +281,4 @@
373, 374, 375, 376, 377, 378
};
/*************************************************************************/
/* */
/* t1_expert_subset_encoding: */
/* */
/* A simple table used to encode the Adobe ExpertEncoding subset */
/* defined in the CFF specification. It will probably evolve into */
/* another form sooner or later, as we deal with charsets */
/* differently than with encodings. */
/* */
LOCAL_FUNC
FT_Short t1_expert_subset_encoding[256] =
{
/* 0 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 231, 232, 0, 0,
235, 236, 237, 238, 13, 14, 15, 99, 239, 240,
/* 50 */
241, 242, 243, 244, 245, 246, 247, 248, 27, 28,
249, 250, 251, 252, 0, 253, 254, 255, 256, 257,
0, 0, 0, 258, 0, 0, 259, 260, 261, 262,
0, 0, 263, 264, 265, 0, 266, 109, 110, 267,
268, 269, 0, 270, 0, 272, 0, 0, 0, 0,
/* 100 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 300, 301, 302, 303, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 150 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 304, 305, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 314, 315,
0, 0, 0, 0, 0, 0, 0, 0, 158, 155,
163, 0, 320, 321, 322, 323, 324, 325, 0, 0,
/* 200 */
326, 150, 164, 169, 327, 328, 329, 330, 331, 332,
333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
343, 344, 345, 346, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 250 */
0, 0, 0, 0, 0, 0
};
/* END */

View File

@ -56,7 +56,7 @@
/* (this correspond to the exclamation mark `!'). */
/* */
LOCAL_DEF
T1_Short t1_standard_encoding[256];
T1_Byte t1_standard_encoding[256];
/*************************************************************************/
@ -79,17 +79,6 @@
T1_Short t1_expert_encoding[256];
/*************************************************************************/
/* */
/* t1_expert_subset_encoding: */
/* */
/* A simple table used to encode the Adobe ExpertEncoding subset */
/* defined in the CFF specification. It will probably evolve into */
/* another form sooner or later, as we deal with charsets */
/* differently than with encodings. */
/* */
LOCAL_DEF
T1_Short t1_expert_subset_encoding[256];
#endif /* T1ENCODE_H */

File diff suppressed because it is too large Load Diff

View File

@ -42,57 +42,6 @@
#endif
/*************************************************************************/
/* */
/* <Structure> T1_Builder_Funcs */
/* */
/* <Description> */
/* a structure used to store the address of various functions */
/* used by a glyph builder to implement the outline's "path */
/* construction". */
/* */
/* */
typedef struct T1_Builder_ T1_Builder;
typedef T1_Error (*T1_Builder_EndChar)( T1_Builder* loader );
typedef T1_Error (*T1_Builder_Sbw) ( T1_Builder* loader,
T1_Pos sbx,
T1_Pos sby,
T1_Pos wx,
T1_Pos wy );
typedef T1_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
typedef T1_Error (*T1_Builder_RLineTo)( T1_Builder* loader,
T1_Pos dx,
T1_Pos dy );
typedef T1_Error (*T1_Builder_RMoveTo)( T1_Builder* loader,
T1_Pos dx,
T1_Pos dy );
typedef T1_Error (*T1_Builder_RCurveTo)( T1_Builder* loader,
T1_Pos dx1,
T1_Pos dy1,
T1_Pos dx2,
T1_Pos dy2,
T1_Pos dx3,
T1_Pos dy3 );
typedef struct T1_Builder_Funcs_
{
T1_Builder_EndChar end_char;
T1_Builder_Sbw set_bearing_point;
T1_Builder_ClosePath close_path;
T1_Builder_RLineTo rline_to;
T1_Builder_RMoveTo rmove_to;
T1_Builder_RCurveTo rcurve_to;
} T1_Builder_Funcs;
/*************************************************************************/
/* */
/* <Structure> T1_Builder */
@ -103,7 +52,6 @@
/* <Fields> */
/* system :: current system object */
/* face :: current face object */
/* size :: current size object */
/* glyph :: current glyph slot */
/* */
/* current :: current glyph outline */
@ -125,22 +73,18 @@
/* path_begun :: flag, indicates that a new path has begun */
/* load_points :: flag, if not set, no points are loaded */
/* */
/* pass :: pass number for multi-pass hinters */
/* */
/* funcs :: table of builder functions used to perform */
/* the outline's path construction */
/* */
/* hint_point :: index of next point to hint.. */
/* */
/* */
/* 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.. */
/* */
struct T1_Builder_
typedef struct T1_Builder_
{
FT_Memory memory;
T1_Face face;
T1_Size size;
T1_GlyphSlot glyph;
FT_Outline current; /* the current glyph outline */
@ -163,88 +107,11 @@
T1_BBox bbox; /* bounding box */
T1_Bool path_begun;
T1_Bool load_points;
T1_Int pass;
T1_Int hint_point;
/* path construction function interface */
T1_Builder_Funcs funcs;
};
/*************************************************************************/
/* */
/* <Structure> T1_Hinter_Funcs */
/* */
/* <Description> */
/* a structure used to store the address of various functions */
/* used by a Type 1 hinter to perform outline hinting. */
/* */
typedef T1_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
typedef T1_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
typedef T1_Error (*T1_Hinter_Stem)( T1_Builder* builder,
T1_Pos pos,
T1_Pos width,
T1_Bool vertical );
typedef T1_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
T1_Pos pos0,
T1_Pos width0,
T1_Pos pos1,
T1_Pos width1,
T1_Pos pos2,
T1_Pos width2,
T1_Bool vertical );
typedef struct T1_Hinter_Func_
{
T1_Hinter_ChangeHints change_hints;
T1_Hinter_DotSection dot_section;
T1_Hinter_Stem stem;
T1_Hinter_Stem3 stem3;
} T1_Hinter_Funcs;
typedef enum T1_Operator_
{
op_none = 0,
op_endchar,
op_hsbw,
op_seac,
op_sbw,
op_closepath,
op_hlineto,
op_hmoveto,
op_hvcurveto,
op_rlineto,
op_rmoveto,
op_rrcurveto,
op_vhcurveto,
op_vlineto,
op_vmoveto,
op_dotsection,
op_hstem,
op_hstem3,
op_vstem,
op_vstem3,
op_div,
op_callothersubr,
op_callsubr,
op_pop,
op_return,
op_setcurrentpoint,
op_max /* never remove this one */
} T1_Operator;
T1_Error error; /* only used for memory errors */
T1_Bool metrics_only;
} T1_Builder;
/* execution context charstring zone */
@ -260,7 +127,6 @@
typedef struct T1_Decoder_
{
T1_Builder builder;
T1_Hinter_Funcs hinter;
T1_Int stack[ T1_MAX_CHARSTRINGS_OPERANDS ];
T1_Int* top;
@ -276,82 +142,18 @@
/*********************************************************************
*
* <Function>
* T1_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
* funcs :: glyph builder functions (or "methods").
*
* <Note>
* This function is exported for now because it is used by the
* "t1dump" utility. Later, it will be accessed through a
* format-specific extension
*
*********************************************************************/
EXPORT_DEF
LOCAL_DEF
void T1_Init_Builder( T1_Builder* builder,
T1_Face face,
T1_Size size,
T1_GlyphSlot glyph,
const T1_Builder_Funcs* funcs );
T1_GlyphSlot glyph );
/*********************************************************************
*
* <Function>
* T1_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
*
* <Note>
* This function is exported for now because it is used by the
* "t1dump" utility. Later, it will be accessed through a
* format-specific extension
*
*********************************************************************/
EXPORT_DEF
LOCAL_DEF
void T1_Done_Builder( T1_Builder* builder );
/*********************************************************************
*
* <Function>
* T1_Init_Decoder
*
* <Description>
* Initialise a given Type 1 decoder for parsing
*
* <Input>
* decoder :: Type 1 decoder to initialise
* funcs :: hinter functions interface
*
* <Note>
* This function is exported for now because it is used by the
* "t1dump" utility. Later, it will be accessed through a
* format-specific extension
*
*********************************************************************/
EXPORT_DEF
void T1_Init_Decoder( T1_Decoder* decoder,
const T1_Hinter_Funcs* funcs );
LOCAL_DEF
void T1_Init_Decoder( T1_Decoder* decoder );
/* Compute the maximum advance width of a font through quick parsing */

View File

@ -92,13 +92,19 @@
FACE.##x = T1_ToString(&loader->parser); \
FT_TRACE2(( "type1.parse_##x##: \"%s\"\n", FACE.##x )); \
}
#define PARSE_NUM(s,x,t) PARSE_(x) \
{ \
FACE.##x = (t)T1_ToInt(&loader->parser); \
FT_TRACE2(( "type1.parse_##x##: \"%d\"\n", FACE.##x )); \
}
#define PARSE_INT(s,x) PARSE_(x) \
{ \
FACE.##x = T1_ToInt(&loader->parser); \
FT_TRACE2(( "type1.parse_##x##: \"%d\"\n", FACE.##x )); \
}
#define PARSE_BOOL(s,x) PARSE_(x) \
{ \
FACE.##x = T1_ToBool(&loader->parser); \
@ -381,10 +387,12 @@
/* "ExpertEncoding" */
else
{
if ( cur+17 < limit && strncmp( cur, "StandardEncoding", 16 ) == 0 )
if ( cur+17 < limit &&
strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
face->type1.encoding_type = t1_encoding_standard;
else if (cur+15 < limit && strncmp( cur, "ExpertEncoding", 14 ) == 0 )
else if ( cur+15 < limit &&
strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
face->type1.encoding_type = t1_encoding_expert;
else
@ -515,6 +523,7 @@
#undef PARSE_STRING
#undef PARSE_INT
#undef PARSE_NUM
#undef PARSE_BOOL
#undef PARSE_FIXED
#undef PARSE_COORDS
@ -527,6 +536,7 @@
#define PARSE_STRING(s,x) PARSE_(s,x)
#define PARSE_INT(s,x) PARSE_(s,x)
#define PARSE_NUM(s,x,t) PARSE_(s,x)
#define PARSE_BOOL(s,x) PARSE_(s,x)
#define PARSE_FIXED(s,x) PARSE_(s,x)
#define PARSE_COORDS(s,c,m,x) PARSE_(s,x)
@ -589,7 +599,8 @@
name = (T1_Byte*)keyword->name;
if (!name) break;
if (cur[0] == name[0] && len == strlen(name) )
if ( cur[0] == name[0] &&
len == (T1_Int)strlen((const char*)name) )
{
T1_Int n;
for ( n = 1; n < len; n++ )
@ -718,11 +729,12 @@
if (char_name)
for ( index = 0; index < type1->num_glyphs; index++ )
{
glyph_name = type1->glyph_names[index];
if ( strcmp( char_name, glyph_name ) == 0 )
glyph_name = (T1_Byte*)type1->glyph_names[index];
if ( strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = index;
type1->encoding.char_name [charcode] = glyph_name;
type1->encoding.char_name [charcode] = (char*)glyph_name;
if (charcode < min_char) min_char = charcode;
if (charcode > max_char) max_char = charcode;

View File

@ -21,10 +21,6 @@
#include <t1gload.h>
#include <t1load.h>
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <t1hinter.h>
#endif
/* Required by tracing mode */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1objs
@ -55,13 +51,7 @@
LOCAL_FUNC
void T1_Done_Size( T1_Size size )
{
if (size)
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Size_Hinter( size );
#endif
size->valid = 0;
}
(void)size;
}
@ -88,13 +78,8 @@
size->valid = 0;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Size_Hinter( size );
return error;
#else
(void)error;
return T1_Err_Ok;
#endif
}
@ -118,12 +103,8 @@
LOCAL_FUNC
T1_Error T1_Reset_Size( T1_Size size )
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
return T1_Reset_Size_Hinter( size );
#else
(void)size;
return 0;
#endif
}
@ -312,9 +293,6 @@
FT_Memory memory = glyph->root.face->memory;
FT_Library library = glyph->root.face->driver->library;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Glyph_Hinter( glyph );
#endif
/* the bitmaps are created on demand */
FREE( glyph->root.bitmap.buffer );
FT_Done_Outline( library, &glyph->root.outline );
@ -339,22 +317,12 @@
T1_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
{
FT_Library library = glyph->root.face->driver->library;
T1_Error error;
glyph->max_points = 0;
glyph->max_contours = 0;
glyph->root.bitmap.buffer = 0;
error = FT_New_Outline( library, 0, 0, &glyph->root.outline );
if (error) return error;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Glyph_Hinter( glyph );
if (error)
FT_Done_Outline( library, &glyph->root.outline );
#endif
return error;
return FT_New_Outline( library, 0, 0, &glyph->root.outline );
}

View File

@ -30,8 +30,8 @@
PARSE_INT("ItalicAngle",italic_angle)
PARSE_BOOL("isFixedPitch",is_fixed_pitch)
PARSE_INT("UnderlinePosition",underline_position)
PARSE_INT("UnderlineThickness",underline_thickness)
PARSE_NUM("UnderlinePosition",underline_position,T1_Short)
PARSE_NUM("UnderlineThickness",underline_thickness,T1_UShort)
/* define the private dict parsing callbacks */
@ -62,8 +62,8 @@
/* define the top-level dictionary parsing callbacks */
/* PARSE_STRING( "FontName", font_name ) -- handled by special routine */
PARSE_INT( "PaintType", paint_type )
PARSE_INT( "FontType", font_type )
PARSE_NUM( "PaintType", paint_type, T1_Byte )
PARSE_NUM( "FontType", font_type, T1_Byte )
PARSE_FIXEDS2( "FontMatrix", 4, font_matrix )
/* PARSE_COORDS2( "FontBBox", 4, font_bbox ) -- handled by special func */
PARSE_INT( "StrokeWidth", stroke_width )

View File

@ -33,9 +33,6 @@
#include <t1load.c>
#include <t1objs.c>
#include <t1driver.c>
/*
#include <t1hinter.c>
#include <t1gload.c>
#include <t1encode.c>
*/