A new round of formatting, adding/fixing documentation etc.

This commit is contained in:
Werner Lemberg 2000-06-16 06:49:56 +00:00
parent 67d301f305
commit e3c11d7f00
19 changed files with 2670 additions and 2607 deletions

View File

@ -91,6 +91,14 @@
trace_t2objs,
trace_t2parse,
/* CID driver components */
trace_cidafm,
trace_ciddriver,
trace_cidgload,
trace_cidload,
trace_cidobjs,
trace_cidparse,
/* other trace levels */
/* the last level must always be `trace_max' */

View File

@ -104,6 +104,7 @@
FT_Driver driver = face->driver;
FT_Set_MM_Blend_Func func;
func = (FT_Set_MM_Blend_Func)driver->interface.get_interface(
driver, "set_mm_blend" );
if ( func )

View File

@ -405,7 +405,7 @@
}
/* add a new point, do not check room */
/* add a new point, do not check space */
static
void add_point( T2_Builder* builder,
TT_Pos x,
@ -528,7 +528,9 @@
}
#define USE_ARGS(n) top -= n; if (top < decoder->stack) goto Stack_Underflow
#define USE_ARGS( n ) top -= n; \
if ( top < decoder->stack ) \
goto Stack_Underflow
/*************************************************************************/
@ -578,7 +580,7 @@
if ( seed == 0 )
seed = 0x7384;
/* First of all, initialize the decoder */
/* initialize the decoder */
decoder->top = decoder->stack;
decoder->zone = decoder->zones;
zone = decoder->zones;
@ -608,7 +610,6 @@
/* */
/* Decode operator or operand */
/* */
/* */
v = *ip++;
if ( v >= 32 || v == 28 )
{
@ -1692,8 +1693,8 @@
glyph->root.format = ft_glyph_format_none;
{
FT_Byte* charstring;
FT_ULong charstring_len;
TT_Byte* charstring;
TT_ULong charstring_len;
T2_Init_Decoder( &decoder, face, size, glyph );
@ -1804,8 +1805,8 @@
{
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;

View File

@ -42,7 +42,7 @@
/*************************************************************************/
/* */
/* GLYPH ZONE FUNCTIONS */
/* FACE FUNCTIONS */
/* */
/*************************************************************************/
@ -246,12 +246,14 @@
/* <Input> */
/* size :: A handle to the target size object. */
/* */
/* <Output> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error T2_Reset_Size( T2_Size size )
{
T2_Face face = (T2_Face)size->face;
FT_Size_Metrics* metrics = &size->metrics;
TT_Error error = T2_Err_Ok;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
@ -270,7 +272,7 @@
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
return error;
return T2_Err_Ok;
}

View File

@ -26,6 +26,16 @@
#include <ctype.h> /* for isalnum() */
/*************************************************************************/
/* */
/* 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_cidafm
LOCAL_FUNC
void CID_Done_AFM( FT_Memory memory,
T1_AFM* afm )

View File

@ -16,8 +16,8 @@
/***************************************************************************/
#ifndef T1AFM_H
#define T1AFM_H
#ifndef CIDAFM_H
#define CIDAFM_H
#include <cidobjs.h>
@ -55,7 +55,7 @@ void CID_Get_Kerning( T1_AFM* afm,
#endif
#endif /* T1AFM_H */
#endif /* CIDAFM_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,20 @@
/*******************************************************************
*
* cidgload.h 1.0
*
* CID-Keyed 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, CID_Builder, used to store the built outline
*
* - a glyph hinter, T1_Hinter, used to record and apply the stem
* hints
*
* - a charstrings interpreter, CID_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).
*
******************************************************************/
/***************************************************************************/
/* */
/* cidgload.h */
/* */
/* OpenType 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 CIDGLOAD_H
#define CIDGLOAD_H
@ -42,46 +26,59 @@
#endif
/*************************************************************************/
/* */
/* <Structure> CID_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 CID_Builder_
/*************************************************************************/
/* */
/* <Structure> */
/* CID_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. */
/* */
/* current :: The current glyph outline. */
/* */
/* base :: The base glyph outline. */
/* */
/* max_points :: maximum points in builder outline */
/* */
/* max_contours :: Maximal number of contours in builder 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 (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* bbox :: Unused. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
/* 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 CID_Builder_
{
FT_Memory memory;
CID_Face face;
@ -90,8 +87,8 @@
FT_Outline current; /* the current glyph outline */
FT_Outline base; /* the composite glyph outline */
FT_Int max_points; /* capacity of base outline in points */
FT_Int max_contours; /* capacity of base outline in contours */
T1_Int max_points; /* capacity of base outline in points */
T1_Int max_contours; /* capacity of base outline in contours */
T1_Vector last;
@ -109,80 +106,86 @@
T1_Bool load_points;
T1_Bool no_recurse;
FT_Error error; /* only used for memory errors */
T1_Error error; /* only used for memory errors */
T1_Bool metrics_only;
} CID_Builder;
/* execution context charstring zone */
typedef struct CID_Decoder_Zone_
typedef struct CID_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
T1_Byte* base;
T1_Byte* limit;
T1_Byte* cursor;
} CID_Decoder_Zone;
typedef struct CID_Decoder_
typedef struct CID_Decoder_
{
CID_Builder builder;
FT_Int stack[ T1_MAX_CHARSTRINGS_OPERANDS ];
FT_Int* top;
T1_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
T1_Int* top;
CID_Decoder_Zone zones[ T1_MAX_SUBRS_CALLS+1 ];
CID_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
CID_Decoder_Zone* zone;
FT_Matrix font_matrix;
T1_Matrix font_matrix;
CID_Subrs* subrs;
FT_UInt lenIV;
T1_UInt lenIV;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
T1_Int flex_state;
T1_Int num_flex_vectors;
T1_Vector flex_vectors[7];
} CID_Decoder;
LOCAL_DEF
void CID_Init_Builder( CID_Builder* builder,
CID_Face face,
T1_Size size,
T1_GlyphSlot glyph );
void CID_Init_Builder( CID_Builder* builder,
CID_Face face,
T1_Size size,
T1_GlyphSlot glyph );
LOCAL_DEF
void CID_Done_Builder( CID_Builder* builder );
LOCAL_DEF
void CID_Init_Decoder( CID_Decoder* decoder );
void CID_Init_Decoder( CID_Decoder* decoder );
#if 0
/* Compute the maximum advance width of a font through quick parsing */
LOCAL_DEF
FT_Error CID_Compute_Max_Advance( CID_Face face,
FT_Int *max_advance );
T1_Error CID_Compute_Max_Advance( CID_Face face,
T1_Int* max_advance );
#endif
/* This function is exported, because it is used by the T1Dump utility */
LOCAL_DEF
FT_Error CID_Parse_CharStrings( CID_Decoder* decoder,
FT_Byte* charstring_base,
FT_Int charstring_len );
T1_Error CID_Parse_CharStrings( CID_Decoder* decoder,
T1_Byte* charstring_base,
T1_Int charstring_len );
LOCAL_DEF
FT_Error CID_Load_Glyph( T1_GlyphSlot glyph,
T1_Error CID_Load_Glyph( T1_GlyphSlot glyph,
T1_Size size,
FT_Int glyph_index,
FT_Int load_flags );
T1_Int glyph_index,
T1_Int load_flags );
#ifdef __cplusplus
}
#endif
#endif /* T1GLOAD_H */
#endif /* CIDGLOAD_H */
/* END */

View File

@ -1,59 +1,20 @@
/*******************************************************************
*
* cidload.h 2.0
*
* CID-keyed foint 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.
*
*
* This is the new and improved Type 1 data loader for FreeType 2.
* The old loader has several problems: it is slow, complex, difficult
* to maintain, and contains incredible hacks to make it accept some
* ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5%
* of the Type 1 fonts on my machine still aren't loaded correctly
* with it.
*
* This version is much simpler, much faster and also easier to
* read and maintain by a great order of magnitude. The idea behind
* it is to _not_ try to read the Type 1 token stream with a state
* machine (i.e. a Postscript-like interpreter) but rather to perform
* simple pattern-matching.
*
* Indeed, nearly all data definitions follow a simple pattern
* like :
*
* ..... /Field <data> ....
*
* where <data> can be a number, a boolean, a string, or an
* array of numbers. There are a few exceptions, namely the
* encoding, font name, charstrings and subrs and they are
* handled with a special pattern-matching routine.
*
* All other common cases are handled very simply. The matching
* rules are defined in the file "t1tokens.h" through the use
* of several macros calls T1_FIELD_XXX
*
* The function "parse_dict" simply scans *linearly* a given
* dictionary (either the top-level or private one) and calls
* the appropriate callback when it encounters an immediate
* keyword.
*
* This is by far the fastest way one can find to parse and read
* all data :-)
*
* This led to tremendous code size reduction. Note that later,
* the glyph loader will also be _greatly_ simplified, and the
* automatic hinter will replace the clumsy "t1hinter"..
*
******************************************************************/
/***************************************************************************/
/* */
/* cidload.c */
/* */
/* CID-keyed Type1 font 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/config/ftconfig.h>
@ -62,290 +23,322 @@
#include <freetype/internal/t1types.h>
#include <freetype/internal/t1errors.h>
#include <cidload.h>
#include <stdio.h>
#include <ctype.h> /* for isspace(), isalnum() */
/*************************************************************************/
/* */
/* 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_t1load
#define FT_COMPONENT trace_cidload
/* reads a single offset */
/* read a single offset */
LOCAL_FUNC
FT_Long cid_get_offset( FT_Byte** start, FT_Byte offsize )
T1_Long cid_get_offset( T1_Byte** start,
T1_Byte offsize )
{
FT_Long result;
FT_Byte* p = *start;
T1_Long result;
T1_Byte* p = *start;
for ( result = 0; offsize > 0; offsize-- )
result = (result << 8) | *p++;
result = ( result << 8 ) | *p++;
*start = p;
return result;
}
LOCAL_FUNC
void cid_decrypt( FT_Byte* buffer,
FT_Int length,
FT_UShort seed )
void cid_decrypt( T1_Byte* buffer,
T1_Int length,
T1_UShort seed )
{
while ( length > 0 )
{
FT_Byte plain;
T1_Byte plain;
plain = (*buffer ^ (seed >> 8));
seed = (*buffer+seed)*52845+22719;
plain = ( *buffer ^ ( seed >> 8 ) );
seed = ( *buffer + seed ) * 52845 + 22719;
*buffer++ = plain;
length--;
}
}
/***************************************************************************/
/***************************************************************************/
/***** *****/
/***** TYPE 1 SYMBOL PARSING *****/
/***** *****/
/***************************************************************************/
/***************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** TYPE 1 SYMBOL PARSING *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static FT_Error cid_load_keyword( CID_Face face,
CID_Loader* loader,
const T1_Field_Rec* keyword )
static
T1_Error cid_load_keyword( CID_Face face,
CID_Loader* loader,
const T1_Field_Rec* keyword )
{
FT_Error error;
T1_Error error;
CID_Parser* parser = &loader->parser;
FT_Byte* object;
T1_Byte* object;
CID_Info* cid = &face->cid;
/* if the keyword has a dedicated callback, call it */
if (keyword->type == t1_field_callback)
if ( keyword->type == t1_field_callback )
{
error = keyword->reader( face, parser );
goto Exit;
}
/* we must now compute the address of our target object */
switch (keyword->location)
switch ( keyword->location )
{
case t1_field_cid_info:
object = (FT_Byte*)cid;
break;
case t1_field_font_info:
object = (FT_Byte*)&cid->font_info;
break;
default:
case t1_field_cid_info:
object = (T1_Byte*)cid;
break;
case t1_field_font_info:
object = (T1_Byte*)&cid->font_info;
break;
default:
{
CID_FontDict* dict;
if ( parser->num_dict < 0 )
{
CID_FontDict* dict;
if ( parser->num_dict < 0 )
{
FT_ERROR(( "CID.Load_Keyword: invalid use of '%s' !!\n", keyword->ident ));
error = T1_Err_Syntax_Error;
goto Exit;
}
dict = cid->font_dicts + parser->num_dict;
switch (keyword->location)
{
case t1_field_private:
object = (FT_Byte*)&dict->private_dict;
break;
default:
object = (FT_Byte*)dict;
}
FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",
keyword->ident ));
error = T1_Err_Syntax_Error;
goto Exit;
}
dict = cid->font_dicts + parser->num_dict;
switch ( keyword->location )
{
case t1_field_private:
object = (T1_Byte*)&dict->private_dict;
break;
default:
object = (T1_Byte*)dict;
}
}
}
/* now, load the keyword data in the object's field(s) */
if ( keyword->type == t1_field_integer_array ||
keyword->type == t1_field_fixed_array )
error = CID_Load_Field_Table( parser, keyword, object );
else
error = CID_Load_Field( parser, keyword, object );
Exit:
return error;
}
}
static
FT_Error parse_font_bbox( CID_Face face, CID_Parser* parser )
T1_Error parse_font_bbox( CID_Face face,
CID_Parser* parser )
{
FT_Short temp[4];
T1_BBox* bbox = &face->cid.font_bbox;
T1_Short temp[4];
T1_BBox* bbox = &face->cid.font_bbox;
(void)CID_ToCoordArray( parser, 4, temp );
bbox->xMin = temp[0];
bbox->yMin = temp[1];
bbox->xMax = temp[2];
bbox->yMax = temp[3];
return 0;
return T1_Err_Ok; /* this is a callback function; */
/* we must return an error code */
}
static
FT_Error parse_font_matrix( CID_Face face, CID_Parser* parser )
T1_Error parse_font_matrix( CID_Face face,
CID_Parser* parser )
{
FT_Matrix* matrix;
T1_Matrix* matrix;
CID_FontDict* dict;
T1_Fixed temp[4];
if (parser->num_dict >= 0)
if ( parser->num_dict >= 0 )
{
dict = face->cid.font_dicts + parser->num_dict;
matrix = &dict->font_matrix;
(void)CID_ToFixedArray( parser, 4, temp, 3 );
matrix->xx = temp[0];
matrix->yx = temp[1];
matrix->xy = temp[2];
matrix->yy = temp[3];
}
return 0;
return T1_Err_Ok; /* this is a callback function; */
/* we must return an error code */
}
static
FT_Error parse_fd_array( CID_Face face, CID_Parser* parser )
T1_Error parse_fd_array( CID_Face face,
CID_Parser* parser )
{
CID_Info* cid = &face->cid;
FT_Memory memory = face->root.memory;
FT_Error error;
FT_Long num_dicts;
num_dicts = CID_ToInt(parser);
T1_Error error = T1_Err_Ok;
T1_Long num_dicts;
num_dicts = CID_ToInt( parser );
if ( !cid->font_dicts )
{
FT_Int n;
T1_Int n;
if ( ALLOC_ARRAY( cid->font_dicts, num_dicts, CID_FontDict ) )
goto Exit;
cid->num_dicts = (FT_UInt)num_dicts;
/* don't forget to set a few defauts !! */
cid->num_dicts = (T1_UInt)num_dicts;
/* don't forget to set a few defaults */
for ( n = 0; n < cid->num_dicts; n++ )
{
CID_FontDict* dict = cid->font_dicts + n;
/* default value for lenIV !! */
/* default value for lenIV */
dict->private_dict.lenIV = 4;
}
}
Exit:
return error;
}
static
const T1_Field_Rec t1_field_records[] =
const T1_Field_Rec t1_field_records[] =
{
#include <cidtokens.h>
#include <cidtokens.h>
{ 0, 0, 0, 0, 0, 0 }
};
static
int is_space( char c )
int is_alpha( char c )
{
return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' );
return ( isalnum( c ) ||
c == '.' ||
c == '_' );
}
static
int is_alpha( char c )
{
return ( (c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
(c == '.') ||
(c == '_') );
}
static
void skip_whitespace( CID_Parser* parser )
void skip_whitespace( CID_Parser* parser )
{
FT_Byte* cur = parser->cursor;
T1_Byte* cur = parser->cursor;
while ( cur < parser->limit && is_space(*cur) )
while ( cur < parser->limit && isspace( *cur ) )
cur++;
parser->cursor = cur;
}
static
FT_Error parse_dict( CID_Face face,
T1_Error parse_dict( CID_Face face,
CID_Loader* loader,
FT_Byte* base,
FT_Long size )
T1_Byte* base,
T1_Long size )
{
CID_Parser* parser = &loader->parser;
CID_Parser* parser = &loader->parser;
parser->cursor = base;
parser->limit = base + size;
parser->error = 0;
{
FT_Byte* cur = base;
FT_Byte* limit = cur + size;
T1_Byte* cur = base;
T1_Byte* limit = cur + size;
for ( ;cur < limit; cur++ )
{
/* look for %ADOBegin... */
/* look for `%ADOBeginFontDict' */
if ( *cur == '%' && cur + 20 < limit &&
strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
{
cur += 17;
/* if /FDArray was found, then cid->num_dicts is > 0, and */
/* we can start increasing parser->num_dict */
if ( face->cid.num_dicts > 0 )
parser->num_dict++;
}
/* look for immediates */
else if (*cur == '/' && cur+2 < limit)
else if ( *cur == '/' && cur + 2 < limit )
{
FT_Byte* cur2;
FT_Int len;
T1_Byte* cur2;
T1_Int len;
cur++;
cur ++;
cur2 = cur;
while (cur2 < limit && is_alpha(*cur2)) cur2++;
len = cur2-cur;
while ( cur2 < limit && is_alpha( *cur2 ) )
cur2++;
if (len > 0 && len < 22)
len = cur2 - cur;
if ( len > 0 && len < 22 )
{
/* now, compare the immediate name to the keyword table */
const T1_Field_Rec* keyword = t1_field_records;
for (;;)
{
FT_Byte* name;
T1_Byte* name;
name = (FT_Byte*)keyword->ident;
if (!name) break;
if ( cur[0] == name[0] &&
len == (FT_Int)strlen((const char*)name) )
name = (T1_Byte*)keyword->ident;
if ( !name )
break;
if ( cur[0] == name[0] &&
len == (T1_Int)strlen( (const char*)name ) )
{
FT_Int n;
T1_Int n;
for ( n = 1; n < len; n++ )
if (cur[n] != name[n])
if ( cur[n] != name[n] )
break;
if (n >= len)
if ( n >= len )
{
/* we found it - run the parsing callback !! */
/* we found it - run the parsing callback */
parser->cursor = cur2;
skip_whitespace( parser );
parser->error = cid_load_keyword( face, loader, keyword );
if (parser->error)
if ( parser->error )
return parser->error;
cur = parser->cursor;
@ -362,56 +355,60 @@
}
/* read the subrmap and the subrs of each font dict */
static
FT_Error cid_read_subrs( CID_Face face )
T1_Error cid_read_subrs( CID_Face face )
{
CID_Info* cid = &face->cid;
FT_Memory memory = face->root.memory;
FT_Stream stream = face->root.stream;
FT_Error error;
FT_UInt n;
T1_Error error;
T1_UInt n;
CID_Subrs* subr;
FT_UInt max_offsets = 0;
FT_ULong* offsets = 0;
T1_UInt max_offsets = 0;
T1_ULong* offsets = 0;
if ( ALLOC_ARRAY( face->subrs, cid->num_dicts, CID_Subrs ) )
goto Exit;
subr = face->subrs;
for ( n = 0; n < cid->num_dicts; n++, subr++ )
{
CID_FontDict* dict = cid->font_dicts + n;
FT_UInt count, num_subrs = dict->num_subrs;
FT_ULong data_len;
FT_Byte* p;
CID_FontDict* dict = cid->font_dicts + n;
T1_UInt count, num_subrs = dict->num_subrs;
T1_ULong data_len;
T1_Byte* p;
/* reallocate offsets array if needed */
if ( num_subrs+1 > max_offsets )
if ( num_subrs + 1 > max_offsets )
{
FT_UInt new_max = (num_subrs+1+3) & -4;
if ( REALLOC_ARRAY( offsets, max_offsets, new_max, FT_ULong ) )
T1_UInt new_max = ( num_subrs + 1 + 3 ) & -4;
if ( REALLOC_ARRAY( offsets, max_offsets, new_max, T1_ULong ) )
goto Fail;
max_offsets = new_max;
}
/* read the subrmap's offsets */
if ( FILE_Seek( cid->data_offset + dict->subrmap_offset ) ||
ACCESS_Frame( (num_subrs+1) * dict->sd_bytes ) )
ACCESS_Frame( ( num_subrs + 1 ) * dict->sd_bytes ) )
goto Fail;
p = (FT_Byte*)stream->cursor;
for ( count = 0; count <= num_subrs; count++ )
offsets[count] = cid_get_offset( &p, dict->sd_bytes );
FORGET_Frame();
/* now, compute the size of subrs charstrings, allocate and read them */
/* now, compute the size of subrs charstrings, */
/* allocate, and read them */
data_len = offsets[num_subrs] - offsets[0];
if ( ALLOC_ARRAY( subr->code, num_subrs+1, FT_Byte* ) ||
if ( ALLOC_ARRAY( subr->code, num_subrs+1, T1_Byte* ) ||
ALLOC( subr->code[0], data_len ) )
goto Fail;
@ -422,18 +419,20 @@
/* set up pointers */
for ( count = 1; count <= num_subrs; count++ )
{
FT_UInt len;
len = offsets[count] - offsets[count-1];
subr->code[count] = subr->code[count-1] + len;
T1_UInt len;
len = offsets[count] - offsets[count - 1];
subr->code[count] = subr->code[count - 1] + len;
}
/* decrypt subroutines */
/* decrypt subroutines */
for ( count = 0; count < num_subrs; count++ )
{
FT_UInt len;
len = offsets[count+1] - offsets[count];
T1_UInt len;
len = offsets[count + 1] - offsets[count];
cid_decrypt( subr->code[count], len, 4330 );
}
@ -443,15 +442,15 @@
Exit:
FREE( offsets );
return error;
Fail:
if (face->subrs)
if ( face->subrs )
{
for ( n = 0; n < cid->num_dicts; n++ )
{
if (face->subrs[n].code)
if ( face->subrs[n].code )
FREE( face->subrs[n].code[0] );
FREE( face->subrs[n].code );
}
FREE( face->subrs );
@ -459,45 +458,56 @@
goto Exit;
}
static
void t1_init_loader( CID_Loader* loader, CID_Face face )
void t1_init_loader( CID_Loader* loader,
CID_Face face )
{
UNUSED(face);
MEM_Set( loader, 0, sizeof(*loader) );
MEM_Set( loader, 0, sizeof ( *loader ) );
}
static
void t1_done_loader( CID_Loader* loader )
void t1_done_loader( CID_Loader* loader )
{
CID_Parser* parser = &loader->parser;
/* finalize parser */
CID_Done_Parser( parser );
}
LOCAL_FUNC
FT_Error CID_Open_Face( CID_Face face )
T1_Error CID_Open_Face( CID_Face face )
{
CID_Loader loader;
CID_Parser* parser;
FT_Error error;
T1_Error error;
t1_init_loader( &loader, face );
parser = &loader.parser;
error = CID_New_Parser( parser, face->root.stream, face->root.memory );
if (error) goto Exit;
if ( error )
goto Exit;
error = parse_dict( face, &loader,
parser->postscript,
parser->postscript_len );
if (error) goto Exit;
if ( error )
goto Exit;
face->cid.data_offset = loader.parser.data_offset;
error = cid_read_subrs( face );
Exit:
t1_done_loader( &loader );
return error;
}
/* END */

View File

@ -1,22 +1,23 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidload.h */
/* */
/* CID-keyed Type1 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 T1LOAD_H
#define T1LOAD_H
#ifndef CIDLOAD_H
#define CIDLOAD_H
#include <freetype/internal/ftstream.h>
#include <cidparse.h>
@ -25,30 +26,34 @@
extern "C" {
#endif
typedef struct CID_Loader_
{
CID_Parser parser; /* parser used to read the stream */
FT_Int num_chars; /* number of characters in encoding */
typedef struct CID_Loader_
{
CID_Parser parser; /* parser used to read the stream */
T1_Int num_chars; /* number of characters in encoding */
} CID_Loader;
LOCAL_DEF
FT_Long cid_get_offset( FT_Byte** start, FT_Byte offsize );
LOCAL_DEF
void cid_decrypt( FT_Byte* buffer,
FT_Int length,
FT_UShort seed );
T1_Long cid_get_offset( T1_Byte** start,
T1_Byte offsize );
LOCAL_DEF
FT_Error CID_Open_Face( CID_Face face );
void cid_decrypt( T1_Byte* buffer,
T1_Int length,
T1_UShort seed );
LOCAL_DEF
T1_Error CID_Open_Face( CID_Face face );
#ifdef __cplusplus
}
#endif
#endif /* T1LOAD_H */
#endif /* CIDLOAD_H */
/* END */

View File

@ -1,19 +1,20 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidobjs.c */
/* */
/* CID 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>
@ -23,90 +24,90 @@
#include <freetype/internal/psnames.h>
#include <cidafm.h>
/* Required by tracing mode */
/*************************************************************************/
/* */
/* 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_t1objs
#define FT_COMPONENT trace_cidobjs
/*******************************************************************
* *
* SIZE FUNCTIONS *
* *
* *
*******************************************************************/
/*******************************************************************
*
* <Function> T1_Done_Size
*
* <Description>
* The TrueDoc instance object destructor. Used to discard
* a given instance object..
*
* <Input>
* instance :: handle to the target instance object
*
* <Return>
* TrueDoc error code. 0 means success
*
******************************************************************/
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Done_Size */
/* */
/* <Description> */
/* The CID size object finalizer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_FUNC
void T1_Done_Size( T1_Size size )
void CID_Done_Size( T1_Size size )
{
UNUSED(size);
UNUSED( size );
}
/*******************************************************************
*
* <Function> T1_Init_Size
*
* <Description>
* The instance object constructor
*
* <Input>
* instance : handle to new instance object
* face : pointer to parent face object
*
* <Return>
* TrueDoc error code. 0 means success.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Init_Size */
/* */
/* <Description> */
/* Initializes a new CID size object. */
/* */
/* <InOut> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* Type1 error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size )
T1_Error CID_Init_Size( T1_Size size )
{
size->valid = 0;
return T1_Err_Ok;
}
/*******************************************************************
*
* <Function> T1_Reset_Size
*
* <Description>
* Resets an instance to a new pointsize/transform.
* This function is in charge of resetting the blue zones,
* As well as the stem snap tables for a given size..
*
* <Input>
* instance the instance object to destroy
*
* <Output>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Reset_Size */
/* */
/* <Description> */
/* Resets a OpenType size when resolutions and character dimensions */
/* have been changed. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
/* <Output> */
/* Type1 error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Reset_Size( T1_Size size )
T1_Error CID_Reset_Size( T1_Size size )
{
/* recompute ascender, descender, etc.. */
/* recompute ascender, descender, etc. */
CID_Face face = (CID_Face)size->root.face;
FT_Size_Metrics* metrics = &size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return FT_Err_Invalid_Argument;
return T1_Err_Invalid_Argument;
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->root.ascender,
@ -120,125 +121,135 @@
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
return 0;
return T1_Err_Ok;
}
/*******************************************************************
* *
* FACE FUNCTIONS *
* *
* *
*******************************************************************/
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
/* */
/*************************************************************************/
/*******************************************************************
*
* <Function> T1_Done_Face
*
* <Description>
* The face object destructor.
*
* <Input>
* face :: typeless pointer to the face object to destroy
*
* <Return>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Done_Face */
/* */
/* <Description> */
/* Finalizes a given face object. */
/* */
/* <Input> */
/* face :: A pointer to the face object to destroy. */
/* */
LOCAL_FUNC
void T1_Done_Face( CID_Face face )
void CID_Done_Face( CID_Face face )
{
FT_Memory memory;
if (face)
if ( face )
{
CID_Info* cid = &face->cid;
T1_FontInfo* info = &cid->font_info;
CID_Info* cid = &face->cid;
T1_FontInfo* info = &cid->font_info;
memory = face->root.memory;
/* release FontInfo strings */
FREE( info->version );
FREE( info->notice );
FREE( info->full_name );
FREE( info->family_name );
FREE( info->weight );
/* release font dictionaries */
FREE( cid->font_dicts );
cid->num_dicts = 0;
/* release other strings */
FREE( cid->cid_font_name );
FREE( cid->registry );
FREE( cid->ordering );
face->root.family_name = 0;
face->root.style_name = 0;
}
}
/*******************************************************************
*
* <Function> T1_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> */
/* CID_Init_Face */
/* */
/* <Description> */
/* Initializes a given CID face object. */
/* */
/* <Input> */
/* stream :: The source font stream. */
/* */
/* 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 newly built face object. */
/* */
/* <Return> */
/* Type1 error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Init_Face( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
T1_Error CID_Init_Face( FT_Stream stream,
CID_Face face,
T1_Int face_index,
T1_Int num_params,
FT_Parameter* params )
{
FT_Error error;
T1_Error error;
PSNames_Interface* psnames;
UNUSED(num_params);
UNUSED(params);
UNUSED(face_index);
UNUSED(stream);
UNUSED( num_params );
UNUSED( params );
UNUSED( face_index );
UNUSED( stream );
face->root.num_faces = 1;
psnames = (PSNames_Interface*)face->psnames;
if (!psnames)
if ( !psnames )
{
/* look-up the PSNames driver */
FT_Driver psnames_driver;
psnames_driver = FT_Get_Driver( face->root.driver->library, "psnames" );
if (psnames_driver)
if ( psnames_driver )
face->psnames = (PSNames_Interface*)
(psnames_driver->interface.format_interface);
(psnames_driver->interface.format_interface);
}
/* open the tokenizer, this will also check the font format */
if ( FILE_Seek(0) )
/* open the tokenizer; this will also check the font format */
if ( FILE_Seek( 0 ) )
goto Exit;
error = CID_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(( "CID_Init_Face: invalid face index\n" ));
error = T1_Err_Invalid_Argument;
goto Exit;
}
@ -250,6 +261,7 @@
{
FT_Face root = (FT_Face)&face->root;
root->num_glyphs = face->cid.cid_count;
root->num_charmaps = 0;
@ -261,12 +273,12 @@
if ( face->cid.font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX : TO DO - add kerning with .afm support */
/* XXX: TO DO - add kerning with .afm support */
/* get style name - be careful, some broken fonts only */
/* have a /FontName dictionary entry .. !! */
/* have a /FontName dictionary entry! */
root->family_name = face->cid.font_info.family_name;
if (root->family_name)
if ( root->family_name )
{
char* full = face->cid.font_info.full_name;
char* family = root->family_name;
@ -277,12 +289,13 @@
full++;
}
root->style_name = ( *full == ' ' ? full+1 : "Regular" );
root->style_name = ( *full == ' ' ) ? full + 1
: "Regular";
}
else
{
/* do we have a /FontName ?? */
if (face->cid.cid_font_name)
/* do we have a `/FontName'? */
if ( face->cid.cid_font_name )
{
root->family_name = face->cid.cid_font_name;
root->style_name = "Regular";
@ -297,29 +310,35 @@
root->units_per_EM = 1000;
root->ascender = (FT_Short)face->cid.font_bbox.yMax;
root->descender = -(FT_Short)face->cid.font_bbox.yMin;
root->height = ((root->ascender + root->descender)*12)/10;
root->height = ( ( root->ascender + root->descender ) * 12 )
/ 10;
#if 0
/* now compute the maximum advance width */
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)
if ( !face->type1.font_info.is_fixed_pitch )
{
FT_Int max_advance;
T1_Int max_advance;
error = T1_Compute_Max_Advance( face, &max_advance );
/* in case of error, keep the standard width */
if (!error)
if ( !error )
root->max_advance_width = max_advance;
else
error = 0; /* clear error */
}
root->max_advance_height = root->height;
#endif
#endif /* 0 */
root->underline_position = face->cid.font_info.underline_position;
root->underline_thickness = face->cid.font_info.underline_thickness;
@ -329,23 +348,28 @@
}
#if 0
/* charmap support - synthetize unicode charmap when possible */
{
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)
/* 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;
@ -355,88 +379,93 @@
charmap++;
}
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
/* simply clear the error in case of failure (which really */
/* means that out of memory or no unicode glyph names) */
error = 0;
}
}
/* now, support either the standard, expert, or custom encodings */
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];
}
#endif
#endif /* 0 */
Exit:
return error;
}
/*******************************************************************
*
* Function : Glyph_Destroy
*
* Description : The glyph object destructor.
*
* Input : _glyph typeless pointer to the glyph record to destroy
*
* Output : Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Done_GlyphSlot */
/* */
/* <Description> */
/* The CID glyph slot finalizer. */
/* */
/* <Input> */
/* slot :: A handle to the glyph slot object. */
/* */
LOCAL_FUNC
void T1_Done_GlyphSlot( T1_GlyphSlot glyph )
void CID_Done_GlyphSlot( T1_GlyphSlot glyph )
{
FT_Memory memory = glyph->root.face->memory;
FT_Library library = glyph->root.face->driver->library;
/* the bitmaps are created on demand */
FREE( glyph->root.bitmap.buffer );
FT_Outline_Done( library, &glyph->root.outline );
return;
}
/*******************************************************************
*
* Function : Glyph_Create
*
* Description : The glyph object constructor.
*
* Input : glyph glyph record to build.
* face the glyph's parent face.
*
* Output : Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Init_GlyphSlot */
/* */
/* <Description> */
/* The CID glyph slot initializer. */
/* */
/* <Input> */
/* slot :: The glyph record to build. */
/* */
/* <Output> */
/* Type1 error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
T1_Error CID_Init_GlyphSlot( T1_GlyphSlot glyph )
{
FT_Library library = glyph->root.face->driver->library;
glyph->max_points = 0;
glyph->max_contours = 0;
glyph->root.bitmap.buffer = 0;
@ -445,46 +474,44 @@
}
/*******************************************************************
*
* <Function> T1_Init_Driver
*
* <Description>
* Initialise a given Type 1 driver object
*
* <Input>
* driver :: handle to target driver object
*
* <Return>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Init_Driver */
/* */
/* <Description> */
/* Initializes a given CID driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* Type1 error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Init_Driver( T1_Driver driver )
T1_Error CID_Init_Driver( T1_Driver driver )
{
UNUSED(driver);
UNUSED( driver );
return T1_Err_Ok;
}
/*******************************************************************
*
* <Function> T1_Done_Driver
*
* <Description>
* finalise a given Type 1 driver
*
* <Input>
* driver :: handle to target Type 1 driver
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* CID_Done_Driver */
/* */
/* <Description> */
/* Finalizes a given CID driver. */
/* */
/* <Input> */
/* driver :: A handle to the target CID driver. */
/* */
LOCAL_DEF
void T1_Done_Driver( T1_Driver driver )
void CID_Done_Driver( T1_Driver driver )
{
UNUSED(driver);
UNUSED( driver );
}

View File

@ -1,304 +1,167 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidobjs.h */
/* */
/* CID 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 T1OBJS_H
#define T1OBJS_H
#ifndef CIDOBJS_H
#define CIDOBJS_H
#include <freetype/internal/ftobjs.h>
#include <freetype/config/ftconfig.h>
#include <freetype/internal/t1errors.h>
#include <freetype/internal/t1types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The following structures must be defined by the hinter */
typedef struct T1_Size_Hints_ T1_Size_Hints;
typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
/***********************************************************************/
/* */
/* <Type> T1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct T1_DriverRec_ *T1_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* T1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct T1_DriverRec_* T1_Driver;
/***********************************************************************/
/* */
/* <Type> T1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
/*************************************************************************/
/* */
/* <Type> */
/* T1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
typedef struct T1_SizeRec_* T1_Size;
/***********************************************************************/
/* */
/* <Type> T1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
/*************************************************************************/
/* */
/* <Type> */
/* T1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
/***********************************************************************/
/* */
/* <Type> T1_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> */
/* T1_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 T1_CharMapRec_* T1_CharMap;
/*************************************************************************/
/* */
/* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
/* */
/*************************************************************************/
/**************************************************************************/
/* */
/* NOW BEGINS THE TYPE1 SPECIFIC STUFF .............................. */
/* */
/**************************************************************************/
/***************************************************/
/* */
/* T1_Size : */
/* */
/* Type 1 size record.. */
/* */
typedef struct T1_SizeRec_
{
FT_SizeRec root;
T1_Bool valid;
T1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
/* change 't1objs' each time.. */
T1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
/* change `cidobjs' each time. */
} T1_SizeRec;
/***************************************************/
/* */
/* T1_GlyphSlot : */
/* */
/* TrueDoc glyph record.. */
/* */
typedef struct T1_GlyphSlotRec_
typedef struct T1_GlyphSlotRec_
{
FT_GlyphSlotRec root;
T1_Bool hint;
T1_Bool scaled;
FT_Int max_points;
FT_Int max_contours;
T1_Int max_points;
T1_Int max_contours;
FT_Fixed x_scale;
FT_Fixed y_scale;
T1_Fixed x_scale;
T1_Fixed y_scale;
T1_Glyph_Hints* hints; /* defined in the hinter */
} T1_GlyphSlotRec;
/*******************************************************************
*
* <Function> T1_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
T1_Error CID_Init_Face( FT_Stream stream,
CID_Face face,
T1_Int face_index,
T1_Int num_params,
FT_Parameter* params );
LOCAL_DEF
FT_Error T1_Init_Face( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
void CID_Done_Face( CID_Face face );
/*******************************************************************
*
* <Function> T1_Done_Face
*
* <Description>
* Finalise a given face object
*
* <Input>
* face :: handle to the face object to destroy
*
******************************************************************/
LOCAL_DEF
void T1_Done_Face( CID_Face face );
/*******************************************************************
*
* <Function> T1_Init_Size
*
* <Description>
* Initialise a new Type 1 size object
*
* <Input>
* size :: handle to size object
*
* <Return>
* Type 1 error code. 0 means success.
*
******************************************************************/
T1_Error CID_Init_Size( T1_Size size );
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Done_Size
*
* <Description>
* The Type 1 size object finaliser.
*
* <Input>
* size :: handle to the target size object.
*
******************************************************************/
void CID_Done_Size( T1_Size size );
LOCAL_DEF
void T1_Done_Size( T1_Size size );
T1_Error CID_Reset_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Reset_Size
*
* <Description>
* Reset a Type 1 size when resolutions and character dimensions
* have been changed..
*
* <Input>
* size :: handle to the target size object.
*
******************************************************************/
LOCAL_DEF
FT_Error T1_Reset_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Init_GlyphSlot
*
* <Description> The TrueType glyph slot initialiser
*
* <Input> glyph :: glyph record to build.
*
* <Output> Error code.
*
******************************************************************/
T1_Error CID_Init_GlyphSlot( T1_GlyphSlot slot );
LOCAL_DEF
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot slot );
void CID_Done_GlyphSlot( T1_GlyphSlot slot );
/*******************************************************************
*
* <Function> T1_Done_GlyphSlot
*
* <Description> The Type 1 glyph slot finaliser
*
* <Input> glyph :: handle to glyph slot object
*
* <Output> Error code.
*
******************************************************************/
LOCAL_DEF
void T1_Done_GlyphSlot( T1_GlyphSlot slot );
/*******************************************************************
*
* <Function> T1_Init_Driver
*
* <Description>
* Initialise a given Type 1 driver object
*
* <Input>
* driver :: handle to target driver object
*
* <Return>
* Error code.
*
******************************************************************/
T1_Error CID_Init_Driver( T1_Driver driver );
LOCAL_DEF
FT_Error T1_Init_Driver( T1_Driver driver );
void CID_Done_Driver( T1_Driver driver );
/*******************************************************************
*
* <Function> T1_Done_Driver
*
* <Description>
* finalise a given Type 1 driver
*
* <Input>
* driver :: handle to target Type 1 driver
*
******************************************************************/
LOCAL_DEF
void T1_Done_Driver( T1_Driver driver );
#ifdef __cplusplus
}
#endif
#endif /* T1OBJS_H */
#endif /* CIDOBJS_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,68 @@
/*******************************************************************
*
* cidparse.h 2.0
*
* CID-Keyed 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 T1_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
*
******************************************************************/
/***************************************************************************/
/* */
/* cidparse.h */
/* */
/* CID-keyed Type1 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 CIDPARSE_H
#define CIDPARSE_H
#include <freetype/internal/t1types.h>
#ifdef __cplusplus
extern "C" {
#endif
#if 0
/*************************************************************************
*
* <Struct> T1_Table
*
* <Description>
* A T1_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 T1_Table_
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Table */
/* */
/* <Description> */
/* A T1_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 `realloc()'. */
/* */
/* cursor :: The current top of the growheap within its block. */
/* */
/* capacity :: The current size of the heap block. Increments by */
/* blocks of 1 kByte. */
/* */
/* init :: A boolean. Set when the table has been initialized */
/* (the table user should set this field). */
/* */
/* max_elems :: The maximal number of elements in the table. */
/* */
/* num_elems :: The current number of elements (in use) 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 resp. reallocation). */
/* */
typedef struct T1_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
@ -87,73 +80,77 @@
LOCAL_DEF
FT_Error T1_New_Table( T1_Table* table,
FT_Int count,
FT_Memory memory );
T1_Error T1_New_Table( T1_Table* table,
T1_Int count,
T1_Memory memory );
LOCAL_DEF
FT_Error T1_Add_Table( T1_Table* table,
FT_Int index,
T1_Error T1_Add_Table( T1_Table* table,
T1_Int index,
void* object,
FT_Int length );
T1_Int length );
LOCAL_DEF
void T1_Release_Table( T1_Table* table );
#endif
/*************************************************************************
*
* <Struct> CID_Parser
*
* <Description>
* A CID_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
*/
#endif /* 0 */
/*************************************************************************/
/* */
/* <Struct> */
/* CID_Parser */
/* */
/* <Description> */
/* A CID_Parser is an object used to parse a Type 1 fonts very */
/* quickly. */
/* */
/* <Fields> */
/* stream :: The current input stream. */
/* */
/* memory :: The current memory object. */
/* */
/* postscript :: A pointer to the data to be parsed. */
/* */
/* postscript_len :: The length of the data to be parsed. */
/* */
/* data_offset :: The start position of the binary data (i.e., the */
/* end of the data to be parsed. */
/* */
/* cursor :: The current parser cursor. */
/* */
/* limit :: The current parser limit (i.e., the first byte */
/* after the current dictionary). */
/* */
/* error :: The current parsing error. */
/* */
/* cid :: A structure which holds the information about */
/* the current font. */
/* */
/* num_dict :: The number of font dictionaries. */
/* */
typedef struct CID_Parser_
{
FT_Stream stream;
FT_Memory memory;
FT_Byte* postscript;
FT_Int postscript_len;
T1_Byte* postscript;
T1_Int postscript_len;
FT_ULong data_offset;
T1_ULong data_offset;
FT_Byte* cursor;
FT_Byte* limit;
FT_Error error;
T1_Byte* cursor;
T1_Byte* limit;
T1_Error error;
CID_Info* cid;
FT_Int num_dict;
T1_Int num_dict;
} CID_Parser;
LOCAL_DEF
FT_Error CID_New_Parser( CID_Parser* parser,
T1_Error CID_New_Parser( CID_Parser* parser,
FT_Stream stream,
FT_Memory memory );
@ -161,66 +158,61 @@
void CID_Done_Parser( CID_Parser* parser );
/*************************************************************************
*
* PARSING ROUTINES
*
*************************************************************************/
/*************************************************************************/
/* */
/* PARSING ROUTINES */
/* */
/*************************************************************************/
LOCAL_DEF
FT_Long CID_ToInt ( CID_Parser* parser );
T1_Long CID_ToInt( CID_Parser* parser );
LOCAL_DEF
FT_Int CID_ToCoordArray( CID_Parser* parser,
FT_Int max_coords,
FT_Short* coords );
T1_Int CID_ToCoordArray( CID_Parser* parser,
T1_Int max_coords,
T1_Short* coords );
LOCAL_DEF
FT_Int CID_ToFixedArray( CID_Parser* parser,
FT_Int max_values,
T1_Fixed* values,
FT_Int power_ten );
T1_Int CID_ToFixedArray( CID_Parser* parser,
T1_Int max_values,
T1_Fixed* values,
T1_Int power_ten );
LOCAL_DEF
void CID_Skip_Spaces( CID_Parser* parser );
void CID_Skip_Spaces( CID_Parser* parser );
/* simple enumeration type used to identify token types */
typedef enum T1_Token_Type_
typedef enum T1_Token_Type_
{
t1_token_none = 0,
t1_token_any,
t1_token_string,
t1_token_array,
/* do not remove */
t1_token_max
} T1_Token_Type;
/* a simple structure used to identify tokens */
typedef struct T1_Token_Rec_
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
T1_Byte* start; /* first character of token in input stream */
T1_Byte* limit; /* first character after the token */
T1_Token_Type type; /* type of token.. */
} T1_Token_Rec;
} T1_Token_Rec;
LOCAL_DEF
void CID_ToToken( CID_Parser* parser,
T1_Token_Rec* token );
void CID_ToToken( CID_Parser* parser,
T1_Token_Rec* token );
/* enumeration type used to identify object fields */
typedef enum T1_Field_Type_
typedef enum T1_Field_Type_
{
t1_field_none = 0,
t1_field_bool,
@ -230,118 +222,132 @@
t1_field_integer_array,
t1_field_fixed_array,
t1_field_callback,
/* do not remove */
t1_field_max
} T1_Field_Type;
typedef enum T1_Field_Location_
typedef enum T1_Field_Location_
{
t1_field_cid_info,
t1_field_font_dict,
t1_field_font_info,
t1_field_private,
/* do not remove */
t1_field_location_max
} T1_Field_Location;
typedef FT_Error (*CID_Field_Parser)( CID_Face face,
typedef T1_Error (*CID_Field_Parser)( CID_Face face,
CID_Parser* parser );
/* structure type used to model object fields */
typedef struct T1_Field_Rec_
typedef struct T1_Field_Rec_
{
const char* ident; /* field identifier */
const char* ident; /* field identifier */
T1_Field_Location location;
T1_Field_Type type; /* type of field */
T1_Field_Type type; /* type of field */
CID_Field_Parser reader;
T1_UInt offset; /* offset of field in object */
FT_UInt size; /* size of field in bytes */
FT_UInt array_max; /* maximum number of elements for array */
FT_UInt count_offset; /* offset of element count for arrays */
T1_UInt offset; /* offset of field in object */
T1_UInt size; /* size of field in bytes */
T1_UInt array_max; /* maximal number of elements for */
/* array */
T1_UInt count_offset; /* offset of element count for */
/* arrays */
} T1_Field_Rec;
#define T1_FIELD_REF(s,f) (((s*)0)->f)
#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
{ _ident, T1CODE, _type, \
0, \
(FT_UInt)(char*)&T1_FIELD_REF(T1TYPE,_fname), \
sizeof(T1_FIELD_REF(T1TYPE,_fname)), \
0, 0 },
#define T1_FIELD_REF( s, f ) ( ((s*)0)->f )
#define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \
{ _ident, T1CODE, t1_field_callback, \
_reader, \
0, 0, 0, 0 },
#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
{ \
_ident, T1CODE, _type, \
0, \
(T1_UInt)(char*)&T1_FIELD_REF( T1TYPE, _fname ), \
sizeof ( T1_FIELD_REF( T1TYPE, _fname ) ), \
0, 0 \
},
#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \
{ _ident, T1CODE, _type, \
0, \
(FT_UInt)(char*)&T1_FIELD_REF(T1TYPE,_fname), \
sizeof(T1_FIELD_REF(T1TYPE,_fname)[0]), \
_max, \
(FT_UInt)(char*)&T1_FIELD_REF(T1TYPE,num_ ## _fname) },
#define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \
{ \
_ident, T1CODE, t1_field_callback, \
_reader, \
0, 0, \
0, 0 \
},
#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \
{ \
_ident, T1CODE, _type, \
0, \
(T1_UInt)(char*)&T1_FIELD_REF( T1TYPE, _fname ), \
sizeof ( T1_FIELD_REF( T1TYPE, _fname )[0] ), \
_max, \
(T1_UInt)(char*)&T1_FIELD_REF( T1TYPE, num_ ## _fname ) \
},
#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \
{ _ident, T1CODE, _type, \
0, \
(FT_UInt)(char*)&T1_FIELD_REF(T1TYPE,_fname), \
sizeof(T1_FIELD_REF(T1TYPE,_fname)[0]), \
_max, 0 },
{ \
_ident, T1CODE, _type, \
0, \
(T1_UInt)(char*)&T1_FIELD_REF( T1TYPE, _fname ), \
sizeof ( T1_FIELD_REF( T1TYPE, _fname )[0] ), \
_max, 0 \
},
#define T1_FIELD_BOOL( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname )
#define T1_FIELD_BOOL( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname )
#define T1_FIELD_NUM( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname )
#define T1_FIELD_NUM( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname )
#define T1_FIELD_FIXED( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname )
#define T1_FIELD_FIXED( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname )
#define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname )
#define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname )
#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_integer_array, _fname, _fmax )
#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, _fname, _fmax )
#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \
_fname, _fmax )
#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, _fname, _fmax )
#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \
_fname, _fmax )
#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, _fname, _fmax )
#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \
_fname, _fmax )
#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \
_fname, _fmax )
#define T1_FIELD_CALLBACK( _ident, _name ) \
T1_NEW_CALLBACK_FIELD( _ident, parse_ ## _name )
#define T1_FIELD_CALLBACK( _ident, _name ) \
T1_NEW_CALLBACK_FIELD( _ident, parse_ ## _name )
LOCAL_DEF
FT_Error CID_Load_Field( CID_Parser* parser,
T1_Error CID_Load_Field( CID_Parser* parser,
const T1_Field_Rec* field,
void* object );
LOCAL_DEF
FT_Error CID_Load_Field_Table( CID_Parser* parser,
T1_Error CID_Load_Field_Table( CID_Parser* parser,
const T1_Field_Rec* field,
void* object );
#ifdef __cplusplus
}
#endif
#endif /* CIDPARSE_H */
/* END */

View File

@ -1,19 +1,20 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidriver.c */
/* */
/* CID 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. */
/* */
/***************************************************************************/
#include <cidriver.h>
#include <cidgload.h>
@ -23,8 +24,18 @@
#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_ciddriver
/*************************************************************************/
/* */
@ -55,16 +66,18 @@
/* */
static
FTDriver_Interface Get_Interface( FT_Driver driver,
const FT_String* interface )
const T1_String* interface )
{
UNUSED(driver);
UNUSED(interface);
UNUSED( driver );
UNUSED( interface );
return 0;
}
#ifdef xxxT1_CONFIG_OPTION_NO_AFM
/*************************************************************************/
/* */
/* <Function> */
@ -98,94 +111,104 @@
/* They can be implemented by format-specific interfaces. */
/* */
static
FT_Error Get_Kerning( T1_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
T1_Error Get_Kerning( T1_Face face,
T1_UInt left_glyph,
T1_UInt right_glyph,
T1_Vector* kerning )
{
T1_AFM* afm;
kerning->x = 0;
kerning->y = 0;
afm = (T1_AFM*)face->afm_data;
if (afm)
if ( afm )
CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return T1_Err_Ok;
}
#endif
/******************************************************************/
/* */
/* <Function> Set_Char_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes */
/* (horizontal and vertical) expressed in fractional points. */
/* */
/* <Input> */
/* size :: handle to target size object */
/* char_width :: character width expressed in 26.6 points */
/* char_height :: character height expressed in 26.6 points */
/* */
/* <Return> */
/* FreeType error code. 0 means success */
/* */
#endif /* xxxT1_CONFIG_OPTION_NO_AFM */
/*************************************************************************/
/* */
/* <Function> */
/* Set_Char_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in fractional points. */
/* */
/* <Input> */
/* char_width :: The character width expressed in 26.6 */
/* fractional points. */
/* */
/* char_height :: The character height expressed in 26.6 */
/* fractional points. */
/* */
/* horz_resolution :: The horizontal resolution of the output device. */
/* */
/* vert_resolution :: The vertical resolution of the output device. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* Type1 error code. 0 means success. */
/* */
static
FT_Error Set_Char_Sizes( T1_Size size,
T1_F26Dot6 char_width,
T1_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
T1_Error Set_Char_Sizes( T1_Size size,
T1_F26Dot6 char_width,
T1_F26Dot6 char_height,
T1_UInt horz_resolution,
T1_UInt vert_resolution )
{
UNUSED(char_width);
UNUSED(char_height);
UNUSED(horz_resolution);
UNUSED(vert_resolution);
UNUSED( char_width );
UNUSED( char_height );
UNUSED( horz_resolution );
UNUSED( vert_resolution );
size->valid = FALSE;
return T1_Reset_Size( size );
return CID_Reset_Size( size );
}
/******************************************************************/
/* */
/* <Function> Set_Pixel_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes */
/* (horizontal and vertical) expressed in integer pixels. */
/* */
/* <Input> */
/* size :: handle to target size object */
/* */
/* pixel_width :: character width expressed in 26.6 points */
/* */
/* pixel_height :: character height expressed in 26.6 points */
/* */
/* char_size :: the corresponding character size in points */
/* This value is only sent to the TrueType */
/* bytecode interpreter, even though 99% of */
/* glyph programs will simply ignore it. A */
/* safe value there is the maximum of the */
/* pixel width and height (multiplied by */
/* 64 to make it a 26.6 fixed float !) */
/* <Return> */
/* FreeType error code. 0 means success */
/* */
/*************************************************************************/
/* */
/* <Function> */
/* Set_Pixel_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in integer pixels. */
/* */
/* <Input> */
/* pixel_width :: The character width expressed in integer pixels. */
/* */
/* pixel_height :: The character height expressed in integer pixels. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* Type1 error code. 0 means success. */
/* */
static
FT_Error Set_Pixel_Sizes( T1_Size size,
FT_Int pixel_width,
FT_Int pixel_height )
T1_Error Set_Pixel_Sizes( T1_Size size,
T1_Int pixel_width,
T1_Int pixel_height )
{
UNUSED(pixel_width);
UNUSED(pixel_height);
UNUSED( pixel_width );
UNUSED( pixel_height );
size->valid = FALSE;
return T1_Reset_Size(size);
return CID_Reset_Size( size );
}
/*************************************************************************/
/* */
/* <Function> */
@ -202,227 +225,158 @@
/* Glyph index. 0 means `undefined character code'. */
/* */
static
FT_UInt Get_Char_Index( FT_CharMap charmap,
FT_Long charcode )
T1_UInt Get_Char_Index( FT_CharMap charmap,
T1_Long charcode )
{
T1_Face face;
FT_UInt result = 0;
T1_UInt result = 0;
PSNames_Interface* psnames;
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,
(T1_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:
/*******************************************************************/
/* */
/* 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;
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
if ( charcode < 256 )
{
T1_UInt code;
T1_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];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
break;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
T1_Encoding* encoding = &face->type1.encoding;
if (charcode >= encoding->code_first &&
charcode <= encoding->code_last)
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
strcmp( gname, glyph_name ) == 0 )
{
result = encoding->char_index[charcode];
result = n;
break;
}
goto Exit;
}
/********************************************************************/
/* */
/* 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];
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;
}
/******************************************************************/
/* */
/* <Struct> FT_DriverInterface */
/* */
/* <Description> */
/* A structure used to hold a font driver's basic interface */
/* used by the high-level parts of FreeType (or other apps) */
/* */
/* Most scalable drivers provide a specialized interface to */
/* access format-specific features. It can be retrieved with */
/* a call to the "get_format_interface", and should be defined */
/* in each font driver header (e.g. ttdriver.h, t1driver.h,..) */
/* */
/* All fields are function pointers .. */
/* */
/* */
/* <Fields> */
/* */
/* new_engine :: */
/* used to create and initialise a new driver object */
/* */
/* done_engine :: */
/* used to finalise and destroy a given driver object */
/* */
/* get_format_interface :: */
/* return a typeless pointer to the format-specific */
/* driver interface. */
/* */
/* new_face :: */
/* create a new face object from a resource */
/* */
/* done_face :: */
/* discards a face object, as well as all child objects */
/* ( sizes, charmaps, glyph slots ) */
/* */
/* get_face_properties :: */
/* return generic face properties */
/* */
/* get_kerning :: */
/* return the kerning vector corresponding to a pair */
/* of glyphs, expressed in unscaled font units. */
/* */
/* new_size :: */
/* create and initialise a new scalable size object. */
/* */
/* new_fixed_size :: */
/* create and initialise a new fixed-size object. */
/* */
/* done_size :: */
/* finalize a given face size object. */
/* */
/* set_size_resolutions :: */
/* reset a scalable size object's output resolutions */
/* */
/* set_size_char_sizes :: */
/* reset a scalable size object's character size */
/* */
/* set_pixel_sizes :: */
/* reset a face size object's pixel dimensions. Applies */
/* to both scalable and fixed faces. */
/* */
/* new_glyph_slot :: */
/* create and initialise a new glyph slot */
/* */
/* done_glyph_slot :: */
/* discard a given glyph slot */
/* */
/* load_glyph :: */
/* load a given glyph into a given slot */
/* */
/* get_glyph_metrics :: */
/* return a loaded glyph's metrics. */
/* */
const FT_DriverInterface t1cid_driver_interface =
const FT_DriverInterface t1cid_driver_interface =
{
sizeof( FT_DriverRec ),
sizeof( CID_FaceRec ),
sizeof( T1_SizeRec ),
sizeof( T1_GlyphSlotRec ),
"type1",
"t1cid",
100,
200,
0, /* format interface */
(FTDriver_initDriver) T1_Init_Driver,
(FTDriver_doneDriver) T1_Done_Driver,
(FTDriver_initDriver) CID_Init_Driver,
(FTDriver_doneDriver) CID_Done_Driver,
(FTDriver_getInterface) Get_Interface,
(FTDriver_getInterface) Get_Interface,
(FTDriver_initFace) T1_Init_Face,
(FTDriver_doneFace) T1_Done_Face,
(FTDriver_initFace) CID_Init_Face,
(FTDriver_doneFace) CID_Done_Face,
#ifndef xxxxT1_CONFIG_OPTION_NO_AFM
(FTDriver_getKerning) 0,
(FTDriver_getKerning) 0,
#else
(FTDriver_getKerning) Get_Kerning,
(FTDriver_getKerning) Get_Kerning,
#endif
(FTDriver_initSize) T1_Init_Size,
(FTDriver_doneSize) T1_Done_Size,
(FTDriver_setCharSizes) Set_Char_Sizes,
(FTDriver_setPixelSizes) Set_Pixel_Sizes,
(FTDriver_initSize) CID_Init_Size,
(FTDriver_doneSize) CID_Done_Size,
(FTDriver_setCharSizes) Set_Char_Sizes,
(FTDriver_setPixelSizes)Set_Pixel_Sizes,
(FTDriver_initGlyphSlot) T1_Init_GlyphSlot,
(FTDriver_doneGlyphSlot) T1_Done_GlyphSlot,
(FTDriver_loadGlyph) CID_Load_Glyph,
(FTDriver_initGlyphSlot)CID_Init_GlyphSlot,
(FTDriver_doneGlyphSlot)CID_Done_GlyphSlot,
(FTDriver_loadGlyph) CID_Load_Glyph,
(FTDriver_getCharIndex) Get_Char_Index,
(FTDriver_getCharIndex) Get_Char_Index,
};
/******************************************************************/
/* */
/* <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(FT_DriverInterface*) getDriverInterface( void )
/*************************************************************************/
/* */
/* <Function> */
/* getDriverInterface */
/* */
/* <Description> */
/* This function is used when compiling the CID 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> */
/* The address of the CID's driver generic interface. The */
/* format-specific interface can then be retrieved through the method */
/* interface->get_format_interface. */
/* */
EXPORT_FUNC( FT_DriverInterface* ) getDriverInterface( void )
{
return &t1cid_driver_interface;
}
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */

View File

@ -1,27 +1,30 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidriver.h */
/* */
/* High-level CID 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 T1DRIVER_H
#define T1DRIVER_H
#ifndef CIDRIVER_H
#define CIDRIVER_H
#include <cidobjs.h>
#include <freetype/internal/t1errors.h>
FT_EXPORT_VAR(const FT_DriverInterface) t1cid_driver_interface;
FT_EXPORT_VAR( const FT_DriverInterface ) t1cid_driver_interface;
#endif /* T1DRIVER_H */
#endif /* CIDRIVER_H */
/* END */

View File

@ -1,22 +1,23 @@
/*******************************************************************
*
* 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* cidtokens.h */
/* */
/* CID token definitions (specification only). */
/* */
/* 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
#undef T1CODE
#define T1TYPE CID_Info
#define T1CODE t1_field_cid_info
@ -33,7 +34,8 @@
T1_FIELD_NUM ( "FDBytes", fd_bytes )
T1_FIELD_NUM ( "GDBytes", gd_bytes )
T1_FIELD_NUM ( "CIDCount", cid_count )
#undef T1TYPE
#undef T1CODE
#define T1TYPE T1_FontInfo
@ -49,6 +51,7 @@
T1_FIELD_NUM ( "UnderlinePosition", underline_position )
T1_FIELD_NUM ( "UnderlineThickness", underline_thickness )
#undef T1TYPE
#undef T1CODE
#define T1TYPE CID_FontDict
@ -64,21 +67,22 @@
T1_FIELD_FIXED ( "ForceBoldThreshold", forcebold_threshold )
T1_FIELD_FIXED ( "ExpansionFactor", expansion_factor )
T1_FIELD_NUM ( "StrokeWidth", stroke_width )
#undef T1TYPE
#undef T1CODE
#define T1TYPE T1_Private
#define T1CODE t1_field_private
T1_FIELD_NUM ( "UniqueID", unique_id )
T1_FIELD_NUM ( "lenIV", lenIV )
T1_FIELD_NUM ( "LanguageGroup", language_group )
T1_FIELD_NUM ( "password", password )
T1_FIELD_FIXED( "BlueScale", blue_scale )
T1_FIELD_NUM ( "BlueShift", blue_shift )
T1_FIELD_NUM ( "BlueFuzz", blue_fuzz )
T1_FIELD_NUM ( "UniqueID", unique_id )
T1_FIELD_NUM ( "lenIV", lenIV )
T1_FIELD_NUM ( "LanguageGroup", language_group )
T1_FIELD_NUM ( "password", password )
T1_FIELD_FIXED ( "BlueScale", blue_scale )
T1_FIELD_NUM ( "BlueShift", blue_shift )
T1_FIELD_NUM ( "BlueFuzz", blue_fuzz )
T1_FIELD_NUM_TABLE( "BlueValues", blue_values, 14 )
T1_FIELD_NUM_TABLE( "OtherBlues", other_blues, 10 )
T1_FIELD_NUM_TABLE( "FamilyBlues", family_blues, 14 )
@ -87,8 +91,9 @@
T1_FIELD_NUM_TABLE2( "StdHW", standard_width, 1 )
T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
/* END */

View File

@ -1,32 +1,21 @@
/***************************************************************************/
/* */
/* type1.c */
/* cff.c */
/* */
/* FreeType Type 1 driver component */
/* FreeType OpenType driver component (body only). */
/* */
/* Copyright 1996-1998 by */
/* 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 */
/* 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 is used to compile the FreeType Type 1 font driver. */
/* It relies on all components included in the "base" layer (see */
/* the file "ftbase.c"). Source code is located in "freetype/ttlib" */
/* and contains : */
/* */
/* - a driver interface */
/* - an object manager */
/* - a table loader */
/* - a glyph loader */
/* - a glyph hinter */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <cidparse.c>
@ -39,3 +28,5 @@
#include <cidafm.c>
#endif
/* END */

View File

@ -175,7 +175,7 @@
/* vert_resolution :: The vertical resolution of the output device. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */