forked from minhngoc25a/freetype2
The next round of formatting, checking documentation, etc.
This commit is contained in:
parent
78575dc0d1
commit
7a4fda8821
|
@ -16,6 +16,7 @@
|
|||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
|
@ -24,6 +25,8 @@
|
|||
#include <t2driver.h>
|
||||
#include <t2gload.h>
|
||||
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
|
@ -47,6 +50,7 @@
|
|||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
#define PAIR_TAG( left, right ) ( ( (TT_ULong)left << 16 ) | \
|
||||
(TT_ULong)right )
|
||||
|
@ -74,12 +78,12 @@
|
|||
/* formats. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Only horizontal layouts (left-to-right & right-to-left) are */
|
||||
/* supported by this function. Other layouts, or more sophisticated */
|
||||
/* kernings are out of scope of this method (the basic driver */
|
||||
/* kernings, are out of scope of this method (the basic driver */
|
||||
/* interface is meant to be simple). */
|
||||
/* */
|
||||
/* They can be implemented by format-specific interfaces. */
|
||||
|
@ -94,7 +98,7 @@
|
|||
|
||||
|
||||
if ( !face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
return T2_Err_Invalid_Face_Handle;
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
|
@ -111,7 +115,7 @@
|
|||
|
||||
while ( left <= right )
|
||||
{
|
||||
TT_Int middle = left + ((right-left) >> 1);
|
||||
TT_Int middle = left + ( ( right - left ) >> 1 );
|
||||
TT_ULong cur_pair;
|
||||
|
||||
|
||||
|
@ -122,14 +126,14 @@
|
|||
goto Found;
|
||||
|
||||
if ( cur_pair < search_tag )
|
||||
left = middle+1;
|
||||
left = middle + 1;
|
||||
else
|
||||
right = middle-1;
|
||||
right = middle - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return FT_Err_Ok;
|
||||
return T2_Err_Ok;
|
||||
|
||||
Found:
|
||||
kerning->x = pair->value;
|
||||
|
@ -163,47 +167,54 @@
|
|||
/* 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. */
|
||||
/* 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> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
TT_Error Set_Char_Sizes( T2_Size size,
|
||||
FT_F26Dot6 char_width,
|
||||
FT_F26Dot6 char_height,
|
||||
FT_UInt horz_resolution,
|
||||
FT_UInt vert_resolution )
|
||||
TT_F26Dot6 char_width,
|
||||
TT_F26Dot6 char_height,
|
||||
TT_UInt horz_resolution,
|
||||
TT_UInt vert_resolution )
|
||||
{
|
||||
FT_Size_Metrics* metrics = &size->metrics;
|
||||
T2_Face face = (T2_Face)size->face;
|
||||
FT_Long dim_x, dim_y;
|
||||
|
||||
|
||||
/* This bit flag, when set, indicates that the pixel size must be */
|
||||
/* truncated to an integer. Nearly all TrueType fonts have this */
|
||||
/* truncated to an integer. Nearly all TrueType fonts have this */
|
||||
/* bit set, as hinting won't work really well otherwise. */
|
||||
/* */
|
||||
/* However, for those rare fonts who do not set it, we override */
|
||||
/* the default computations performed by the base layer. I really */
|
||||
/* don't know if this is useful, but hey, that's the spec :-) */
|
||||
/* the default computations performed by the base layer. I */
|
||||
/* really don't know whether this is useful, but hey, that's the */
|
||||
/* spec :-) */
|
||||
/* */
|
||||
if ( (face->header.Flags & 8) == 0 )
|
||||
if ( ( face->header.Flags & 8 ) == 0 )
|
||||
{
|
||||
/* Compute pixel sizes in 26.6 units */
|
||||
dim_x = (char_width * horz_resolution) / 72;
|
||||
dim_y = (char_height * vert_resolution) / 72;
|
||||
dim_x = ( char_width * horz_resolution ) / 72;
|
||||
dim_y = ( char_height * vert_resolution ) / 72;
|
||||
|
||||
metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
|
||||
metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
|
||||
|
||||
metrics->x_ppem = (TT_UShort)(dim_x >> 6);
|
||||
metrics->y_ppem = (TT_UShort)(dim_y >> 6);
|
||||
metrics->x_ppem = (TT_UShort)( dim_x >> 6 );
|
||||
metrics->y_ppem = (TT_UShort)( dim_y >> 6 );
|
||||
}
|
||||
|
||||
return T2_Reset_Size( size );
|
||||
|
@ -228,15 +239,15 @@
|
|||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success */
|
||||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Set_Pixel_Sizes( T2_Size size,
|
||||
FT_UInt pixel_width,
|
||||
FT_UInt pixel_height )
|
||||
TT_Error Set_Pixel_Sizes( T2_Size size,
|
||||
TT_UInt pixel_width,
|
||||
TT_UInt pixel_height )
|
||||
{
|
||||
UNUSED(pixel_width);
|
||||
UNUSED(pixel_height);
|
||||
UNUSED( pixel_width );
|
||||
UNUSED( pixel_height );
|
||||
|
||||
return T2_Reset_Size( size );
|
||||
}
|
||||
|
@ -255,7 +266,7 @@
|
|||
/* will be loaded. */
|
||||
/* */
|
||||
/* size :: A handle to the source face size at which the glyph */
|
||||
/* must be scaled/loaded/etc. */
|
||||
/* must be scaled, loaded, etc. */
|
||||
/* */
|
||||
/* glyph_index :: The index of the glyph in the font file. */
|
||||
/* */
|
||||
|
@ -264,27 +275,23 @@
|
|||
/* glyph loading process (e.g., whether the outline */
|
||||
/* should be scaled, whether to load bitmaps or not, */
|
||||
/* whether to hint the outline, etc). */
|
||||
/* <Output> */
|
||||
/* result :: A set of bit flags indicating the type of data that */
|
||||
/* was loaded in the glyph slot (outline, bitmap, */
|
||||
/* pixmap, etc). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Load_Glyph( T2_GlyphSlot slot,
|
||||
TT_Error Load_Glyph( T2_GlyphSlot slot,
|
||||
T2_Size size,
|
||||
FT_UShort glyph_index,
|
||||
FT_UInt load_flags )
|
||||
TT_UShort glyph_index,
|
||||
TT_UInt load_flags )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
if ( !slot )
|
||||
return FT_Err_Invalid_Handle;
|
||||
return T2_Err_Invalid_Glyph_Handle;
|
||||
|
||||
/* check that we want a scaled outline or bitmap */
|
||||
/* check whether we want a scaled outline or bitmap */
|
||||
if ( !size )
|
||||
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
||||
|
||||
|
@ -296,7 +303,7 @@
|
|||
{
|
||||
/* these two object must have the same parent */
|
||||
if ( size->face != slot->root.face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
return T2_Err_Invalid_Face_Handle;
|
||||
}
|
||||
|
||||
/* now load the glyph outline if necessary */
|
||||
|
@ -336,13 +343,14 @@
|
|||
/* Glyph index. 0 means `undefined character code'. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt Get_Char_Index( TT_CharMap charmap,
|
||||
FT_Long charcode )
|
||||
TT_UInt Get_Char_Index( TT_CharMap charmap,
|
||||
TT_Long charcode )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
T2_Face face;
|
||||
TT_CMapTable* cmap;
|
||||
|
||||
|
||||
cmap = &charmap->cmap;
|
||||
face = (T2_Face)charmap->root.face;
|
||||
|
||||
|
@ -351,29 +359,47 @@
|
|||
{
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
error = sfnt->load_charmap( face, cmap, face->root.stream );
|
||||
if (error) return error;
|
||||
if ( error )
|
||||
return 0;
|
||||
|
||||
cmap->loaded = TRUE;
|
||||
}
|
||||
|
||||
return (cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 );
|
||||
return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** D R I V E R I N T E R F A C E ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FTDriver_Interface t2_get_interface( T2_Driver driver, const char* interface )
|
||||
FTDriver_Interface t2_get_interface( T2_Driver driver,
|
||||
const char* interface )
|
||||
{
|
||||
FT_Driver sfntd = FT_Get_Driver( driver->root.library, "sfnt" );
|
||||
SFNT_Interface* sfnt;
|
||||
|
||||
|
||||
|
||||
/* only return the default interface from the SFNT module */
|
||||
if (sfntd)
|
||||
if ( sfntd )
|
||||
{
|
||||
sfnt = (SFNT_Interface*)(sfntd->interface.format_interface);
|
||||
if (sfnt)
|
||||
if ( sfnt )
|
||||
return sfnt->get_interface( (FT_Driver)driver, interface );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -393,27 +419,29 @@
|
|||
|
||||
(void*)0,
|
||||
|
||||
(FTDriver_initDriver) T2_Init_Driver,
|
||||
(FTDriver_doneDriver) T2_Done_Driver,
|
||||
(FTDriver_getInterface) t2_get_interface,
|
||||
(FTDriver_initDriver) T2_Init_Driver,
|
||||
(FTDriver_doneDriver) T2_Done_Driver,
|
||||
(FTDriver_getInterface) t2_get_interface,
|
||||
|
||||
(FTDriver_initFace) T2_Init_Face,
|
||||
(FTDriver_doneFace) T2_Done_Face,
|
||||
(FTDriver_getKerning) Get_Kerning,
|
||||
(FTDriver_initFace) T2_Init_Face,
|
||||
(FTDriver_doneFace) T2_Done_Face,
|
||||
(FTDriver_getKerning) Get_Kerning,
|
||||
|
||||
(FTDriver_initSize) T2_Init_Size,
|
||||
(FTDriver_doneSize) T2_Done_Size,
|
||||
(FTDriver_setCharSizes) Set_Char_Sizes,
|
||||
(FTDriver_setPixelSizes) Set_Pixel_Sizes,
|
||||
(FTDriver_initSize) T2_Init_Size,
|
||||
(FTDriver_doneSize) T2_Done_Size,
|
||||
(FTDriver_setCharSizes) Set_Char_Sizes,
|
||||
(FTDriver_setPixelSizes) Set_Pixel_Sizes,
|
||||
|
||||
(FTDriver_initGlyphSlot) T2_Init_GlyphSlot,
|
||||
(FTDriver_doneGlyphSlot) T2_Done_GlyphSlot,
|
||||
(FTDriver_loadGlyph) Load_Glyph,
|
||||
(FTDriver_initGlyphSlot) T2_Init_GlyphSlot,
|
||||
(FTDriver_doneGlyphSlot) T2_Done_GlyphSlot,
|
||||
(FTDriver_loadGlyph) Load_Glyph,
|
||||
|
||||
(FTDriver_getCharIndex) Get_Char_Index,
|
||||
(FTDriver_getCharIndex) Get_Char_Index,
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
|
@ -434,13 +462,12 @@
|
|||
/* format-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 )
|
||||
EXPORT_FUNC( FT_DriverInterface* ) getDriverInterface( void )
|
||||
{
|
||||
return &cff_driver_interface;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* High-level OpenType driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-1999 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, */
|
||||
|
@ -19,13 +19,12 @@
|
|||
#ifndef T2DRIVER_H
|
||||
#define T2DRIVER_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
#include <t2objs.h>
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
|
||||
FT_EXPORT_VAR(const FT_DriverInterface) cff_driver_interface;
|
||||
FT_EXPORT_VAR( const FT_DriverInterface ) cff_driver_interface;
|
||||
|
||||
|
||||
#endif /* T2DRIVER_H */
|
||||
|
|
2171
src/cff/t2gload.c
2171
src/cff/t2gload.c
File diff suppressed because it is too large
Load Diff
|
@ -4,11 +4,11 @@
|
|||
/* */
|
||||
/* OpenType Glyph Loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-1999 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. */
|
||||
|
@ -19,55 +19,71 @@
|
|||
#ifndef T2GLOAD_H
|
||||
#define T2GLOAD_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <t2objs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define T2_MAX_OPERANDS 48
|
||||
#define T2_MAX_SUBRS_CALLS 32
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> T2_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.. */
|
||||
/* */
|
||||
#define T2_MAX_OPERANDS 48
|
||||
#define T2_MAX_SUBRS_CALLS 32
|
||||
|
||||
typedef struct T2_Builder_
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* T2_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 T2_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
TT_Face face;
|
||||
|
@ -76,107 +92,104 @@
|
|||
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 */
|
||||
TT_Int max_points; /* capacity of base outline in points */
|
||||
TT_Int max_contours; /* capacity of base outline in contours */
|
||||
|
||||
FT_Vector last;
|
||||
TT_Vector last;
|
||||
|
||||
FT_Fixed scale_x;
|
||||
FT_Fixed scale_y;
|
||||
TT_Fixed scale_x;
|
||||
TT_Fixed scale_y;
|
||||
|
||||
FT_Pos pos_x;
|
||||
FT_Pos pos_y;
|
||||
TT_Pos pos_x;
|
||||
TT_Pos pos_y;
|
||||
|
||||
FT_Vector left_bearing;
|
||||
FT_Vector advance;
|
||||
TT_Vector left_bearing;
|
||||
TT_Vector advance;
|
||||
|
||||
FT_BBox bbox; /* bounding box */
|
||||
FT_Bool path_begun;
|
||||
FT_Bool load_points;
|
||||
FT_Bool no_recurse;
|
||||
TT_BBox bbox; /* bounding box */
|
||||
TT_Bool path_begun;
|
||||
TT_Bool load_points;
|
||||
TT_Bool no_recurse;
|
||||
|
||||
FT_Error error; /* only used for memory errors */
|
||||
FT_Bool metrics_only;
|
||||
TT_Error error; /* only used for memory errors */
|
||||
TT_Bool metrics_only;
|
||||
|
||||
} T2_Builder;
|
||||
|
||||
|
||||
/* execution context charstring zone */
|
||||
typedef struct T2_Decoder_Zone_
|
||||
|
||||
typedef struct T2_Decoder_Zone_
|
||||
{
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
TT_Byte* base;
|
||||
TT_Byte* limit;
|
||||
TT_Byte* cursor;
|
||||
|
||||
} T2_Decoder_Zone;
|
||||
|
||||
|
||||
typedef struct T2_Decoder_
|
||||
typedef struct T2_Decoder_
|
||||
{
|
||||
T2_Builder builder;
|
||||
CFF_Font* cff;
|
||||
T2_Builder builder;
|
||||
CFF_Font* cff;
|
||||
|
||||
FT_Fixed stack[ T2_MAX_OPERANDS+1 ];
|
||||
FT_Fixed* top;
|
||||
TT_Fixed stack[T2_MAX_OPERANDS + 1];
|
||||
TT_Fixed* top;
|
||||
|
||||
T2_Decoder_Zone zones[ T2_MAX_SUBRS_CALLS+1 ];
|
||||
T2_Decoder_Zone* zone;
|
||||
T2_Decoder_Zone zones[T2_MAX_SUBRS_CALLS + 1];
|
||||
T2_Decoder_Zone* zone;
|
||||
|
||||
FT_Int flex_state;
|
||||
FT_Int num_flex_vectors;
|
||||
FT_Vector flex_vectors[7];
|
||||
TT_Int flex_state;
|
||||
TT_Int num_flex_vectors;
|
||||
TT_Vector flex_vectors[7];
|
||||
|
||||
FT_Pos glyph_width;
|
||||
FT_Pos nominal_width;
|
||||
|
||||
FT_Bool read_width;
|
||||
FT_Int num_hints;
|
||||
FT_Fixed* buildchar;
|
||||
FT_Int len_buildchar;
|
||||
TT_Pos glyph_width;
|
||||
TT_Pos nominal_width;
|
||||
|
||||
FT_UInt num_locals;
|
||||
FT_UInt num_globals;
|
||||
|
||||
FT_Int locals_bias;
|
||||
FT_Int globals_bias;
|
||||
|
||||
FT_Byte** locals;
|
||||
FT_Byte** globals;
|
||||
TT_Bool read_width;
|
||||
TT_Int num_hints;
|
||||
TT_Fixed* buildchar;
|
||||
TT_Int len_buildchar;
|
||||
|
||||
TT_UInt num_locals;
|
||||
TT_UInt num_globals;
|
||||
|
||||
TT_Int locals_bias;
|
||||
TT_Int globals_bias;
|
||||
|
||||
TT_Byte** locals;
|
||||
TT_Byte** globals;
|
||||
|
||||
} T2_Decoder;
|
||||
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Init_Decoder( T2_Decoder* decoder,
|
||||
TT_Face face,
|
||||
T2_Size size,
|
||||
T2_GlyphSlot slot );
|
||||
void T2_Init_Decoder( T2_Decoder* decoder,
|
||||
TT_Face face,
|
||||
T2_Size size,
|
||||
T2_GlyphSlot slot );
|
||||
|
||||
|
||||
#if 0 /* unused until we support pure CFF fonts */
|
||||
|
||||
/* Compute the maximum advance width of a font through quick parsing */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Compute_Max_Advance( TT_Face face,
|
||||
FT_Int *max_advance );
|
||||
TT_Error T2_Compute_Max_Advance( TT_Face face,
|
||||
TT_Int* max_advance );
|
||||
|
||||
#endif
|
||||
|
||||
/* This function is exported, because it is used by the T1Dump utility */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
|
||||
FT_Byte* charstring_base,
|
||||
FT_Int charstring_len );
|
||||
|
||||
|
||||
TT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
|
||||
TT_Byte* charstring_base,
|
||||
TT_Int charstring_len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Load_Glyph( T2_GlyphSlot glyph,
|
||||
TT_Error T2_Load_Glyph( T2_GlyphSlot glyph,
|
||||
T2_Size size,
|
||||
FT_Int glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
TT_Int glyph_index,
|
||||
TT_Int load_flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
363
src/cff/t2load.c
363
src/cff/t2load.c
|
@ -21,7 +21,7 @@
|
|||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/internal/t2errors.h>
|
||||
#include <freetype/tttags.h>
|
||||
#include <t2load.h>
|
||||
#include <t2parse.h>
|
||||
|
@ -39,37 +39,42 @@
|
|||
|
||||
/* read a CFF offset from memory */
|
||||
static
|
||||
FT_ULong t2_get_offset( FT_Byte* p,
|
||||
FT_Byte off_size )
|
||||
TT_ULong t2_get_offset( TT_Byte* p,
|
||||
TT_Byte off_size )
|
||||
{
|
||||
FT_ULong result;
|
||||
TT_ULong result;
|
||||
|
||||
|
||||
for ( result = 0; off_size > 0; off_size-- )
|
||||
result = (result <<= 8) | *p++;
|
||||
result = ( result <<= 8 ) | *p++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
FT_Error t2_new_cff_index( CFF_Index* index,
|
||||
TT_Error t2_new_cff_index( CFF_Index* index,
|
||||
FT_Stream stream,
|
||||
FT_Bool load )
|
||||
TT_Bool load )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_UShort count;
|
||||
TT_UShort count;
|
||||
|
||||
|
||||
MEM_Set( index, 0, sizeof ( *index ) );
|
||||
|
||||
MEM_Set( index, 0, sizeof(*index) );
|
||||
index->stream = stream;
|
||||
if ( !READ_UShort( count ) &&
|
||||
count > 0 )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Byte offsize;
|
||||
FT_ULong data_size;
|
||||
FT_ULong* poff;
|
||||
TT_Byte* p;
|
||||
TT_Byte offsize;
|
||||
TT_ULong data_size;
|
||||
TT_ULong* poff;
|
||||
|
||||
/* there is at least one element, read the offset size */
|
||||
|
||||
/* there is at least one element; read the offset size */
|
||||
/* then access the offset table to compute the index's total size */
|
||||
if ( READ_Byte( offsize ) )
|
||||
goto Exit;
|
||||
|
@ -77,15 +82,16 @@
|
|||
index->stream = stream;
|
||||
index->count = count;
|
||||
index->off_size = offsize;
|
||||
data_size = (FT_ULong)(count+1) * offsize;
|
||||
data_size = (TT_ULong)( count + 1 ) * offsize;
|
||||
|
||||
if ( ALLOC_ARRAY( index->offsets, count+1, FT_ULong ) ||
|
||||
ACCESS_Frame( data_size ))
|
||||
if ( ALLOC_ARRAY( index->offsets, count + 1, FT_ULong ) ||
|
||||
ACCESS_Frame( data_size ) )
|
||||
goto Exit;
|
||||
|
||||
poff = index->offsets;
|
||||
p = (FT_Byte*)stream->cursor;
|
||||
for ( ; (FT_Short)count >= 0; count-- )
|
||||
p = (TT_Byte*)stream->cursor;
|
||||
|
||||
for ( ; (TT_Short)count >= 0; count-- )
|
||||
{
|
||||
poff[0] = t2_get_offset( p, offsize );
|
||||
poff++;
|
||||
|
@ -95,9 +101,9 @@
|
|||
FORGET_Frame();
|
||||
|
||||
index->data_offset = FILE_Pos();
|
||||
data_size = poff[-1]-1;
|
||||
data_size = poff[-1] - 1;
|
||||
|
||||
if (load)
|
||||
if ( load )
|
||||
{
|
||||
/* load the data */
|
||||
if ( EXTRACT_Frame( data_size, index->bytes ) )
|
||||
|
@ -109,8 +115,9 @@
|
|||
(void)FILE_Skip( data_size );
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
if (error)
|
||||
if ( error )
|
||||
FREE( index->offsets );
|
||||
|
||||
return error;
|
||||
|
@ -124,88 +131,96 @@
|
|||
{
|
||||
FT_Stream stream = index->stream;
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
if (index->bytes)
|
||||
|
||||
|
||||
if ( index->bytes )
|
||||
RELEASE_Frame( index->bytes );
|
||||
|
||||
FREE( index->offsets );
|
||||
MEM_Set( index, 0, sizeof(*index) );
|
||||
MEM_Set( index, 0, sizeof ( *index ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error t2_explicit_cff_index( CFF_Index* index,
|
||||
FT_Byte** *table )
|
||||
TT_Error t2_explicit_cff_index( CFF_Index* index,
|
||||
TT_Byte*** table )
|
||||
{
|
||||
FT_Error error = 0;
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_UInt n, offset, old_offset;
|
||||
FT_Byte** t;
|
||||
TT_Error error = 0;
|
||||
FT_Memory memory = index->stream->memory;
|
||||
TT_UInt n, offset, old_offset;
|
||||
TT_Byte** t;
|
||||
|
||||
*table = 0;
|
||||
if ( index->count > 0 && !ALLOC_ARRAY( t, index->count+1, FT_Byte* ) )
|
||||
|
||||
*table = 0;
|
||||
|
||||
if ( index->count > 0 && !ALLOC_ARRAY( t, index->count + 1, TT_Byte* ) )
|
||||
{
|
||||
old_offset = 1;
|
||||
for ( n = 0; n <= index->count; n++ )
|
||||
{
|
||||
offset = index->offsets[n];
|
||||
if (!offset)
|
||||
if ( !offset )
|
||||
offset = old_offset;
|
||||
|
||||
|
||||
t[n] = index->bytes + offset - 1;
|
||||
|
||||
|
||||
old_offset = offset;
|
||||
}
|
||||
*table = t;
|
||||
}
|
||||
return error;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Access_Element( CFF_Index* index,
|
||||
FT_UInt element,
|
||||
FT_Byte* *pbytes,
|
||||
FT_ULong *pbyte_len )
|
||||
TT_Error T2_Access_Element( CFF_Index* index,
|
||||
TT_UInt element,
|
||||
TT_Byte** pbytes,
|
||||
TT_ULong* pbyte_len )
|
||||
{
|
||||
FT_Error error = 0;
|
||||
TT_Error error = 0;
|
||||
|
||||
|
||||
if ( index && index->count > element )
|
||||
{
|
||||
/* compute start and end offsets */
|
||||
FT_ULong off1, off2;
|
||||
|
||||
TT_ULong off1, off2;
|
||||
|
||||
|
||||
off1 = index->offsets[element];
|
||||
if (off1)
|
||||
if ( off1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
element++;
|
||||
off2 = index->offsets[element];
|
||||
}
|
||||
while (off2 == 0 && element < index->count);
|
||||
if (!off2)
|
||||
while ( off2 == 0 && element < index->count );
|
||||
|
||||
if ( !off2 )
|
||||
off1 = 0;
|
||||
}
|
||||
|
||||
|
||||
/* access element */
|
||||
if (off1)
|
||||
if ( off1 )
|
||||
{
|
||||
*pbyte_len = off2 - off1;
|
||||
|
||||
if (index->bytes)
|
||||
|
||||
if ( index->bytes )
|
||||
{
|
||||
/* this index was completely loaded in memory, that's easy */
|
||||
*pbytes = index->bytes + off1 - 1;
|
||||
*pbytes = index->bytes + off1 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this index is still on disk/file, access it through a frame */
|
||||
FT_Stream stream = index->stream;
|
||||
|
||||
|
||||
|
||||
if ( FILE_Seek( index->data_offset + off1 - 1 ) ||
|
||||
EXTRACT_Frame( off2-off1, *pbytes ) )
|
||||
EXTRACT_Frame( off2 - off1, *pbytes ) )
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
@ -217,8 +232,8 @@
|
|||
}
|
||||
}
|
||||
else
|
||||
error = FT_Err_Invalid_Argument;
|
||||
|
||||
error = T2_Err_Invalid_Argument;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
@ -226,30 +241,34 @@
|
|||
|
||||
LOCAL_FUNC
|
||||
void T2_Forget_Element( CFF_Index* index,
|
||||
FT_Byte* *pbytes )
|
||||
TT_Byte** pbytes )
|
||||
{
|
||||
if (index->bytes == 0)
|
||||
if ( index->bytes == 0 )
|
||||
{
|
||||
FT_Stream stream = index->stream;
|
||||
|
||||
|
||||
RELEASE_Frame( *pbytes );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_String* T2_Get_Name( CFF_Index* index,
|
||||
FT_UInt element )
|
||||
TT_String* T2_Get_Name( CFF_Index* index,
|
||||
TT_UInt element )
|
||||
{
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_Byte* bytes;
|
||||
FT_ULong byte_len;
|
||||
FT_Error error;
|
||||
FT_String* name = 0;
|
||||
|
||||
FT_Memory memory = index->stream->memory;
|
||||
TT_Byte* bytes;
|
||||
TT_ULong byte_len;
|
||||
TT_Error error;
|
||||
TT_String* name = 0;
|
||||
|
||||
|
||||
error = T2_Access_Element( index, element, &bytes, &byte_len );
|
||||
if (error) goto Exit;
|
||||
|
||||
if ( !ALLOC( name, byte_len+1 ) )
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
if ( !ALLOC( name, byte_len + 1 ) )
|
||||
{
|
||||
MEM_Copy( name, bytes, byte_len );
|
||||
name[byte_len] = 0;
|
||||
|
@ -258,60 +277,69 @@
|
|||
|
||||
Exit:
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* unused until we fully support pure-CFF fonts */
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_String* T2_Get_String( CFF_Index* index,
|
||||
FT_UInt sid,
|
||||
TT_String* T2_Get_String( CFF_Index* index,
|
||||
TT_UInt sid,
|
||||
PSNames_Interface* interface )
|
||||
{
|
||||
/* if it's not a standard string, return it */
|
||||
/* if it is not a standard string, return it */
|
||||
if ( sid > 390 )
|
||||
return T2_Get_Name( index, sid - 390 );
|
||||
|
||||
/* that's a standard string, fetch a copy from the psnamed module */
|
||||
|
||||
/* that's a standard string, fetch a copy from the PSName module */
|
||||
{
|
||||
FT_String* name = 0;
|
||||
TT_String* name = 0;
|
||||
const char* adobe_name = interface->adobe_std_strings( sid );
|
||||
FT_UInt len;
|
||||
|
||||
if (adobe_name)
|
||||
TT_UInt len;
|
||||
|
||||
|
||||
if ( adobe_name )
|
||||
{
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_Error error;
|
||||
|
||||
len = (FT_UInt)strlen(adobe_name);
|
||||
if ( !ALLOC( name, len+1 ) )
|
||||
TT_Error error;
|
||||
|
||||
|
||||
len = (TT_UInt)strlen( adobe_name );
|
||||
if ( !ALLOC( name, len + 1 ) )
|
||||
{
|
||||
MEM_Copy( name, adobe_name, len );
|
||||
name[len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
FT_Int face_index,
|
||||
CFF_Font* font )
|
||||
FT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
TT_Int face_index,
|
||||
CFF_Font* font )
|
||||
{
|
||||
static const FT_Frame_Field cff_header_fields[] = {
|
||||
FT_FRAME_START(4),
|
||||
FT_FRAME_BYTE( CFF_Font, version_major ),
|
||||
FT_FRAME_BYTE( CFF_Font, version_minor ),
|
||||
FT_FRAME_BYTE( CFF_Font, header_size ),
|
||||
FT_FRAME_BYTE( CFF_Font, absolute_offsize ),
|
||||
FT_FRAME_END };
|
||||
static const FT_Frame_Field cff_header_fields[] =
|
||||
{
|
||||
FT_FRAME_START( 4 ),
|
||||
FT_FRAME_BYTE( CFF_Font, version_major ),
|
||||
FT_FRAME_BYTE( CFF_Font, version_minor ),
|
||||
FT_FRAME_BYTE( CFF_Font, header_size ),
|
||||
FT_FRAME_BYTE( CFF_Font, absolute_offsize ),
|
||||
FT_FRAME_END
|
||||
};
|
||||
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_ULong base_offset;
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_ULong base_offset;
|
||||
|
||||
MEM_Set( font, 0, sizeof(*font) );
|
||||
|
||||
MEM_Set( font, 0, sizeof ( *font ) );
|
||||
font->stream = stream;
|
||||
font->memory = memory;
|
||||
base_offset = FILE_Pos();
|
||||
|
@ -325,7 +353,7 @@
|
|||
font->header_size < 4 ||
|
||||
font->absolute_offsize > 4 )
|
||||
{
|
||||
FT_ERROR(( "incorrect CFF font header !!\n" ));
|
||||
FT_ERROR(( "incorrect CFF font header!\n" ));
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
@ -338,126 +366,138 @@
|
|||
t2_new_cff_index( &font->top_dict_index, stream, 0 ) ||
|
||||
t2_new_cff_index( &font->string_index, stream, 0 ) ||
|
||||
t2_new_cff_index( &font->global_subrs_index, stream, 1 );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* well, we don't really forget the "disabled" fonts.. */
|
||||
/* well, we don't really forget the `disabled' fonts... */
|
||||
font->num_faces = font->name_index.count;
|
||||
if (face_index >= font->num_faces)
|
||||
if ( face_index >= font->num_faces )
|
||||
{
|
||||
FT_ERROR(( "T2.Load_Font: incorrect face index = %d\n", face_index ));
|
||||
error = FT_Err_Invalid_Argument;
|
||||
FT_ERROR(( "T2_Load_CFF_Font: incorrect face index = %d\n",
|
||||
face_index ));
|
||||
error = T2_Err_Invalid_Argument;
|
||||
}
|
||||
|
||||
/* in case of a font format check, simply exit now */
|
||||
if (face_index >= 0)
|
||||
if ( face_index >= 0 )
|
||||
{
|
||||
T2_Parser parser;
|
||||
FT_Byte* dict;
|
||||
FT_ULong dict_len;
|
||||
CFF_Index* index = &font->top_dict_index;
|
||||
CFF_Top_Dict* top = &font->top_dict;
|
||||
T2_Parser parser;
|
||||
TT_Byte* dict;
|
||||
TT_ULong dict_len;
|
||||
CFF_Index* index = &font->top_dict_index;
|
||||
CFF_Top_Dict* top = &font->top_dict;
|
||||
|
||||
/* parse the top-level font dictionary */
|
||||
|
||||
/* parse the top-level font dictionary */
|
||||
T2_Parser_Init( &parser, T2CODE_TOPDICT, &font->top_dict );
|
||||
|
||||
/* set defaults */
|
||||
memset( top, 0, sizeof(*top) );
|
||||
memset( top, 0, sizeof ( *top ) );
|
||||
|
||||
top->underline_position = -100;
|
||||
top->underline_thickness = 50;
|
||||
top->charstring_type = 2;
|
||||
top->font_matrix.xx = 0x10000;
|
||||
top->font_matrix.yy = 0x10000;
|
||||
top->font_matrix.xx = 0x10000L;
|
||||
top->font_matrix.yy = 0x10000L;
|
||||
top->cid_count = 8720;
|
||||
|
||||
|
||||
error = T2_Access_Element( index, face_index, &dict, &dict_len ) ||
|
||||
T2_Parser_Run( &parser, dict, dict + dict_len );
|
||||
|
||||
T2_Forget_Element( &font->top_dict_index, &dict );
|
||||
if (error) goto Exit;
|
||||
|
||||
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* parse the private dictionary, if any */
|
||||
if (font->top_dict.private_offset && font->top_dict.private_size)
|
||||
{
|
||||
CFF_Private* priv = &font->private_dict;
|
||||
|
||||
|
||||
|
||||
/* set defaults */
|
||||
priv->blue_shift = 7;
|
||||
priv->blue_fuzz = 1;
|
||||
priv->lenIV = -1;
|
||||
priv->expansion_factor = (FT_Fixed)0.06*0x10000;
|
||||
priv->blue_scale = (FT_Fixed)0.039625*0x10000;
|
||||
priv->expansion_factor = (TT_Fixed)0.06 * 0x10000L;
|
||||
priv->blue_scale = (TT_Fixed)0.039625 * 0x10000L;
|
||||
|
||||
T2_Parser_Init( &parser, T2CODE_PRIVATE, priv );
|
||||
|
||||
|
||||
if ( FILE_Seek( base_offset + font->top_dict.private_offset ) ||
|
||||
ACCESS_Frame( font->top_dict.private_size ) )
|
||||
goto Exit;
|
||||
|
||||
error = T2_Parser_Run( &parser,
|
||||
(FT_Byte*)stream->cursor,
|
||||
(FT_Byte*)stream->limit );
|
||||
FORGET_Frame();
|
||||
if (error) goto Exit;
|
||||
(TT_Byte*)stream->cursor,
|
||||
(TT_Byte*)stream->limit );
|
||||
FORGET_Frame();
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/* read the charstrings index now */
|
||||
if ( font->top_dict.charstrings_offset == 0 )
|
||||
{
|
||||
FT_ERROR(( "T2.New_CFF_Font: no charstrings offset !!\n" ));
|
||||
FT_ERROR(( "T2_Load_CFF_Font: no charstrings offset!\n" ));
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
if ( FILE_Seek( base_offset + font->top_dict.charstrings_offset ) )
|
||||
goto Exit;
|
||||
|
||||
|
||||
error = t2_new_cff_index( &font->charstrings_index, stream, 0 );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* read the local subrs, if any */
|
||||
|
||||
if (font->private_dict.local_subrs_offset) {
|
||||
if ( font->private_dict.local_subrs_offset )
|
||||
{
|
||||
if ( FILE_Seek( base_offset + font->top_dict.private_offset +
|
||||
font->private_dict.local_subrs_offset ) )
|
||||
goto Exit;
|
||||
|
||||
if ( FILE_Seek( base_offset + font->top_dict.private_offset +
|
||||
font->private_dict.local_subrs_offset ) )
|
||||
goto Exit;
|
||||
|
||||
error = t2_new_cff_index( &font->local_subrs_index, stream, 1 );
|
||||
if (error) goto Exit;
|
||||
error = t2_new_cff_index( &font->local_subrs_index, stream, 1 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/* explicit the global and local subrs */
|
||||
|
||||
if (font->private_dict.local_subrs_offset) {
|
||||
font->num_local_subrs = font->local_subrs_index.count;
|
||||
} else {
|
||||
font->num_local_subrs = 0;
|
||||
}
|
||||
if ( font->private_dict.local_subrs_offset )
|
||||
font->num_local_subrs = font->local_subrs_index.count;
|
||||
else
|
||||
font->num_local_subrs = 0;
|
||||
|
||||
font->num_global_subrs = font->global_subrs_index.count;
|
||||
|
||||
|
||||
error = t2_explicit_cff_index( &font->global_subrs_index, &font->global_subrs ) ;
|
||||
error = t2_explicit_cff_index( &font->global_subrs_index,
|
||||
&font->global_subrs ) ;
|
||||
|
||||
if (font->private_dict.local_subrs_offset) {
|
||||
error |= t2_explicit_cff_index( &font->local_subrs_index, &font->local_subrs ) ;
|
||||
}
|
||||
if ( font->private_dict.local_subrs_offset )
|
||||
error |= t2_explicit_cff_index( &font->local_subrs_index,
|
||||
&font->local_subrs ) ;
|
||||
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* get the font name */
|
||||
/* get the font name */
|
||||
font->font_name = T2_Get_Name( &font->name_index, face_index );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T2_Done_CFF_Font( CFF_Font* font )
|
||||
{
|
||||
FT_Memory memory = font->memory;
|
||||
|
||||
|
||||
|
||||
t2_done_cff_index( &font->global_subrs_index );
|
||||
t2_done_cff_index( &font->string_index );
|
||||
t2_done_cff_index( &font->top_dict_index );
|
||||
|
@ -465,20 +505,9 @@
|
|||
t2_done_cff_index( &font->charstrings_index );
|
||||
|
||||
FREE( font->local_subrs );
|
||||
FREE( font->global_subrs );
|
||||
FREE( font->global_subrs );
|
||||
FREE( font->font_name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/***********************************************************************/
|
||||
/***********************************************************************/
|
||||
/***** *****/
|
||||
/***** TYPE 2 TABLES DECODING.. *****/
|
||||
/***** *****/
|
||||
/***********************************************************************/
|
||||
/***********************************************************************/
|
||||
/***********************************************************************/
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
/* */
|
||||
/* OpenType glyph data/program tables loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-1999 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. */
|
||||
|
@ -25,33 +25,35 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
LOCAL_FUNC
|
||||
LOCAL_DEF
|
||||
FT_String* T2_Get_Name( CFF_Index* index,
|
||||
FT_UInt element );
|
||||
|
||||
#if 0 /* will be used later for pure-CFF font support */
|
||||
|
||||
LOCAL_DEF
|
||||
FT_String* T2_Get_String( CFF_Index* index,
|
||||
FT_UInt sid,
|
||||
TT_String* T2_Get_String( CFF_Index* index,
|
||||
TT_UInt sid,
|
||||
PSNames_Interface* interface );
|
||||
|
||||
#endif
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Access_Element( CFF_Index* index,
|
||||
FT_UInt element,
|
||||
FT_Byte* *pbytes,
|
||||
FT_ULong *pbyte_len );
|
||||
TT_Error T2_Access_Element( CFF_Index* index,
|
||||
TT_UInt element,
|
||||
TT_Byte** pbytes,
|
||||
TT_ULong* pbyte_len );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Forget_Element( CFF_Index* index,
|
||||
FT_Byte* *pbytes );
|
||||
TT_Byte** pbytes );
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
FT_Int face_index,
|
||||
LOCAL_DEF
|
||||
TT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
TT_Int face_index,
|
||||
CFF_Font* font );
|
||||
|
||||
LOCAL_FUNC
|
||||
LOCAL_DEF
|
||||
void T2_Done_CFF_Font( CFF_Font* font );
|
||||
|
||||
|
||||
|
|
120
src/cff/t2objs.c
120
src/cff/t2objs.c
|
@ -53,11 +53,18 @@
|
|||
/* T2_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given TrueType face object. */
|
||||
/* Initializes a given OpenType face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* resource :: The source font resource. */
|
||||
/* 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> */
|
||||
|
@ -70,70 +77,77 @@
|
|||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
TT_Error error;
|
||||
FT_Driver sfnt_driver;
|
||||
SFNT_Interface* sfnt;
|
||||
TT_Error error;
|
||||
FT_Driver sfnt_driver;
|
||||
SFNT_Interface* sfnt;
|
||||
|
||||
|
||||
sfnt_driver = FT_Get_Driver( face->root.driver->library, "sfnt" );
|
||||
if (!sfnt_driver) goto Bad_Format;
|
||||
if ( !sfnt_driver )
|
||||
goto Bad_Format;
|
||||
|
||||
sfnt = (SFNT_Interface*)(sfnt_driver->interface.format_interface);
|
||||
if (!sfnt) goto Bad_Format;
|
||||
if ( !sfnt )
|
||||
goto Bad_Format;
|
||||
|
||||
/* create input stream from resource */
|
||||
if ( FILE_Seek(0) )
|
||||
if ( FILE_Seek( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
/* check that we have a valid TrueType file */
|
||||
/* check that we have a valid OpenType file */
|
||||
error = sfnt->init_face( stream, face, face_index, num_params, params );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
|
||||
if ( face->format_tag != 0x4f54544f ) /* OpenType/CFF font */
|
||||
if ( face->format_tag != 0x4f54544fL ) /* OpenType/CFF font */
|
||||
{
|
||||
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
|
||||
goto Bad_Format;
|
||||
}
|
||||
|
||||
/* If we're performing a simple font format check, exit immediately */
|
||||
/* If we are performing a simple font format check, exit immediately */
|
||||
if ( face_index < 0 )
|
||||
return FT_Err_Ok;
|
||||
return T2_Err_Ok;
|
||||
|
||||
/* Load font directory */
|
||||
error = sfnt->load_face( stream, face, face_index, num_params, params );
|
||||
if ( error ) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* now, load the CFF part of the file.. */
|
||||
error = face->goto_table( face, TTAG_CFF, stream, 0 );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
{
|
||||
CFF_Font* cff;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Face root;
|
||||
|
||||
if ( ALLOC( cff, sizeof(*cff) ) )
|
||||
|
||||
|
||||
if ( ALLOC( cff, sizeof ( *cff ) ) )
|
||||
goto Exit;
|
||||
|
||||
|
||||
face->other = cff;
|
||||
error = T2_Load_CFF_Font( stream, face_index, cff );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* complement the root flags with some interesting information */
|
||||
/* Complement the root flags with some interesting information. */
|
||||
/* note that for OpenType/CFF, there is no need to do this, but */
|
||||
/* this will be necessary for pure CFF fonts through.. */
|
||||
/* this will be necessary for pure CFF fonts through. */
|
||||
root = &face->root;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
Bad_Format:
|
||||
|
||||
Bad_Format:
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -149,23 +163,26 @@
|
|||
void T2_Done_Face( T2_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
#if 0
|
||||
#if 0
|
||||
FT_Stream stream = face->root.stream;
|
||||
#endif
|
||||
|
||||
SFNT_Interface* sfnt = face->sfnt;
|
||||
|
||||
if (sfnt)
|
||||
sfnt->done_face(face);
|
||||
|
||||
if ( sfnt )
|
||||
sfnt->done_face( face );
|
||||
|
||||
{
|
||||
CFF_Font* cff = (CFF_Font*)face->other;
|
||||
if (cff)
|
||||
|
||||
|
||||
if ( cff )
|
||||
{
|
||||
T2_Done_CFF_Font(cff);
|
||||
FREE(face->other);
|
||||
T2_Done_CFF_Font( cff );
|
||||
FREE( face->other );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,7 +210,8 @@
|
|||
LOCAL_DEF
|
||||
FT_Error T2_Init_Size( T2_Size size )
|
||||
{
|
||||
UNUSED(size);
|
||||
UNUSED( size );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -212,7 +230,7 @@
|
|||
LOCAL_FUNC
|
||||
void T2_Done_Size( T2_Size size )
|
||||
{
|
||||
UNUSED(size);
|
||||
UNUSED( size );
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,14 +247,15 @@
|
|||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Reset_Size( T2_Size size )
|
||||
TT_Error T2_Reset_Size( T2_Size size )
|
||||
{
|
||||
T2_Face face = (T2_Face)size->face;
|
||||
FT_Size_Metrics* metrics = &size->metrics;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
TT_Error error = T2_Err_Ok;
|
||||
|
||||
|
||||
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
|
||||
return FT_Err_Invalid_Argument;
|
||||
return T2_Err_Invalid_PPem;
|
||||
|
||||
/* Compute root ascender, descender, test height, and max_advance */
|
||||
metrics->ascender = ( FT_MulFix( face->root.ascender,
|
||||
|
@ -250,6 +269,7 @@
|
|||
|
||||
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
|
||||
metrics->x_scale ) + 32 ) & -64;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -269,10 +289,11 @@
|
|||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Init_GlyphSlot( T2_GlyphSlot slot )
|
||||
TT_Error T2_Init_GlyphSlot( T2_GlyphSlot slot )
|
||||
{
|
||||
FT_Library library = slot->root.face->driver->library;
|
||||
|
||||
|
||||
slot->max_points = 0;
|
||||
slot->max_contours = 0;
|
||||
slot->root.bitmap.buffer = 0;
|
||||
|
@ -284,7 +305,7 @@
|
|||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_GlyphSlot */
|
||||
/* T2_Done_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The OpenType glyph slot finalizer. */
|
||||
|
@ -298,7 +319,8 @@
|
|||
FT_Library library = slot->root.face->driver->library;
|
||||
FT_Memory memory = library->memory;
|
||||
|
||||
if (slot->root.flags & ft_glyph_own_bitmap)
|
||||
|
||||
if ( slot->root.flags & ft_glyph_own_bitmap )
|
||||
FREE( slot->root.bitmap.buffer );
|
||||
|
||||
FT_Outline_Done( library, &slot->root.outline );
|
||||
|
@ -321,19 +343,22 @@
|
|||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Init_Driver( T2_Driver driver )
|
||||
TT_Error T2_Init_Driver( T2_Driver driver )
|
||||
{
|
||||
FT_Memory memory = driver->root.memory;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = FT_New_GlyphZone( memory, 0, 0, &driver->zone );
|
||||
if (error) return error;
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
/* init extension registry if needed */
|
||||
#ifdef T2_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
return TT_Init_Extensions( driver );
|
||||
#else
|
||||
return FT_Err_Ok;
|
||||
return T2_Err_Ok;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -341,19 +366,20 @@
|
|||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_Driver */
|
||||
/* T2_Done_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given TrueType driver. */
|
||||
/* Finalizes a given OpenType driver. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target TrueType driver. */
|
||||
/* driver :: A handle to the target OpenType driver. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T2_Done_Driver( T2_Driver driver )
|
||||
{
|
||||
/* destroy extensions registry if needed */
|
||||
#ifdef T2_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
TT_Done_Extensions( driver );
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
/* */
|
||||
/* t2objs.h */
|
||||
/* */
|
||||
/* Objects manager (specification). */
|
||||
/* OpenType objects manager (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-1999 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. */
|
||||
|
@ -42,6 +42,7 @@
|
|||
|
||||
typedef TT_Face T2_Face;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
|
@ -61,23 +62,18 @@
|
|||
/* <Description> */
|
||||
/* A handle to an OpenType glyph slot object. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This is a direct typedef of FT_GlyphSlot, as there is nothing */
|
||||
/* specific about the OpenType glyph slot. */
|
||||
/* */
|
||||
|
||||
typedef struct T2_GlyphSlotRec_
|
||||
{
|
||||
FT_GlyphSlotRec root;
|
||||
|
||||
FT_Bool hint;
|
||||
FT_Bool scaled;
|
||||
TT_Bool hint;
|
||||
TT_Bool scaled;
|
||||
|
||||
FT_Int max_points;
|
||||
FT_Int max_contours;
|
||||
TT_Int max_points;
|
||||
TT_Int max_contours;
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
TT_Fixed x_scale;
|
||||
TT_Fixed y_scale;
|
||||
|
||||
} T2_GlyphSlotRec, *T2_GlyphSlot;
|
||||
|
||||
|
@ -89,9 +85,9 @@
|
|||
/* */
|
||||
typedef struct T2_Transform_
|
||||
{
|
||||
FT_Fixed xx, xy; /* transformation matrix coefficients */
|
||||
FT_Fixed yx, yy;
|
||||
FT_F26Dot6 ox, oy; /* offsets */
|
||||
TT_Fixed xx, xy; /* transformation matrix coefficients */
|
||||
TT_Fixed yx, yy;
|
||||
TT_F26Dot6 ox, oy; /* offsets */
|
||||
|
||||
} T2_Transform;
|
||||
|
||||
|
@ -110,38 +106,55 @@
|
|||
} T2_DriverRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* Face Funcs */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Face functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Init_Face( FT_Stream stream,
|
||||
T2_Face face,
|
||||
TT_Int face_index,
|
||||
TT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF FT_Error T2_Init_Face( FT_Stream stream,
|
||||
T2_Face face,
|
||||
TT_Int face_index,
|
||||
TT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF void T2_Done_Face( T2_Face face );
|
||||
LOCAL_DEF
|
||||
void T2_Done_Face( T2_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* Size funcs */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Size functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Init_Size( T2_Size size );
|
||||
|
||||
LOCAL_DEF FT_Error T2_Init_Size ( T2_Size size );
|
||||
LOCAL_DEF void T2_Done_Size ( T2_Size size );
|
||||
LOCAL_DEF FT_Error T2_Reset_Size( T2_Size size );
|
||||
LOCAL_DEF
|
||||
void T2_Done_Size( T2_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
TT_Error T2_Reset_Size( T2_Size size );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* GlyphSlot funcs */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* GlyphSlot functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
TT_Error T2_Init_GlyphSlot( T2_GlyphSlot slot );
|
||||
|
||||
LOCAL_DEF FT_Error T2_Init_GlyphSlot( T2_GlyphSlot slot );
|
||||
LOCAL_DEF void T2_Done_GlyphSlot( T2_GlyphSlot slot );
|
||||
LOCAL_DEF
|
||||
void T2_Done_GlyphSlot( T2_GlyphSlot slot );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* Driver funcs */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Driver functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
TT_Error T2_Init_Driver( T2_Driver driver );
|
||||
|
||||
LOCAL_DEF FT_Error T2_Init_Driver( T2_Driver driver );
|
||||
LOCAL_DEF void T2_Done_Driver( T2_Driver driver );
|
||||
LOCAL_DEF
|
||||
void T2_Done_Driver( T2_Driver driver );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
|
||||
#include <t2parse.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -33,6 +33,7 @@
|
|||
#define T2_Err_Stack_Underflow FT_Err_Invalid_Argument
|
||||
#define T2_Err_Syntax_Error FT_Err_Invalid_Argument
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
t2_kind_none = 0,
|
||||
|
@ -42,83 +43,87 @@
|
|||
t2_kind_bool,
|
||||
t2_kind_delta,
|
||||
t2_kind_callback,
|
||||
|
||||
|
||||
t2_kind_max /* do not remove */
|
||||
};
|
||||
|
||||
|
||||
/* now generate handlers for the most simple fields */
|
||||
typedef FT_Error (*T2_Field_Reader)( T2_Parser* parser );
|
||||
typedef TT_Error (*T2_Field_Reader)( T2_Parser* parser );
|
||||
|
||||
typedef struct T2_Field_Handler_
|
||||
typedef struct T2_Field_Handler_
|
||||
{
|
||||
int kind;
|
||||
int code;
|
||||
FT_UInt offset;
|
||||
FT_Byte size;
|
||||
TT_UInt offset;
|
||||
TT_Byte size;
|
||||
T2_Field_Reader reader;
|
||||
FT_UInt array_max;
|
||||
FT_UInt count_offset;
|
||||
|
||||
TT_UInt array_max;
|
||||
TT_UInt count_offset;
|
||||
|
||||
} T2_Field_Handler;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T2_Parser_Init( T2_Parser* parser, FT_UInt code, void* object )
|
||||
void T2_Parser_Init( T2_Parser* parser,
|
||||
TT_UInt code,
|
||||
void* object )
|
||||
{
|
||||
MEM_Set(parser,0,sizeof(*parser));
|
||||
MEM_Set( parser, 0, sizeof ( *parser ) );
|
||||
|
||||
parser->top = parser->stack;
|
||||
parser->object_code = code;
|
||||
parser->object = object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* reads an integer */
|
||||
static
|
||||
FT_Long parse_t2_integer( FT_Byte* start,
|
||||
FT_Byte* limit )
|
||||
TT_Long parse_t2_integer( TT_Byte* start,
|
||||
TT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Int v = *p++;
|
||||
FT_Long val = 0;
|
||||
TT_Byte* p = start;
|
||||
TT_Int v = *p++;
|
||||
TT_Long val = 0;
|
||||
|
||||
if (v == 28)
|
||||
|
||||
if ( v == 28 )
|
||||
{
|
||||
if ( p+2 > limit ) goto Bad;
|
||||
val = (FT_Short)(((FT_Int)p[0] << 8) | p[1]);
|
||||
if ( p + 2 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = (TT_Short)( ( (TT_Int)p[0] << 8 ) | p[1] );
|
||||
p += 2;
|
||||
}
|
||||
else if (v == 29)
|
||||
else if ( v == 29 )
|
||||
{
|
||||
if ( p+4 > limit ) goto Bad;
|
||||
val = ((FT_Long)p[0] << 24) |
|
||||
((FT_Long)p[1] << 16) |
|
||||
((FT_Long)p[2] << 8) | p[3];
|
||||
if ( p + 4 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = ( (TT_Long)p[0] << 24 ) |
|
||||
( (TT_Long)p[1] << 16 ) |
|
||||
( (TT_Long)p[2] << 8 ) | p[3];
|
||||
p += 4;
|
||||
}
|
||||
else if (v < 247)
|
||||
else if ( v < 247 )
|
||||
{
|
||||
val = v - 139;
|
||||
}
|
||||
else if (v < 251)
|
||||
else if ( v < 251 )
|
||||
{
|
||||
if (p+1 > limit) goto Bad;
|
||||
val = (v-247)*256 + p[0]+108;
|
||||
p ++;
|
||||
if ( p + 1 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = ( v - 247 ) * 256 + p[0] + 108;
|
||||
p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p+1 > limit) goto Bad;
|
||||
val = -(v-251)*256 - p[0]-108;
|
||||
p ++;
|
||||
if ( p + 1 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = -( v - 251 ) * 256 - p[0] - 108;
|
||||
p++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
@ -132,15 +137,16 @@
|
|||
|
||||
/* reads a real */
|
||||
static
|
||||
FT_Fixed parse_t2_real( FT_Byte* start,
|
||||
FT_Byte* limit,
|
||||
FT_Int power_ten )
|
||||
TT_Fixed parse_t2_real( TT_Byte* start,
|
||||
TT_Byte* limit,
|
||||
TT_Int power_ten )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Long num, divider, result, exp;
|
||||
FT_Int sign = 0, exp_sign = 0;
|
||||
FT_Byte nib;
|
||||
FT_Byte phase;
|
||||
TT_Byte* p = start;
|
||||
TT_Long num, divider, result, exp;
|
||||
TT_Int sign = 0, exp_sign = 0;
|
||||
TT_Byte nib;
|
||||
TT_Byte phase;
|
||||
|
||||
|
||||
result = 0;
|
||||
num = 0;
|
||||
|
@ -149,86 +155,98 @@
|
|||
/* first of all, read the integer part */
|
||||
phase = 4;
|
||||
p--;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if (phase && ++p >= limit) goto Bad;
|
||||
nib = (p[0] >> phase) & 0xF;
|
||||
phase = 4-phase;
|
||||
if ( phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
if (nib == 0xE)
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
phase = 4 - phase;
|
||||
|
||||
if ( nib == 0xE )
|
||||
sign = 1;
|
||||
else if (nib > 9)
|
||||
else if ( nib > 9 )
|
||||
break;
|
||||
else
|
||||
result = result*10 + nib;
|
||||
result = result * 10 + nib;
|
||||
}
|
||||
|
||||
/* read decimal part, if any */
|
||||
if (nib == 0xa)
|
||||
if ( nib == 0xa )
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if (!phase && ++p >= limit) goto Bad;
|
||||
phase = 4-phase;
|
||||
nib = (p[0] >> phase) & 0xF;
|
||||
if ( !phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
if (nib >= 10)
|
||||
phase = 4 - phase;
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
|
||||
if ( nib >= 10 )
|
||||
break;
|
||||
|
||||
if (divider < 10000000L)
|
||||
{
|
||||
num = num*10 + nib;
|
||||
num = num * 10 + nib;
|
||||
divider *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
/* read exponent, if any */
|
||||
if (nib == 12)
|
||||
if ( nib == 12 )
|
||||
{
|
||||
exp_sign = 1;
|
||||
nib = 11;
|
||||
}
|
||||
if (nib == 11)
|
||||
|
||||
if ( nib == 11 )
|
||||
{
|
||||
exp = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if (!phase && ++p >= limit) goto Bad;
|
||||
phase = 4-phase;
|
||||
nib = (p[0] >> phase) & 0xF;
|
||||
if ( !phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
if (nib >= 10)
|
||||
phase = 4 - phase;
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
|
||||
if ( nib >= 10 )
|
||||
break;
|
||||
|
||||
exp = exp*10 + nib;
|
||||
exp = exp * 10 + nib;
|
||||
}
|
||||
if (exp_sign)
|
||||
|
||||
if ( exp_sign )
|
||||
exp = -exp;
|
||||
|
||||
power_ten += exp;
|
||||
}
|
||||
|
||||
/* raise to power of ten if needed */
|
||||
while (power_ten > 0)
|
||||
while ( power_ten > 0 )
|
||||
{
|
||||
result = result*10;
|
||||
num = num*10;
|
||||
result = result * 10;
|
||||
num = num * 10;
|
||||
|
||||
power_ten--;
|
||||
}
|
||||
|
||||
while (power_ten < 0)
|
||||
while ( power_ten < 0 )
|
||||
{
|
||||
result = result/10;
|
||||
divider = divider*10;
|
||||
result = result / 10;
|
||||
divider = divider * 10;
|
||||
|
||||
power_ten++;
|
||||
}
|
||||
|
||||
if (num)
|
||||
if ( num )
|
||||
result += FT_DivFix( num, divider );
|
||||
|
||||
if (sign)
|
||||
if ( sign )
|
||||
result = -result;
|
||||
|
||||
Exit:
|
||||
|
@ -242,32 +260,34 @@
|
|||
|
||||
/* reads a number, either integer or real */
|
||||
static
|
||||
FT_Long t2_parse_num( FT_Byte** d )
|
||||
TT_Long t2_parse_num( TT_Byte** d )
|
||||
{
|
||||
return ( **d == 30 ? (parse_t2_real ( d[0], d[1], 0 ) >> 16):
|
||||
parse_t2_integer( d[0], d[1] ) );
|
||||
return ( **d == 30 ? ( parse_t2_real( d[0], d[1], 0 ) >> 16 )
|
||||
: parse_t2_integer( d[0], d[1] ) );
|
||||
}
|
||||
|
||||
|
||||
/* reads a floating point number, either integer or real */
|
||||
static
|
||||
FT_Fixed t2_parse_fixed( FT_Byte** d )
|
||||
TT_Fixed t2_parse_fixed( TT_Byte** d )
|
||||
{
|
||||
return ( **d == 30 ? parse_t2_real( d[0], d[1], 0 ) :
|
||||
parse_t2_integer( d[0], d[1] ) << 16 );
|
||||
return ( **d == 30 ? parse_t2_real( d[0], d[1], 0 )
|
||||
: parse_t2_integer( d[0], d[1] ) << 16 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_matrix( T2_Parser* parser )
|
||||
TT_Error parse_font_matrix( T2_Parser* parser )
|
||||
{
|
||||
CFF_Top_Dict* dict = (CFF_Top_Dict*)parser->object;
|
||||
FT_Matrix* matrix = &dict->font_matrix;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
TT_Matrix* matrix = &dict->font_matrix;
|
||||
TT_Byte** data = parser->stack;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
if (parser->top >= parser->stack + 4)
|
||||
|
||||
if ( parser->top >= parser->stack + 4 )
|
||||
{
|
||||
matrix->xx = t2_parse_fixed( data++ );
|
||||
matrix->yx = t2_parse_fixed( data++ );
|
||||
|
@ -275,20 +295,23 @@
|
|||
matrix->yy = t2_parse_fixed( data );
|
||||
error = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_bbox( T2_Parser* parser )
|
||||
TT_Error parse_font_bbox( T2_Parser* parser )
|
||||
{
|
||||
CFF_Top_Dict* dict = (CFF_Top_Dict*)parser->object;
|
||||
FT_BBox* bbox = &dict->font_bbox;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
TT_Byte** data = parser->stack;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
if (parser->top >= parser->stack + 4)
|
||||
|
||||
if ( parser->top >= parser->stack + 4 )
|
||||
{
|
||||
bbox->xMin = t2_parse_num( data++ );
|
||||
bbox->yMin = t2_parse_num( data++ );
|
||||
|
@ -296,247 +319,288 @@
|
|||
bbox->yMax = t2_parse_num( data );
|
||||
error = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_private_dict( T2_Parser* parser )
|
||||
TT_Error parse_private_dict( T2_Parser* parser )
|
||||
{
|
||||
CFF_Top_Dict* dict = (CFF_Top_Dict*)parser->object;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
CFF_Top_Dict* dict = (CFF_Top_Dict*)parser->object;
|
||||
TT_Byte** data = parser->stack;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
if (parser->top >= parser->stack + 2)
|
||||
|
||||
if ( parser->top >= parser->stack + 2 )
|
||||
{
|
||||
dict->private_size = t2_parse_num( data++ );
|
||||
dict->private_offset = t2_parse_num( data );
|
||||
error = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_cid_ros( T2_Parser* parser )
|
||||
TT_Error parse_cid_ros( T2_Parser* parser )
|
||||
{
|
||||
CFF_Top_Dict* dict = (CFF_Top_Dict*)parser->object;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
TT_Byte** data = parser->stack;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
if (parser->top >= parser->stack + 3)
|
||||
|
||||
if ( parser->top >= parser->stack + 3 )
|
||||
{
|
||||
dict->cid_registry = (FT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_ordering = (FT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_supplement = (FT_ULong)t2_parse_num( data );
|
||||
dict->cid_registry = (TT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_ordering = (TT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_supplement = (TT_ULong)t2_parse_num( data );
|
||||
error = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#define T2_FIELD_NUM( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_num )
|
||||
#define T2_FIELD_FIXED( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_fixed )
|
||||
#define T2_FIELD_STRING( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_string )
|
||||
#define T2_FIELD_BOOL( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_bool )
|
||||
#define T2_FIELD_DELTA( code, name,max ) \
|
||||
T2_FIELD( code, name, t2_kind_delta )
|
||||
|
||||
#define T2_FIELD_NUM(code,name) T2_FIELD( code, name, t2_kind_num )
|
||||
#define T2_FIELD_FIXED(code,name) T2_FIELD( code, name, t2_kind_fixed )
|
||||
#define T2_FIELD_STRING(code,name) T2_FIELD( code, name, t2_kind_string )
|
||||
#define T2_FIELD_BOOL(code,name) T2_FIELD( code, name, t2_kind_bool )
|
||||
#define T2_FIELD_DELTA(code,name,max) T2_FIELD( code, name, t2_kind_delta )
|
||||
|
||||
|
||||
#define T2_REF(s,f) (((s*)0)->f)
|
||||
#define T2_REF( s, f ) ( ((s*)0)->f )
|
||||
|
||||
#define T2_FIELD_CALLBACK( code, name ) \
|
||||
{ t2_kind_callback, code | T2CODE, 0, 0, parse_ ## name, 0, 0 },
|
||||
|
||||
{ \
|
||||
t2_kind_callback, \
|
||||
code | T2CODE, \
|
||||
0, 0, \
|
||||
parse_ ## name, \
|
||||
0, 0 },
|
||||
|
||||
#undef T2_FIELD
|
||||
#define T2_FIELD( code, name, kind ) \
|
||||
{ kind, code | T2CODE, \
|
||||
(FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name ) ), \
|
||||
0 },
|
||||
|
||||
#undef T2_FIELD_DELTA
|
||||
#define T2_FIELD_DELTA( code, name, max ) \
|
||||
{ t2_kind_delta, code | T2CODE, \
|
||||
(FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name ) ), \
|
||||
0, \
|
||||
max, (FT_UInt)(char*)&T2_REF( T2TYPE, num_ ## name ) },
|
||||
#define T2_FIELD( code, name, kind ) \
|
||||
{ \
|
||||
kind, \
|
||||
code | T2CODE, \
|
||||
(TT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name ) ), \
|
||||
0 \
|
||||
},
|
||||
|
||||
#undef T2_FIELD_DELTA
|
||||
#define T2_FIELD_DELTA( code, name, max ) \
|
||||
{ \
|
||||
t2_kind_delta, \
|
||||
code | T2CODE, \
|
||||
(TT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name ) ), \
|
||||
0, \
|
||||
max, \
|
||||
(TT_UInt)(char*)&T2_REF( T2TYPE, num_ ## name ) \
|
||||
},
|
||||
|
||||
#define T2CODE_TOPDICT 0x1000
|
||||
#define T2CODE_PRIVATE 0x2000
|
||||
|
||||
static const T2_Field_Handler t2_field_handlers[] =
|
||||
{
|
||||
#include <t2tokens.h>
|
||||
#include <t2tokens.h>
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
FT_Byte* start,
|
||||
FT_Byte* limit )
|
||||
TT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
TT_Byte* start,
|
||||
TT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Error error = 0;
|
||||
|
||||
TT_Byte* p = start;
|
||||
TT_Error error = 0;
|
||||
|
||||
|
||||
parser->top = parser->stack;
|
||||
parser->start = start;
|
||||
parser->limit = limit;
|
||||
parser->cursor = start;
|
||||
|
||||
while (p < limit)
|
||||
|
||||
while ( p < limit )
|
||||
{
|
||||
FT_Byte v = *p;
|
||||
TT_Byte v = *p;
|
||||
|
||||
|
||||
if ( v >= 27 && v != 31 )
|
||||
{
|
||||
/* its a number, we'll push its position on the stack */
|
||||
if (parser->top - parser->stack >= T2_MAX_STACK_DEPTH)
|
||||
/* it's a number; we will push its position on the stack */
|
||||
if ( parser->top - parser->stack >= T2_MAX_STACK_DEPTH )
|
||||
goto Stack_Overflow;
|
||||
|
||||
*parser->top ++ = p;
|
||||
|
||||
|
||||
/* now, skip it */
|
||||
if (v == 30)
|
||||
if ( v == 30 )
|
||||
{
|
||||
/* skip real number */
|
||||
for (;;)
|
||||
{
|
||||
if (p >= limit) goto Syntax_Error;
|
||||
if ( p >= limit )
|
||||
goto Syntax_Error;
|
||||
v = p[0] >> 4;
|
||||
if (v == 15) break;
|
||||
if ( v == 15 )
|
||||
break;
|
||||
v = p[0] & 0xF;
|
||||
if (v == 15) break;
|
||||
if ( v == 15 )
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if (v == 28)
|
||||
else if ( v == 28 )
|
||||
p += 2;
|
||||
else if (v == 29)
|
||||
else if ( v == 29 )
|
||||
p += 4;
|
||||
else if (v > 246)
|
||||
else if ( v > 246 )
|
||||
p += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this is not a number, hence it's an operator. Compute its code */
|
||||
/* and look for it in our current list.. */
|
||||
FT_UInt code;
|
||||
FT_Int num_args = parser->top - parser->stack;
|
||||
/* this is not a number, hence it's an operator. Compute its code */
|
||||
/* and look for it in our current list. */
|
||||
|
||||
TT_UInt code;
|
||||
TT_Int num_args = parser->top - parser->stack;
|
||||
const T2_Field_Handler* field;
|
||||
|
||||
|
||||
/* first of all, a trivial check */
|
||||
if ( num_args < 1 ) goto Stack_Underflow;
|
||||
if ( num_args < 1 )
|
||||
goto Stack_Underflow;
|
||||
|
||||
*parser->top = p;
|
||||
code = v;
|
||||
if (v == 12)
|
||||
if ( v == 12 )
|
||||
{
|
||||
/* two byte operator */
|
||||
p++;
|
||||
code = 0x100 | p[0];
|
||||
}
|
||||
code = code | parser->object_code;
|
||||
|
||||
|
||||
for ( field = t2_field_handlers; field->kind; field++ )
|
||||
{
|
||||
if (field->code == code)
|
||||
if ( field->code == code )
|
||||
{
|
||||
/* we found our field's handler, read it.. */
|
||||
FT_Long val;
|
||||
FT_Byte* q = (FT_Byte*)parser->object + field->offset;
|
||||
|
||||
switch (field->kind)
|
||||
{
|
||||
case t2_kind_bool:
|
||||
case t2_kind_string:
|
||||
case t2_kind_num:
|
||||
val = t2_parse_num( parser->stack );
|
||||
goto Store_Number;
|
||||
|
||||
case t2_kind_fixed:
|
||||
val = t2_parse_fixed( parser->stack );
|
||||
|
||||
Store_Number:
|
||||
switch (field->size)
|
||||
{
|
||||
case 1: *(FT_Byte*) q = (FT_Byte)val; break;
|
||||
case 2: *(FT_Short*)q = (FT_Short)val; break;
|
||||
default: *(FT_Long*)q = val;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case t2_kind_delta:
|
||||
{
|
||||
FT_Byte* qcount = (FT_Byte*)parser->object +
|
||||
field->count_offset;
|
||||
/* we found our field's handler; read it */
|
||||
TT_Long val;
|
||||
TT_Byte* q = (TT_Byte*)parser->object + field->offset;
|
||||
|
||||
FT_Long val;
|
||||
FT_Byte** data = parser->stack;
|
||||
|
||||
if (num_args > field->array_max)
|
||||
num_args = field->array_max;
|
||||
|
||||
/* store count */
|
||||
*qcount = (FT_Byte)num_args;
|
||||
|
||||
val = 0;
|
||||
while (num_args > 0)
|
||||
{
|
||||
val += t2_parse_num( data++ );
|
||||
switch (field->size)
|
||||
{
|
||||
case 1: *(FT_Byte*) q = (FT_Byte)val; break;
|
||||
case 2: *(FT_Short*)q = (FT_Short)val; break;
|
||||
default: *(FT_Long*)q = val;
|
||||
}
|
||||
q += field->size;
|
||||
num_args--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* callback */
|
||||
error = field->reader( parser );
|
||||
if (error) goto Exit;
|
||||
|
||||
switch ( field->kind )
|
||||
{
|
||||
case t2_kind_bool:
|
||||
case t2_kind_string:
|
||||
case t2_kind_num:
|
||||
val = t2_parse_num( parser->stack );
|
||||
goto Store_Number;
|
||||
|
||||
case t2_kind_fixed:
|
||||
val = t2_parse_fixed( parser->stack );
|
||||
|
||||
Store_Number:
|
||||
switch ( field->size )
|
||||
{
|
||||
case 1:
|
||||
*(TT_Byte*)q = (TT_Byte)val;
|
||||
break;
|
||||
case 2:
|
||||
*(TT_Short*)q = (TT_Short)val;
|
||||
break;
|
||||
default:
|
||||
*(TT_Long*)q = val;
|
||||
}
|
||||
break;
|
||||
|
||||
case t2_kind_delta:
|
||||
{
|
||||
TT_Byte* qcount = (TT_Byte*)parser->object +
|
||||
field->count_offset;
|
||||
|
||||
TT_Long val;
|
||||
TT_Byte** data = parser->stack;
|
||||
|
||||
|
||||
if ( num_args > field->array_max )
|
||||
num_args = field->array_max;
|
||||
|
||||
/* store count */
|
||||
*qcount = (TT_Byte)num_args;
|
||||
|
||||
val = 0;
|
||||
while ( num_args > 0 )
|
||||
{
|
||||
val += t2_parse_num( data++ );
|
||||
switch ( field->size )
|
||||
{
|
||||
case 1:
|
||||
*(TT_Byte*)q = (TT_Byte)val;
|
||||
break;
|
||||
case 2:
|
||||
*(TT_Short*)q = (TT_Short)val;
|
||||
break;
|
||||
default:
|
||||
*(TT_Long*)q = val;
|
||||
}
|
||||
|
||||
q += field->size;
|
||||
num_args--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* callback */
|
||||
error = field->reader( parser );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
goto Found;
|
||||
}
|
||||
}
|
||||
|
||||
/* this is an unknown operator, or it is unsupported, we will ignore */
|
||||
/* it for now... */
|
||||
/* this is an unknown operator, or it is unsupported; */
|
||||
/* we will ignore it for now. */
|
||||
|
||||
Found:
|
||||
Found:
|
||||
/* clear stack */
|
||||
parser->top = parser->stack;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
|
||||
Stack_Overflow:
|
||||
error = FT_Err_Invalid_Argument;
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
|
||||
|
||||
Stack_Underflow:
|
||||
error = FT_Err_Invalid_Argument;
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
|
||||
|
||||
Syntax_Error:
|
||||
error = FT_Err_Invalid_Argument;
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2parse.h */
|
||||
/* */
|
||||
/* OpenType 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 T2PARSE_H
|
||||
#define T2PARSE_H
|
||||
|
||||
|
@ -6,31 +24,47 @@
|
|||
|
||||
#define T2_MAX_STACK_DEPTH 96
|
||||
|
||||
#define T2CODE_TOPDICT 0x1000
|
||||
#define T2CODE_PRIVATE 0x2000
|
||||
#define T2CODE_TOPDICT 0x1000
|
||||
#define T2CODE_PRIVATE 0x2000
|
||||
|
||||
typedef struct T2_Parser_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct T2_Parser_
|
||||
{
|
||||
FT_Byte* start;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
FT_Byte* stack[ T2_MAX_STACK_DEPTH+1 ];
|
||||
FT_Byte** top;
|
||||
|
||||
FT_UInt object_code;
|
||||
TT_Byte* start;
|
||||
TT_Byte* limit;
|
||||
TT_Byte* cursor;
|
||||
|
||||
TT_Byte* stack[T2_MAX_STACK_DEPTH + 1];
|
||||
TT_Byte** top;
|
||||
|
||||
TT_UInt object_code;
|
||||
void* object;
|
||||
|
||||
|
||||
} T2_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Parser_Init( T2_Parser* parser, FT_UInt code, void* object );
|
||||
|
||||
void T2_Parser_Init( T2_Parser* parser,
|
||||
TT_UInt code,
|
||||
void* object );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
FT_Byte* start,
|
||||
FT_Byte* limit );
|
||||
TT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
TT_Byte* start,
|
||||
TT_Byte* limit );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T2PARSE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2tokens.h */
|
||||
/* */
|
||||
/* OpenType 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 T2TYPE
|
||||
#undef T2CODE
|
||||
|
@ -28,7 +45,7 @@
|
|||
T2_FIELD_STRING ( 0x115, postscript )
|
||||
T2_FIELD_STRING ( 0x116, base_font_name )
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
T2_FIELD_DELTA ( 0x117, base_font_blend, 16 )
|
||||
T2_FIELD_CALLBACK( 0x118, multiple_master )
|
||||
T2_FIELD_CALLBACK( 0x119, blend_axit_types )
|
||||
|
@ -48,8 +65,9 @@
|
|||
T2_FIELD_NUM ( 0x127, chameleon )
|
||||
#endif
|
||||
|
||||
#undef T2TYPE
|
||||
#undef T2CODE
|
||||
|
||||
#undef T2TYPE
|
||||
#undef T2CODE
|
||||
#define T2TYPE CFF_Private
|
||||
#define T2CODE T2CODE_PRIVATE
|
||||
|
||||
|
@ -74,3 +92,5 @@
|
|||
T2_FIELD_NUM ( 20, default_width )
|
||||
T2_FIELD_NUM ( 21, nominal_width )
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
189
src/cid/cidafm.c
189
src/cid/cidafm.c
|
@ -1,50 +1,76 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* t1afm.c - support for reading Type 1 AFM files
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.c */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (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 <cidafm.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
#include <stdlib.h> /* for qsort */
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
#include <stdlib.h> /* for qsort() */
|
||||
#include <string.h> /* for strcmp() */
|
||||
#include <ctype.h> /* for isalnum() */
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CID_Done_AFM( FT_Memory memory, T1_AFM* afm )
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
T1_AFM* afm )
|
||||
{
|
||||
FREE( afm->kern_pairs );
|
||||
afm->num_pairs = 0;
|
||||
}
|
||||
|
||||
|
||||
#undef IS_KERN_PAIR
|
||||
#define IS_KERN_PAIR(p) ( p[0] == 'K' && p[1] == 'P' )
|
||||
#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
|
||||
|
||||
#define IS_ALPHANUM(c) ( (c >= 'A' && c <= 'Z') || \
|
||||
(c >= 'a' && c <= 'z') || \
|
||||
(c >= '0' && c <= '9') || \
|
||||
(c == '_' && c == '.') )
|
||||
#define IS_ALPHANUM( c ) ( isalnum( c ) || \
|
||||
c == '_' || \
|
||||
c == '.' )
|
||||
|
||||
/* read a glyph name and return the equivalent glyph index */
|
||||
|
||||
/* read a glyph name and return the equivalent glyph index */
|
||||
static
|
||||
FT_UInt afm_atoindex( FT_Byte* *start, FT_Byte* limit, T1_Font* type1 )
|
||||
T1_UInt afm_atoindex( T1_Byte** start,
|
||||
T1_Byte* limit,
|
||||
T1_Font* type1 )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
FT_Int len;
|
||||
FT_UInt result = 0;
|
||||
char temp[64];
|
||||
T1_Byte* p = *start;
|
||||
T1_Int len;
|
||||
T1_UInt result = 0;
|
||||
char temp[64];
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
while ( (*p == ' ' || *p == '\t' || *p == ':' || *p == ';') && p < limit )
|
||||
while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
|
||||
p < limit )
|
||||
p++;
|
||||
*start = p;
|
||||
|
||||
/* now, read glyph name */
|
||||
while ( IS_ALPHANUM(*p) && p < limit ) p++;
|
||||
while ( IS_ALPHANUM( *p ) && p < limit )
|
||||
p++;
|
||||
|
||||
len = p - *start;
|
||||
if (len > 0 && len < 64)
|
||||
|
||||
if ( len > 0 && len < 64 )
|
||||
{
|
||||
FT_Int n;
|
||||
T1_Int n;
|
||||
|
||||
|
||||
/* copy glyph name to intermediate array */
|
||||
MEM_Copy( temp, *start, len );
|
||||
|
@ -55,7 +81,8 @@
|
|||
{
|
||||
char* gname = (char*)type1->glyph_names[n];
|
||||
|
||||
if ( gname && gname[0] == temp[0] && strcmp(gname,temp) == 0 )
|
||||
|
||||
if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
|
||||
{
|
||||
result = n;
|
||||
break;
|
||||
|
@ -67,16 +94,18 @@
|
|||
}
|
||||
|
||||
|
||||
/* read an integer */
|
||||
/* read an integer */
|
||||
static
|
||||
int afm_atoi( FT_Byte** start, FT_Byte* limit )
|
||||
int afm_atoi( T1_Byte** start,
|
||||
T1_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
T1_Byte* p = *start;
|
||||
int sum = 0;
|
||||
int sign = 1;
|
||||
|
||||
|
||||
/* skip everything that is not a number */
|
||||
while ( p < limit && (*p < '0' || *p > '9') )
|
||||
while ( p < limit && !isdigit( *p ) )
|
||||
{
|
||||
sign = 1;
|
||||
if (*p == '-')
|
||||
|
@ -85,70 +114,75 @@
|
|||
p++;
|
||||
}
|
||||
|
||||
while ( p < limit && (*p >= '0' && *p < '9') )
|
||||
while ( p < limit && isdigit( *p ) )
|
||||
{
|
||||
sum = sum*10 + (*p - '0');
|
||||
sum = sum * 10 + ( *p - '0' );
|
||||
p++;
|
||||
}
|
||||
*start = p;
|
||||
return sum*sign;
|
||||
|
||||
return sum * sign;
|
||||
}
|
||||
|
||||
|
||||
#undef KERN_INDEX
|
||||
#define KERN_INDEX(g1,g2) (((FT_ULong)g1 << 16) | g2)
|
||||
#define KERN_INDEX( g1, g2 ) ( ( (T1_ULong)g1 << 16 ) | g2 )
|
||||
|
||||
/* compare two kerning pairs */
|
||||
|
||||
/* compare two kerning pairs */
|
||||
static
|
||||
int compare_kern_pairs( const void* a, const void* b )
|
||||
int compare_kern_pairs( const void* a,
|
||||
const void* b )
|
||||
{
|
||||
T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a;
|
||||
T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b;
|
||||
|
||||
FT_ULong index1 = KERN_INDEX(pair1->glyph1,pair1->glyph2);
|
||||
FT_ULong index2 = KERN_INDEX(pair2->glyph1,pair2->glyph2);
|
||||
T1_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
|
||||
T1_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
|
||||
|
||||
|
||||
return ( index1 - index2 );
|
||||
}
|
||||
|
||||
|
||||
/* parse an AFM file - for now, only read the kerning pairs */
|
||||
/* parse an AFM file - for now, only read the kerning pairs */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Read_AFM( FT_Face t1_face,
|
||||
FT_Stream stream )
|
||||
T1_Error CID_Read_AFM( FT_Face t1_face,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
T1_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_Byte* start;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* p;
|
||||
FT_Int count = 0;
|
||||
T1_Byte* start;
|
||||
T1_Byte* limit;
|
||||
T1_Byte* p;
|
||||
T1_Int count = 0;
|
||||
T1_Kern_Pair* pair;
|
||||
T1_Font* type1 = &((T1_Face)t1_face)->type1;
|
||||
T1_AFM* afm = 0;
|
||||
|
||||
if ( ACCESS_Frame(stream->size) )
|
||||
|
||||
if ( ACCESS_Frame( stream->size ) )
|
||||
return error;
|
||||
|
||||
start = (FT_Byte*)stream->cursor;
|
||||
limit = (FT_Byte*)stream->limit;
|
||||
start = (T1_Byte*)stream->cursor;
|
||||
limit = (T1_Byte*)stream->limit;
|
||||
p = start;
|
||||
|
||||
/* we are now going to count the occurences of "KP" or "KPX" in */
|
||||
/* the AFM file.. */
|
||||
/* the AFM file. */
|
||||
count = 0;
|
||||
for ( p = start; p < limit-3; p++ )
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR(p) )
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
count++;
|
||||
}
|
||||
|
||||
/* Actually, kerning pairs are simply optional !! */
|
||||
if (count == 0)
|
||||
/* Actually, kerning pairs are simply optional! */
|
||||
if ( count == 0 )
|
||||
goto Exit;
|
||||
|
||||
/* allocate the pairs */
|
||||
if ( ALLOC( afm, sizeof(*afm ) ) ||
|
||||
if ( ALLOC( afm, sizeof ( *afm ) ) ||
|
||||
ALLOC_ARRAY( afm->kern_pairs, count, T1_Kern_Pair ) )
|
||||
goto Exit;
|
||||
|
||||
|
@ -159,15 +193,17 @@
|
|||
/* save in face object */
|
||||
((T1_Face)t1_face)->afm_data = afm;
|
||||
|
||||
for ( p = start; p < limit-3; p++ )
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR(p) )
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
{
|
||||
FT_Byte* q;
|
||||
T1_Byte* q;
|
||||
|
||||
|
||||
/* skip keyword (KP or KPX) */
|
||||
q = p+2;
|
||||
if (*q == 'X') q++;
|
||||
q = p + 2;
|
||||
if ( *q == 'X' )
|
||||
q++;
|
||||
|
||||
pair->glyph1 = afm_atoindex( &q, limit, type1 );
|
||||
pair->glyph2 = afm_atoindex( &q, limit, type1 );
|
||||
|
@ -182,47 +218,56 @@
|
|||
}
|
||||
|
||||
/* now, sort the kern pairs according to their glyph indices */
|
||||
qsort( afm->kern_pairs, count, sizeof(T1_Kern_Pair), compare_kern_pairs );
|
||||
qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ),
|
||||
compare_kern_pairs );
|
||||
|
||||
Exit:
|
||||
if (error)
|
||||
if ( error )
|
||||
FREE( afm );
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* find the kerning for a given glyph pair */
|
||||
/* find the kerning for a given glyph pair */
|
||||
LOCAL_FUNC
|
||||
void CID_Get_Kerning( T1_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning )
|
||||
T1_UInt glyph1,
|
||||
T1_UInt glyph2,
|
||||
T1_Vector* kerning )
|
||||
{
|
||||
T1_Kern_Pair *min, *mid, *max;
|
||||
FT_ULong index = KERN_INDEX(glyph1,glyph2);
|
||||
T1_ULong index = KERN_INDEX( glyph1, glyph2 );
|
||||
|
||||
|
||||
/* simple binary search */
|
||||
min = afm->kern_pairs;
|
||||
max = min + afm->num_pairs-1;
|
||||
max = min + afm->num_pairs - 1;
|
||||
|
||||
while (min <= max)
|
||||
while ( min <= max )
|
||||
{
|
||||
FT_ULong midi;
|
||||
T1_ULong midi;
|
||||
|
||||
mid = min + (max-min)/2;
|
||||
midi = KERN_INDEX(mid->glyph1,mid->glyph2);
|
||||
|
||||
mid = min + ( max - min ) / 2;
|
||||
midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
|
||||
if ( midi == index )
|
||||
{
|
||||
*kerning = mid->kerning;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( midi < index ) min = mid+1;
|
||||
else max = mid-1;
|
||||
if ( midi < index )
|
||||
min = mid + 1;
|
||||
else
|
||||
max = mid - 1;
|
||||
}
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -1,49 +1,61 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* t1afm.h - support for reading Type 1 AFM files
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.h */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (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 T1AFM_H
|
||||
#define T1AFM_H
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <cidobjs.h>
|
||||
|
||||
/* In this version, we only read the kerning table from the */
|
||||
/* AFM file. We may add support for ligatures a bit later.. */
|
||||
typedef struct T1_Kern_Pair_
|
||||
{
|
||||
T1_UInt glyph1;
|
||||
T1_UInt glyph2;
|
||||
T1_Vector kerning;
|
||||
|
||||
typedef struct T1_Kern_Pair_
|
||||
{
|
||||
FT_UInt glyph1;
|
||||
FT_UInt glyph2;
|
||||
FT_Vector kerning;
|
||||
} T1_Kern_Pair;
|
||||
|
||||
} T1_Kern_Pair;
|
||||
typedef struct T1_AFM_
|
||||
{
|
||||
T1_Int num_pairs;
|
||||
T1_Kern_Pair* kern_pairs;
|
||||
|
||||
} T1_AFM;
|
||||
|
||||
typedef struct T1_AFM_
|
||||
{
|
||||
FT_Int num_pairs;
|
||||
T1_Kern_Pair* kern_pairs;
|
||||
|
||||
} T1_AFM;
|
||||
|
||||
#if 0
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Read_AFM( FT_Face face,
|
||||
T1_Error CID_Read_AFM( FT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
T1_AFM* afm );
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
T1_AFM* afm );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Get_Kerning( T1_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning );
|
||||
T1_UInt glyph1,
|
||||
T1_UInt glyph2,
|
||||
T1_Vector* kerning );
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* T1AFM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <sfobjs.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
#include <freetype/internal/tterrors.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -49,13 +50,13 @@
|
|||
/* Character string. NULL if no name is present. */
|
||||
/* */
|
||||
static
|
||||
FT_String* Get_Name( TT_Face face,
|
||||
FT_UShort nameid )
|
||||
TT_String* Get_Name( TT_Face face,
|
||||
TT_UShort nameid )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_UShort n;
|
||||
TT_UShort n;
|
||||
TT_NameRec* rec;
|
||||
FT_Bool wide_chars = 1;
|
||||
TT_Bool wide_chars = 1;
|
||||
|
||||
|
||||
rec = face->name_table.names;
|
||||
|
@ -64,7 +65,7 @@
|
|||
if ( rec->nameID == nameid )
|
||||
{
|
||||
/* found the name - now create an ASCII string from it */
|
||||
FT_Bool found = 0;
|
||||
TT_Bool found = 0;
|
||||
|
||||
|
||||
/* test for Microsoft English language */
|
||||
|
@ -88,8 +89,8 @@
|
|||
/* found a Unicode name */
|
||||
if ( found )
|
||||
{
|
||||
FT_String* string;
|
||||
FT_UInt len;
|
||||
TT_String* string;
|
||||
TT_UInt len;
|
||||
|
||||
|
||||
if ( wide_chars )
|
||||
|
@ -172,13 +173,13 @@
|
|||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
TT_Int face_index,
|
||||
TT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
SFNT_Interface* sfnt;
|
||||
PSNames_Interface* psnames;
|
||||
SFNT_Header sfnt_header;
|
||||
|
@ -249,7 +250,7 @@
|
|||
|
||||
|
||||
#undef LOAD_
|
||||
#define LOAD_( x ) ( (error = sfnt->load_##x( face, stream )) != FT_Err_Ok )
|
||||
#define LOAD_( x ) ( (error = sfnt->load_##x( face, stream )) != TT_Err_Ok )
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
|
@ -259,7 +260,7 @@
|
|||
TT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
|
@ -268,10 +269,10 @@
|
|||
LOAD_( max_profile ) ||
|
||||
|
||||
/* load the `hhea' & `hmtx' tables at once */
|
||||
( error = sfnt->load_metrics( face, stream, 0 ) ) != FT_Err_Ok ||
|
||||
( error = sfnt->load_metrics( face, stream, 0 ) ) != TT_Err_Ok ||
|
||||
|
||||
/* try to load the `vhea' & `vmtx' at once if present */
|
||||
( error = sfnt->load_metrics( face, stream, 1 ) ) != FT_Err_Ok ||
|
||||
( error = sfnt->load_metrics( face, stream, 1 ) ) != TT_Err_Ok ||
|
||||
|
||||
LOAD_( charmaps ) ||
|
||||
LOAD_( names ) ||
|
||||
|
@ -294,7 +295,7 @@
|
|||
goto Exit;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
if ( ( error = TT_Extension_Create( face ) ) != FT_Err_Ok )
|
||||
if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
|
||||
goto Exit;
|
||||
#endif
|
||||
|
||||
|
@ -304,7 +305,7 @@
|
|||
/* now set up root fields */
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
FT_Int flags;
|
||||
TT_Int flags;
|
||||
TT_CharMap charmap;
|
||||
TT_Int n;
|
||||
FT_Memory memory;
|
||||
|
@ -377,8 +378,8 @@
|
|||
|
||||
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
|
||||
{
|
||||
FT_Int platform = charmap->cmap.platformID;
|
||||
FT_Int encoding = charmap->cmap.platformEncodingID;
|
||||
TT_Int platform = charmap->cmap.platformID;
|
||||
TT_Int encoding = charmap->cmap.platformEncodingID;
|
||||
|
||||
|
||||
charmap->root.face = (FT_Face)face;
|
||||
|
@ -501,7 +502,7 @@
|
|||
/* freeing the character mapping tables */
|
||||
if (sfnt && sfnt->load_charmaps )
|
||||
{
|
||||
FT_UShort n;
|
||||
TT_UShort n;
|
||||
|
||||
|
||||
for ( n = 0; n < face->num_charmaps; n++ )
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
TT_Int face_index,
|
||||
TT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error SFNT_Load_Face( FT_Stream stream,
|
||||
TT_Error SFNT_Load_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
TT_Int face_index,
|
||||
TT_Int num_params,
|
||||
|
|
|
@ -157,9 +157,9 @@
|
|||
TT_Long face_index,
|
||||
SFNT_Header* sfnt )
|
||||
{
|
||||
TT_Error error;
|
||||
TT_ULong format_tag;
|
||||
FT_Memory memory = stream->memory;
|
||||
TT_Error error;
|
||||
TT_ULong format_tag;
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
const FT_Frame_Field sfnt_header_fields[] =
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
/* the 258 default Mac PS glyph names */
|
||||
|
||||
FT_String* TT_Post_Default_Names[258] =
|
||||
TT_String* TT_Post_Default_Names[258] =
|
||||
{
|
||||
/* 0 */
|
||||
".notdef", ".null", "CR", "space", "exclam",
|
||||
|
|
|
@ -63,18 +63,18 @@
|
|||
/* */
|
||||
static
|
||||
void blit_sbit( FT_Bitmap* target,
|
||||
FT_Byte* source,
|
||||
FT_Int line_bits,
|
||||
FT_Bool byte_padded,
|
||||
FT_Int x_offset,
|
||||
FT_Int y_offset )
|
||||
TT_Byte* source,
|
||||
TT_Int line_bits,
|
||||
TT_Bool byte_padded,
|
||||
TT_Int x_offset,
|
||||
TT_Int y_offset )
|
||||
{
|
||||
FT_Byte* line_buff;
|
||||
FT_Int line_incr;
|
||||
FT_Int height;
|
||||
TT_Byte* line_buff;
|
||||
TT_Int line_incr;
|
||||
TT_Int height;
|
||||
|
||||
FT_UShort acc;
|
||||
FT_Byte loaded;
|
||||
TT_UShort acc;
|
||||
TT_Byte loaded;
|
||||
|
||||
|
||||
/* first of all, compute starting write position */
|
||||
|
@ -102,10 +102,10 @@
|
|||
|
||||
for ( height = target->rows; height > 0; height-- )
|
||||
{
|
||||
FT_Byte* cur = line_buff; /* current write cursor */
|
||||
FT_Int count = line_bits; /* # of bits to extract per line */
|
||||
FT_Byte shift = x_offset & 7; /* current write shift */
|
||||
FT_Byte space = 8 - shift;
|
||||
TT_Byte* cur = line_buff; /* current write cursor */
|
||||
TT_Int count = line_bits; /* # of bits to extract per line */
|
||||
TT_Byte shift = x_offset & 7; /* current write shift */
|
||||
TT_Byte space = 8 - shift;
|
||||
|
||||
|
||||
/* first of all, read individual source bytes */
|
||||
|
@ -115,18 +115,18 @@
|
|||
{
|
||||
do
|
||||
{
|
||||
FT_Byte val;
|
||||
TT_Byte val;
|
||||
|
||||
|
||||
/* ensure that there are at least 8 bits in the accumulator */
|
||||
if ( loaded < 8 )
|
||||
{
|
||||
acc |= (FT_UShort)*source++ << ( 8 - loaded );
|
||||
acc |= (TT_UShort)*source++ << ( 8 - loaded );
|
||||
loaded += 8;
|
||||
}
|
||||
|
||||
/* now write one byte */
|
||||
val = (FT_Byte)( acc >> 8 );
|
||||
val = (TT_Byte)( acc >> 8 );
|
||||
if ( shift )
|
||||
{
|
||||
cur[0] |= val >> shift;
|
||||
|
@ -150,18 +150,18 @@
|
|||
/* now write remaining bits (count < 8) */
|
||||
if ( count > 0 )
|
||||
{
|
||||
FT_Byte val;
|
||||
TT_Byte val;
|
||||
|
||||
|
||||
/* ensure that there are at least `count' bits in the accumulator */
|
||||
if ( loaded < count )
|
||||
{
|
||||
acc |= (FT_UShort)*source++ << ( 8 - loaded );
|
||||
acc |= (TT_UShort)*source++ << ( 8 - loaded );
|
||||
loaded += 8;
|
||||
}
|
||||
|
||||
/* now write remaining bits */
|
||||
val = ( (FT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count );
|
||||
val = ( (TT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count );
|
||||
cur[0] |= val >> shift;
|
||||
|
||||
if ( count > space )
|
||||
|
@ -1148,7 +1148,7 @@
|
|||
/* don't forget to multiply `x_offset' by `map->pix_bits' as */
|
||||
/* the sbit blitter doesn't make a difference between pixmap */
|
||||
/* depths. */
|
||||
blit_sbit( map, (FT_Byte*)stream->cursor, line_bits, pad_bytes,
|
||||
blit_sbit( map, (TT_Byte*)stream->cursor, line_bits, pad_bytes,
|
||||
x_offset * pix_bits, y_offset );
|
||||
|
||||
FORGET_Frame();
|
||||
|
@ -1403,8 +1403,8 @@
|
|||
if ( strike->flags & 1 )
|
||||
{
|
||||
/* in case of a horizontal strike only */
|
||||
FT_Int advance;
|
||||
FT_Int top;
|
||||
TT_Int advance;
|
||||
TT_Int top;
|
||||
|
||||
|
||||
advance = strike->hori.ascender - strike->hori.descender;
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
#define PAIR_TAG( left, right ) ( ( (TT_ULong)left << 16 ) | \
|
||||
(TT_ULong)right )
|
||||
|
@ -397,6 +396,7 @@
|
|||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FTDriver_Interface tt_get_interface( TT_Driver driver,
|
||||
const char* interface )
|
||||
|
|
|
@ -681,7 +681,7 @@
|
|||
do
|
||||
{
|
||||
TT_Fixed xx, xy, yy, yx;
|
||||
FT_UInt total_subglyphs;
|
||||
TT_UInt total_subglyphs;
|
||||
|
||||
|
||||
/* grow the `glyph->subglyphs' table if necessary */
|
||||
|
@ -689,7 +689,7 @@
|
|||
|
||||
if ( total_subglyphs >= glyph->max_subglyphs )
|
||||
{
|
||||
FT_UInt new_max = glyph->max_subglyphs;
|
||||
TT_UInt new_max = glyph->max_subglyphs;
|
||||
FT_Memory memory = loader->face->root.memory;
|
||||
|
||||
|
||||
|
@ -1113,8 +1113,9 @@
|
|||
if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
|
||||
loader->load_flags & FT_LOAD_LINEAR )
|
||||
{
|
||||
FT_Pos em_size = face->root.units_per_EM;
|
||||
FT_Pos pixel_size = (FT_Pos)face->root.size->metrics.x_ppem << 16;
|
||||
TT_Pos em_size = face->root.units_per_EM;
|
||||
TT_Pos pixel_size = (TT_Pos)face->root.size->metrics.x_ppem << 16;
|
||||
|
||||
|
||||
lsb2 = FT_MulDiv( lsb2, pixel_size, em_size );
|
||||
adv2 = FT_MulDiv( adv2, pixel_size, em_size );
|
||||
|
|
|
@ -854,7 +854,7 @@
|
|||
static TT_F26Dot6 Norm( TT_F26Dot6 X,
|
||||
TT_F26Dot6 Y )
|
||||
{
|
||||
FT_Int64 T1, T2;
|
||||
TT_INT64 T1, T2;
|
||||
|
||||
|
||||
MUL_64( X, X, T1 );
|
||||
|
|
|
@ -133,7 +133,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -645,7 +644,7 @@
|
|||
TT_Error TT_Init_Driver( TT_Driver driver )
|
||||
{
|
||||
FT_Memory memory = driver->root.memory;
|
||||
FT_Error error;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = FT_New_GlyphZone( memory, 0, 0, &driver->zone );
|
||||
|
|
Loading…
Reference in New Issue