forked from minhngoc25a/freetype2
* src/psaux/t1cmap.h, src/psaux/t1cmap.c, src/type1/t1cmap.h,
src/type1/t1cmap.c: updating and moving the Type 1 FT_CMap support from "src/type1" to "src/psaux" since it's going to be shared by the Type 1 and CID font drivers.. * src/psaux/Jamfile, src/psaux/psaux.c, src/psaux/psauxmod.c, src/psaux/rules.mk, include/freetype/internal/psaux.h: added support for Type 1 FT_CMaps.
This commit is contained in:
parent
1eae664342
commit
7884957c9b
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2002-03-21 David Turner <david@freetype.org>
|
||||
|
||||
* src/base/ftobjs.c, src/pcf/pcfdriver.c, src/pcf/pcfread.c: updated
|
||||
to new FT_CMap definitions
|
||||
|
||||
* src/psaux/t1cmap.h, src/psaux/t1cmap.c, src/type1/t1cmap.h,
|
||||
src/type1/t1cmap.c: updating and moving the Type 1 FT_CMap support
|
||||
from "src/type1" to "src/psaux" since it's going to be shared
|
||||
by the Type 1 and CID font drivers..
|
||||
|
||||
* src/psaux/Jamfile, src/psaux/psaux.c, src/psaux/psauxmod.c,
|
||||
src/psaux/rules.mk, include/freetype/internal/psaux.h: added support
|
||||
for Type 1 FT_CMaps.
|
||||
|
||||
2002-03-20 David Turner <david@freetype.org>
|
||||
|
||||
* src/base/ftgloadr.c (FT_GlyphLoader_CheckSubGlyphs): fixed a memory
|
||||
|
|
|
@ -651,6 +651,25 @@ FT_BEGIN_HEADER
|
|||
|
||||
} T1_DecoderRec;
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** TYPE1 CHARMAPS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes;
|
||||
|
||||
typedef struct T1_CMap_ClassesRec_
|
||||
{
|
||||
FT_CMap_Class standard;
|
||||
FT_CMap_Class expert;
|
||||
FT_CMap_Class custom;
|
||||
FT_CMap_Class unicode;
|
||||
|
||||
} T1_CMap_ClassesRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
@ -660,7 +679,7 @@ FT_BEGIN_HEADER
|
|||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
typedef struct PSAux_Interface_
|
||||
typedef struct PSAux_ServiceRec_
|
||||
{
|
||||
const PS_Table_Funcs ps_table_funcs;
|
||||
const PS_Parser_Funcs ps_parser_funcs;
|
||||
|
@ -672,9 +691,12 @@ FT_BEGIN_HEADER
|
|||
FT_Offset length,
|
||||
FT_UShort seed );
|
||||
|
||||
} PSAux_Interface;
|
||||
T1_CMap_Classes t1_cmap_classes;
|
||||
|
||||
typedef PSAux_Interface* PSAux_Service;
|
||||
} PSAux_ServiceRec, *PSAux_Service;
|
||||
|
||||
/* backwards-compatible type definition */
|
||||
typedef PSAux_ServiceRec PSAux_Interface;
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
|
|
@ -37,6 +37,198 @@ THE SOFTWARE.
|
|||
|
||||
#include "pcferror.h"
|
||||
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_pcfread
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_CMAPS
|
||||
|
||||
typedef struct PCF_CMapRec_
|
||||
{
|
||||
FT_CMapRec cmap;
|
||||
FT_UInt num_encodings;
|
||||
PCF_Encoding encodings;
|
||||
|
||||
} PCF_CMapRec, *PCF_CMap;
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_cmap_init( PCF_CMap cmap )
|
||||
{
|
||||
PCF_Face face = (PCF_Face) FT_CMAP_FACE(cmap);
|
||||
|
||||
cmap->num_encodings = (FT_UInt) face->nencodings;
|
||||
cmap->encodings = face->encodings;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
pcf_cmap_done( PCF_CMap cmap )
|
||||
{
|
||||
cmap->encodings = NULL;
|
||||
cmap->num_encodings = 0;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
pcf_cmap_char_index( FT_CMap cmap,
|
||||
FT_UInt32 charcode )
|
||||
{
|
||||
PCF_Encoding encoding = cmap->encodings;
|
||||
FT_UInt min, max, mid;
|
||||
FT_UInt result = 0;
|
||||
|
||||
min = 0;
|
||||
max = cmap->num_encodings;
|
||||
|
||||
while ( min < max )
|
||||
{
|
||||
FT_UInt32 code;
|
||||
|
||||
mid = ( min + max ) >> 1;
|
||||
code = encodings[mid].enc;
|
||||
|
||||
if ( charcode == code )
|
||||
{
|
||||
result = encodings[mid].glyph;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( charcode < code )
|
||||
max = mid;
|
||||
else
|
||||
min = mid+1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
pcf_cmap_char_next( PCF_CMap cmap,
|
||||
FT_UInt32 *acharcode )
|
||||
{
|
||||
PCF_Encoding encodings = cmap->encodings;
|
||||
FT_UInt min, max, mid;
|
||||
FT_UInt32 charcode = *acharcode + 1;
|
||||
FT_UInt result = 0;
|
||||
|
||||
min = 0;
|
||||
max = cmap->num_encodings;
|
||||
|
||||
while ( min < max )
|
||||
{
|
||||
FT_UInt32 code;
|
||||
|
||||
mid = ( min + max ) >> 1;
|
||||
code = encodings[mid].enc;
|
||||
|
||||
if ( charcode == code )
|
||||
{
|
||||
result = encodings[mid].glyph;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( charcode < code )
|
||||
max = mid;
|
||||
else
|
||||
min = mid+1;
|
||||
}
|
||||
|
||||
charcode = 0;
|
||||
if ( ++min < cmap->num_encodings )
|
||||
{
|
||||
charcode = encodings[min].enc;
|
||||
glyph = encodings[min].glyph;
|
||||
}
|
||||
|
||||
Exit:
|
||||
*acharcode = charcode;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE const FT_CMap_ClassRec pcf_cmap_class =
|
||||
{
|
||||
sizeof( PCF_CMapRec ),
|
||||
(FT_CMap_InitFunc) pcf_cmap_init,
|
||||
(FT_CMap_DoneFunc) pcf_cmap_done,
|
||||
(FT_CMap_CharIndexFunc) pcf_cmap_char_index,
|
||||
(FT_CMap_CharNextFunc) pcf_cmap_char_next
|
||||
};
|
||||
|
||||
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
|
||||
|
||||
static FT_UInt
|
||||
PCF_Char_Get_Index( FT_CharMap charmap,
|
||||
FT_Long char_code )
|
||||
{
|
||||
PCF_Face face = (PCF_Face)charmap->face;
|
||||
PCF_Encoding en_table = face->encodings;
|
||||
int low, high, mid;
|
||||
|
||||
|
||||
FT_TRACE4(( "get_char_index %ld\n", char_code ));
|
||||
|
||||
low = 0;
|
||||
high = face->nencodings - 1;
|
||||
while ( low <= high )
|
||||
{
|
||||
mid = ( low + high ) / 2;
|
||||
if ( char_code < en_table[mid].enc )
|
||||
high = mid - 1;
|
||||
else if ( char_code > en_table[mid].enc )
|
||||
low = mid + 1;
|
||||
else
|
||||
return en_table[mid].glyph;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static FT_Long
|
||||
PCF_Char_Get_Next( FT_CharMap charmap,
|
||||
FT_Long char_code )
|
||||
{
|
||||
PCF_Face face = (PCF_Face)charmap->face;
|
||||
PCF_Encoding en_table = face->encodings;
|
||||
int low, high, mid;
|
||||
|
||||
|
||||
FT_TRACE4(( "get_next_char %ld\n", char_code ));
|
||||
|
||||
char_code++;
|
||||
low = 0;
|
||||
high = face->nencodings - 1;
|
||||
|
||||
while ( low <= high )
|
||||
{
|
||||
mid = ( low + high ) / 2;
|
||||
if ( char_code < en_table[mid].enc )
|
||||
high = mid - 1;
|
||||
else if ( char_code > en_table[mid].enc )
|
||||
low = mid + 1;
|
||||
else
|
||||
return char_code;
|
||||
}
|
||||
|
||||
if ( high < 0 )
|
||||
high = 0;
|
||||
|
||||
while ( high < face->nencodings )
|
||||
{
|
||||
if ( en_table[high].enc >= char_code )
|
||||
return en_table[high].enc;
|
||||
high++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
|
@ -48,7 +240,7 @@ THE SOFTWARE.
|
|||
#define FT_COMPONENT trace_pcfdriver
|
||||
|
||||
|
||||
static FT_Error
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
PCF_Face_Done( PCF_Face face )
|
||||
{
|
||||
FT_Memory memory = FT_FACE_MEMORY( face );
|
||||
|
@ -86,7 +278,7 @@ THE SOFTWARE.
|
|||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
PCF_Face_Init( FT_Stream stream,
|
||||
PCF_Face face,
|
||||
FT_Int face_index,
|
||||
|
@ -104,13 +296,75 @@ THE SOFTWARE.
|
|||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
return PCF_Err_Ok;
|
||||
/* set-up charmap */
|
||||
{
|
||||
FT_String *charset_registry, *charset_encoding;
|
||||
FT_Face root = FT_FACE(face);
|
||||
FT_Bool unicode_charmap = 0;
|
||||
|
||||
|
||||
charset_registry = face->charset_registry;
|
||||
charset_encoding = face->charset_encoding;
|
||||
|
||||
if ( ( charset_registry != NULL ) &&
|
||||
( charset_encoding != NULL ) )
|
||||
{
|
||||
if ( !strcmp( face->charset_registry, "ISO10646" ) ||
|
||||
( !strcmp( face->charset_registry, "ISO8859" ) &&
|
||||
!strcmp( face->charset_encoding, "1" ) ) )
|
||||
unicode_charmap = 1;
|
||||
}
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_CMAPS
|
||||
{
|
||||
FT_CharMapRec charmap;
|
||||
|
||||
charmap.face = FT_FACE(face);
|
||||
charmap.encoding = ft_encoding_none;
|
||||
charmap.platform_id = 0;
|
||||
charmap.encoding_id = 0;
|
||||
|
||||
if ( unicode_charmap )
|
||||
{
|
||||
charmap.encoding = ft_encoding_unicode;
|
||||
charmap.platform_id = 3;
|
||||
charmap.encoding_id = 1;
|
||||
}
|
||||
|
||||
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
|
||||
}
|
||||
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
|
||||
|
||||
/* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */
|
||||
root->charmaps = &face->charmap_handle;
|
||||
root->num_charmaps = 1;
|
||||
|
||||
face->charmap.encoding = ft_encoding_none;
|
||||
face->charmap.platform_id = 0;
|
||||
face->charmap.encoding_id = 0;
|
||||
|
||||
if ( unicode_charmap )
|
||||
{
|
||||
face->charmap.encoding = ft_encoding_unicode;
|
||||
face->charmap.platform_id = 3;
|
||||
face->charmap.encoding_id = 1;
|
||||
}
|
||||
|
||||
face->charmap.face = root;
|
||||
face->charmap_handle = &face->charmap;
|
||||
root->charmap = face->charmap_handle;
|
||||
|
||||
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
|
||||
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Fail:
|
||||
FT_TRACE2(( "[not a valid PCF file]\n" ));
|
||||
PCF_Face_Done( face );
|
||||
|
||||
return PCF_Err_Unknown_File_Format; /* error */
|
||||
error = PCF_Err_Unknown_File_Format; /* error */
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,74 +510,6 @@ THE SOFTWARE.
|
|||
}
|
||||
|
||||
|
||||
static FT_UInt
|
||||
PCF_Char_Get_Index( FT_CharMap charmap,
|
||||
FT_Long char_code )
|
||||
{
|
||||
PCF_Face face = (PCF_Face)charmap->face;
|
||||
PCF_Encoding en_table = face->encodings;
|
||||
int low, high, mid;
|
||||
|
||||
|
||||
FT_TRACE4(( "get_char_index %ld\n", char_code ));
|
||||
|
||||
low = 0;
|
||||
high = face->nencodings - 1;
|
||||
while ( low <= high )
|
||||
{
|
||||
mid = ( low + high ) / 2;
|
||||
if ( char_code < en_table[mid].enc )
|
||||
high = mid - 1;
|
||||
else if ( char_code > en_table[mid].enc )
|
||||
low = mid + 1;
|
||||
else
|
||||
return en_table[mid].glyph;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static FT_Long
|
||||
PCF_Char_Get_Next( FT_CharMap charmap,
|
||||
FT_Long char_code )
|
||||
{
|
||||
PCF_Face face = (PCF_Face)charmap->face;
|
||||
PCF_Encoding en_table = face->encodings;
|
||||
int low, high, mid;
|
||||
|
||||
|
||||
FT_TRACE4(( "get_next_char %ld\n", char_code ));
|
||||
|
||||
char_code++;
|
||||
low = 0;
|
||||
high = face->nencodings - 1;
|
||||
|
||||
while ( low <= high )
|
||||
{
|
||||
mid = ( low + high ) / 2;
|
||||
if ( char_code < en_table[mid].enc )
|
||||
high = mid - 1;
|
||||
else if ( char_code > en_table[mid].enc )
|
||||
low = mid + 1;
|
||||
else
|
||||
return char_code;
|
||||
}
|
||||
|
||||
if ( high < 0 )
|
||||
high = 0;
|
||||
|
||||
while ( high < face->nencodings )
|
||||
{
|
||||
if ( en_table[high].enc >= char_code )
|
||||
return en_table[high].enc;
|
||||
high++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE_DEF
|
||||
const FT_Driver_ClassRec pcf_driver_class =
|
||||
{
|
||||
|
@ -353,17 +539,26 @@ THE SOFTWARE.
|
|||
(FT_Slot_InitFunc)0,
|
||||
(FT_Slot_DoneFunc)0,
|
||||
|
||||
(FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
|
||||
(FT_Size_ResetPixelsFunc)PCF_Set_Pixel_Size,
|
||||
(FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
|
||||
(FT_Size_ResetPixelsFunc) PCF_Set_Pixel_Size,
|
||||
|
||||
(FT_Slot_LoadFunc) PCF_Glyph_Load,
|
||||
(FT_Slot_LoadFunc) PCF_Glyph_Load,
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_USE_CMAPS
|
||||
(FT_CharMap_CharIndexFunc) PCF_Char_Get_Index,
|
||||
#else
|
||||
(FT_CharMap_CharNextFunc) 0,
|
||||
#endif
|
||||
|
||||
(FT_Face_GetKerningFunc) 0,
|
||||
(FT_Face_AttachFunc) 0,
|
||||
(FT_Face_AttachFunc) 0,
|
||||
(FT_Face_GetAdvancesFunc) 0,
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_USE_CMAPS
|
||||
(FT_CharMap_CharNextFunc) PCF_Char_Get_Next,
|
||||
#else
|
||||
(FT_CharMap_CharNextFunc) 0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -866,11 +866,11 @@ THE SOFTWARE.
|
|||
|
||||
error = pcf_read_TOC( stream, face );
|
||||
if ( error )
|
||||
return error;
|
||||
goto Exit;
|
||||
|
||||
error = pcf_get_properties( stream, face );
|
||||
if ( error )
|
||||
return error;;
|
||||
goto Exit;
|
||||
|
||||
/* Use the old accelerators if no BDF accelerators are in the file. */
|
||||
hasBDFAccelerators = pcf_has_table_type( face->toc.tables,
|
||||
|
@ -880,30 +880,30 @@ THE SOFTWARE.
|
|||
{
|
||||
error = pcf_get_accel( stream, face, PCF_ACCELERATORS );
|
||||
if ( error )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* metrics */
|
||||
error = pcf_get_metrics( stream, face );
|
||||
if ( error )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
/* bitmaps */
|
||||
error = pcf_get_bitmaps( stream, face );
|
||||
if ( error )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
/* encodings */
|
||||
error = pcf_get_encodings( stream, face );
|
||||
if ( error )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */
|
||||
if ( hasBDFAccelerators )
|
||||
{
|
||||
error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS );
|
||||
if ( error )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* XXX: TO DO: inkmetrics and glyph_names are missing */
|
||||
|
@ -958,7 +958,7 @@ THE SOFTWARE.
|
|||
|
||||
|
||||
if ( ALLOC( root->family_name, l * sizeof ( char ) ) )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
strcpy( root->family_name, prop->value.atom );
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ THE SOFTWARE.
|
|||
|
||||
root->num_fixed_sizes = 1;
|
||||
if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
prop = pcf_find_property( face, "PIXEL_SIZE" );
|
||||
if ( prop != NULL )
|
||||
|
@ -977,12 +977,6 @@ THE SOFTWARE.
|
|||
root->available_sizes->height =
|
||||
root->available_sizes->width = (FT_Short)( prop->value.integer );
|
||||
|
||||
#if 0 /* average width property support removed until maturation */
|
||||
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
|
||||
if ( prop != NULL )
|
||||
root->available_sizes->width = (FT_Short)( prop->value.integer / 10 );
|
||||
#endif
|
||||
|
||||
size_set = 1;
|
||||
}
|
||||
else
|
||||
|
@ -1003,12 +997,6 @@ THE SOFTWARE.
|
|||
(FT_Short)( prop->value.integer *
|
||||
yres->value.integer / 720 );
|
||||
|
||||
#if 0 /* average width property support removed until maturation */
|
||||
if ( avgw != NULL )
|
||||
root->available_sizes->width =
|
||||
(FT_Short)( avgw->value.integer / 10 );
|
||||
else
|
||||
#endif
|
||||
root->available_sizes->width =
|
||||
(FT_Short)( prop->value.integer *
|
||||
xres->value.integer / 720 );
|
||||
|
@ -1020,28 +1008,19 @@ THE SOFTWARE.
|
|||
|
||||
if (size_set == 0 )
|
||||
{
|
||||
#if 0
|
||||
printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
|
||||
#endif
|
||||
root->available_sizes->width = 12;
|
||||
root->available_sizes->height = 12;
|
||||
}
|
||||
|
||||
/* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */
|
||||
root->charmaps = &face->charmap_handle;
|
||||
root->num_charmaps = 1;
|
||||
|
||||
face->charmap.encoding = ft_encoding_none;
|
||||
face->charmap.platform_id = 0;
|
||||
face->charmap.encoding_id = 0;
|
||||
|
||||
/* set-up charset */
|
||||
{
|
||||
PCF_Property charset_registry = 0, charset_encoding = 0;
|
||||
|
||||
|
||||
FT_Bool unicode_charmap = 0;
|
||||
|
||||
|
||||
charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
|
||||
charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );
|
||||
|
||||
|
||||
if ( ( charset_registry != NULL ) &&
|
||||
( charset_encoding != NULL ) )
|
||||
{
|
||||
|
@ -1051,34 +1030,29 @@ THE SOFTWARE.
|
|||
if ( ALLOC( face->charset_encoding,
|
||||
( strlen( charset_encoding->value.atom ) + 1 ) *
|
||||
sizeof ( char ) ) )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
if ( ALLOC( face->charset_registry,
|
||||
( strlen( charset_registry->value.atom ) + 1 ) *
|
||||
sizeof ( char ) ) )
|
||||
goto Bail;
|
||||
goto Exit;
|
||||
|
||||
strcpy( face->charset_registry, charset_registry->value.atom );
|
||||
strcpy( face->charset_encoding, charset_encoding->value.atom );
|
||||
|
||||
if ( !strcmp( face->charset_registry, "ISO10646" ) ||
|
||||
( !strcmp( face->charset_registry, "ISO8859" ) &&
|
||||
!strcmp( face->charset_encoding, "1" ) ) )
|
||||
{
|
||||
face->charmap.encoding = ft_encoding_unicode;
|
||||
face->charmap.platform_id = 3;
|
||||
face->charmap.encoding_id = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
face->charmap.face = root;
|
||||
face->charmap_handle = &face->charmap;
|
||||
root->charmap = face->charmap_handle;
|
||||
}
|
||||
return PCF_Err_Ok;
|
||||
|
||||
Bail:
|
||||
return PCF_Err_Invalid_File_Format;
|
||||
|
||||
Exit:
|
||||
if (error)
|
||||
{
|
||||
/* this is done to respect the behaviour of the original */
|
||||
/* PCF font driver.. */
|
||||
error = PCF_Err_Invalid_File_Format;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ SubDirHdrs [ FT2_SubDir src psaux ] ;
|
|||
|
||||
if $(FT2_MULTI)
|
||||
{
|
||||
_sources = psauxmod psobjs t1decode ;
|
||||
_sources = psauxmod psobjs t1decode t1cmap ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "psobjs.c"
|
||||
#include "psauxmod.c"
|
||||
#include "t1decode.c"
|
||||
#include "t1cmap.c"
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "psauxmod.h"
|
||||
#include "psobjs.h"
|
||||
#include "t1decode.h"
|
||||
#include "t1cmap.h"
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE_DEF
|
||||
|
@ -73,6 +74,16 @@
|
|||
};
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE_DEF
|
||||
const T1_CMap_ClassesRec t1_cmap_classes =
|
||||
{
|
||||
&t1_cmap_standard_class_rec,
|
||||
&t1_cmap_expert_class_rec,
|
||||
&t1_cmap_custom_class_rec,
|
||||
&t1_cmap_unicode_class_rec
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
const PSAux_Interface psaux_interface =
|
||||
{
|
||||
|
@ -81,7 +92,9 @@
|
|||
&t1_builder_funcs,
|
||||
&t1_decoder_funcs,
|
||||
|
||||
T1_Decrypt
|
||||
T1_Decrypt,
|
||||
|
||||
(const T1_CMap_ClassesRec*) &t1_cmap_classes,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ PSAUX_COMPILE := $(FT_COMPILE) $I$(PSAUX_DIR)
|
|||
#
|
||||
PSAUX_DRV_SRC := $(PSAUX_DIR_)psobjs.c \
|
||||
$(PSAUX_DIR_)t1decode.c \
|
||||
$(PSAUX_DIR_)t1cmap.c \
|
||||
$(PSAUX_DIR_)psauxmod.c
|
||||
|
||||
# PSAUX driver headers
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include "t1cmap.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include FT_INTERNAL_DEBUG_H
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
@ -8,18 +11,18 @@
|
|||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
||||
static( void )
|
||||
static void
|
||||
t1_cmap_std_init( T1_CMapStd cmap,
|
||||
FT_Int is_expert )
|
||||
{
|
||||
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
|
||||
PSNames_Service psnames = face->psnames;
|
||||
|
||||
cmap->num_glyphs = face->type1.num_glyphs;
|
||||
cmap->glyph_names = face->type1.glyph_names;
|
||||
cmap->sid_strings = sid_strings;
|
||||
cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
|
||||
: psnames->adobe_std_encoding;
|
||||
cmap->num_glyphs = face->type1.num_glyphs;
|
||||
cmap->glyph_names = face->type1.glyph_names;
|
||||
cmap->sid_to_string = psnames->adobe_std_strings;
|
||||
cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
|
||||
: psnames->adobe_std_encoding;
|
||||
|
||||
FT_ASSERT( cmap->code_to_sid != NULL );
|
||||
}
|
||||
|
@ -28,10 +31,10 @@
|
|||
FT_CALLBACK_DEF( void )
|
||||
t1_cmap_std_done( T1_CMapStd cmap )
|
||||
{
|
||||
cmap->num_glyphs = 0;
|
||||
cmap->glyph_names = NULL;
|
||||
cmap->sid_strings = NULL;
|
||||
cmap->code_to_sid = NULL;
|
||||
cmap->num_glyphs = 0;
|
||||
cmap->glyph_names = NULL;
|
||||
cmap->sid_to_string = NULL;
|
||||
cmap->code_to_sid = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,13 +46,12 @@
|
|||
|
||||
if ( char_code < 256 )
|
||||
{
|
||||
FT_UInt code;
|
||||
FT_UInt code, n;
|
||||
const char* glyph_name;
|
||||
FT_Int n;
|
||||
|
||||
/* conver character code to Adobe SID string */
|
||||
code = cmap->code_to_sid[ char_code ];
|
||||
glyph_name = cmap->adobe_sid_strings[ code ];
|
||||
glyph_name = cmap->sid_to_string( code );
|
||||
|
||||
/* look for the corresponding glyph name */
|
||||
for ( n = 0; n < cmap->num_glyphs; n++ )
|
||||
|
@ -77,7 +79,7 @@
|
|||
|
||||
while ( char_code < 256 )
|
||||
{
|
||||
result = t1_cmap_standard_char_index( cmap, char_code );
|
||||
result = t1_cmap_std_char_index( cmap, char_code );
|
||||
if ( result != 0 )
|
||||
goto Exit;
|
||||
|
||||
|
@ -99,46 +101,39 @@
|
|||
}
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE const T1_CMap_ClassRec
|
||||
FT_LOCAL_DEF( const FT_CMap_ClassRec )
|
||||
t1_cmap_standard_class_rec =
|
||||
{
|
||||
sizeof( T1_CMapStdRec ),
|
||||
|
||||
t1_cmap_standard_init,
|
||||
t1_cmap_std_done,
|
||||
t1_cmap_std_char_index,
|
||||
t1_cmap_std_char_next
|
||||
(FT_CMap_InitFunc) t1_cmap_standard_init,
|
||||
(FT_CMap_DoneFunc) t1_cmap_std_done,
|
||||
(FT_CMap_CharIndexFunc) t1_cmap_std_char_index,
|
||||
(FT_CMap_CharNextFunc) t1_cmap_std_char_next
|
||||
};
|
||||
|
||||
|
||||
FT_LOCAL_DEF( T1_CMap_Class )
|
||||
t1_cmap_standard_class = &t1_cmap_standard_class_rec;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
t1_cmap_expert_init( T1_CMapStd cmap )
|
||||
{
|
||||
t1_cmap_std_init( cmap, 1 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
FT_CALLBACK_TABLE const FT_CMap_ClassRec
|
||||
FT_LOCAL_DEF( const FT_CMap_ClassRec )
|
||||
t1_cmap_expert_class_rec =
|
||||
{
|
||||
sizeof( T1_CMapStdRec ),
|
||||
|
||||
t1_cmap_expert_init,
|
||||
t1_cmap_std_done,
|
||||
t1_cmap_std_char_index,
|
||||
t1_cmap_std_char_next
|
||||
(FT_CMap_InitFunc) t1_cmap_expert_init,
|
||||
(FT_CMap_DoneFunc) t1_cmap_std_done,
|
||||
(FT_CMap_CharIndexFunc) t1_cmap_std_char_index,
|
||||
(FT_CMap_CharNextFunc) t1_cmap_std_char_next
|
||||
};
|
||||
|
||||
|
||||
FT_LOCAL_DEF( FT_CMap_Class )
|
||||
t1_cmap_expert_class = &t1_cmap_expert_class_rec;
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -153,8 +148,8 @@
|
|||
FT_CALLBACK_DEF( FT_Error )
|
||||
t1_cmap_custom_init( T1_CMapCustom cmap )
|
||||
{
|
||||
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
|
||||
T1_Encoding encoding = face->type1.encoding;
|
||||
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
|
||||
T1_Encoding encoding = &face->type1.encoding;
|
||||
|
||||
cmap->first = encoding->code_first;
|
||||
cmap->count = (FT_UInt)(encoding->code_last - cmap->first + 1);
|
||||
|
@ -192,8 +187,8 @@
|
|||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
t1_cmap_custom_char_next( T1_CMapCustion cmap,
|
||||
FT_UInt32 *pchar_code )
|
||||
t1_cmap_custom_char_next( T1_CMapCustom cmap,
|
||||
FT_UInt32 *pchar_code )
|
||||
{
|
||||
FT_UInt result = 0;
|
||||
FT_UInt32 char_code = *pchar_code;
|
||||
|
@ -205,7 +200,7 @@
|
|||
char_code = cmap->first;
|
||||
|
||||
index = (FT_UInt32)( char_code - cmap->first );
|
||||
while ( index < cmap->count; index++, char_code++ )
|
||||
for ( ; index < cmap->count; index++, char_code++ )
|
||||
{
|
||||
result = cmap->indices[index];
|
||||
if ( result != 0 )
|
||||
|
@ -220,19 +215,17 @@
|
|||
}
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE const FT_CMap_ClassRec
|
||||
FT_LOCAL_DEF( const FT_CMap_ClassRec )
|
||||
t1_cmap_custom_class_rec =
|
||||
{
|
||||
sizeof( T1_CMapCustomRec ),
|
||||
t1_cmap_custom_init,
|
||||
t1_cmap_custom_done,
|
||||
t1_cmap_custom_char_index,
|
||||
t1_cmap_custom_char_next
|
||||
(FT_CMap_InitFunc) t1_cmap_custom_init,
|
||||
(FT_CMap_DoneFunc) t1_cmap_custom_done,
|
||||
(FT_CMap_CharIndexFunc) t1_cmap_custom_char_index,
|
||||
(FT_CMap_CharNextFunc) t1_cmap_custom_char_next
|
||||
};
|
||||
|
||||
|
||||
FT_LOCAL_DEF( FT_CMap_Class )
|
||||
t1_cmap_custom_class = &t1_cmap_custom_class_rec;
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -243,14 +236,32 @@
|
|||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
||||
FT_CALLBACK_DEF( FT_Int )
|
||||
t1_cmap_uni_pair_compare( const void* pair1,
|
||||
const void* pair2 )
|
||||
{
|
||||
FT_UInt32 u1 = ((T1_CMapUniPair)pair1)->unicode;
|
||||
FT_UInt32 u2 = ((T1_CMapUniPair)pair2)->unicode;
|
||||
|
||||
if ( u1 < u2 )
|
||||
return -1;
|
||||
|
||||
if ( u1 > u2 )
|
||||
return +1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
t1_cmap_unicode_init( T1_CMapUnicode cmap )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_UInt count;
|
||||
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
|
||||
FT_Memory memory = FT_FACE_MEMORY(face);
|
||||
FT_Error error;
|
||||
FT_UInt count;
|
||||
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
|
||||
FT_Memory memory = FT_FACE_MEMORY(face);
|
||||
PSNames_Service psnames = face->psnames;
|
||||
|
||||
cmap->num_pairs = 0;
|
||||
cmap->pairs = NULL;
|
||||
|
@ -272,7 +283,7 @@
|
|||
/* build unsorted pair table by matching glyph names */
|
||||
if ( gname )
|
||||
{
|
||||
uni_code = PS_Unicode_Value( gname );
|
||||
uni_code = psnames->unicode_value( gname );
|
||||
|
||||
if ( uni_code != 0 )
|
||||
{
|
||||
|
@ -281,28 +292,32 @@
|
|||
pair++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( new_count == 0 )
|
||||
}
|
||||
|
||||
new_count = (FT_UInt)( pair - cmap->pairs );
|
||||
if ( new_count == 0 )
|
||||
{
|
||||
/* there are no unicode characters in here !! */
|
||||
FREE( cmap->pairs );
|
||||
error = FT_Err_Invalid_Argument;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* re-allocate if the new array is much smaller than the original */
|
||||
/* one.. */
|
||||
if ( new_count != count && new_count < count/2 )
|
||||
{
|
||||
/* there are no unicode characters in here !! */
|
||||
FREE( cmap->pairs );
|
||||
error = FT_Err_Invalid_Argument;
|
||||
(void)REALLOC_ARRAY( cmap->pairs, count, new_count, T1_CMapUniPairRec );
|
||||
error = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* re-allocate if the new array is much smaller than the original */
|
||||
/* one.. */
|
||||
if ( new_count != count && new_count < count/2 )
|
||||
REALLOC_ARRAY( cmap->pairs, count, new_count, T1_CMapUniPairRec )
|
||||
|
||||
/* sort the pairs table to allow efficient binary searches */
|
||||
qsort( cmap->pairs,
|
||||
new_count,
|
||||
sizeof(T1_CMapUniPairRec),
|
||||
t1_cmap_uni_pair_compare );
|
||||
/* sort the pairs table to allow efficient binary searches */
|
||||
qsort( cmap->pairs,
|
||||
new_count,
|
||||
sizeof(T1_CMapUniPairRec),
|
||||
t1_cmap_uni_pair_compare );
|
||||
|
||||
cmap->num_pairs = new_count;
|
||||
}
|
||||
cmap->num_pairs = new_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +328,7 @@
|
|||
FT_CALLBACK_DEF( void )
|
||||
t1_cmap_unicode_done( T1_CMapUnicode cmap )
|
||||
{
|
||||
FT_Face face = FT_CMAP_FACE(cmap);
|
||||
FT_Face face = FT_CMAP_FACE(cmap);
|
||||
FT_Memory memory = FT_FACE_MEMORY(face);
|
||||
|
||||
FREE( cmap->pairs );
|
||||
|
@ -321,6 +336,7 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
t1_cmap_unicode_char_index( T1_CMapUnicode cmap,
|
||||
FT_UInt32 char_code )
|
||||
|
@ -351,7 +367,8 @@
|
|||
t1_cmap_unicode_char_next( T1_CMapUnicode cmap,
|
||||
FT_UInt32 *pchar_code )
|
||||
{
|
||||
FT_UInt32 char_code = *pchar_code + 1;
|
||||
FT_UInt result = 0;
|
||||
FT_UInt32 char_code = *pchar_code + 1;
|
||||
|
||||
Restart:
|
||||
{
|
||||
|
@ -362,7 +379,7 @@
|
|||
|
||||
while ( min < max )
|
||||
{
|
||||
mid = min + (max - min)/2;
|
||||
mid = min + ((max - min) >> 1);
|
||||
pair = cmap->pairs + mid;
|
||||
|
||||
if ( pair->unicode == char_code )
|
||||
|
@ -386,7 +403,7 @@
|
|||
|
||||
if ( min < cmap->num_pairs )
|
||||
{
|
||||
pair = cmap->num_pairs + min;
|
||||
pair = cmap->pairs + min;
|
||||
result = pair->gindex;
|
||||
if ( result != 0 )
|
||||
char_code = pair->unicode;
|
||||
|
@ -403,8 +420,14 @@
|
|||
t1_cmap_unicode_class_rec =
|
||||
{
|
||||
sizeof( T1_CMapUnicodeRec ),
|
||||
t1_cmap_unicode_init,
|
||||
t1_cmap_unicode_done,
|
||||
t1_cmap_unicode_char_index,
|
||||
t1_cmap_unicode_char_next
|
||||
(FT_CMap_InitFunc) t1_cmap_unicode_init,
|
||||
(FT_CMap_DoneFunc) t1_cmap_unicode_done,
|
||||
(FT_CMap_CharIndexFunc) t1_cmap_unicode_char_index,
|
||||
(FT_CMap_CharNextFunc) t1_cmap_unicode_char_next
|
||||
};
|
||||
|
||||
|
||||
|
||||
FT_LOCAL_DEF( const FT_CMap_Class )
|
||||
t1_cmap_unicode_class = &t1_cmap_unicode_class_rec;
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#ifndef __FT_TYPE1_CMAP_H__
|
||||
#define __FT_TYPE1_CMAP_H__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_INTERNAL_OBJECTS_H
|
||||
#include FT_INTERNAL_TYPE1_TYPES_H
|
||||
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -16,22 +21,21 @@ FT_BEGIN_HEADER
|
|||
|
||||
typedef struct T1_CMapStdRec_
|
||||
{
|
||||
FT_CMapRec cmap;
|
||||
FT_CMapRec cmap;
|
||||
|
||||
const FT_UShort* charcode_to_sid;
|
||||
const char* const* adobe_sid_strings;
|
||||
const FT_UShort* code_to_sid;
|
||||
PS_Adobe_Std_Strings_Func sid_to_string;
|
||||
|
||||
FT_UInt num_glyphs;
|
||||
const char** glyph_names;
|
||||
|
||||
FT_UInt num_glyphs;
|
||||
const char* const* glyph_names;
|
||||
|
||||
} T1_CMapStdRec;
|
||||
|
||||
|
||||
FT_LOCAL( FT_CMap_Class ) t1_cmap_standard_class;
|
||||
|
||||
FT_LOCAL( FT_CMap_Class ) t1_cmap_expert_class;
|
||||
|
||||
FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_standard_class_rec;
|
||||
|
||||
FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_expert_class_rec;
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***** *****/
|
||||
|
@ -47,13 +51,12 @@ FT_BEGIN_HEADER
|
|||
FT_CMapRec cmap;
|
||||
FT_UInt first;
|
||||
FT_UInt count;
|
||||
FT_UInt* indices;
|
||||
FT_UShort* indices;
|
||||
|
||||
} T1_CMapCustomRec;
|
||||
|
||||
|
||||
FT_LOCAL( FT_CMap_Class ) t1_cmap_custom_class;
|
||||
|
||||
FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_custom_class_rec;
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***** *****/
|
||||
|
@ -82,7 +85,7 @@ FT_BEGIN_HEADER
|
|||
} T1_CMapUnicodeRec;
|
||||
|
||||
|
||||
FT_LOCAL( FT_CMap_Class ) t1_cmap_unicode_class;
|
||||
FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_unicode_class_rec;
|
||||
|
||||
/* */
|
||||
|
||||
|
|
Loading…
Reference in New Issue