mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
avoid reading a few optional font tables, 6 less i/o reads at startup
This commit is contained in:
parent
2cdd20b4ae
commit
c4f39e57f9
@ -166,8 +166,8 @@
|
|||||||
tt_face_free_name, /* TT_Free_Table_Func free_name */
|
tt_face_free_name, /* TT_Free_Table_Func free_name */
|
||||||
|
|
||||||
NULL, /* TT_Load_Table_Func load_kern */
|
NULL, /* TT_Load_Table_Func load_kern */
|
||||||
tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */
|
NULL, /* TT_Load_Table_Func load_gasp */
|
||||||
tt_face_load_pclt, /* TT_Load_Table_Func load_init */
|
NULL, /* TT_Load_Table_Func load_init */
|
||||||
|
|
||||||
/* see `ttload.h' */
|
/* see `ttload.h' */
|
||||||
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
|
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
|
||||||
|
@ -1334,10 +1334,6 @@
|
|||||||
if ( sfnt->load_eblc )
|
if ( sfnt->load_eblc )
|
||||||
LOAD_( eblc );
|
LOAD_( eblc );
|
||||||
|
|
||||||
/* consider the pclt and gasp tables as optional */
|
|
||||||
LOAD_( pclt );
|
|
||||||
LOAD_( gasp );
|
|
||||||
|
|
||||||
face->root.num_glyphs = face->max_profile.numGlyphs;
|
face->root.num_glyphs = face->max_profile.numGlyphs;
|
||||||
|
|
||||||
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
|
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
|
||||||
@ -1742,10 +1738,6 @@
|
|||||||
face->vertical_info = 0;
|
face->vertical_info = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* freeing the gasp table */
|
|
||||||
FT_FREE( face->gasp.gaspRanges );
|
|
||||||
face->gasp.numRanges = 0;
|
|
||||||
|
|
||||||
/* freeing the name table */
|
/* freeing the name table */
|
||||||
if ( sfnt )
|
if ( sfnt )
|
||||||
sfnt->free_name( face );
|
sfnt->free_name( face );
|
||||||
|
@ -1288,140 +1288,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Function> */
|
|
||||||
/* tt_face_load_pclt */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Loads the PCL 5 Table. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* face :: A handle to the target face object. */
|
|
||||||
/* */
|
|
||||||
/* stream :: A handle to the input stream. */
|
|
||||||
/* */
|
|
||||||
/* <Return> */
|
|
||||||
/* FreeType error code. 0 means success. */
|
|
||||||
/* */
|
|
||||||
FT_LOCAL_DEF( FT_Error )
|
|
||||||
tt_face_load_pclt( TT_Face face,
|
|
||||||
FT_Stream stream )
|
|
||||||
{
|
|
||||||
static const FT_Frame_Field pclt_fields[] =
|
|
||||||
{
|
|
||||||
#undef FT_STRUCTURE
|
|
||||||
#define FT_STRUCTURE TT_PCLT
|
|
||||||
|
|
||||||
FT_FRAME_START( 54 ),
|
|
||||||
FT_FRAME_ULONG ( Version ),
|
|
||||||
FT_FRAME_ULONG ( FontNumber ),
|
|
||||||
FT_FRAME_USHORT( Pitch ),
|
|
||||||
FT_FRAME_USHORT( xHeight ),
|
|
||||||
FT_FRAME_USHORT( Style ),
|
|
||||||
FT_FRAME_USHORT( TypeFamily ),
|
|
||||||
FT_FRAME_USHORT( CapHeight ),
|
|
||||||
FT_FRAME_USHORT( SymbolSet ),
|
|
||||||
FT_FRAME_BYTES ( TypeFace, 16 ),
|
|
||||||
FT_FRAME_BYTES ( CharacterComplement, 8 ),
|
|
||||||
FT_FRAME_BYTES ( FileName, 6 ),
|
|
||||||
FT_FRAME_CHAR ( StrokeWeight ),
|
|
||||||
FT_FRAME_CHAR ( WidthType ),
|
|
||||||
FT_FRAME_BYTE ( SerifStyle ),
|
|
||||||
FT_FRAME_BYTE ( Reserved ),
|
|
||||||
FT_FRAME_END
|
|
||||||
};
|
|
||||||
|
|
||||||
FT_Error error;
|
|
||||||
TT_PCLT* pclt = &face->pclt;
|
|
||||||
|
|
||||||
|
|
||||||
/* optional table */
|
|
||||||
error = face->goto_table( face, TTAG_PCLT, stream, 0 );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
Exit:
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Function> */
|
|
||||||
/* tt_face_load_gasp */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Loads the `gasp' table into a face object. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* face :: A handle to the target face object. */
|
|
||||||
/* */
|
|
||||||
/* stream :: The input stream. */
|
|
||||||
/* */
|
|
||||||
/* <Return> */
|
|
||||||
/* FreeType error code. 0 means success. */
|
|
||||||
/* */
|
|
||||||
FT_LOCAL_DEF( FT_Error )
|
|
||||||
tt_face_load_gasp( TT_Face face,
|
|
||||||
FT_Stream stream )
|
|
||||||
{
|
|
||||||
FT_Error error;
|
|
||||||
FT_Memory memory = stream->memory;
|
|
||||||
|
|
||||||
FT_UInt j,num_ranges;
|
|
||||||
TT_GaspRange gaspranges = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/* the gasp table is optional */
|
|
||||||
error = face->goto_table( face, TTAG_gasp, stream, 0 );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
if ( FT_FRAME_ENTER( 4L ) )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
face->gasp.version = FT_GET_USHORT();
|
|
||||||
face->gasp.numRanges = FT_GET_USHORT();
|
|
||||||
|
|
||||||
FT_FRAME_EXIT();
|
|
||||||
|
|
||||||
/* only support versions 0 and 1 of the table */
|
|
||||||
if ( face->gasp.version >= 2 )
|
|
||||||
{
|
|
||||||
face->gasp.numRanges = 0;
|
|
||||||
error = FT_THROW( Invalid_Table );
|
|
||||||
goto Exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_ranges = face->gasp.numRanges;
|
|
||||||
FT_TRACE3(( "numRanges: %u\n", num_ranges ));
|
|
||||||
|
|
||||||
if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) ||
|
|
||||||
FT_FRAME_ENTER( num_ranges * 4L ) )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
gaspranges = face->gasp.gaspRanges;
|
|
||||||
|
|
||||||
for ( j = 0; j < num_ranges; j++ )
|
|
||||||
{
|
|
||||||
gaspranges[j].maxPPEM = FT_GET_USHORT();
|
|
||||||
gaspranges[j].gaspFlag = FT_GET_USHORT();
|
|
||||||
|
|
||||||
FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n",
|
|
||||||
j,
|
|
||||||
gaspranges[j].maxPPEM,
|
|
||||||
gaspranges[j].gaspFlag ));
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_FRAME_EXIT();
|
|
||||||
|
|
||||||
Exit:
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* END */
|
/* END */
|
||||||
|
@ -82,19 +82,9 @@ FT_BEGIN_HEADER
|
|||||||
tt_face_load_post( TT_Face face,
|
tt_face_load_post( TT_Face face,
|
||||||
FT_Stream stream );
|
FT_Stream stream );
|
||||||
|
|
||||||
|
|
||||||
FT_LOCAL( FT_Error )
|
|
||||||
tt_face_load_pclt( TT_Face face,
|
|
||||||
FT_Stream stream );
|
|
||||||
|
|
||||||
FT_LOCAL( void )
|
FT_LOCAL( void )
|
||||||
tt_face_free_name( TT_Face face );
|
tt_face_free_name( TT_Face face );
|
||||||
|
|
||||||
|
|
||||||
FT_LOCAL( FT_Error )
|
|
||||||
tt_face_load_gasp( TT_Face face,
|
|
||||||
FT_Stream stream );
|
|
||||||
|
|
||||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||||
|
|
||||||
FT_LOCAL( FT_Error )
|
FT_LOCAL( FT_Error )
|
||||||
|
@ -463,36 +463,6 @@ FT_BEGIN_HEADER
|
|||||||
} TT_Postscript;
|
} TT_Postscript;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Struct> */
|
|
||||||
/* TT_PCLT */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* A structure to model a TrueType `PCLT' table. All fields comply */
|
|
||||||
/* to the OpenType specification. */
|
|
||||||
/* */
|
|
||||||
typedef struct TT_PCLT_
|
|
||||||
{
|
|
||||||
FT_Fixed Version;
|
|
||||||
FT_ULong FontNumber;
|
|
||||||
FT_UShort Pitch;
|
|
||||||
FT_UShort xHeight;
|
|
||||||
FT_UShort Style;
|
|
||||||
FT_UShort TypeFamily;
|
|
||||||
FT_UShort CapHeight;
|
|
||||||
FT_UShort SymbolSet;
|
|
||||||
FT_Char TypeFace[16];
|
|
||||||
FT_Char CharacterComplement[8];
|
|
||||||
FT_Char FileName[6];
|
|
||||||
FT_Char StrokeWeight;
|
|
||||||
FT_Char WidthType;
|
|
||||||
FT_Byte SerifStyle;
|
|
||||||
FT_Byte Reserved;
|
|
||||||
|
|
||||||
} TT_PCLT;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Struct> */
|
/* <Struct> */
|
||||||
|
@ -347,71 +347,6 @@ FT_BEGIN_HEADER
|
|||||||
} TT_NameTableRec, *TT_NameTable;
|
} TT_NameTableRec, *TT_NameTable;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/*************************************************************************/
|
|
||||||
/*************************************************************************/
|
|
||||||
/*** ***/
|
|
||||||
/*** ***/
|
|
||||||
/*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
|
|
||||||
/*** ***/
|
|
||||||
/*** ***/
|
|
||||||
/*************************************************************************/
|
|
||||||
/*************************************************************************/
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Struct> */
|
|
||||||
/* TT_GaspRangeRec */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* A tiny structure used to model a gasp range according to the */
|
|
||||||
/* TrueType specification. */
|
|
||||||
/* */
|
|
||||||
/* <Fields> */
|
|
||||||
/* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */
|
|
||||||
/* */
|
|
||||||
/* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */
|
|
||||||
/* modes to be used. */
|
|
||||||
/* */
|
|
||||||
typedef struct TT_GaspRangeRec_
|
|
||||||
{
|
|
||||||
FT_UShort maxPPEM;
|
|
||||||
FT_UShort gaspFlag;
|
|
||||||
|
|
||||||
} TT_GaspRangeRec, *TT_GaspRange;
|
|
||||||
|
|
||||||
|
|
||||||
#define TT_GASP_GRIDFIT 0x01
|
|
||||||
#define TT_GASP_DOGRAY 0x02
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Struct> */
|
|
||||||
/* TT_GaspRec */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* A structure modeling the TrueType `gasp' table used to specify */
|
|
||||||
/* grid-fitting and anti-aliasing behaviour. */
|
|
||||||
/* */
|
|
||||||
/* <Fields> */
|
|
||||||
/* version :: The version number. */
|
|
||||||
/* */
|
|
||||||
/* numRanges :: The number of gasp ranges in table. */
|
|
||||||
/* */
|
|
||||||
/* gaspRanges :: An array of gasp ranges. */
|
|
||||||
/* */
|
|
||||||
typedef struct TT_Gasp_
|
|
||||||
{
|
|
||||||
FT_UShort version;
|
|
||||||
FT_UShort numRanges;
|
|
||||||
TT_GaspRange gaspRanges;
|
|
||||||
|
|
||||||
} TT_GaspRec;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
@ -1146,12 +1081,6 @@ FT_BEGIN_HEADER
|
|||||||
/* (`hdmx' table). This table is optional in */
|
/* (`hdmx' table). This table is optional in */
|
||||||
/* TrueType/OpenType fonts. */
|
/* TrueType/OpenType fonts. */
|
||||||
/* */
|
/* */
|
||||||
/* gasp :: The grid-fitting and scaling properties */
|
|
||||||
/* table (`gasp'). This table is optional in */
|
|
||||||
/* TrueType/OpenType fonts. */
|
|
||||||
/* */
|
|
||||||
/* pclt :: The `pclt' SFNT table. */
|
|
||||||
/* */
|
|
||||||
/* num_sbit_scales :: The number of sbit scales for this font. */
|
/* num_sbit_scales :: The number of sbit scales for this font. */
|
||||||
/* */
|
/* */
|
||||||
/* sbit_scales :: Array of sbit scales embedded in this */
|
/* sbit_scales :: Array of sbit scales embedded in this */
|
||||||
@ -1339,12 +1268,6 @@ FT_BEGIN_HEADER
|
|||||||
/* */
|
/* */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/* grid-fitting and scaling table */
|
|
||||||
TT_GaspRec gasp; /* the `gasp' table */
|
|
||||||
|
|
||||||
/* PCL 5 table */
|
|
||||||
TT_PCLT pclt;
|
|
||||||
|
|
||||||
/* embedded bitmaps support */
|
/* embedded bitmaps support */
|
||||||
FT_ULong num_sbit_scales;
|
FT_ULong num_sbit_scales;
|
||||||
TT_SBit_Scale sbit_scales;
|
TT_SBit_Scale sbit_scales;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user