@ -25,6 +25,7 @@
# include FT_TRUETYPE_TAGS_H
# include FT_INTERNAL_SFNT_H
# include FT_INTERNAL_POSTSCRIPT_NAMES_H
# include FT_INTERNAL_POSTSCRIPT_HINTS_H
# include "cffobjs.h"
# include "cffload.h"
@ -43,6 +44,178 @@
# define FT_COMPONENT trace_cffobjs
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/* note that we store the global hints in the size's "internal" root */
/* field */
/* */
/*************************************************************************/
static PSH_Globals_Funcs
CFF_Size_Get_Globals_Funcs ( CFF_Size size )
{
CFF_Face face = ( CFF_Face ) size - > face ;
CFF_Font * font = face - > extra . data ;
PSHinter_Interface * pshinter = font - > pshinter ;
FT_Module module ;
module = FT_Get_Module ( size - > face - > driver - > root . library ,
" pshinter " ) ;
return ( module & & pshinter & & pshinter - > get_globals_funcs )
? pshinter - > get_globals_funcs ( module )
: 0 ;
}
FT_LOCAL_DEF void
CFF_Size_Done ( CFF_Size size )
{
if ( size - > internal )
{
PSH_Globals_Funcs funcs ;
funcs = CFF_Size_Get_Globals_Funcs ( size ) ;
if ( funcs )
funcs - > destroy ( ( PSH_Globals ) size - > internal ) ;
size - > internal = 0 ;
}
}
FT_LOCAL_DEF FT_Error
CFF_Size_Init ( CFF_Size size )
{
FT_Error error = 0 ;
PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs ( size ) ;
if ( funcs )
{
PSH_Globals globals ;
CFF_Face face = ( CFF_Face ) size - > face ;
CFF_Font * font = face - > extra . data ;
CFF_SubFont * subfont = & font - > top_font ;
CFF_Private * cpriv = & subfont - > private_dict ;
T1_Private priv ;
/* IMPORTANT: the CFF and Type1 private dictionaries have */
/* slightly different structures, we need to */
/* synthetize a type1 dictionary on the fly here !! */
{
FT_UInt n , count ;
MEM_Set ( & priv , 0 , sizeof ( priv ) ) ;
count = priv . num_blue_values = cpriv - > num_blue_values ;
for ( n = 0 ; n < count ; n + + )
priv . blue_values [ n ] = cpriv - > blue_values [ n ] ;
count = priv . num_other_blues = cpriv - > num_other_blues ;
for ( n = 0 ; n < count ; n + + )
priv . other_blues [ n ] = cpriv - > other_blues [ n ] ;
count = priv . num_family_blues = cpriv - > num_family_blues ;
for ( n = 0 ; n < count ; n + + )
priv . family_blues [ n ] = cpriv - > family_blues [ n ] ;
count = priv . num_family_other_blues = cpriv - > num_family_other_blues ;
for ( n = 0 ; n < count ; n + + )
priv . family_other_blues [ n ] = cpriv - > family_other_blues [ n ] ;
priv . blue_scale = cpriv - > blue_scale ;
priv . blue_shift = cpriv - > blue_shift ;
priv . blue_fuzz = cpriv - > blue_fuzz ;
priv . standard_width [ 0 ] = ( FT_UShort ) cpriv - > standard_width ;
priv . standard_height [ 0 ] = ( FT_UShort ) cpriv - > standard_height ;
count = priv . num_snap_widths = cpriv - > num_snap_widths ;
for ( n = 0 ; n < count ; n + + )
priv . snap_widths [ n ] = cpriv - > snap_widths [ n ] ;
count = priv . num_snap_heights = cpriv - > num_snap_heights ;
for ( n = 0 ; n < count ; n + + )
priv . snap_heights [ n ] = cpriv - > snap_heights [ n ] ;
priv . force_bold = cpriv - > force_bold ;
priv . language_group = cpriv - > language_group ;
priv . lenIV = cpriv - > lenIV ;
}
error = funcs - > create ( size - > face - > memory , & priv , & globals ) ;
if ( ! error )
size - > internal = ( FT_Size_Internal ) ( void * ) globals ;
}
return error ;
}
FT_LOCAL_DEF FT_Error
CFF_Size_Reset ( CFF_Size size )
{
PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs ( size ) ;
FT_Error error = 0 ;
if ( funcs )
error = funcs - > set_scale ( ( PSH_Globals ) size - > internal ,
size - > metrics . x_scale ,
size - > metrics . y_scale ,
0 , 0 ) ;
return error ;
}
/*************************************************************************/
/* */
/* SLOT FUNCTIONS */
/* */
/*************************************************************************/
FT_LOCAL_DEF void
CFF_GlyphSlot_Done ( CFF_GlyphSlot slot )
{
slot - > root . internal - > glyph_hints = 0 ;
}
FT_LOCAL_DEF FT_Error
CFF_GlyphSlot_Init ( CFF_GlyphSlot slot )
{
CFF_Face face = ( CFF_Face ) slot - > root . face ;
CFF_Font * font = face - > extra . data ;
PSHinter_Interface * pshinter = font - > pshinter ;
if ( pshinter )
{
FT_Module module ;
module = FT_Get_Module ( slot - > root . face - > driver - > root . library , " pshinter " ) ;
if ( module )
{
T2_Hints_Funcs funcs ;
funcs = pshinter - > get_t2_funcs ( module ) ;
slot - > root . internal - > glyph_hints = ( void * ) funcs ;
}
}
return 0 ;
}
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
@ -240,7 +413,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Init_ Face */
/* CFF_Face_Init */
/* */
/* <Description> */
/* Initializes a given OpenType face object. */
@ -261,7 +434,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF FT_Error
CFF_Init_ Face ( FT_Stream stream ,
CFF_Face_Init ( FT_Stream stream ,
CFF_Face face ,
FT_Int face_index ,
FT_Int num_params ,
@ -270,6 +443,7 @@
FT_Error error ;
SFNT_Interface * sfnt ;
PSNames_Interface * psnames ;
PSHinter_Interface * pshinter ;
FT_Bool pure_cff = 1 ;
FT_Bool sfnt_format = 0 ;
@ -282,6 +456,9 @@
psnames = ( PSNames_Interface * ) FT_Get_Module_Interface (
face - > root . driver - > root . library , " psnames " ) ;
pshinter = ( PSHinter_Interface * ) FT_Get_Module_Interface (
face - > root . driver - > root . library , " pshinter " ) ;
/* create input stream from resource */
if ( FILE_Seek ( 0 ) )
goto Exit ;
@ -356,10 +533,14 @@
if ( error )
goto Exit ;
cff - > pshinter = pshinter ;
/* Complement the root flags with some interesting information. */
/* Note that this is only necessary for pure CFF and CEF fonts. */
root = & face - > root ;
root - > num_glyphs = cff - > num_glyphs ;
if ( pure_cff )
{
CFF_Font_Dict * dict = & cff - > top_font . font_dict ;
@ -368,7 +549,7 @@
/* we need the `PSNames' module for pure-CFF and CEF formats */
if ( ! psnames )
{
FT_ERROR ( ( " CFF_Init_ Face: " ) ) ;
FT_ERROR ( ( " CFF_Face_Init : " ) ) ;
FT_ERROR ( ( " cannot open CFF & CEF fonts \n " ) ) ;
FT_ERROR ( ( " " ) ) ;
FT_ERROR ( ( " without the `PSNames' module \n " ) ) ;
@ -503,7 +684,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Done_ Face */
/* CFF_Face_Don e */
/* */
/* <Description> */
/* Finalizes a given face object. */
@ -512,7 +693,7 @@
/* face :: A pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF void
CFF_Done_ Face ( CFF_Face face )
CFF_Face_Don e ( CFF_Face face )
{
FT_Memory memory = face - > root . memory ;
SFNT_Interface * sfnt = ( SFNT_Interface * ) face - > sfnt ;
@ -537,7 +718,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Init_ Driver */
/* CFF_Driver_Init */
/* */
/* <Description> */
/* Initializes a given OpenType driver object. */
@ -549,7 +730,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF FT_Error
CFF_Init_ Driver ( CFF_Driver driver )
CFF_Driver_Init ( CFF_Driver driver )
{
/* init extension registry if needed */
@ -570,7 +751,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Done_D river */
/* CFF_Driver_Done */
/* */
/* <Description> */
/* Finalizes a given OpenType driver. */
@ -579,7 +760,7 @@
/* driver :: A handle to the target OpenType driver. */
/* */
FT_LOCAL_DEF void
CFF_Done_D river ( CFF_Driver driver )
CFF_Driver_Done ( CFF_Driver driver )
{
/* destroy extensions registry if needed */