Formatting, small fixes.

Adding copyright notices etc.
This commit is contained in:
Werner Lemberg 2000-08-23 17:32:42 +00:00
parent b466a7650c
commit 8728f294bc
28 changed files with 939 additions and 579 deletions

View File

@ -354,11 +354,12 @@
/*************************************************************************/
/* */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */
/* A minimum of 16 is required.. */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */
/* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32
/*************************************************************************/
/* */
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */

View File

@ -14,9 +14,6 @@
# indicate that you have read the license and understand and accept it
# fully.
#
# NOTE: This version requires that GNU Make is invoked from the Windows
# Shell (_not_ Cygwin BASH)!
#
ifndef TOP
TOP := .
@ -25,8 +22,8 @@ endif
DELETE := rm -f
SEP := /
HOSTSEP := $(SEP)
BUILD := $(TOP)/builds/unix/devel
PLATFORM := unixdev # do not set it to "unix", or libtool will trick you..
BUILD := $(TOP)/builds/unix/devel # we use a special devel ftoption.h
PLATFORM := unixdev # do not set it to `unix', or libtool will trick you
CC := gcc
# The directory where all object files are placed.

View File

@ -354,11 +354,12 @@
/*************************************************************************/
/* */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */
/* A minimum of 16 is required.. */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */
/* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32
/*************************************************************************/
/* */
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */

View File

@ -25,7 +25,7 @@ endif
DELETE := del
SEP := /
HOSTSEP := $(strip \ )
BUILD := $(TOP)/builds/win32/devel
BUILD := $(TOP)/builds/win32/devel # we use a special devel ftoption.h
PLATFORM := win32
CC := gcc

View File

@ -354,11 +354,12 @@
/*************************************************************************/
/* */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */
/* A minimum of 16 is required.. */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */
/* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32
/*************************************************************************/
/* */
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */

View File

@ -218,10 +218,10 @@
enum
{
ft_glyph_bbox_subpixels = 0, /* return unfitted coordinates in 26.6 pixels */
ft_glyph_bbox_gridfit = 1, /* return grid-fitted coordinates */
ft_glyph_bbox_truncate = 2, /* return coordinates in integer pixels */
ft_glyph_bbox_pixels = 3 /* return grid-fitted pixel coordinates */
ft_glyph_bbox_subpixels = 0, /* return unfitted 26.6 coordinates */
ft_glyph_bbox_gridfit = 1, /* return grid-fitted coordinates */
ft_glyph_bbox_truncate = 2, /* return coordinates in integer pixels */
ft_glyph_bbox_pixels = 3 /* return grid-fitted pixel coordinates */
};

View File

@ -1,18 +1,51 @@
/***************************************************************************/
/* */
/* ftsynth.h */
/* */
/* FreeType synthesizing code for emboldening and slanting */
/* (specification). */
/* */
/* Copyright 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 FTSYNTH_H
#define FTSYNTH_H
#include <freetype/freetype.h>
/* this code is completely experimental - use with care */
/* it will probably be completely rewritten in the future */
#ifdef __cplusplus
extern "C" {
#endif
/* This code is completely experimental - use with care! */
/* It will probably be completely rewritten in the future */
/* or even integrated within the library... */
FT_EXPORT_DEF(FT_Error) FT_Embolden_Outline( FT_Face original,
FT_Outline* outline,
FT_Pos* advance );
FT_EXPORT_DEF( FT_Error ) FT_Embolden_Outline( FT_Face original,
FT_Outline* outline,
FT_Pos* advance );
FT_EXPORT_DEF(FT_Error) FT_Oblique_Outline( FT_Face original,
FT_Outline* outline,
FT_Pos* advance );
FT_EXPORT_DEF( FT_Error ) FT_Oblique_Outline( FT_Face original,
FT_Outline* outline,
FT_Pos* advance );
#endif /* FTEMBOLD_H */
#ifdef __cplusplus
}
#endif
#endif /* FTSYNTH_H */
/* END */

View File

@ -84,7 +84,7 @@
trace_t1load,
trace_t1objs,
/* Postcript helper module 'psaux' */
/* PostScript helper module `psaux' */
trace_t1decode,
trace_psobjs,

View File

@ -37,36 +37,41 @@
/*************************************************************************/
/*************************************************************************/
typedef struct PS_Table_ PS_Table;
/*************************************************************************/
/* */
/* <Struct> */
/* PS_Table_Funcs */
/* */
/* <Description> */
/* A set of function pointers used to manage PS_Table objects.. */
/* A set of function pointers to manage PS_Table objects. */
/* */
/* <Fields> */
/* table_init :: used to initialise a a table */
/* table_done :: finalize/destroy a given table */
/* table_add :: add one new object to a table */
/* table_release :: release table data, then finalize it */
/* table_init :: Used to initialize a table. */
/* */
typedef struct PS_Table_Funcs_
/* table_done :: Finalizes resp. destroy a given table. */
/* */
/* table_add :: Adds a new object to a table. */
/* */
/* table_release :: Releases table data, then finalizes it. */
/* */
typedef struct PS_Table_Funcs_
{
FT_Error (*init) ( PS_Table* table,
FT_Int count,
FT_Memory memory );
FT_Error (*init) ( PS_Table* table,
FT_Int count,
FT_Memory memory );
void (*done) ( PS_Table* table );
void (*done) ( PS_Table* table );
FT_Error (*add) ( PS_Table* table,
FT_Int index,
void* object,
FT_Int length );
FT_Error (*add) ( PS_Table* table,
FT_Int index,
void* object,
FT_Int length );
void (*release)( PS_Table* table );
void (*release)( PS_Table* table );
} PS_Table_Funcs;
@ -101,19 +106,19 @@
/* memory :: The object used for memory operations */
/* (alloc/realloc). */
/* */
/* funcs :: table of method pointers for this object */
/* funcs :: A table of method pointers for this object. */
/* */
struct PS_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
FT_Int capacity; /* current size of memory block */
FT_Long init;
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
FT_Int capacity; /* current size of memory block */
FT_Long init;
FT_Int max_elems;
FT_Int num_elems;
FT_Byte** elements; /* addresses of table elements */
FT_Int* lengths; /* lengths of table elements */
FT_Int max_elems;
FT_Int num_elems;
FT_Byte** elements; /* addresses of table elements */
FT_Int* lengths; /* lengths of table elements */
FT_Memory memory;
PS_Table_Funcs funcs;
@ -121,8 +126,6 @@
};
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -131,6 +134,7 @@
/*************************************************************************/
/*************************************************************************/
/* simple enumeration type used to identify token types */
typedef enum T1_Token_Type_
{
@ -264,28 +268,10 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Parser */
/* */
/* <Description> */
/* A T1_Parser is an object used to parse a Type 1 font very quickly. */
/* */
/* <Fields> */
/* cursor :: The current position in the text. */
/* */
/* base :: Start of the processed text. */
/* */
/* limit :: End of the processed text. */
/* */
/* error :: The last error returned. */
/* */
/* funcs :: table of functions for the parser */
/* */
/* */
typedef struct T1_Parser_ T1_Parser;
typedef struct T1_Parser_Funcs_
{
void (*init) ( T1_Parser* parser,
@ -331,13 +317,34 @@
} T1_Parser_Funcs;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Parser */
/* */
/* <Description> */
/* A T1_Parser is an object used to parse a Type 1 font very quickly. */
/* */
/* <Fields> */
/* cursor :: The current position in the text. */
/* */
/* base :: Start of the processed text. */
/* */
/* limit :: End of the processed text. */
/* */
/* error :: The last error returned. */
/* */
/* memory :: The object used for memory operations (alloc/realloc). */
/* */
/* funcs :: A table of functions for the parser. */
/* */
struct T1_Parser_
{
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Error error;
FT_Memory memory;
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Error error;
FT_Memory memory;
T1_Parser_Funcs funcs;
};
@ -352,8 +359,10 @@
/*************************************************************************/
/*************************************************************************/
typedef struct T1_Builder_ T1_Builder;
typedef FT_Error (*T1_Builder_Check_Points_Func) ( T1_Builder* builder,
FT_Int count );
@ -449,38 +458,38 @@
/* the metrics of a given glyph, not load all of its */
/* points. */
/* */
/* funcs :: array of function pointers for the builder */
/* funcs :: An array of function pointers for the builder. */
/* */
struct T1_Builder_
{
FT_Memory memory;
FT_Face face;
FT_GlyphSlot glyph;
FT_GlyphLoader* loader;
FT_Outline* base;
FT_Outline* current;
FT_Memory memory;
FT_Face face;
FT_GlyphSlot glyph;
FT_GlyphLoader* loader;
FT_Outline* base;
FT_Outline* current;
FT_Vector last;
FT_Vector last;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Vector left_bearing;
FT_Vector advance;
FT_Vector left_bearing;
FT_Vector advance;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool shift;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool shift;
FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
T1_Builder_Funcs funcs;
T1_Builder_Funcs funcs;
};
@ -493,8 +502,9 @@
/*************************************************************************/
#if 0
#define T1_MAX_CHARSTRINGS_OPERANDS 64
#define T1_MAX_SUBRS_CALLS 16
#define T1_MAX_CHARSTRINGS_OPERANDS 64
#define T1_MAX_SUBRS_CALLS 16
/*************************************************************************/
/* */
@ -506,15 +516,15 @@
/*************************************************************************/
/* */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */
/* A minimum of 16 is required.. */
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */
/* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32
#endif
#endif /* 0 */
typedef struct T1_Decoder_Zone_
typedef struct T1_Decoder_Zone_
{
FT_Byte* cursor;
FT_Byte* base;
@ -526,57 +536,58 @@
typedef struct T1_Decoder_ T1_Decoder;
typedef struct T1_Decoder_Funcs_ T1_Decoder_Funcs;
typedef FT_Error (*T1_Decoder_Callback)( T1_Decoder* decoder,
FT_UInt glyph_index );
struct T1_Decoder_Funcs_
struct T1_Decoder_Funcs_
{
FT_Error (*init) ( T1_Decoder* decoder,
FT_Face face,
FT_Size size,
FT_GlyphSlot slot,
FT_Byte** glyph_names,
T1_Blend* blend,
T1_Decoder_Callback callback );
FT_Error (*init) ( T1_Decoder* decoder,
FT_Face face,
FT_Size size,
FT_GlyphSlot slot,
FT_Byte** glyph_names,
T1_Blend* blend,
T1_Decoder_Callback callback );
void (*done) ( T1_Decoder* decoder );
void (*done) ( T1_Decoder* decoder );
FT_Error (*parse_charstrings)( T1_Decoder* decoder,
FT_Byte* base,
FT_UInt len );
FT_Error (*parse_charstrings)( T1_Decoder* decoder,
FT_Byte* base,
FT_UInt len );
};
struct T1_Decoder_
struct T1_Decoder_
{
T1_Builder builder;
T1_Builder builder;
FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
FT_Long* top;
FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
FT_Long* top;
T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
T1_Decoder_Zone* zone;
T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
T1_Decoder_Zone* zone;
PSNames_Interface* psnames; /* for seac */
FT_UInt num_glyphs;
FT_Byte** glyph_names;
PSNames_Interface* psnames; /* for seac */
FT_UInt num_glyphs;
FT_Byte** glyph_names;
FT_UInt lenIV; /* internal for sub routine calls */
FT_UInt num_subrs;
FT_Byte** subrs;
FT_Int* subrs_len; /* array of subrs length (optional) */
FT_UInt lenIV; /* internal for sub routine calls */
FT_UInt num_subrs;
FT_Byte** subrs;
FT_Int* subrs_len; /* array of subrs length (optional) */
FT_Matrix font_matrix;
FT_Matrix font_matrix;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
T1_Blend* blend; /* for multiple master support */
T1_Blend* blend; /* for multiple master support */
T1_Decoder_Callback parse_callback;
T1_Decoder_Funcs funcs;
T1_Decoder_Callback parse_callback;
T1_Decoder_Funcs funcs;
};
@ -590,14 +601,14 @@
typedef struct PSAux_Interface_
{
const PS_Table_Funcs* ps_table_funcs;
const T1_Parser_Funcs* t1_parser_funcs;
const T1_Builder_Funcs* t1_builder_funcs;
const T1_Decoder_Funcs* t1_decoder_funcs;
const PS_Table_Funcs* ps_table_funcs;
const T1_Parser_Funcs* t1_parser_funcs;
const T1_Builder_Funcs* t1_builder_funcs;
const T1_Decoder_Funcs* t1_decoder_funcs;
void (*t1_decrypt)( FT_Byte* buffer,
FT_Int length,
FT_UShort seed );
void (*t1_decrypt)( FT_Byte* buffer,
FT_Int length,
FT_UShort seed );
} PSAux_Interface;

View File

@ -793,7 +793,7 @@
/* prepare dummy slot for rendering */
error = clazz->glyph_prepare( glyph, &dummy );
if (!error)
if ( !error )
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
if ( !destroy && origin )
@ -859,9 +859,4 @@
}
#if 1
#endif /* 0 -- EXPERIMENTAL STUFF! */
/* END */

View File

@ -1,7 +1,27 @@
/***************************************************************************/
/* */
/* ftsynth.c */
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
/* Copyright 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/ftsynth.h>
#define FT_BOLD_THRESHOLD 0x0100
/*************************************************************************/
/*************************************************************************/
/**** ****/
@ -10,16 +30,20 @@
/*************************************************************************/
/*************************************************************************/
FT_EXPORT_DEF(FT_Error) FT_Oblique_Outline( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance )
FT_EXPORT_DEF( FT_Error ) FT_Oblique_Outline( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance )
{
FT_Matrix transform;
FT_UNUSED(original);
FT_UNUSED( original );
/* we don't touch the advance width */
FT_UNUSED(advance);
/* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees.. */
/* of about 12 degrees. */
transform.xx = 0x10000;
transform.yx = 0x00000;
@ -29,12 +53,10 @@
FT_Transform_Outline( outline, &transform );
/* we don't touch the advance width */
FT_UNUSED(advance);
return 0;
}
/*************************************************************************/
/*************************************************************************/
/**** ****/
@ -43,6 +65,7 @@
/*************************************************************************/
/*************************************************************************/
/* Compute the norm of a vector */
#ifdef FT_CONFIG_OPTION_OLD_CALCS
@ -245,19 +268,19 @@
/* test orientation of the xmin */
n = ft_test_extrema( outline, indices.xMin );
if (n)
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.yMin );
if (n)
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.xMax );
if (n)
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.yMax );
if (!n)
if ( !n )
n = 1;
Exit:
@ -269,12 +292,12 @@
FT_Outline* outline,
FT_Pos* advance )
{
FT_Vector u, v;
FT_Vector* points;
FT_Vector cur, prev, next;
FT_Pos distance;
FT_Face face = FT_SLOT_FACE(original);
int c, n, first, orientation;
FT_Vector u, v;
FT_Vector* points;
FT_Vector cur, prev, next;
FT_Pos distance;
FT_Face face = FT_SLOT_FACE( original );
int c, n, first, orientation;
FT_UNUSED( advance );
@ -369,3 +392,4 @@
}
/* END */

128
src/cache/ftcimage.c vendored
View File

@ -1,80 +1,106 @@
/***************************************************************************/
/* */
/* ftcimage.c */
/* */
/* XXX */
/* */
/* Copyright 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 <cache/ftcimage.h>
static
void ftc_done_glyph_image( FTC_Image_Queue queue,
FTC_ImageNode node )
void ftc_done_glyph_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
FT_UNUSED(queue);
FT_Done_Glyph( FTC_IMAGENODE_GET_GLYPH(node) );
FT_UNUSED( queue );
FT_Done_Glyph( FTC_IMAGENODE_GET_GLYPH( node ) );
}
static
FT_ULong ftc_size_bitmap_image( FTC_Image_Queue queue,
FTC_ImageNode node )
FT_ULong ftc_size_bitmap_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
FT_Long pitch;
FT_BitmapGlyph glyph;
FT_UNUSED(queue);
FT_UNUSED( queue );
glyph = (FT_BitmapGlyph)FTC_IMAGENODE_GET_GLYPH(node);
pitch = glyph->bitmap.pitch;
if (pitch < 0)
if ( pitch < 0 )
pitch = -pitch;
return (FT_ULong)(pitch * glyph->bitmap->rows + sizeof(*glyph));
return (FT_ULong)(pitch * glyph->bitmap->rows + sizeof ( *glyph ) );
}
static
FT_ULong ftc_size_outline_image( FTC_Image_Queue queue,
FTC_ImageNode node )
FT_ULong ftc_size_outline_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
FT_Long pitch;
FT_OutlineGlyph glyph;
FT_Outline* outline;
FT_UNUSED(queue);
glyph = (FT_OutlineGlyph)FTC_IMAGENODE_GET_GLYPH(node);
FT_UNUSED( queue );
glyph = (FT_OutlineGlyph)FTC_IMAGENODE_GET_GLYPH( node );
outline = &glyph->outline;
return (FT_ULong)(
outline->n_points * (sizeof(FT_Vector)+sizeof(FT_Byte)) +
outline->n_contours * sizeof(FT_Short) +
sizeof(*glyph) );
outline->n_points * ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
outline->n_contours * sizeof ( FT_Short ) +
sizeof( *glyph ) );
}
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** MONOCHROME BITMAP CALLBACKS *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MONOCHROME BITMAP CALLBACKS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static
FT_Error ftc_init_mono_image( FTC_Image_Queue queue,
FTC_ImageNode node )
FT_Error ftc_init_mono_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
FT_Face face;
FT_Size size;
FT_Error error;
FT_Face face;
FT_Size size;
FT_Error error;
error = FTC_Manager_Lookup_Size( queue->manager,
&queue->size_rec,
&face, &size );
if (!error)
if ( !error )
{
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX(node);
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX( node );
error = FT_Load_Glyph( face, glyph_index,
FT_LOAD_RENDER | FT_LOAD_MONOCHROME );
if (!error)
if ( !error )
{
if ( face->glyph->format != ft_image_format_bitmap ||
face->glyph->bitmap.pixel_mode != ft_pixel_mode_mono )
face->glyph->bitmap.pixel_mode != ft_pixel_mode_mono )
{
/* there is no monochrome glyph for this font !! */
/* there is no monochrome glyph for this font! */
error = FT_Err_Invalid_Glyph_Index;
}
else
@ -84,8 +110,8 @@
error = FT_Get_Glyph( face->glyph, &glyph );
if (!error)
FTC_IMAGENODE_SET_GLYPH(node,glyph);
if ( !error )
FTC_IMAGENODE_SET_GLYPH( node, glyph );
}
}
}
@ -94,30 +120,30 @@
static
FT_Error ftc_init_gray_image( FTC_Image_Queue queue,
FTC_ImageNode node )
FT_Error ftc_init_gray_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
FT_Face face;
FT_Size size;
FT_Error error;
FT_Face face;
FT_Size size;
FT_Error error;
error = FTC_Manager_Lookup_Size( queue->manager,
&queue->size_rec,
&face, &size );
if (!error)
if ( !error )
{
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX(node);
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX( node );
error = FT_Load_Glyph( face, glyph_index,
FT_LOAD_RENDER );
if (!error)
if ( !error )
{
if ( face->glyph->format != ft_image_format_bitmap ||
face->glyph->bitmap.pixel_mode != ft_pixel_mode_grays )
{
/* there is no monochrome glyph for this font !! */
/* there is no monochrome glyph for this font! */
error = FT_Err_Invalid_Glyph_Index;
}
else
@ -127,8 +153,8 @@
error = FT_Get_Glyph( face->glyph, &glyph );
if (!error)
FTC_IMAGENODE_SET_GLYPH(node,glyph);
if ( !error )
FTC_IMAGENODE_SET_GLYPH( node, glyph );
}
}
}
@ -136,12 +162,4 @@
}
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** MONOCHROME BITMAP CALLBACKS *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
/* END */

122
src/cache/ftcimage.h vendored
View File

@ -1,15 +1,40 @@
/***************************************************************************/
/* */
/* ftcimage.h */
/* */
/* XXX */
/* */
/* Copyright 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 FTCIMAGE_H
#define FTCIMAGE_H
#include <cache/ftcmanag.h>
#include <freetype/ftglyph.h>
typedef struct FTC_Image_QueueRec_* FTC_Image_Queue;
typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
typedef struct FTC_ImageNodeRec_* FTC_ImageNode;
#ifdef __cplusplus
extern "C" {
#endif
typedef struct FTC_Image_QueueRec_* FTC_Image_Queue;
typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
typedef struct FTC_ImageNodeRec_* FTC_ImageNode;
/* types of glyph images */
typedef enum FTC_Image_Type_
typedef enum FTC_Image_Type_
{
ftc_image_mono = 0, /* monochrome bitmap */
ftc_image_grays, /* anti-aliased bitmap */
@ -22,34 +47,43 @@
/* a descriptor used to describe all glyphs in a given queue */
typedef struct FTC_Image_Desc_
{
FTC_FaceID face_id;
FT_UInt pix_width;
FT_UInt pix_height;
FT_UInt image_type;
FTC_FaceID face_id;
FT_UInt pix_width;
FT_UInt pix_height;
FT_UInt image_type;
} FTC_Image_Desc;
/* macros used to pack a glyph index and a queue index in a single ptr */
#define FTC_PTR_TO_GINDEX(p) ((FT_UInt)((FT_ULong)(p) >> 16))
#define FTC_PTR_TO_QINDEX(p) ((FT_UInt)((FT_ULong)(p) & 0xFFFF))
#define FTC_INDICES_TO_PTR(g,q) ((FT_Pointer)(((FT_ULong)(g) << 16) | \
((FT_ULong)(q) & 0xFFFF)))
/* macros used to pack a glyph index and a queue index in a single ptr */
#define FTC_PTR_TO_GINDEX( p ) ( (FT_UInt)( (FT_ULong)(p) >> 16 ) )
#define FTC_PTR_TO_QINDEX( p ) ( (FT_UInt)( (FT_ULong)(p) & 0xFFFF ) )
#define FTC_INDICES_TO_PTR( g, q ) \
( (FT_Pointer)( ( (FT_ULong)(g) << 16 ) | \
( (FT_ULong)(q) & 0xFFFF) ) )
typedef struct FTC_ImageNodeRec_
typedef struct FTC_ImageNodeRec_
{
FT_ListNodeRec root1; /* root1.data contains a FT_Glyph handle */
FT_ListNodeRec root2; /* root2.data contains a glyph index + queue index */
/* root1.data contains a FT_Glyph handle */
FT_ListNodeRec root1;
/* root2.data contains a glyph index + queue index */
FT_ListNodeRec root2;
} FTC_ImageNodeRec;
/* macros to read/set the glyph & queue index in a FTC_ImageNode */
#define FTC_IMAGENODE_GET_GINDEX(n) FTC_PTR_TO_GINDEX((n)->root2.data)
#define FTC_IMAGENODE_GET_QINDEX(n) FTC_PTR_TO_QINDEX((n)->root2.data)
#define FTC_IMAGENODE_SET_INDICES(g,q) \
do { (n)->root2.data = FTC_INDICES_TO_PTR(g,q); } while (0)
/* macros to read/set the glyph & queue index in a FTC_ImageNode */
#define FTC_IMAGENODE_GET_GINDEX( n ) FTC_PTR_TO_GINDEX( (n)->root2.data )
#define FTC_IMAGENODE_GET_QINDEX( n ) FTC_PTR_TO_QINDEX( (n)->root2.data )
#define FTC_IMAGENODE_SET_INDICES( g, q ) \
do \
{ \
(n)->root2.data = FTC_INDICES_TO_PTR( g, q ); \
} while ( 0 )
typedef struct FTC_Image_CacheRec_
typedef struct FTC_Image_CacheRec_
{
FTC_Manager manager;
FT_Memory memory;
@ -62,22 +96,22 @@
} FTC_Image_Cache;
/* a table of functions used to generate/manager glyph images */
typedef struct FTC_Image_Class_
/* a table of functions used to generate/manager glyph images */
typedef struct FTC_Image_Class_
{
FT_Error (*init_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
FT_Error (*init_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
void (*done_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
void (*done_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
FT_ULong (*size_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
FT_ULong (*size_image)( FTC_Image_Queue queue,
FTC_Image_Node node );
} FTC_Image_Class;
typedef struct FTC_Image_QueueRec_
typedef struct FTC_Image_QueueRec_
{
FTC_Image_Cache cache;
FTC_Manager manager;
@ -90,15 +124,25 @@
} FTC_Image_SubCacheRec;
FT_EXPORT_DEF(FT_Error) FTC_Image_Cache_New( FTC_Manager manager,
FT_ULong max_bytes,
FTC_Image_Cache *acache );
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager,
FT_ULong max_bytes,
FTC_Image_Cache* acache );
FT_EXPORT_DEF(void) FTC_Image_Cache_Done( FTC_Image_Cache cache );
FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache );
FT_EXPORT_DEF(FT_Error) FTC_Image_Cache_Lookup( FTC_Image_Cache cache,
FTC_Image_Desc* desc,
FT_UInt gindex,
FT_Glyph *aglyph );
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache,
FTC_Image_Desc* desc,
FT_UInt gindex,
FT_Glyph* aglyph );
#ifdef __cplusplus
}
#endif
#endif /* FTCIMAGE_H */
/* END */

179
src/cache/ftcmanag.c vendored
View File

@ -1,55 +1,82 @@
/***************************************************************************/
/* */
/* ftcmanag.h */
/* */
/* XXX */
/* */
/* Copyright 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 <cache/ftcmanag.h>
#include <freetype/internal/ftobjs.h>
#define FTC_LRU_GET_MANAGER(lru) ((FTC_Manager_Lru)lru)->manager
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** FACE & SIZE LRU CALLBACKS *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
#define FTC_LRU_GET_MANAGER( lru ) ((FTC_Manager_Lru)lru)->manager
/**************************************************************************/
/**************************************************************************/
/***** *****/
/***** FACE & SIZE LRU CALLBACKS *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
static
FT_Error ftc_manager_init_face( FT_Lru lru,
FT_LruNode node )
{
FTC_Manager manager = FTC_LRU_GET_MANAGER(lru);
FTC_Manager manager = FTC_LRU_GET_MANAGER( lru );
FT_Error error;
error = manager->request_face( (FTC_FaceID)node->key,
manager->request_data,
(FT_Face*)&node->root.data );
if (!error)
if ( !error )
{
/* destroy initial size object, it will be re-created later */
/* destroy initial size object; it will be re-created later */
FT_Face face = (FT_Face)node->root.data;
FT_Done_Size( face->size );
}
return error;
}
/* helper function for ftc_manager_done_face */
static
FT_Bool ftc_manager_size_selector( FT_Lru lru,
FT_LruNode node,
FT_Pointer data )
{
FT_UNUSED(lru);
return ((FT_Size)node->root.data)->face == (FT_Face)data;
}
/* helper function for ftc_manager_done_face */
static
FT_Bool ftc_manager_size_selector( FT_Lru lru,
FT_LruNode node,
FT_Pointer data )
{
FT_UNUSED( lru );
return ((FT_Size)node->root.data)->face == (FT_Face)data;
}
static
void ftc_manager_done_face( FT_Lru lru,
FT_LruNode node )
void ftc_manager_done_face( FT_Lru lru,
FT_LruNode node )
{
FTC_Manager manager = FTC_LRU_GET_MANAGER(lru);
FTC_Manager manager = FTC_LRU_GET_MANAGER( lru );
FT_Face face = (FT_Face)node->root.data;
/* we must begin by removing all sizes for the target face */
/* from the manager's list.. */
/* from the manager's list */
FT_Lru_Remove_Selection( manager->sizes_lru,
ftc_manager_size_selector,
face );
@ -60,7 +87,7 @@
}
typedef struct FTC_SizeRequest_
typedef struct FTC_SizeRequest_
{
FT_Face face;
FT_UShort width;
@ -70,24 +97,25 @@
static
FT_Error ftc_manager_init_size( FT_Lru lru,
FT_LruNode node )
FT_Error ftc_manager_init_size( FT_Lru lru,
FT_LruNode node )
{
FTC_SizeRequest* size_req = (FTC_SizeRequest*)node->key;
FT_Size size;
FT_Error error;
FT_UNUSED(lru);
FT_UNUSED( lru );
node->root.data = 0;
error = FT_New_Size( size_req->face, &size );
if (!error)
if ( !error )
{
error = FT_Set_Pixel_Sizes( size_req->face,
size_req->width,
size_req->height );
if (error)
FT_Done_Size(size);
if ( error )
FT_Done_Size( size );
else
node->root.data = size;
}
@ -96,34 +124,35 @@
static
void ftc_manager_done_size( FT_Lru lru,
FT_LruNode node )
void ftc_manager_done_size( FT_Lru lru,
FT_LruNode node )
{
FT_UNUSED(lru);
FT_UNUSED( lru );
FT_Done_Size( (FT_Size)node->root.data );
}
static
FT_Error ftc_manager_flush_size( FT_Lru lru,
FT_LruNode node,
FT_LruKey key )
FT_Error ftc_manager_flush_size( FT_Lru lru,
FT_LruNode node,
FT_LruKey key )
{
FTC_SizeRequest* req = (FTC_SizeRequest*)key;
FT_Size size = (FT_Size)node->root.data;
FT_Error error;
if ( size->face == req->face )
{
size->face->size = size; /* set current size */
error = FT_Set_Pixel_Sizes( req->face, req->width, req->height );
if (error)
if ( error )
FT_Done_Size( size );
}
else
{
FT_Done_Size(size);
FT_Done_Size( size );
node->key = key;
error = ftc_manager_init_size( lru, node );
}
@ -132,25 +161,25 @@
static
FT_Bool ftc_manager_compare_size( FT_LruNode node,
FT_LruKey key )
FT_Bool ftc_manager_compare_size( FT_LruNode node,
FT_LruKey key )
{
FTC_SizeRequest* req = (FTC_SizeRequest*)key;
FT_Size size = (FT_Size)node->root.data;
FT_UNUSED(node);
return ( size->face == req->face &&
size->metrics.x_ppem == req->width &&
FT_UNUSED( node );
return ( size->face == req->face &&
size->metrics.x_ppem == req->width &&
size->metrics.y_ppem == req->height );
}
static
const FT_Lru_Class ftc_face_lru_class =
{
sizeof( FTC_Manager_LruRec ),
sizeof ( FTC_Manager_LruRec ),
ftc_manager_init_face,
ftc_manager_done_face,
0,
@ -161,7 +190,7 @@
static
const FT_Lru_Class ftc_size_lru_class =
{
sizeof( FTC_Manager_LruRec ),
sizeof ( FTC_Manager_LruRec ),
ftc_manager_init_size,
ftc_manager_done_size,
ftc_manager_flush_size,
@ -169,18 +198,17 @@
};
FT_EXPORT_FUNC(FT_Error) FTC_Manager_New ( FT_Library library,
FT_EXPORT_FUNC( FT_Error ) FTC_Manager_New( FT_Library library,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager *amanager )
FTC_Manager* amanager )
{
FT_Error error;
FT_Memory memory = library->memory;
FTC_Manager manager = 0;
if ( ALLOC( manager, sizeof(*manager) ) )
if ( ALLOC( manager, sizeof ( *manager ) ) )
goto Exit;
error = FT_Lru_New( &ftc_face_lru_class,
@ -188,7 +216,7 @@
memory,
1, /* pre_alloc = TRUE */
(FT_Lru*)&manager->faces_lru );
if (error)
if ( error )
goto Exit;
error = FT_Lru_New( &ftc_size_lru_class,
@ -196,7 +224,7 @@
memory,
1, /* pre_alloc = TRUE */
(FT_Lru*)&manager->sizes_lru );
if (error)
if ( error )
goto Exit;
((FTC_Manager_Lru)manager->faces_lru)->manager = manager;
@ -208,7 +236,7 @@
*amanager = manager;
Exit:
if (error && manager)
if ( error && manager )
{
FT_Lru_Done( manager->sizes_lru );
FT_Lru_Done( manager->faces_lru );
@ -218,63 +246,68 @@
return error;
}
FT_EXPORT_DEF(void) FTC_Manager_Done ( FTC_Manager manager )
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager )
{
FT_Memory memory = manager->library->memory;
FT_Lru_Done( manager->sizes_lru );
FT_Lru_Done( manager->faces_lru );
FREE( manager );
}
FT_EXPORT_DEF(void) FTC_Manager_Reset( FTC_Manager manager )
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager )
{
FT_Lru_Reset( manager->sizes_lru );
FT_Lru_Reset( manager->faces_lru );
}
FT_EXPORT_DEF(FT_Error) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face *aface )
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face* aface )
{
return FT_Lru_Lookup( manager->faces_lru,
(FT_LruKey)face_id,
(FT_Pointer*)aface );
(FT_LruKey)face_id,
(FT_Pointer*)aface );
}
FT_EXPORT_DEF(FT_Error) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id,
FT_Face *aface,
FT_Size *asize )
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id,
FT_Face* aface,
FT_Size* asize )
{
FTC_SizeRequest req;
FT_Error error;
FT_Face face;
*aface = 0;
*asize = 0;
error = FTC_Manager_Lookup_Face( manager, size_id->face_id, &face );
if (!error)
if ( !error )
{
req.face = face;
req.width = size_id->pix_width;
req.height = size_id->pix_height;
error = FT_Lru_Lookup( manager->sizes_lru,
(FT_LruKey)&req,
(FT_Pointer*)asize );
if (!error)
error = FT_Lru_Lookup( manager->sizes_lru,
(FT_LruKey)&req,
(FT_Pointer*)asize );
if ( !error )
{
/* select the size as the current one for this face */
face->size = *asize;
*aface = face;
}
}
return error;
}
/* END */

70
src/cache/ftcmanag.h vendored
View File

@ -1,30 +1,55 @@
/***************************************************************************/
/* */
/* ftcmanag.h */
/* */
/* XXX */
/* */
/* Copyright 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 FTCMANAG_H
#define FTCMANAG_H
#include <cache/ftlru.h>
#ifdef __cplusplus
extern "C" {
#endif
#define FTC_MAX_FACES 4
#define FTC_MAX_SIZES 8
typedef FT_Pointer FTC_FaceID;
typedef struct FTC_SizeRec_
typedef struct FTC_SizeRec_
{
FTC_FaceID face_id;
FT_UShort pix_width;
FT_UShort pix_height;
FTC_FaceID face_id;
FT_UShort pix_width;
FT_UShort pix_height;
} FTC_SizeRec, *FTC_SizeID;
typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id,
FT_Pointer data,
FT_Face *aface );
FT_Face* aface );
typedef struct FTC_ManagerRec_* FTC_Manager;
typedef struct FTC_Manager_LruRec_
typedef struct FTC_Manager_LruRec_
{
FT_LruRec root;
FTC_Manager manager;
@ -32,7 +57,7 @@
} FTC_Manager_LruRec, *FTC_Manager_Lru;
typedef struct FTC_ManagerRec_
typedef struct FTC_ManagerRec_
{
FT_Library library;
FT_Lru faces_lru;
@ -44,22 +69,31 @@
} FTC_ManagerRec;
FT_EXPORT_DEF(FT_Error) FTC_Manager_New ( FT_Library library,
FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager *amanager );
FTC_Manager* amanager );
FT_EXPORT_DEF(void) FTC_Manager_Done ( FTC_Manager manager );
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
FT_EXPORT_DEF(void) FTC_Manager_Reset( FTC_Manager manager );
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager );
FT_EXPORT_DEF(FT_Error) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face *aface );
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face* aface );
FT_EXPORT_DEF(FT_Error) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id,
FT_Face *aface,
FT_Size *asize );
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id,
FT_Face* aface,
FT_Size* asize );
#ifdef __cplusplus
}
#endif
#endif /* FTCMANAG_H */
/* END */

138
src/cache/ftlru.c vendored
View File

@ -1,7 +1,26 @@
/***************************************************************************/
/* */
/* ftlru.c */
/* */
/* XXX */
/* */
/* Copyright 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 <cache/ftlru.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftlist.h>
static
void lru_build_free_list( FT_LruNode nodes,
FT_UInt count,
@ -10,25 +29,27 @@
FT_LruNode node = nodes;
FT_LruNode limit = node + count;
free_list->head = free_list->tail = 0;
for ( ; node < limit; node++ )
FT_List_Add( free_list, (FT_ListNode)node );
}
FT_EXPORT_FUNC(FT_Error) FT_Lru_New ( const FT_Lru_Class* clazz,
FT_UInt max_elements,
FT_Memory memory,
FT_Bool pre_alloc,
FT_Lru *alru )
FT_EXPORT_FUNC( FT_Error ) FT_Lru_New( const FT_Lru_Class* clazz,
FT_UInt max_elements,
FT_Memory memory,
FT_Bool pre_alloc,
FT_Lru* alru )
{
FT_Error error;
FT_Lru lru;
*alru = 0;
if ( !ALLOC( lru, sizeof(*lru) ) )
if ( !ALLOC( lru, sizeof ( *lru ) ) )
{
if (pre_alloc)
if ( pre_alloc )
{
/* allocate static array of lru list nodes */
if ( ALLOC_ARRAY( lru->nodes, max_elements, FT_LruNodeRec ) )
@ -37,7 +58,7 @@
goto Exit;
}
/* build the 'free_nodes' list from the array */
/* build the `free_nodes' list from the array */
lru_build_free_list( lru->nodes, max_elements, &lru->free_nodes );
}
@ -45,53 +66,57 @@
lru->clazz = (FT_Lru_Class*)clazz;
lru->max_elements = max_elements;
lru->memory = memory;
*alru = lru;
}
Exit:
return error;
}
FT_EXPORT_DEF(void) FT_Lru_Reset ( FT_Lru lru )
FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru )
{
FT_ListNode node = lru->elements.head;
FT_Lru_Class* clazz = lru->clazz;
FT_Memory memory = lru->memory;
while (node)
while ( node )
{
FT_ListNode next = node->next;
clazz->done_element( lru, (FT_LruNode)node );
if (!lru->nodes)
FREE(node);
if ( !lru->nodes )
FREE( node );
node = next;
}
/* rebuild free list if necessary */
if (lru->nodes)
if ( lru->nodes )
lru_build_free_list( lru->nodes, lru->max_elements, &lru->free_nodes );
lru->elements.head = lru->elements.tail = 0;
lru->elements.head = lru->elements.tail = 0;
lru->num_elements = 0;
}
FT_EXPORT_DEF(void) FT_Lru_Done ( FT_Lru lru )
FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru )
{
FT_Memory memory = lru->memory;
FT_Lru_Reset(lru);
FREE(lru);
FT_Lru_Reset( lru );
FREE( lru );
}
FT_EXPORT_DEF(FT_Error) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
FT_LruNode* anode )
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
FT_LruNode* anode )
{
FT_Error error = 0;
FT_ListNode node = lru->elements.head;
@ -99,10 +124,11 @@
FT_LruNode found = 0;
FT_Memory memory = lru->memory;
if (clazz->compare_element)
if ( clazz->compare_element )
{
for ( ; node; node = node->next )
if (clazz->compare_element( (FT_LruNode)node, key ))
if ( clazz->compare_element( (FT_LruNode)node, key ) )
{
found = (FT_LruNode)node;
break;
@ -111,20 +137,20 @@
else
{
for ( ; node; node = node->next )
if (((FT_LruNode)node)->key == key)
if ( ((FT_LruNode)node)->key == key )
{
found = (FT_LruNode)node;
break;
}
}
if (!found)
if ( !found )
{
/* we didn't find the relevant element. We will now try */
/* to create a new one.. */
/* we haven't found the relevant element. We will now try */
/* to create a new one. */
if ( lru->num_elements >= lru->max_elements )
{
/* this lru list is full, we will now flush */
/* this lru list is full; we will now flush */
/* the oldest node */
FT_LruNode lru_node;
@ -132,7 +158,7 @@
node = lru->elements.tail;
lru_node = (FT_LruNode)node;
if (clazz->flush_element)
if ( clazz->flush_element )
error = clazz->flush_element( lru, lru_node, key );
else
{
@ -142,7 +168,7 @@
error = clazz->init_element( lru, lru_node );
}
if (!error)
if ( !error )
{
/* now, move element to top of list */
FT_List_Up( &lru->elements, node );
@ -153,7 +179,7 @@
FT_List_Remove( &lru->elements, node );
lru->num_elements--;
if (lru->nodes)
if ( lru->nodes )
FT_List_Insert( &lru->free_nodes, node );
else
FREE( lru_node );
@ -163,27 +189,28 @@
{
FT_LruNode lru_node;
/* create a new lru list node, then the element for it */
if (lru->nodes)
if ( lru->nodes )
{
node = lru->free_nodes.head;
lru_node = (FT_LruNode)node;
lru_node->key = key;
error = clazz->init_element( lru, lru_node );
if (error)
if ( error )
goto Exit;
FT_List_Remove( &lru->free_nodes, node );
}
else
{
if ( ALLOC( lru_node, sizeof(*lru_node) ) )
if ( ALLOC( lru_node, sizeof ( *lru_node ) ) )
goto Exit;
lru_node->key = key;
error = clazz->init_element( lru, lru_node );
if (error)
if ( error )
{
FREE( lru_node );
goto Exit;
@ -203,52 +230,57 @@
}
FT_EXPORT_DEF(FT_Error) FT_Lru_Lookup( FT_Lru lru,
FT_LruKey key,
FT_Pointer *aobject )
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup( FT_Lru lru,
FT_LruKey key,
FT_Pointer* aobject )
{
FT_Error error;
FT_LruNode node;
*aobject = 0;
error = FT_Lru_Lookup_Node( lru, key, &node );
if (!error)
if ( !error )
*aobject = node->root.data;
return error;
}
FT_EXPORT_FUNC(void) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node )
FT_EXPORT_FUNC( void ) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node )
{
if (lru->num_elements > 0)
if ( lru->num_elements > 0 )
{
FT_List_Remove( &lru->elements, (FT_ListNode)node );
lru->clazz->done_element( lru, node );
if (lru->nodes)
if ( lru->nodes )
FT_List_Insert( &lru->free_nodes, (FT_ListNode)node );
else
{
FT_Memory memory = lru->memory;
FREE(node);
FREE( node );
}
lru->num_elements--;
}
}
FT_EXPORT_FUNC(void) FT_Lru_Remove_Selection( FT_Lru lru,
FT_Lru_Selector selector,
FT_Pointer data )
FT_EXPORT_FUNC( void ) FT_Lru_Remove_Selection( FT_Lru lru,
FT_Lru_Selector selector,
FT_Pointer data )
{
if (lru->num_elements > 0)
if ( lru->num_elements > 0 )
{
FT_ListNode node = lru->elements.head;
FT_ListNode next;
FT_ListNode node = lru->elements.head;
FT_ListNode next;
while (node)
while ( node )
{
next = node->next;
if ( selector( lru, (FT_LruNode)node, data ) )
@ -261,3 +293,5 @@
}
}
/* END */

96
src/cache/ftlru.h vendored
View File

@ -1,13 +1,36 @@
/***************************************************************************/
/* */
/* ftlru.h */
/* */
/* XXX */
/* */
/* Copyright 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 FTLRU_H
#define FTLRU_H
#include <freetype/freetype.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef FT_Pointer FT_LruKey;
typedef struct FT_LruNodeRec_
typedef struct FT_LruNodeRec_
{
FT_ListNodeRec root;
FT_LruKey key;
@ -17,22 +40,23 @@
typedef struct FT_LruRec_* FT_Lru;
typedef struct FT_Lru_Class_
typedef struct FT_Lru_Class_
{
FT_UInt lru_size; /* object size in bytes */
FT_UInt lru_size; /* object size in bytes */
FT_Error (*init_element)( FT_Lru lru,
FT_LruNode node );
FT_Error (*init_element)( FT_Lru lru,
FT_LruNode node );
void (*done_element)( FT_Lru lru,
FT_LruNode node );
void (*done_element)( FT_Lru lru,
FT_LruNode node );
FT_Error (*flush_element)( FT_Lru lru,
FT_LruNode node,
FT_LruKey new_key );
FT_Error (*flush_element)( FT_Lru lru,
FT_LruNode node,
FT_LruKey new_key );
FT_Bool (*compare_element)( FT_LruNode node,
FT_LruKey key );
FT_Bool (*compare_element)( FT_LruNode node,
FT_LruKey key );
} FT_Lru_Class;
@ -40,7 +64,8 @@
FT_LruNode node,
FT_Pointer data );
typedef struct FT_LruRec_
typedef struct FT_LruRec_
{
FT_Lru_Class* clazz;
FT_UInt max_elements;
@ -55,29 +80,38 @@
} FT_LruRec;
FT_EXPORT_DEF(FT_Error) FT_Lru_New ( const FT_Lru_Class* clazz,
FT_UInt max_elements,
FT_Memory memory,
FT_Bool pre_alloc,
FT_Lru *alru );
FT_EXPORT_DEF( FT_Error ) FT_Lru_New( const FT_Lru_Class* clazz,
FT_UInt max_elements,
FT_Memory memory,
FT_Bool pre_alloc,
FT_Lru* alru );
FT_EXPORT_DEF(void) FT_Lru_Reset ( FT_Lru lru );
FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru );
FT_EXPORT_DEF(void) FT_Lru_Done ( FT_Lru lru );
FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru );
FT_EXPORT_DEF(FT_Error) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
FT_LruNode* anode );
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
FT_LruNode* anode );
FT_EXPORT_DEF(FT_Error) FT_Lru_Lookup( FT_Lru lru,
FT_LruKey key,
FT_Pointer *aobject );
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup( FT_Lru lru,
FT_LruKey key,
FT_Pointer* aobject );
FT_EXPORT_DEF(void) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node );
FT_EXPORT_DEF( void ) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node );
FT_EXPORT_DEF( void ) FT_Lru_Remove_Selection( FT_Lru lru,
FT_Lru_Selector selector,
FT_Pointer data );
#ifdef __cplusplus
}
#endif
FT_EXPORT_DEF(void) FT_Lru_Remove_Selection( FT_Lru lru,
FT_Lru_Selector selector,
FT_Pointer data );
#endif /* FTLRU_H */
/* END */

View File

@ -1,3 +1,21 @@
/***************************************************************************/
/* */
/* psaux.c */
/* */
/* FreeType auxiliary PostScript driver component (body 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
@ -14,3 +32,5 @@
#endif
/* END */

View File

@ -45,7 +45,7 @@
/* PS_Table_New */
/* */
/* <Description> */
/* Initialises a PS_Table. */
/* Initializes a PS_Table. */
/* */
/* <InOut> */
/* table :: The address of the target table. */
@ -1137,7 +1137,8 @@
FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
if (builder->shift)
if ( builder->shift )
{
x >>= 16;
y >>= 16;

View File

@ -36,10 +36,10 @@
/*************************************************************************/
LOCAL_DEF
const PS_Table_Funcs ps_table_funcs;
const PS_Table_Funcs ps_table_funcs;
LOCAL_DEF
const T1_Parser_Funcs t1_parser_funcs;
const T1_Parser_Funcs t1_parser_funcs;
LOCAL_DEF
const T1_Builder_Funcs t1_builder_funcs;
@ -56,11 +56,11 @@
FT_Int length );
LOCAL_DEF
void PS_Table_Done( PS_Table* table );
void PS_Table_Done( PS_Table* table );
LOCAL_DEF
void PS_Table_Release( PS_Table* table );
void PS_Table_Release( PS_Table* table );
/*************************************************************************/
@ -124,13 +124,13 @@
LOCAL_DEF
void T1_Init_Parser( T1_Parser* parser,
FT_Byte* base,
FT_Byte* limit,
FT_Memory memory );
void T1_Init_Parser( T1_Parser* parser,
FT_Byte* base,
FT_Byte* limit,
FT_Memory memory );
LOCAL_DEF
void T1_Done_Parser( T1_Parser* parser );
void T1_Done_Parser( T1_Parser* parser );
/*************************************************************************/

View File

@ -1,8 +1,27 @@
/***************************************************************************/
/* */
/* t1decode.c */
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
/* Copyright 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 <psaux/t1decode.h>
#include <psaux/psobjs.h>
#include <freetype/internal/t1errors.h>
#include <freetype/ftoutln.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@ -81,11 +100,11 @@
/*************************************************************************/
/* */
/* <Function> */
/* lookup_glyph_by_stdcharcode */
/* t1_lookup_glyph_by_stdcharcode */
/* */
/* <Description> */
/* Looks up a given glyph by its StandardEncoding charcode. Used */
/* to implement the SEAC Type 1 operator. */
/* Looks up a given glyph by its StandardEncoding charcode. Used to */
/* implement the SEAC Type 1 operator. */
/* */
/* <Input> */
/* face :: The current face object. */
@ -254,6 +273,7 @@
dummy.n_points = base->n_points - n_base_points;
dummy.points = base->points + n_base_points;
FT_Outline_Translate( &dummy, adx - asb, ady );
}
@ -262,7 +282,6 @@
}
/*************************************************************************/
/* */
/* <Function> */
@ -279,7 +298,7 @@
/* charstring_len :: The length in bytes of the charstring stream. */
/* */
/* <Return> */
/* Free error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Decoder_Parse_Charstrings( T1_Decoder* decoder,
@ -294,13 +313,14 @@
FT_Outline* outline;
FT_Pos x, y;
/* we don't want to touch the source code -- use macro trick */
#define start_point T1_Builder_Start_Point
#define check_points T1_Builder_Check_Points
#define add_point T1_Builder_Add_Point
#define add_point1 T1_Builder_Add_Point1
#define add_contour T1_Builder_Add_Contour
#define close_contour T1_Builder_Close_Contour
#define start_point T1_Builder_Start_Point
#define check_points T1_Builder_Check_Points
#define add_point T1_Builder_Add_Point
#define add_point1 T1_Builder_Add_Point1
#define add_contour T1_Builder_Add_Contour
#define close_contour T1_Builder_Close_Contour
/* First of all, initialize the decoder */
decoder->top = decoder->stack;
@ -897,7 +917,7 @@
case op_pop:
FT_TRACE4(( " pop" ));
/* theorically, the arguments are already on the stack */
/* theoretically, the arguments are already on the stack */
top++;
break;
@ -990,17 +1010,19 @@
T1_Blend* blend,
T1_Decoder_Callback parse_callback )
{
MEM_Set( decoder, 0, sizeof(*decoder) );
MEM_Set( decoder, 0, sizeof ( *decoder ) );
/* retrieve PSNames interface from list of current modules */
{
PSNames_Interface* psnames = 0;
psnames = (PSNames_Interface*)FT_Get_Module_Interface(
FT_FACE_LIBRARY(face), "psnames" );
if (!psnames)
if ( !psnames )
{
FT_ERROR(( "T1_Decoder_Init: the 'psnames' module is not available\n" ));
FT_ERROR(( "T1_Decoder_Init: " ));
FT_ERROR(( "the `psnames' module is not available\n" ));
return FT_Err_Unimplemented_Feature;
}
@ -1014,6 +1036,7 @@
decoder->parse_callback = parse_callback;
decoder->funcs = t1_decoder_funcs;
return 0;
}
@ -1024,3 +1047,5 @@
T1_Builder_Done( &decoder->builder );
}
/* END */

View File

@ -1,3 +1,21 @@
/***************************************************************************/
/* */
/* t1decode.h */
/* */
/* PostScript Type 1 decoding routines (specification). */
/* */
/* Copyright 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 T1DECODE_H
#define T1DECODE_H
@ -5,17 +23,18 @@
#include <freetype/internal/psnames.h>
#include <freetype/internal/t1types.h>
LOCAL_DEF
const T1_Decoder_Funcs t1_decoder_funcs;
LOCAL_DEF
FT_Error T1_Decoder_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index );
const T1_Decoder_Funcs t1_decoder_funcs;
LOCAL_DEF
FT_Error T1_Decoder_Parse_Charstrings( T1_Decoder* decoder,
FT_Byte* base,
FT_UInt len );
FT_Error T1_Decoder_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index );
LOCAL_DEF
FT_Error T1_Decoder_Parse_Charstrings( T1_Decoder* decoder,
FT_Byte* base,
FT_UInt len );
LOCAL_DEF
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
@ -29,4 +48,8 @@
LOCAL_DEF
void T1_Decoder_Done( T1_Decoder* decoder );
#endif /* T1DECODE_H */
/* END */

View File

@ -46,7 +46,6 @@
#define FT_COMPONENT trace_z1gload
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -68,14 +67,17 @@
FT_Error Z1_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index )
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font* type1 = &face->type1;
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font* type1 = &face->type1;
return decoder->funcs.parse_charstrings( decoder,
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index] );
return decoder->funcs.parse_charstrings(
decoder,
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index] );
}
LOCAL_FUNC
FT_Error Z1_Compute_Max_Advance( T1_Face face,
FT_Int* max_advance )
@ -89,7 +91,7 @@
*max_advance = 0;
/* Initialize load decoder */
/* initialize load decoder */
error = psaux->t1_decoder_funcs->init( &decoder,
(FT_Face)face,
0, /* size */
@ -172,10 +174,10 @@
(FT_Byte**)type1->glyph_names,
face->blend,
Z1_Parse_Glyph );
if (error)
if ( error )
goto Exit;
decoder.builder.no_recurse = ( load_flags & FT_LOAD_NO_RECURSE ) != 0;
decoder.builder.no_recurse = ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
decoder.num_subrs = type1->num_subrs;
decoder.subrs = type1->subrs;
@ -184,7 +186,7 @@
/* now load the unscaled outline */
error = Z1_Parse_Glyph( &decoder, glyph_index );
if (error)
if ( error )
goto Exit;
/* save new glyph tables */
@ -207,8 +209,8 @@
}
else
{
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
/* copy the _unscaled_ advance width */
@ -233,9 +235,11 @@
face->type1.font_offset.y );
#if 0
glyph->root.outline.second_pass = TRUE;
glyph->root.outline.high_precision = size->root.metrics.y_ppem < 24;
glyph->root.outline.dropout_mode = 2;
#endif /* 0 */
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
@ -284,6 +288,7 @@
metrics->horiBearingY = cbox.yMax;
}
}
Exit:
return error;
}

View File

@ -36,7 +36,6 @@
#endif
LOCAL_DEF
FT_Error Z1_Compute_Max_Advance( T1_Face face,
FT_Int* max_advance );

View File

@ -393,11 +393,11 @@
void parse_blend_axis_types( T1_Face face,
Z1_Loader* loader )
{
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
FT_Int n, num_axis;
FT_Error error = 0;
T1_Blend* blend;
FT_Memory memory;
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
FT_Int n, num_axis;
FT_Error error = 0;
T1_Blend* blend;
FT_Memory memory;
/* take an array of objects */
@ -423,8 +423,8 @@
for ( n = 0; n < num_axis; n++ )
{
T1_Token* token = axis_tokens + n;
FT_Byte* name;
FT_Int len;
FT_Byte* name;
FT_Int len;
/* skip first slash, if any */
if (token->start[0] == '/')
@ -454,13 +454,13 @@
void parse_blend_design_positions( T1_Face face,
Z1_Loader* loader )
{
T1_Token design_tokens[ T1_MAX_MM_DESIGNS ];
FT_Int num_designs;
FT_Int num_axis;
Z1_Parser* parser = &loader->parser;
T1_Token design_tokens[ T1_MAX_MM_DESIGNS ];
FT_Int num_designs;
FT_Int num_axis;
Z1_Parser* parser = &loader->parser;
FT_Error error = 0;
T1_Blend* blend;
FT_Error error = 0;
T1_Blend* blend;
/* get the array of design tokens - compute number of designs */
@ -536,14 +536,14 @@
void parse_blend_design_map( T1_Face face,
Z1_Loader* loader )
{
FT_Error error = 0;
Z1_Parser* parser = &loader->parser;
T1_Blend* blend;
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
FT_Int n, num_axis;
FT_Byte* old_cursor;
FT_Byte* old_limit;
FT_Memory memory = face->root.memory;
FT_Error error = 0;
Z1_Parser* parser = &loader->parser;
T1_Blend* blend;
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
FT_Int n, num_axis;
FT_Byte* old_cursor;
FT_Byte* old_limit;
FT_Memory memory = face->root.memory;
Z1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &num_axis );
@ -565,9 +565,9 @@
/* now, read each axis design map */
for ( n = 0; n < num_axis; n++ )
{
T1_DesignMap* map = blend->design_map + n;
T1_Token* token;
FT_Int p, num_points;
T1_DesignMap* map = blend->design_map + n;
T1_Token* token;
FT_Int p, num_points;
token = axis_tokens + n;
@ -617,13 +617,13 @@
void parse_weight_vector( T1_Face face,
Z1_Loader* loader )
{
FT_Error error = 0;
Z1_Parser* parser = &loader->parser;
T1_Blend* blend = face->blend;
T1_Token master;
FT_UInt n;
FT_Byte* old_cursor;
FT_Byte* old_limit;
FT_Error error = 0;
Z1_Parser* parser = &loader->parser;
T1_Blend* blend = face->blend;
T1_Token master;
FT_UInt n;
FT_Byte* old_cursor;
FT_Byte* old_limit;
if ( !blend || blend->num_designs == 0 )
@ -693,48 +693,48 @@
/*************************************************************************/
/* */
/* First of all, define the token field static variables. This is a set */
/* of T1_Field variables used later. */
/* of T1_Field variables used later. */
/* */
/*************************************************************************/
#define Z1_NEW_STRING( _name, _field ) \
static \
#define Z1_NEW_STRING( _name, _field ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_STRING( _field );
#define Z1_NEW_BOOL( _name, _field ) \
static \
#define Z1_NEW_BOOL( _name, _field ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_BOOL( _field );
#define Z1_NEW_NUM( _name, _field ) \
static \
#define Z1_NEW_NUM( _name, _field ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_NUM( _field );
#define Z1_NEW_FIXED( _name, _field ) \
static \
const T1_Field z1_field_ ## _field = \
#define Z1_NEW_FIXED( _name, _field ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_FIXED( _field, _power );
#define Z1_NEW_NUM_TABLE( _name, _field, _max, _count ) \
static \
const T1_Field z1_field_ ## _field = \
#define Z1_NEW_NUM_TABLE( _name, _field, _max, _count ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_NUM_ARRAY( _field, _count, _max );
#define Z1_NEW_FIXED_TABLE( _name, _field, _max, _count ) \
static \
const T1_Field z1_field_ ## _field = \
#define Z1_NEW_FIXED_TABLE( _name, _field, _max, _count ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_FIXED_ARRAY( _field, _count, _max );
#define Z1_NEW_NUM_TABLE2( _name, _field, _max ) \
static \
const T1_Field z1_field_ ## _field = \
#define Z1_NEW_NUM_TABLE2( _name, _field, _max ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_NUM_ARRAY2( _field, _max );
#define Z1_NEW_FIXED_TABLE2( _name, _field, _max ) \
static \
const T1_Field z1_field_ ## _field = \
#define Z1_NEW_FIXED_TABLE2( _name, _field, _max ) \
static \
const T1_Field z1_field_ ## _field = \
T1_FIELD_FIXED_ARRAY2( _field, _max );
@ -796,7 +796,7 @@
Z1_KeyWord_Type type;
Z1_KeyWord_Location location;
Z1_Parse_Func parsing;
const T1_Field* field;
const T1_Field* field;
} Z1_KeyWord;
@ -924,14 +924,14 @@
static
int is_space( FT_Byte c )
{
return (c == ' ' || c == '\t' || c == '\r' || c == '\n' );
return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' );
}
static
int is_alpha( FT_Byte c )
{
return (isalnum(c) || c == '.' || c == '_' );
return ( isalnum( c ) || c == '.' || c == '_' );
}
@ -964,7 +964,7 @@
/* `RD' or `-|' token */
*base = parser->root.cursor + 1;
parser->root.cursor += *size+1;
parser->root.cursor += *size + 1;
return 1;
}
@ -1114,9 +1114,10 @@
/* we use a Z1_Table to store our charnames */
encode->num_chars = count;
if ( ALLOC_ARRAY( encode->char_index, count, FT_Short ) ||
ALLOC_ARRAY( encode->char_name, count, FT_String* ) ||
( error = psaux->ps_table_funcs->init( char_table, count, memory ) ) != 0 )
if ( ALLOC_ARRAY( encode->char_index, count, FT_Short ) ||
ALLOC_ARRAY( encode->char_name, count, FT_String* ) ||
( error = psaux->ps_table_funcs->init(
char_table, count, memory ) ) != 0 )
{
parser->root.error = error;
return;
@ -1200,7 +1201,7 @@
}
face->type1.encoding_type = t1_encoding_array;
parser->root.cursor = cur;
parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding' or */
/* `ExpertEncoding' */
@ -1234,6 +1235,7 @@
FT_Int n;
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
loader->num_subrs = Z1_ToInt( parser );
if ( parser->root.error )
@ -1333,11 +1335,15 @@
return;
/* initialize tables */
error = psaux->ps_table_funcs->init( code_table, loader->num_glyphs, memory );
if (error)
error = psaux->ps_table_funcs->init( code_table,
loader->num_glyphs,
memory );
if ( error )
goto Fail;
error = psaux->ps_table_funcs->init( name_table, loader->num_glyphs, memory );
error = psaux->ps_table_funcs->init( name_table,
loader->num_glyphs,
memory );
if ( error )
goto Fail;
@ -1555,7 +1561,9 @@
/* we found it -- run the parsing callback! */
parser->root.cursor = cur2;
Z1_Skip_Spaces( parser );
parser->root.error = t1_load_keyword( face, loader, keyword );
parser->root.error = t1_load_keyword( face,
loader,
keyword );
if ( parser->root.error )
return parser->root.error;
@ -1620,13 +1628,17 @@
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
t1_init_loader( &loader, face );
/* default lenIV */
type1->private_dict.lenIV = 4;
parser = &loader.parser;
error = Z1_New_Parser( parser, face->root.stream, face->root.memory, psaux );
error = Z1_New_Parser( parser,
face->root.stream,
face->root.memory,
psaux );
if ( error )
goto Exit;

View File

@ -179,7 +179,7 @@
}
psaux = (PSAux_Interface*)face->psaux;
if (!psaux)
if ( !psaux )
{
psaux = (PSAux_Interface*)
FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psaux" );

View File

@ -81,7 +81,7 @@
#define IS_Z1_SPACE( c ) ( IS_Z1_WHITESPACE( c ) || IS_Z1_LINESPACE( c ) )
typedef struct PFB_Tag_
typedef struct PFB_Tag_
{
FT_UShort tag;
FT_Long size;
@ -92,10 +92,11 @@
#undef FT_STRUCTURE
#define FT_STRUCTURE PFB_Tag
static
const FT_Frame_Field pfb_tag_fields[] =
{
FT_FRAME_START(6),
FT_FRAME_START( 6 ),
FT_FRAME_USHORT ( tag ),
FT_FRAME_LONG_LE( size ),
FT_FRAME_END
@ -110,6 +111,7 @@
FT_Error error;
PFB_Tag head;
*tag = 0;
*size = 0;
if ( !READ_Fields( pfb_tag_fields, &head ) )
@ -130,9 +132,10 @@
FT_Memory memory,
PSAux_Interface* psaux )
{
FT_Error error;
FT_UShort tag;
FT_Long size;
FT_Error error;
FT_UShort tag;
FT_Long size;
psaux->t1_parser_funcs->init( &parser->root,0, 0, memory );
@ -253,7 +256,7 @@
static
int hexa_value( char c )
{
unsigned int d;
unsigned int d;
d = (unsigned int)( c - '0' );

View File

@ -37,9 +37,9 @@
/* quickly. */
/* */
/* <Fields> */
/* stream :: The current input stream. */
/* root :: The root parser. */
/* */
/* memory :: The current memory object. */
/* stream :: The current input stream. */
/* */
/* base_dict :: A pointer to the top-level dictionary. */
/* */
@ -57,13 +57,6 @@
/* single_block :: A boolean. Indicates that the private dictionary */
/* is stored in lieu of the base dictionary. */
/* */
/* cursor :: The current parser cursor. */
/* */
/* limit :: The current parser limit (first byte after the */
/* current dictionary). */
/* */
/* error :: The current parsing error. */
/* */
typedef struct Z1_Parser_
{
T1_Parser root;
@ -82,24 +75,41 @@
} Z1_Parser;
#define Z1_Add_Table(p,i,o,l) (p)->funcs.add( (p), i, o, l )
#define Z1_Done_Table(p) do { if ((p)->funcs.done) (p)->funcs.done( p ); } while (0)
#define Z1_Release_Table(p) do { if ((p)->funcs.release) (p)->funcs.release( p ); } while (0)
#define Z1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l )
#define Z1_Done_Table( p ) \
do \
{ \
if ( (p)->funcs.done ) \
(p)->funcs.done( p ); \
} while ( 0 )
#define Z1_Release_Table( p ) \
do \
{ \
if ( (p)->funcs.release ) \
(p)->funcs.release( p ); \
} while ( 0 )
#define Z1_Skip_Spaces(p) (p)->root.funcs.skip_spaces( &(p)->root )
#define Z1_Skip_Alpha(p) (p)->root.funcs.skip_alpha ( &(p)->root )
#define Z1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
#define Z1_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
#define Z1_ToInt(p) (p)->root.funcs.to_int( &(p)->root )
#define Z1_ToFixed(p,t) (p)->root.funcs.to_fixed( &(p)->root, t )
#define Z1_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
#define Z1_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
#define Z1_ToCoordArray(p,m,c) (p)->root.funcs.to_coord_array( &(p)->root, m, c )
#define Z1_ToFixedArray(p,m,f,t) (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
#define Z1_ToToken(p,t) (p)->root.funcs.to_token( &(p)->root, t )
#define Z1_ToTokenArray(p,t,m,c) (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
#define Z1_ToCoordArray( p, m, c ) \
(p)->root.funcs.to_coord_array( &(p)->root, m, c )
#define Z1_ToFixedArray( p, m, f, t ) \
(p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
#define Z1_ToToken( p, t ) \
(p)->root.funcs.to_token( &(p)->root, t )
#define Z1_ToTokenArray( p, t, m, c ) \
(p)->root.funcs.to_token_array( &(p)->root, t, m, c )
#define Z1_Load_Field( p, f, o, m, pf ) \
(p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
#define Z1_Load_Field_Table( p, f, o, m, pf ) \
(p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
#define Z1_Load_Field(p,f,o,m,pf) (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
#define Z1_Load_Field_Table(p,f,o,m,pf) (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
LOCAL_DEF
FT_Error Z1_New_Parser( Z1_Parser* parser,
@ -118,10 +128,12 @@
LOCAL_DEF
void Z1_Done_Parser( Z1_Parser* parser );
#ifdef __cplusplus
}
#endif
#endif /* Z1PARSE_H */