moved a lot of things from the TrueType driver to the SFNT
module (whose interface has changed, by the way) This allows even more code re-use between TrueType and OpenType formats..
This commit is contained in:
parent
2c5f482b48
commit
2e421319fc
7
CHANGES
7
CHANGES
|
@ -1,5 +1,12 @@
|
|||
LATEST_CHANGES
|
||||
|
||||
- moved a lot of stuff from the TrueType driver to the SFNT module,
|
||||
this allows greater code re-use between font drivers (e.g. TrueType,
|
||||
OpenType, Compact-TrueType, etc..)
|
||||
|
||||
- added a tiny segment cache to the SFNT Charmap 4 decoder, in order
|
||||
to minimally speed it up..
|
||||
|
||||
- added support for Multiple Master fonts in "type1z". There is also
|
||||
a new file named <freetype/ftmm.h> which defines functions to
|
||||
manage them from client applications.
|
||||
|
|
|
@ -149,6 +149,24 @@
|
|||
FT_Face face );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <FuncType>
|
||||
* FT_AutoHinter_Reset_Func
|
||||
*
|
||||
* <Description>
|
||||
* This function is used to recompute the global metrics in a given
|
||||
* font. This is useful when global font data changes (e.g. multiple
|
||||
* masters fonts where blend coordinates change..)
|
||||
*
|
||||
* <Input>
|
||||
* hinter :: handle to source auto-hinter
|
||||
* face :: handle to the face.
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef FT_Error (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
|
@ -189,6 +207,7 @@
|
|||
{
|
||||
FT_AutoHinter_Init_Func init_autohinter;
|
||||
FT_AutoHinter_Done_Func done_autohinter;
|
||||
FT_AutoHinter_Reset_Func reset_face;
|
||||
FT_AutoHinter_Load_Func load_glyph;
|
||||
|
||||
FT_AutoHinter_Get_Global_Func get_global_hints;
|
||||
|
|
|
@ -195,7 +195,12 @@ typedef struct FT_Frame_Field_
|
|||
|
||||
BASE_DEF(void) FT_Forget_Frame( FT_Stream stream );
|
||||
|
||||
BASE_DEF(FT_Error) FT_Extract_Frame( FT_Stream stream,
|
||||
FT_ULong count,
|
||||
FT_Byte* *pbytes );
|
||||
|
||||
BASE_DEF(void) FT_Release_Frame( FT_Stream stream,
|
||||
FT_Byte* *pbytes );
|
||||
|
||||
BASE_DEF(FT_Char) FT_Get_Char( FT_Stream stream );
|
||||
|
||||
|
@ -233,13 +238,14 @@ typedef struct FT_Frame_Field_
|
|||
#define ACCESS_Frame( size ) \
|
||||
FT_SET_ERROR( FT_Access_Frame( stream, size ) )
|
||||
|
||||
#define ACCESS_Compressed_Frame( size ) \
|
||||
FT_SET_ERROR( FT_Access_Compressed_Frame( stream, size ) )
|
||||
|
||||
|
||||
#define FORGET_Frame() \
|
||||
FT_Forget_Frame( stream )
|
||||
|
||||
#define EXTRACT_Frame( size, bytes ) \
|
||||
FT_SET_ERROR( FT_Extract_Frame( stream, size, (FT_Byte**)&(bytes) ) )
|
||||
|
||||
#define RELEASE_Frame( bytes ) \
|
||||
FT_Release_Frame( stream, (FT_Byte**)&(bytes) )
|
||||
|
||||
#define FILE_Seek( position ) \
|
||||
FT_SET_ERROR( FT_Seek_Stream( stream, position ) )
|
||||
|
|
|
@ -23,6 +23,96 @@
|
|||
#include <freetype/internal/tttypes.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Init_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* First part of the SFNT face object initialisation. This will */
|
||||
/* find the face in a SFNT file or collection, and load its */
|
||||
/* format tag in face->format_tag. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The input stream. */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* faceIndex :: The index of the TrueType font, if we're opening a */
|
||||
/* collection. */
|
||||
/* num_params :: number of additional parameters */
|
||||
/* params :: optional additional parameters */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The stream cursor must be at the font file's origin */
|
||||
/* This function recognizes fonts embedded in a "TrueType collection" */
|
||||
/* */
|
||||
/* Once the format tag has been validated by the font driver, it */
|
||||
/* should then call the TT_Load_Face_Func callback to read the rest */
|
||||
/* of the SFNT tables in the object.. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Init_Face_Func)( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Second part of the SFNT face object initialisation. This will */
|
||||
/* load the common SFNT tables (head, OS/2, maxp, metrics, etc..) */
|
||||
/* in the face object.. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The input stream. */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* faceIndex :: The index of the TrueType font, if we're opening a */
|
||||
/* collection. */
|
||||
/* num_params :: number of additional parameters */
|
||||
/* params :: optional additional parameters */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function must be called after TT_Init_Face_Func */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Face_Func)( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Done_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A callback used to delete the common SFNT data from a face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT destroy the face object.. */
|
||||
/* */
|
||||
typedef
|
||||
void (*TT_Done_Face_Func)( TT_Face face );
|
||||
|
||||
|
||||
typedef
|
||||
FTDriver_Interface (*SFNT_Get_Interface_Func)( FT_Driver driver,
|
||||
const char* interface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
|
@ -338,10 +428,17 @@
|
|||
{
|
||||
TT_Goto_Table_Func goto_table;
|
||||
|
||||
TT_Init_Face_Func init_face;
|
||||
TT_Load_Face_Func load_face;
|
||||
TT_Done_Face_Func done_face;
|
||||
SFNT_Get_Interface_Func get_interface;
|
||||
|
||||
TT_Load_Any_Func load_any;
|
||||
TT_Load_Format_Tag_Func load_format_tag;
|
||||
TT_Load_Directory_Func load_directory;
|
||||
|
||||
/* these functions are called by "load_face" but they can also */
|
||||
/* be called from external modules, if there is a need to */
|
||||
TT_Load_Table_Func load_header;
|
||||
TT_Load_Metrics_Func load_metrics;
|
||||
TT_Load_Table_Func load_charmaps;
|
||||
|
|
|
@ -423,463 +423,6 @@
|
|||
} TT_Table;
|
||||
|
||||
|
||||
#if 0
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Header */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType font header table. All */
|
||||
/* fields follow the TrueType specification. */
|
||||
/* */
|
||||
typedef struct TT_Header_
|
||||
{
|
||||
TT_Fixed Table_Version;
|
||||
TT_Fixed Font_Revision;
|
||||
|
||||
TT_Long CheckSum_Adjust;
|
||||
TT_Long Magic_Number;
|
||||
|
||||
TT_UShort Flags;
|
||||
TT_UShort Units_Per_EM;
|
||||
|
||||
TT_Long Created [2];
|
||||
TT_Long Modified[2];
|
||||
|
||||
TT_FWord xMin;
|
||||
TT_FWord yMin;
|
||||
TT_FWord xMax;
|
||||
TT_FWord yMax;
|
||||
|
||||
TT_UShort Mac_Style;
|
||||
TT_UShort Lowest_Rec_PPEM;
|
||||
|
||||
TT_Short Font_Direction;
|
||||
TT_Short Index_To_Loc_Format;
|
||||
TT_Short Glyph_Data_Format;
|
||||
|
||||
} TT_Header;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_HoriHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType horizontal header, the `hhea' */
|
||||
/* table, as well as the corresponding horizontal metrics table, */
|
||||
/* i.e., the `hmtx' table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of all */
|
||||
/* glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' field */
|
||||
/* of the OS/2 table instead if you want */
|
||||
/* the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the distance */
|
||||
/* from the baseline to the bottom-most of */
|
||||
/* all glyph points found in the font. It */
|
||||
/* is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Width_Max :: This field is the maximum of all advance */
|
||||
/* widths found in the font. It can be */
|
||||
/* used to compute the maximum width of an */
|
||||
/* arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Left_Side_Bearing :: The minimum left side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Right_Side_Bearing :: The minimum right side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* xMax_Extent :: The maximum horizontal extent (i.e., the */
|
||||
/* `width' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* Reserved :: 10 reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always 0. */
|
||||
/* */
|
||||
/* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */
|
||||
/* table -- this value can be smaller than */
|
||||
/* the total number of glyphs in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
|
||||
/* be identical except for the names of their fields which */
|
||||
/* are different. */
|
||||
/* */
|
||||
/* This ensures that a single function in the `ttload' */
|
||||
/* module is able to read both the horizontal and vertical */
|
||||
/* headers. */
|
||||
/* */
|
||||
typedef struct TT_HoriHeader_
|
||||
{
|
||||
TT_Fixed Version;
|
||||
TT_FWord Ascender;
|
||||
TT_FWord Descender;
|
||||
TT_FWord Line_Gap;
|
||||
|
||||
TT_UFWord advance_Width_Max; /* advance width maximum */
|
||||
|
||||
TT_FWord min_Left_Side_Bearing; /* minimum left-sb */
|
||||
TT_FWord min_Right_Side_Bearing; /* minimum right-sb */
|
||||
TT_FWord xMax_Extent; /* xmax extents */
|
||||
TT_FWord caret_Slope_Rise;
|
||||
TT_FWord caret_Slope_Run;
|
||||
TT_FWord caret_Offset;
|
||||
|
||||
TT_Short Reserved[4];
|
||||
|
||||
TT_Short metric_Data_Format;
|
||||
TT_UShort number_Of_HMetrics;
|
||||
|
||||
/* The following fields are not defined by the TrueType specification */
|
||||
/* but they're used to connect the metrics header to the relevant */
|
||||
/* `HMTX' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_HoriHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_VertHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType vertical header, the `vhea' */
|
||||
/* table, as well as the corresponding vertical metrics table, i.e., */
|
||||
/* the `vmtx' table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of */
|
||||
/* all glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the */
|
||||
/* distance from the baseline to the */
|
||||
/* bottom-most of all glyph points found */
|
||||
/* in the font. It is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Height_Max :: This field is the maximum of all */
|
||||
/* advance heights found in the font. It */
|
||||
/* can be used to compute the maximum */
|
||||
/* height of an arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Top_Side_Bearing :: The minimum top side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* yMax_Extent :: The maximum vertical extent (i.e., the */
|
||||
/* `height' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* Reserved :: 10 reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always 0. */
|
||||
/* */
|
||||
/* number_Of_HMetrics :: Number of VMetrics entries in the */
|
||||
/* `vmtx' table -- this value can be */
|
||||
/* smaller than the total number of glyphs */
|
||||
/* in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
|
||||
/* be identical except for the names of their fields which */
|
||||
/* are different. */
|
||||
/* */
|
||||
/* This ensures that a single function in the `ttload' */
|
||||
/* module is able to read both the horizontal and vertical */
|
||||
/* headers. */
|
||||
/* */
|
||||
typedef struct TT_VertHeader_
|
||||
{
|
||||
TT_Fixed Version;
|
||||
TT_FWord Ascender;
|
||||
TT_FWord Descender;
|
||||
TT_FWord Line_Gap;
|
||||
|
||||
TT_UFWord advance_Height_Max; /* advance height maximum */
|
||||
|
||||
TT_FWord min_Top_Side_Bearing; /* minimum left-sb or top-sb */
|
||||
TT_FWord min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */
|
||||
TT_FWord yMax_Extent; /* xmax or ymax extents */
|
||||
TT_FWord caret_Slope_Rise;
|
||||
TT_FWord caret_Slope_Run;
|
||||
TT_FWord caret_Offset;
|
||||
|
||||
TT_Short Reserved[4];
|
||||
|
||||
TT_Short metric_Data_Format;
|
||||
TT_UShort number_Of_VMetrics;
|
||||
|
||||
/* The following fields are not defined by the TrueType specification */
|
||||
/* but they're used to connect the metrics header to the relevant */
|
||||
/* `HMTX' or `VMTX' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_VertHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_OS2 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType OS/2 table. This is the long */
|
||||
/* table version. All fields comply to the TrueType specification. */
|
||||
/* */
|
||||
/* Note that we now support old Mac fonts which do not include an */
|
||||
/* OS/2 table. In this case, the `version' field is always set to */
|
||||
/* 0xFFFF. */
|
||||
/* */
|
||||
typedef struct TT_OS2_
|
||||
{
|
||||
TT_UShort version; /* 0x0001 - more or 0xFFFF */
|
||||
TT_FWord xAvgCharWidth;
|
||||
TT_UShort usWeightClass;
|
||||
TT_UShort usWidthClass;
|
||||
TT_Short fsType;
|
||||
TT_FWord ySubscriptXSize;
|
||||
TT_FWord ySubscriptYSize;
|
||||
TT_FWord ySubscriptXOffset;
|
||||
TT_FWord ySubscriptYOffset;
|
||||
TT_FWord ySuperscriptXSize;
|
||||
TT_FWord ySuperscriptYSize;
|
||||
TT_FWord ySuperscriptXOffset;
|
||||
TT_FWord ySuperscriptYOffset;
|
||||
TT_FWord yStrikeoutSize;
|
||||
TT_FWord yStrikeoutPosition;
|
||||
TT_Short sFamilyClass;
|
||||
|
||||
TT_Byte panose[10];
|
||||
|
||||
TT_ULong ulUnicodeRange1; /* Bits 0-31 */
|
||||
TT_ULong ulUnicodeRange2; /* Bits 32-63 */
|
||||
TT_ULong ulUnicodeRange3; /* Bits 64-95 */
|
||||
TT_ULong ulUnicodeRange4; /* Bits 96-127 */
|
||||
|
||||
TT_Char achVendID[4];
|
||||
|
||||
TT_UShort fsSelection;
|
||||
TT_UShort usFirstCharIndex;
|
||||
TT_UShort usLastCharIndex;
|
||||
TT_Short sTypoAscender;
|
||||
TT_Short sTypoDescender;
|
||||
TT_Short sTypoLineGap;
|
||||
TT_UShort usWinAscent;
|
||||
TT_UShort usWinDescent;
|
||||
|
||||
/* only version 1 tables: */
|
||||
|
||||
TT_ULong ulCodePageRange1; /* Bits 0-31 */
|
||||
TT_ULong ulCodePageRange2; /* Bits 32-63 */
|
||||
|
||||
} TT_OS2;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Postscript */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType Postscript table. All fields */
|
||||
/* comply to the TrueType table. This structure does not reference */
|
||||
/* the Postscript glyph names, which can be nevertheless accessed */
|
||||
/* with the `ttpost' module. */
|
||||
/* */
|
||||
typedef struct TT_Postscript_
|
||||
{
|
||||
TT_Fixed FormatType;
|
||||
TT_Fixed italicAngle;
|
||||
TT_FWord underlinePosition;
|
||||
TT_FWord underlineThickness;
|
||||
TT_ULong isFixedPitch;
|
||||
TT_ULong minMemType42;
|
||||
TT_ULong maxMemType42;
|
||||
TT_ULong minMemType1;
|
||||
TT_ULong maxMemType1;
|
||||
|
||||
/* Glyph names follow in the file, but we don't */
|
||||
/* load them by default. See the ttpost.c file. */
|
||||
|
||||
} TT_Postscript;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_MaxProfile */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The maximum profile is a table containing many max values which */
|
||||
/* can be used to pre-allocate arrays. This ensures that no memory */
|
||||
/* allocation occurs during a glyph load. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* version :: The version number. */
|
||||
/* */
|
||||
/* numGlyphs :: The number of glyphs in this TrueType */
|
||||
/* font. */
|
||||
/* */
|
||||
/* maxPoints :: The maximum number of points in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* the structure element */
|
||||
/* `maxCompositePoints'. */
|
||||
/* */
|
||||
/* maxContours :: The maximum number of contours in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* the structure element */
|
||||
/* `maxCompositeContours'. */
|
||||
/* */
|
||||
/* maxCompositePoints :: The maximum number of points in a */
|
||||
/* composite TrueType glyph. See also the */
|
||||
/* structure element `maxPoints'. */
|
||||
/* */
|
||||
/* maxCompositeContours :: The maximum number of contours in a */
|
||||
/* composite TrueType glyph. See also the */
|
||||
/* structure element `maxContours'. */
|
||||
/* */
|
||||
/* maxZones :: The maximum number of zones used for */
|
||||
/* glyph hinting. */
|
||||
/* */
|
||||
/* maxTwilightPoints :: The maximum number of points in the */
|
||||
/* twilight zone used for glyph hinting. */
|
||||
/* */
|
||||
/* maxStorage :: The maximum number of elements in the */
|
||||
/* storage area used for glyph hinting. */
|
||||
/* */
|
||||
/* maxFunctionDefs :: The maximum number of function */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxInstructionDefs :: The maximum number of instruction */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxStackElements :: The maximum number of stack elements used */
|
||||
/* during bytecode interpretation. */
|
||||
/* */
|
||||
/* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
|
||||
/* used for glyph hinting. */
|
||||
/* */
|
||||
/* maxComponentElements :: An obscure value related to composite */
|
||||
/* glyphs definitions. */
|
||||
/* */
|
||||
/* maxComponentDepth :: An obscure value related to composite */
|
||||
/* glyphs definitions. Probably the maximum */
|
||||
/* number of simple glyphs in a composite. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This structure is only used during font loading. */
|
||||
/* */
|
||||
typedef struct TT_MaxProfile_
|
||||
{
|
||||
TT_Fixed version;
|
||||
TT_UShort numGlyphs;
|
||||
TT_UShort maxPoints;
|
||||
TT_UShort maxContours;
|
||||
TT_UShort maxCompositePoints;
|
||||
TT_UShort maxCompositeContours;
|
||||
TT_UShort maxZones;
|
||||
TT_UShort maxTwilightPoints;
|
||||
TT_UShort maxStorage;
|
||||
TT_UShort maxFunctionDefs;
|
||||
TT_UShort maxInstructionDefs;
|
||||
TT_UShort maxStackElements;
|
||||
TT_UShort maxSizeOfInstructions;
|
||||
TT_UShort maxComponentElements;
|
||||
TT_UShort maxComponentDepth;
|
||||
|
||||
} TT_MaxProfile;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
|
@ -1657,7 +1200,9 @@
|
|||
TT_CMap4Segment* segments;
|
||||
TT_UShort* glyphIdArray;
|
||||
TT_UShort numGlyphId; /* control value */
|
||||
|
||||
|
||||
TT_CMap4Segment* last_segment; /* last used segment, this is a small */
|
||||
/* cache to potentially increase speed */
|
||||
} TT_CMap4;
|
||||
|
||||
|
||||
|
@ -2063,6 +1608,15 @@
|
|||
/* used to hook the debugger for the `ttdebug' utility.. */
|
||||
TT_Interpreter interpreter;
|
||||
|
||||
/***********************************************************************/
|
||||
/* */
|
||||
/* Other tables or fields. This is used by derivative formats like */
|
||||
/* OpenType. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
void* other;
|
||||
|
||||
} TT_FaceRec;
|
||||
|
||||
|
||||
|
|
|
@ -121,6 +121,37 @@
|
|||
}
|
||||
|
||||
|
||||
BASE_FUNC(FT_Error) FT_Extract_Frame( FT_Stream stream,
|
||||
FT_ULong count,
|
||||
FT_Byte* *pbytes )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
error = FT_Access_Frame( stream, count );
|
||||
if (!error)
|
||||
{
|
||||
*pbytes = (FT_Byte*)stream->cursor;
|
||||
|
||||
/* equivalent to FT_Forget_Frame, with no memory block release */
|
||||
stream->cursor = 0;
|
||||
stream->limit = 0;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC(void) FT_Release_Frame( FT_Stream stream,
|
||||
FT_Byte* *pbytes )
|
||||
{
|
||||
if (stream->read)
|
||||
{
|
||||
FT_Memory memory = stream->memory;
|
||||
FREE( *pbytes );
|
||||
}
|
||||
*pbytes = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BASE_FUNC(FT_Error) FT_Access_Frame( FT_Stream stream,
|
||||
FT_ULong count )
|
||||
|
@ -194,7 +225,6 @@
|
|||
if (stream->read)
|
||||
{
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
FREE( stream->base );
|
||||
}
|
||||
stream->cursor = 0;
|
||||
|
|
|
@ -38,12 +38,14 @@ ifndef SFNT_INCLUDE
|
|||
$(SFNT_DIR_)ttcmap.c \
|
||||
$(SFNT_DIR_)ttsbit.c \
|
||||
$(SFNT_DIR_)ttpost.c \
|
||||
$(SFNT_DIR_)sfobjs.c \
|
||||
$(SFNT_DIR_)sfdriver.c
|
||||
|
||||
|
||||
# driver headers
|
||||
#
|
||||
SFNT_DRV_H := $(BASE_H) \
|
||||
$(SFNT_DIR_)sfobjs.h \
|
||||
$(SFNT_DIR_)ttload.h \
|
||||
$(SFNT_DIR_)ttsbit.h \
|
||||
$(SFNT_DIR_)ttcmap.h \
|
||||
|
|
|
@ -5,11 +5,52 @@
|
|||
#include <ttsbit.h>
|
||||
#include <ttpost.h>
|
||||
#include <ttcmap.h>
|
||||
#include <sfobjs.h>
|
||||
|
||||
static
|
||||
void* get_sfnt_table( TT_Face face, FT_Sfnt_Tag tag )
|
||||
{
|
||||
void* table;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case ft_sfnt_head: table = &face->header; break;
|
||||
case ft_sfnt_hhea: table = &face->horizontal; break;
|
||||
case ft_sfnt_vhea: table = (face->vertical_info ? &face->vertical : 0 ); break;
|
||||
case ft_sfnt_os2: table = (face->os2.version == 0xFFFF ? 0 : &face->os2 ); break;
|
||||
case ft_sfnt_post: table = &face->postscript; break;
|
||||
case ft_sfnt_maxp: table = &face->max_profile; break;
|
||||
case ft_sfnt_pclt: table = face->pclt.Version ? &face->pclt : 0 ; break;
|
||||
|
||||
default:
|
||||
table = 0;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FTDriver_Interface SFNT_Get_Interface( FT_Driver driver,
|
||||
const char* interface )
|
||||
{
|
||||
UNUSED(driver);
|
||||
|
||||
if (strcmp(interface,"get_sfnt")==0)
|
||||
return (FTDriver_Interface)get_sfnt_table;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const SFNT_Interface sfnt_interface =
|
||||
{
|
||||
TT_Goto_Table,
|
||||
|
||||
SFNT_Init_Face,
|
||||
SFNT_Load_Face,
|
||||
SFNT_Done_Face,
|
||||
SFNT_Get_Interface,
|
||||
|
||||
TT_Load_Any,
|
||||
TT_Load_Format_Tag,
|
||||
TT_Load_Directory,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <ttload.c>
|
||||
#include <ttcmap.c>
|
||||
#include <sfobjs.c>
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
#include <ttsbit.c>
|
||||
|
|
|
@ -214,6 +214,8 @@
|
|||
FORGET_Frame();
|
||||
|
||||
cmap->get_index = code_to_index4;
|
||||
|
||||
cmap4->last_segment = cmap4->segments;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
@ -438,35 +440,45 @@
|
|||
seg4 = cmap4->segments;
|
||||
limit = seg4 + segCount;
|
||||
|
||||
for ( ; seg4 < limit; seg4++, segCount-- )
|
||||
/* check against the last segment */
|
||||
seg4 = cmap4->last_segment;
|
||||
if ( (TT_ULong)(charCode - seg4->startCount) <
|
||||
(TT_ULong)(seg4->endCount - seg4->startCount) )
|
||||
goto Found;
|
||||
|
||||
for ( seg4 = cmap4->segments; seg4 < limit; seg4++, segCount-- )
|
||||
{
|
||||
if ( charCode <= seg4->endCount )
|
||||
{
|
||||
/* the ranges are sorted in increasing order, if we're out of */
|
||||
/* the range here, the char code isn't in the charmap, so exit */
|
||||
if ( charCode < seg4->startCount )
|
||||
break;
|
||||
|
||||
/* when the idRangeOffset is 0, we can compute the glyph index */
|
||||
/* directly.. */
|
||||
if ( seg4->idRangeOffset == 0 )
|
||||
result = (charCode + seg4->idDelta) & 0xFFFF;
|
||||
else
|
||||
/* otherwise, we must use the glyphIdArray to do it */
|
||||
{
|
||||
index1 = seg4->idRangeOffset/2 + (charCode - seg4->startCount)
|
||||
- segCount;
|
||||
|
||||
if ( index1 < cmap4->numGlyphId &&
|
||||
cmap4->glyphIdArray[index1] != 0 )
|
||||
{
|
||||
result = (cmap4->glyphIdArray[index1] + seg4->idDelta) & 0xFFFF;
|
||||
}
|
||||
}
|
||||
/* the ranges are sorted in increasing order, if we're out of */
|
||||
/* the range here, the char code isn't in the charmap, so exit */
|
||||
if ( charCode > seg4->endCount )
|
||||
break;
|
||||
|
||||
if ( charCode >= seg4->startCount )
|
||||
goto Found;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Found:
|
||||
cmap4->last_segment = seg4;
|
||||
|
||||
/* when the idRangeOffset is 0, we can compute the glyph index */
|
||||
/* directly.. */
|
||||
|
||||
if ( seg4->idRangeOffset == 0 )
|
||||
result = (charCode + seg4->idDelta) & 0xFFFF;
|
||||
|
||||
else
|
||||
/* otherwise, we must use the glyphIdArray to do it */
|
||||
{
|
||||
index1 = seg4->idRangeOffset/2 + (charCode - seg4->startCount)
|
||||
- segCount;
|
||||
|
||||
if ( index1 < cmap4->numGlyphId &&
|
||||
cmap4->glyphIdArray[index1] != 0 )
|
||||
{
|
||||
result = (cmap4->glyphIdArray[index1] + seg4->idDelta) & 0xFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,270 +43,6 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* find_encoding
|
||||
*
|
||||
* <Description>
|
||||
* return the FT_Encoding corresponding to a given
|
||||
* (platform_id,encoding_id) pair, as found in TrueType charmaps
|
||||
*
|
||||
* <Input>
|
||||
* platform_id ::
|
||||
* encoding_id ::
|
||||
*
|
||||
* <Return>
|
||||
* the corresponding FT_Encoding tag. ft_encoding_none by default
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
static
|
||||
FT_Encoding find_encoding( int platform_id,
|
||||
int encoding_id )
|
||||
{
|
||||
typedef struct TEncoding
|
||||
{
|
||||
int platform_id;
|
||||
int encoding_id;
|
||||
FT_Encoding encoding;
|
||||
|
||||
} TEncoding;
|
||||
|
||||
static
|
||||
const TEncoding tt_encodings[] =
|
||||
{
|
||||
{ TT_PLATFORM_ISO, -1, ft_encoding_unicode },
|
||||
|
||||
{ TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
|
||||
|
||||
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
|
||||
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 }
|
||||
};
|
||||
|
||||
const TEncoding *cur, *limit;
|
||||
|
||||
cur = tt_encodings;
|
||||
limit = cur + sizeof(tt_encodings)/sizeof(tt_encodings[0]);
|
||||
|
||||
for ( ; cur < limit; cur++ )
|
||||
{
|
||||
if (cur->platform_id == platform_id)
|
||||
{
|
||||
if (cur->encoding_id == encoding_id ||
|
||||
cur->encoding_id == -1 )
|
||||
return cur->encoding;
|
||||
}
|
||||
}
|
||||
return ft_encoding_none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to initialize a new TrueType face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* resource :: A handle to the source resource. */
|
||||
/* */
|
||||
/* typeface_index :: An index of the face in the font resource. Used */
|
||||
/* to access individual faces in font collections. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `typeface_index' parameter field will be set to -1 if the */
|
||||
/* engine only wants to test the format of the resource. This means */
|
||||
/* that font drivers should simply check the font format, then return */
|
||||
/* immediately with an error code of 0 (meaning success). The field */
|
||||
/* `num_faces' should be set. */
|
||||
/* */
|
||||
/* Done_Face() will be called subsequently, whatever the result was. */
|
||||
/* */
|
||||
static
|
||||
TT_Error Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int typeface_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
TT_Error error;
|
||||
|
||||
/* initialize the TrueType face object */
|
||||
error = TT_Init_Face( stream, face, typeface_index, num_params, params );
|
||||
|
||||
/* now set up root fields */
|
||||
if ( !error && typeface_index >= 0 )
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
FT_Int flags;
|
||||
TT_CharMap charmap;
|
||||
TT_Int n;
|
||||
FT_Memory memory;
|
||||
|
||||
memory = root->memory;
|
||||
|
||||
/*****************************************************************/
|
||||
/* */
|
||||
/* Compute face flags. */
|
||||
/* */
|
||||
flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
|
||||
FT_FACE_FLAG_SFNT | /* SFNT file format */
|
||||
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
|
||||
|
||||
/* fixed width font ? */
|
||||
if ( face->postscript.isFixedPitch )
|
||||
flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
||||
|
||||
/* vertical information ? */
|
||||
if ( face->vertical_info )
|
||||
flags |= FT_FACE_FLAG_VERTICAL;
|
||||
|
||||
/* kerning available ? */
|
||||
if ( face->kern_pairs )
|
||||
flags |= FT_FACE_FLAG_KERNING;
|
||||
|
||||
root->face_flags = flags;
|
||||
|
||||
/*****************************************************************/
|
||||
/* */
|
||||
/* Compute style flags. */
|
||||
/* */
|
||||
flags = 0;
|
||||
|
||||
if ( face->os2.version != 0xFFFF )
|
||||
{
|
||||
/* We have an OS/2 table, use the `fsSelection' field */
|
||||
if ( face->os2.fsSelection & 1 )
|
||||
flags |= FT_STYLE_FLAG_ITALIC;
|
||||
|
||||
if ( face->os2.fsSelection & 32 )
|
||||
flags |= FT_STYLE_FLAG_BOLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an old Mac font, use the header field */
|
||||
if ( face->header.Mac_Style & 1 )
|
||||
flags |= FT_STYLE_FLAG_BOLD;
|
||||
|
||||
if ( face->header.Mac_Style & 2 )
|
||||
flags |= FT_STYLE_FLAG_ITALIC;
|
||||
}
|
||||
|
||||
face->root.style_flags = flags;
|
||||
|
||||
/*****************************************************************/
|
||||
/* */
|
||||
/* Polish the charmaps. */
|
||||
/* */
|
||||
/* Try to set the charmap encoding according to the platform & */
|
||||
/* encoding ID of each charmap. */
|
||||
/* */
|
||||
charmap = face->charmaps;
|
||||
root->num_charmaps = face->num_charmaps;
|
||||
|
||||
/* allocate table of pointers */
|
||||
if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
|
||||
return error;
|
||||
|
||||
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
|
||||
{
|
||||
FT_Int platform = charmap->cmap.platformID;
|
||||
FT_Int encoding = charmap->cmap.platformEncodingID;
|
||||
|
||||
charmap->root.face = (FT_Face)face;
|
||||
charmap->root.platform_id = platform;
|
||||
charmap->root.encoding_id = encoding;
|
||||
charmap->root.encoding = find_encoding(platform,encoding);
|
||||
|
||||
/* now, set root->charmap with a unicode charmap wherever available */
|
||||
if (!root->charmap && charmap->root.encoding == ft_encoding_unicode)
|
||||
root->charmap = (FT_CharMap)charmap;
|
||||
|
||||
root->charmaps[n] = (FT_CharMap)charmap;
|
||||
}
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
if ( face->num_sbit_strikes )
|
||||
{
|
||||
face->root.num_fixed_sizes = face->num_sbit_strikes;
|
||||
if ( ALLOC_ARRAY( face->root.available_sizes,
|
||||
face->num_sbit_strikes,
|
||||
FT_Bitmap_Size ) )
|
||||
return error;
|
||||
|
||||
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
|
||||
{
|
||||
face->root.available_sizes[n].width =
|
||||
face->sbit_strikes[n].x_ppem;
|
||||
face->root.available_sizes[n].height =
|
||||
face->sbit_strikes[n].y_ppem;
|
||||
}
|
||||
}
|
||||
else
|
||||
#else
|
||||
{
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
}
|
||||
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
/*****************************************************************/
|
||||
/* */
|
||||
/* Set up metrics. */
|
||||
/* */
|
||||
root->bbox.xMin = face->header.xMin;
|
||||
root->bbox.yMin = face->header.yMin;
|
||||
root->bbox.xMax = face->header.xMax;
|
||||
root->bbox.yMax = face->header.yMax;
|
||||
root->units_per_EM = face->header.Units_Per_EM;
|
||||
|
||||
/* The ascender/descender/height are computed from the OS/2 table */
|
||||
/* when found. Otherwise, they're taken from the horizontal header */
|
||||
if ( face->os2.version != 0xFFFF )
|
||||
{
|
||||
root->ascender = face->os2.sTypoAscender;
|
||||
root->descender = -face->os2.sTypoDescender;
|
||||
root->height = root->ascender + root->descender +
|
||||
face->os2.sTypoLineGap;
|
||||
}
|
||||
else
|
||||
{
|
||||
root->ascender = face->horizontal.Ascender;
|
||||
root->descender = face->horizontal.Descender;
|
||||
root->height = root->ascender + root->descender +
|
||||
face->horizontal.Line_Gap;
|
||||
}
|
||||
|
||||
root->max_advance_width = face->horizontal.advance_Width_Max;
|
||||
|
||||
root->max_advance_height = root->height;
|
||||
if ( face->vertical_info )
|
||||
root->max_advance_height = face->vertical.advance_Height_Max;
|
||||
|
||||
root->underline_position = face->postscript.underlinePosition;
|
||||
root->underline_thickness = face->postscript.underlineThickness;
|
||||
|
||||
/* root->max_points - already set up */
|
||||
/* root->max_contours - already set up */
|
||||
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
#define PAIR_TAG( left, right ) ( ((TT_ULong)left << 16) | (TT_ULong)right )
|
||||
|
@ -638,36 +374,19 @@
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
void* tt_get_sfnt_table( TT_Face face, FT_Sfnt_Tag tag )
|
||||
{
|
||||
void* table;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case ft_sfnt_head: table = &face->header; break;
|
||||
case ft_sfnt_hhea: table = &face->horizontal; break;
|
||||
case ft_sfnt_vhea: table = (face->vertical_info ? &face->vertical : 0 ); break;
|
||||
case ft_sfnt_os2: table = (face->os2.version == 0xFFFF ? 0 : &face->os2 ); break;
|
||||
case ft_sfnt_post: table = &face->postscript; break;
|
||||
case ft_sfnt_maxp: table = &face->max_profile; break;
|
||||
case ft_sfnt_pclt: table = face->pclt.Version ? &face->pclt : 0 ; break;
|
||||
|
||||
default:
|
||||
table = 0;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FTDriver_Interface tt_get_interface( TT_Driver driver, const char* interface )
|
||||
{
|
||||
UNUSED(driver);
|
||||
|
||||
if (strcmp(interface,"get_sfnt")==0)
|
||||
return (FTDriver_Interface)tt_get_sfnt_table;
|
||||
|
||||
FT_Driver sfntd = FT_Get_Driver( driver->root.library, "sfnt" );
|
||||
SFNT_Interface* sfnt;
|
||||
|
||||
/* only return the default interface from the SFNT module */
|
||||
if (sfntd)
|
||||
{
|
||||
sfnt = (SFNT_Interface*)(sfntd->interface.format_interface);
|
||||
if (sfnt)
|
||||
return sfnt->get_interface( (FT_Driver)driver, interface );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -691,7 +410,7 @@
|
|||
(FTDriver_doneDriver) TT_Done_Driver,
|
||||
(FTDriver_getInterface) tt_get_interface,
|
||||
|
||||
(FTDriver_initFace) Init_Face,
|
||||
(FTDriver_initFace) TT_Init_Face,
|
||||
(FTDriver_doneFace) TT_Done_Face,
|
||||
(FTDriver_getKerning) Get_Kerning,
|
||||
|
||||
|
|
|
@ -45,95 +45,6 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Get_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns a given ENGLISH name record in ASCII. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* nameid :: The name id of the name record to return. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Char string. NULL if no name is present. */
|
||||
/* */
|
||||
static
|
||||
FT_String* Get_Name( TT_Face face,
|
||||
TT_UShort nameid )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
TT_UShort n;
|
||||
TT_NameRec* rec;
|
||||
TT_Bool wide_chars = 1;
|
||||
|
||||
/* first pass, look for a given name record */
|
||||
rec = face->name_table.names;
|
||||
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
|
||||
{
|
||||
if ( rec->nameID == nameid )
|
||||
{
|
||||
/* found the name - now create an ASCII string from it */
|
||||
TT_Bool found = 0;
|
||||
|
||||
/* Test for Microsoft English language */
|
||||
if ( rec->platformID == TT_PLATFORM_MICROSOFT &&
|
||||
rec->encodingID <= TT_MS_ID_UNICODE_CS &&
|
||||
(rec->languageID & 0x3FF) == 0x009 )
|
||||
found = 1;
|
||||
|
||||
/* Test for Apple Unicode encoding */
|
||||
else if ( rec->platformID == TT_PLATFORM_APPLE_UNICODE )
|
||||
found = 1;
|
||||
|
||||
/* Test for Apple Roman */
|
||||
else if ( rec->platformID == TT_PLATFORM_MACINTOSH &&
|
||||
rec->languageID == TT_MAC_ID_ROMAN )
|
||||
{
|
||||
found = 1;
|
||||
wide_chars = 0;
|
||||
}
|
||||
|
||||
/* Found a Unicode Name */
|
||||
if ( found )
|
||||
{
|
||||
TT_String* string;
|
||||
TT_UInt len;
|
||||
|
||||
if ( wide_chars )
|
||||
{
|
||||
TT_UInt m;
|
||||
|
||||
len = (TT_UInt)rec->stringLength / 2;
|
||||
if ( MEM_Alloc( string, len + 1 ) )
|
||||
return NULL;
|
||||
|
||||
for ( m = 0; m < len; m ++ )
|
||||
string[m] = rec->string[2*m + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
len = rec->stringLength;
|
||||
if ( MEM_Alloc( string, len + 1 ) )
|
||||
return NULL;
|
||||
|
||||
MEM_Copy( string, rec->string, len );
|
||||
}
|
||||
|
||||
string[len] = '\0';
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#undef LOAD_
|
||||
#define LOAD_(x) ( (error = sfnt->load_##x( face, stream )) != TT_Err_Ok )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -160,126 +71,51 @@
|
|||
FT_Parameter* params )
|
||||
{
|
||||
TT_Error error;
|
||||
TT_ULong format_tag;
|
||||
FT_Driver sfnt_driver;
|
||||
SFNT_Interface* sfnt;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
/* for now, parameters are unused */
|
||||
UNUSED(num_params);
|
||||
UNUSED(params);
|
||||
sfnt_driver = FT_Get_Driver( face->root.driver->library, "sfnt" );
|
||||
if (!sfnt_driver) goto Bad_Format;
|
||||
|
||||
sfnt = (SFNT_Interface*)face->sfnt;
|
||||
if (!sfnt)
|
||||
{
|
||||
/* look-up the SFNT driver */
|
||||
FT_Driver sfnt_driver;
|
||||
|
||||
sfnt_driver = FT_Get_Driver( face->root.driver->library, "sfnt" );
|
||||
if (!sfnt_driver)
|
||||
return FT_Err_Invalid_File_Format;
|
||||
|
||||
sfnt = (SFNT_Interface*)(sfnt_driver->interface.format_interface);
|
||||
if (!sfnt)
|
||||
return FT_Err_Invalid_File_Format;
|
||||
|
||||
face->sfnt = sfnt;
|
||||
face->goto_table = sfnt->goto_table;
|
||||
}
|
||||
|
||||
psnames = (PSNames_Interface*)face->psnames;
|
||||
if (!psnames)
|
||||
{
|
||||
/* look-up the PSNames driver */
|
||||
FT_Driver psnames_driver;
|
||||
|
||||
psnames_driver = FT_Get_Driver( face->root.driver->library, "psnames" );
|
||||
if (psnames_driver)
|
||||
face->psnames = (PSNames_Interface*)
|
||||
(psnames_driver->interface.format_interface);
|
||||
}
|
||||
sfnt = (SFNT_Interface*)(sfnt_driver->interface.format_interface);
|
||||
if (!sfnt) goto Bad_Format;
|
||||
|
||||
/* create input stream from resource */
|
||||
if ( FILE_Seek(0) )
|
||||
goto Exit;
|
||||
|
||||
/* check that we have a valid TrueType file */
|
||||
error = sfnt->load_format_tag( face, stream, face_index, &format_tag );
|
||||
error = sfnt->init_face( stream, face, face_index, num_params, params );
|
||||
if (error) goto Exit;
|
||||
|
||||
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
|
||||
if ( format_tag != 0x00010000 && /* MS fonts */
|
||||
format_tag != TTAG_true ) /* Mac fonts */
|
||||
if ( face->format_tag != 0x00010000 && /* MS fonts */
|
||||
face->format_tag != TTAG_true ) /* Mac fonts */
|
||||
{
|
||||
FT_TRACE2(( "[not a valid TTF font]" ));
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
goto Bad_Format;
|
||||
}
|
||||
|
||||
/* store format tag */
|
||||
face->format_tag = format_tag;
|
||||
|
||||
/* Load font directory */
|
||||
error = sfnt->load_directory( face, stream, face_index );
|
||||
if ( error ) goto Exit;
|
||||
|
||||
face->root.num_faces = face->ttc_header.DirCount;
|
||||
if ( face->root.num_faces < 1 )
|
||||
face->root.num_faces = 1;
|
||||
|
||||
/* If we're performing a simple font format check, exit immediately */
|
||||
if ( face_index < 0 )
|
||||
return TT_Err_Ok;
|
||||
|
||||
/* Load tables */
|
||||
|
||||
if ( LOAD_( header ) ||
|
||||
LOAD_( max_profile ) ||
|
||||
|
||||
(error = sfnt->load_metrics( face, stream, 0 )) != TT_Err_Ok ||
|
||||
/* load the `hhea' & `hmtx' tables at once */
|
||||
|
||||
(error = sfnt->load_metrics( face, stream, 1 )) != TT_Err_Ok ||
|
||||
/* try to load the `vhea' & `vmtx' at once if present */
|
||||
|
||||
LOAD_( charmaps ) ||
|
||||
LOAD_( names ) ||
|
||||
LOAD_( os2 ) ||
|
||||
LOAD_( psnames ) )
|
||||
goto Exit;
|
||||
|
||||
/* the optional tables */
|
||||
|
||||
/* embedded bitmap support. */
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
if (sfnt->load_sbits && LOAD_(sbits)) goto Exit;
|
||||
#endif
|
||||
|
||||
if ( LOAD_( hdmx ) ||
|
||||
LOAD_( gasp ) ||
|
||||
LOAD_( kerning ) ||
|
||||
LOAD_( pclt ) ||
|
||||
|
||||
(error = TT_Load_Locations( face, stream )) != TT_Err_Ok ||
|
||||
(error = TT_Load_CVT ( face, stream )) != TT_Err_Ok ||
|
||||
(error = TT_Load_Programs ( face, stream )) != TT_Err_Ok )
|
||||
|
||||
goto Exit;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
|
||||
goto Exit;
|
||||
#endif
|
||||
|
||||
face->root.family_name = Get_Name( face, TT_NAME_ID_FONT_FAMILY );
|
||||
face->root.style_name = Get_Name( face, TT_NAME_ID_FONT_SUBFAMILY );
|
||||
/* Load font directory */
|
||||
error = sfnt->load_face( stream, face, face_index, num_params, params );
|
||||
if ( error ) goto Exit;
|
||||
|
||||
error = TT_Load_Locations( face, stream ) ||
|
||||
TT_Load_CVT ( face, stream ) ||
|
||||
TT_Load_Programs ( face, stream );
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Bad_Format:
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
#undef LOAD_
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
|
@ -295,94 +131,27 @@
|
|||
LOCAL_DEF
|
||||
void TT_Done_Face( TT_Face face )
|
||||
{
|
||||
TT_UShort n;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Stream stream = face->root.stream;
|
||||
|
||||
SFNT_Interface* sfnt = face->sfnt;
|
||||
|
||||
if (sfnt)
|
||||
{
|
||||
/* destroy the postscript names table if it is supported */
|
||||
if (sfnt->free_psnames)
|
||||
sfnt->free_psnames( face );
|
||||
|
||||
/* destroy the embedded bitmaps table if it is supported */
|
||||
if (sfnt->free_sbits)
|
||||
sfnt->free_sbits( face );
|
||||
}
|
||||
|
||||
/* freeing the kerning table */
|
||||
FREE( face->kern_pairs );
|
||||
face->num_kern_pairs = 0;
|
||||
|
||||
/* freeing the collection table */
|
||||
FREE( face->ttc_header.TableDirectory );
|
||||
face->ttc_header.DirCount = 0;
|
||||
|
||||
/* freeing table directory */
|
||||
FREE( face->dir_tables );
|
||||
face->num_tables = 0;
|
||||
sfnt->done_face(face);
|
||||
|
||||
/* freeing the locations table */
|
||||
FREE( face->glyph_locations );
|
||||
face->num_locations = 0;
|
||||
|
||||
/* freeing the character mapping tables */
|
||||
if (sfnt && sfnt->load_charmaps )
|
||||
{
|
||||
for ( n = 0; n < face->num_charmaps; n++ )
|
||||
sfnt->free_charmap( face, &face->charmaps[n].cmap );
|
||||
}
|
||||
|
||||
FREE( face->charmaps );
|
||||
face->num_charmaps = 0;
|
||||
|
||||
FREE( face->root.charmaps );
|
||||
face->root.num_charmaps = 0;
|
||||
face->root.charmap = 0;
|
||||
|
||||
/* freeing the CVT */
|
||||
FREE( face->cvt );
|
||||
face->cvt_size = 0;
|
||||
|
||||
/* freeing the horizontal metrics */
|
||||
FREE( face->horizontal.long_metrics );
|
||||
FREE( face->horizontal.short_metrics );
|
||||
|
||||
/* freeing the vertical ones, if any */
|
||||
if ( face->vertical_info )
|
||||
{
|
||||
FREE( face->vertical.long_metrics );
|
||||
FREE( face->vertical.short_metrics );
|
||||
face->vertical_info = 0;
|
||||
}
|
||||
|
||||
/* freeing the programs */
|
||||
FREE( face->font_program );
|
||||
FREE( face->cvt_program );
|
||||
RELEASE_Frame( face->font_program );
|
||||
RELEASE_Frame( face->cvt_program );
|
||||
face->font_program_size = 0;
|
||||
face->cvt_program_size = 0;
|
||||
|
||||
/* freeing the gasp table */
|
||||
FREE( face->gasp.gaspRanges );
|
||||
face->gasp.numRanges = 0;
|
||||
|
||||
/* freeing the name table */
|
||||
sfnt->free_names( face );
|
||||
|
||||
/* freeing the hdmx table */
|
||||
sfnt->free_hdmx( face );
|
||||
|
||||
/* freeing family and style name */
|
||||
FREE( face->root.family_name );
|
||||
FREE( face->root.style_name );
|
||||
|
||||
/* freeing sbit size table */
|
||||
face->root.num_fixed_sizes = 0;
|
||||
if ( face->root.available_sizes )
|
||||
FREE( face->root.available_sizes );
|
||||
|
||||
face->sfnt = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -199,10 +199,8 @@
|
|||
FT_Stream stream )
|
||||
{
|
||||
TT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
TT_ULong table_len;
|
||||
|
||||
|
||||
FT_TRACE2(( "Font program " ));
|
||||
|
||||
/* The font program is optional */
|
||||
|
@ -216,12 +214,7 @@
|
|||
else
|
||||
{
|
||||
face->font_program_size = table_len;
|
||||
|
||||
if ( ALLOC( face->font_program,
|
||||
face->font_program_size ) ||
|
||||
|
||||
FILE_Read( (void*)face->font_program,
|
||||
face->font_program_size ) )
|
||||
if ( EXTRACT_Frame( table_len, face->font_program ) )
|
||||
goto Exit;
|
||||
|
||||
FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size ));
|
||||
|
@ -241,14 +234,8 @@
|
|||
else
|
||||
{
|
||||
face->cvt_program_size = table_len;
|
||||
|
||||
if ( ALLOC( face->cvt_program,
|
||||
face->cvt_program_size ) ||
|
||||
|
||||
FILE_Read( (void*)face->cvt_program,
|
||||
face->cvt_program_size ) )
|
||||
return error;
|
||||
|
||||
if ( EXTRACT_Frame( table_len, face->cvt_program ) )
|
||||
goto Exit;
|
||||
FT_TRACE2(( "loaded, %12d bytes\n", face->cvt_program_size ));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ make_module_list: add_type1_driver
|
|||
|
||||
add_type1_driver:
|
||||
$(OPEN_DRIVER)t1_driver_interface$(CLOSE_DRIVER)
|
||||
$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC) Postscript font files with extension *.pfa or *.pfb $(ECHO_DRIVER_DONE)
|
||||
$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
|
||||
|
||||
|
|
Loading…
Reference in New Issue