Drop Type42 support

This commit is contained in:
UnknownShadow200 2018-10-06 20:54:51 +10:00
parent 509458ad1a
commit 8287ecfeb6
16 changed files with 0 additions and 3014 deletions

View File

@ -342,7 +342,6 @@
<ClCompile Include="_truetype.c" /> <ClCompile Include="_truetype.c" />
<ClCompile Include="_type1.c" /> <ClCompile Include="_type1.c" />
<ClCompile Include="_type1cid.c" /> <ClCompile Include="_type1cid.c" />
<ClCompile Include="_type42.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -575,9 +575,6 @@
<ClCompile Include="_type1cid.c"> <ClCompile Include="_type1cid.c">
<Filter>Source Files\Freetype</Filter> <Filter>Source Files\Freetype</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="_type42.c">
<Filter>Source Files\Freetype</Filter>
</ClCompile>
<ClCompile Include="_truetype.c"> <ClCompile Include="_truetype.c">
<Filter>Source Files\Freetype</Filter> <Filter>Source Files\Freetype</Filter>
</ClCompile> </ClCompile>

View File

@ -11,7 +11,6 @@
#include "freetype/ft2build.h" #include "freetype/ft2build.h"
#include "freetype/freetype.h" #include "freetype/freetype.h"
#include "freetype/ftsnames.h"
#include "freetype/ftmodapi.h" #include "freetype/ftmodapi.h"
#if CC_BUILD_WIN #if CC_BUILD_WIN

View File

@ -1,27 +0,0 @@
/***************************************************************************/
/* */
/* type42.c */
/* */
/* FreeType Type 42 driver component. */
/* */
/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include "freetype/ft2build.h"
#include "freetype/t42drivr.c"
#include "freetype/t42objs.c"
#include "freetype/t42parse.c"
/* END */

View File

@ -16,7 +16,6 @@ FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
FT_USE_MODULE( FT_Module_Class, psaux_module_class ) FT_USE_MODULE( FT_Module_Class, psaux_module_class )
FT_USE_MODULE( FT_Module_Class, psnames_module_class ) FT_USE_MODULE( FT_Module_Class, psnames_module_class )
FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) FT_USE_MODULE( FT_Module_Class, pshinter_module_class )

View File

@ -1,148 +0,0 @@
/***************************************************************************/
/* */
/* ftsnames.c */
/* */
/* Simple interface to access SFNT name tables (which are used */
/* to hold font names, copyright info, notices, etc.) (body). */
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "ft2build.h"
#include FT_INTERNAL_DEBUG_H
#include FT_SFNT_NAMES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_STREAM_H
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face )
{
return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
}
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname )
{
FT_Error error = FT_ERR( Invalid_Argument );
if ( aname && face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( idx < (FT_UInt)ttface->num_names )
{
TT_Name entry = ttface->name_table.names + idx;
/* load name on demand */
if ( entry->stringLength > 0 && !entry->string )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
}
aname->platform_id = entry->platformID;
aname->encoding_id = entry->encodingID;
aname->language_id = entry->languageID;
aname->name_id = entry->nameID;
aname->string = (FT_Byte*)entry->string;
aname->string_len = entry->stringLength;
error = FT_Err_Ok;
}
}
return error;
}
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_LangTag( FT_Face face,
FT_UInt langID,
FT_SfntLangTag *alangTag )
{
FT_Error error = FT_ERR( Invalid_Argument );
if ( alangTag && face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( ttface->name_table.format != 1 )
return FT_THROW( Invalid_Table );
if ( langID > 0x8000U &&
langID - 0x8000U < ttface->name_table.numLangTagRecords )
{
TT_LangTag entry = ttface->name_table.langTags +
( langID - 0x8000U );
/* load name on demand */
if ( entry->stringLength > 0 && !entry->string )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
}
alangTag->string = (FT_Byte*)entry->string;
alangTag->string_len = entry->stringLength;
error = FT_Err_Ok;
}
}
return error;
}
#endif /* TT_CONFIG_OPTION_SFNT_NAMES */
/* END */

View File

@ -1,247 +0,0 @@
/***************************************************************************/
/* */
/* ftsnames.h */
/* */
/* Simple interface to access SFNT `name' tables (which are used */
/* to hold font names, copyright info, notices, etc.) (specification). */
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef FTSNAMES_H_
#define FTSNAMES_H_
#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* sfnt_names */
/* */
/* <Title> */
/* SFNT Names */
/* */
/* <Abstract> */
/* Access the names embedded in TrueType and OpenType files. */
/* */
/* <Description> */
/* The TrueType and OpenType specifications allow the inclusion of */
/* a special names table (`name') in font files. This table contains */
/* textual (and internationalized) information regarding the font, */
/* like family name, copyright, version, etc. */
/* */
/* The definitions below are used to access them if available. */
/* */
/* Note that this has nothing to do with glyph names! */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Struct> */
/* FT_SfntName */
/* */
/* <Description> */
/* A structure used to model an SFNT `name' table entry. */
/* */
/* <Fields> */
/* platform_id :: The platform ID for `string'. */
/* See @TT_PLATFORM_XXX for possible values. */
/* */
/* encoding_id :: The encoding ID for `string'. */
/* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */
/* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */
/* for possible values. */
/* */
/* language_id :: The language ID for `string'. */
/* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */
/* possible values. */
/* */
/* Registered OpenType values for `language_id' are */
/* always smaller than 0x8000; values equal or larger */
/* than 0x8000 usually indicate a language tag string */
/* (introduced in OpenType version 1.6). Use function */
/* @FT_Get_Sfnt_LangTag with `language_id' as its */
/* argument to retrieve the associated language tag. */
/* */
/* name_id :: An identifier for `string'. */
/* See @TT_NAME_ID_XXX for possible values. */
/* */
/* string :: The `name' string. Note that its format differs */
/* depending on the (platform,encoding) pair, being */
/* either a string of bytes (without a terminating */
/* NULL byte) or containing UTF-16BE entities. */
/* */
/* string_len :: The length of `string' in bytes. */
/* */
/* <Note> */
/* Please refer to the TrueType or OpenType specification for more */
/* details. */
/* */
typedef struct FT_SfntName_
{
FT_UShort platform_id;
FT_UShort encoding_id;
FT_UShort language_id;
FT_UShort name_id;
FT_Byte* string; /* this string is *not* null-terminated! */
FT_UInt string_len; /* in bytes */
} FT_SfntName;
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Sfnt_Name_Count */
/* */
/* <Description> */
/* Retrieve the number of name strings in the SFNT `name' table. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* <Return> */
/* The number of strings in the `name' table. */
/* */
FT_EXPORT( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Sfnt_Name */
/* */
/* <Description> */
/* Retrieve a string of the SFNT `name' table for a given index. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* idx :: The index of the `name' string. */
/* */
/* <Output> */
/* aname :: The indexed @FT_SfntName structure. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* The `string' array returned in the `aname' structure is not */
/* null-terminated. Note that you don't have to deallocate `string' */
/* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
/* */
/* Use @FT_Get_Sfnt_Name_Count to get the total number of available */
/* `name' table entries, then do a loop until you get the right */
/* platform, encoding, and name ID. */
/* */
/* `name' table format~1 entries can use language tags also, see */
/* @FT_Get_Sfnt_LangTag. */
/* */
FT_EXPORT( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname );
/*************************************************************************/
/* */
/* <Struct> */
/* FT_SfntLangTag */
/* */
/* <Description> */
/* A structure to model a language tag entry from an SFNT `name' */
/* table. */
/* */
/* <Fields> */
/* string :: The language tag string, encoded in UTF-16BE */
/* (without trailing NULL bytes). */
/* */
/* string_len :: The length of `string' in *bytes*. */
/* */
/* <Note> */
/* Please refer to the TrueType or OpenType specification for more */
/* details. */
/* */
/* <Since> */
/* 2.8 */
/* */
typedef struct FT_SfntLangTag_
{
FT_Byte* string; /* this string is *not* null-terminated! */
FT_UInt string_len; /* in bytes */
} FT_SfntLangTag;
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Sfnt_LangTag */
/* */
/* <Description> */
/* Retrieve the language tag associated with a language ID of an SFNT */
/* `name' table entry. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */
/* This is always a value larger than 0x8000. */
/* */
/* <Output> */
/* alangTag :: The language tag associated with the `name' table */
/* entry's language ID. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* The `string' array returned in the `alangTag' structure is not */
/* null-terminated. Note that you don't have to deallocate `string' */
/* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
/* */
/* Only `name' table format~1 supports language tags. For format~0 */
/* tables, this function always returns FT_Err_Invalid_Table. For */
/* invalid format~1 language ID values, FT_Err_Invalid_Argument is */
/* returned. */
/* */
/* <Since> */
/* 2.8 */
/* */
FT_EXPORT( FT_Error )
FT_Get_Sfnt_LangTag( FT_Face face,
FT_UInt langID,
FT_SfntLangTag *alangTag );
/* */
FT_END_HEADER
#endif /* FTSNAMES_H_ */
/* END */

View File

@ -26,7 +26,6 @@
#include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_TAGS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SFNT_NAMES_H
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_SERVICE_MULTIPLE_MASTERS_H #include FT_SERVICE_MULTIPLE_MASTERS_H

View File

@ -1,246 +0,0 @@
/***************************************************************************/
/* */
/* t42drivr.c */
/* */
/* High-level Type 42 driver interface (body). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This driver implements Type42 fonts as described in the */
/* Technical Note #5012 from Adobe, with these limitations: */
/* */
/* 1) CID Fonts are not currently supported. */
/* 2) Incremental fonts making use of the GlyphDirectory keyword */
/* will be loaded, but the rendering will be using the TrueType */
/* tables. */
/* 3) As for Type1 fonts, CDevProc is not supported. */
/* 4) The Metrics dictionary is not supported. */
/* 5) AFM metrics are not supported. */
/* */
/* In other words, this driver supports Type42 fonts derived from */
/* TrueType fonts in a non-CID manner, as done by usual conversion */
/* programs. */
/* */
/*************************************************************************/
#include "t42drivr.h"
#include "t42objs.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_SERVICE_FONT_FORMAT_H
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
/*
*
* GLYPH DICT SERVICE
*
*/
static FT_Error
t42_get_glyph_name( T42_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
return FT_Err_Ok;
}
static FT_UInt
t42_get_name_index( T42_Face face,
FT_String* glyph_name )
{
FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
FT_String* gname = face->type1.glyph_names[i];
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i],
NULL, 10 );
}
return 0;
}
static const FT_Service_GlyphDictRec t42_service_glyph_dict =
{
(FT_GlyphDict_GetNameFunc) t42_get_glyph_name, /* get_name */
(FT_GlyphDict_NameIndexFunc)t42_get_name_index /* name_index */
};
/*
*
* POSTSCRIPT NAME SERVICE
*
*/
static const char*
t42_get_ps_font_name( T42_Face face )
{
return (const char*)face->type1.font_name;
}
static const FT_Service_PsFontNameRec t42_service_ps_font_name =
{
(FT_PsName_GetFunc)t42_get_ps_font_name /* get_ps_font_name */
};
/*
*
* POSTSCRIPT INFO SERVICE
*
*/
static FT_Error
t42_ps_get_font_info( FT_Face face,
PS_FontInfoRec* afont_info )
{
*afont_info = ((T42_Face)face)->type1.font_info;
return FT_Err_Ok;
}
static FT_Error
t42_ps_get_font_extra( FT_Face face,
PS_FontExtraRec* afont_extra )
{
*afont_extra = ((T42_Face)face)->type1.font_extra;
return FT_Err_Ok;
}
static FT_Int
t42_ps_has_glyph_names( FT_Face face )
{
FT_UNUSED( face );
return 1;
}
static FT_Error
t42_ps_get_font_private( FT_Face face,
PS_PrivateRec* afont_private )
{
*afont_private = ((T42_Face)face)->type1.private_dict;
return FT_Err_Ok;
}
static const FT_Service_PsInfoRec t42_service_ps_info =
{
(PS_GetFontInfoFunc) t42_ps_get_font_info, /* ps_get_font_info */
(PS_GetFontExtraFunc) t42_ps_get_font_extra, /* ps_get_font_extra */
(PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, /* ps_has_glyph_names */
(PS_GetFontPrivateFunc)t42_ps_get_font_private, /* ps_get_font_private */
/* not implemented */
(PS_GetFontValueFunc) NULL /* ps_get_font_value */
};
/*
*
* SERVICE LIST
*
*/
static const FT_ServiceDescRec t42_services[] =
{
{ FT_SERVICE_ID_GLYPH_DICT, &t42_service_glyph_dict },
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &t42_service_ps_info },
{ FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_42 },
{ NULL, NULL }
};
FT_CALLBACK_DEF( FT_Module_Interface )
T42_Get_Interface( FT_Module module,
const FT_String* t42_interface )
{
FT_UNUSED( module );
return ft_service_list_lookup( t42_services, t42_interface );
}
const FT_Driver_ClassRec t42_driver_class =
{
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_MODULE_DRIVER_HAS_HINTER,
#else
0,
#endif
sizeof ( T42_DriverRec ),
"type42",
0x10000L,
0x20000L,
NULL, /* module-specific interface */
T42_Driver_Init, /* FT_Module_Constructor module_init */
T42_Driver_Done, /* FT_Module_Destructor module_done */
T42_Get_Interface, /* FT_Module_Requester get_interface */
},
sizeof ( T42_FaceRec ),
sizeof ( T42_SizeRec ),
sizeof ( T42_GlyphSlotRec ),
T42_Face_Init, /* FT_Face_InitFunc init_face */
T42_Face_Done, /* FT_Face_DoneFunc done_face */
T42_Size_Init, /* FT_Size_InitFunc init_size */
T42_Size_Done, /* FT_Size_DoneFunc done_size */
T42_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
T42_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */
NULL, /* FT_Face_GetKerningFunc get_kerning */
NULL, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_GetAdvancesFunc get_advances */
T42_Size_Request, /* FT_Size_RequestFunc request_size */
T42_Size_Select /* FT_Size_SelectFunc select_size */
};
/* END */

View File

@ -1,39 +0,0 @@
/***************************************************************************/
/* */
/* t42drivr.h */
/* */
/* High-level Type 42 driver interface (specification). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef T42DRIVR_H_
#define T42DRIVR_H_
#include "ft2build.h"
#include FT_INTERNAL_DRIVER_H
FT_BEGIN_HEADER
FT_EXPORT_VAR( const FT_Driver_ClassRec ) t42_driver_class;
FT_END_HEADER
#endif /* T42DRIVR_H_ */
/* END */

View File

@ -1,41 +0,0 @@
/***************************************************************************/
/* */
/* t42error.h */
/* */
/* Type 42 error codes (specification only). */
/* */
/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the Type 42 error enumeration constants. */
/* */
/*************************************************************************/
#ifndef T42ERROR_H_
#define T42ERROR_H_
#include FT_MODULE_ERRORS_H
#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T42_Err_
#define FT_ERR_BASE FT_Mod_Err_Type42
#include FT_ERRORS_H
#endif /* T42ERROR_H_ */
/* END */

View File

@ -1,688 +0,0 @@
/***************************************************************************/
/* */
/* t42objs.c */
/* */
/* Type 42 objects manager (body). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "t42objs.h"
#include "t42parse.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_LIST_H
#include FT_TRUETYPE_IDS_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
static FT_Error
T42_Open_Face( T42_Face face )
{
T42_LoaderRec loader;
T42_Parser parser;
T1_Font type1 = &face->type1;
FT_Memory memory = face->root.memory;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t42_loader_init( &loader, face );
parser = &loader.parser;
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
/* while parsing the font we always update `face->ttf_size' so that */
/* even in case of buggy data (which might lead to premature end of */
/* scanning without causing an error) the call to `FT_Open_Face' in */
/* `T42_Face_Init' passes the correct size */
face->ttf_size = 12;
error = t42_parser_init( parser,
face->root.stream,
memory,
psaux);
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
if ( type1->font_type != 42 )
{
FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
type1->font_type ));
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* now, propagate the charstrings and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = NULL;
loader.glyph_names.elements = NULL;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* as defined in the CharStrings array. */
/* The index is then stored in type1.encoding.char_index, and */
/* the name in type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t42_loader_done( &loader );
return error;
}
/***************** Driver Functions *************/
FT_LOCAL_DEF( FT_Error )
T42_Face_Init( FT_Stream stream,
FT_Face t42face, /* T42_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
T42_Face face = (T42_Face)t42face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( stream );
face->ttf_face = NULL;
face->root.num_faces = 1;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
face->psnames = psnames;
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
if ( !psaux )
{
FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
FT_TRACE2(( "Type 42 driver\n" ));
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
if ( error )
goto Exit;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( ( face_index & 0xFFFF ) > 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Now load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 0;
root->face_index = 0;
root->face_flags |= FT_FACE_FLAG_SCALABLE |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_GLYPH_NAMES;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
root->face_flags |= FT_FACE_FLAG_HINTER;
#endif
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = info->family_name;
/* assume "Regular" style if we don't know better */
root->style_name = (char *)"Regular";
if ( root->family_name )
{
char* full = info->full_name;
char* family = root->family_name;
if ( full )
{
while ( *full )
{
if ( *full == *family )
{
family++;
full++;
}
else
{
if ( *full == ' ' || *full == '-' )
full++;
else if ( *family == ' ' || *family == '-' )
family++;
else
{
if ( !*family )
root->style_name = full;
break;
}
}
}
}
}
else
{
/* do we have a `/FontName'? */
if ( type1->font_name )
root->family_name = type1->font_name;
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = NULL;
/* Load the TTF font embedded in the T42 font */
{
FT_Open_Args args;
args.flags = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
args.driver = FT_Get_Module( FT_FACE_LIBRARY( face ),
"truetype" );
args.memory_base = face->ttf_data;
args.memory_size = face->ttf_size;
if ( num_params )
{
args.flags |= FT_OPEN_PARAMS;
args.num_params = num_params;
args.params = params;
}
error = FT_Open_Face( FT_FACE_LIBRARY( face ),
&args, 0, &face->ttf_face );
}
if ( error )
goto Exit;
FT_Done_Size( face->ttf_face->size );
/* Ignore info in FontInfo dictionary and use the info from the */
/* loaded TTF font. The PostScript interpreter also ignores it. */
root->bbox = face->ttf_face->bbox;
root->units_per_EM = face->ttf_face->units_per_EM;
root->ascender = face->ttf_face->ascender;
root->descender = face->ttf_face->descender;
root->height = face->ttf_face->height;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_height = face->ttf_face->max_advance_height;
root->underline_position = (FT_Short)info->underline_position;
root->underline_thickness = (FT_Short)info->underline_thickness;
/* compute style flags */
root->style_flags = 0;
if ( info->italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
root->style_flags |= FT_STYLE_FLAG_BOLD;
if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
FT_CMap_Class clazz;
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
if ( error &&
FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
goto Exit;
error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.encoding_id = TT_ADOBE_ID_STANDARD;
clazz = cmap_classes->standard;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
charmap.encoding_id = TT_ADOBE_ID_EXPERT;
clazz = cmap_classes->expert;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
clazz = cmap_classes->custom;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
clazz = cmap_classes->unicode;
break;
default:
;
}
if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );
}
}
Exit:
return error;
}
FT_LOCAL_DEF( void )
T42_Face_Done( FT_Face t42face )
{
T42_Face face = (T42_Face)t42face;
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
if ( !face )
return;
type1 = &face->type1;
info = &type1->font_info;
memory = face->root.memory;
/* delete internal ttf face prior to freeing face->ttf_data */
if ( face->ttf_face )
FT_Done_Face( face->ttf_face );
/* release font info strings */
FT_FREE( info->version );
FT_FREE( info->notice );
FT_FREE( info->full_name );
FT_FREE( info->family_name );
FT_FREE( info->weight );
/* release top dictionary */
FT_FREE( type1->charstrings_len );
FT_FREE( type1->charstrings );
FT_FREE( type1->glyph_names );
FT_FREE( type1->charstrings_block );
FT_FREE( type1->glyph_names_block );
FT_FREE( type1->encoding.char_index );
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( face->ttf_data );
#if 0
/* release afm data if present */
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FT_FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = NULL;
face->root.style_name = NULL;
}
/*************************************************************************/
/* */
/* <Function> */
/* T42_Driver_Init */
/* */
/* <Description> */
/* Initializes a given Type 42 driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
T42_Driver_Init( FT_Module module ) /* T42_Driver */
{
T42_Driver driver = (T42_Driver)module;
FT_Module ttmodule;
ttmodule = FT_Get_Module( module->library, "truetype" );
if ( !ttmodule )
{
FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
return FT_THROW( Missing_Module );
}
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return FT_Err_Ok;
}
FT_LOCAL_DEF( void )
T42_Driver_Done( FT_Module module )
{
FT_UNUSED( module );
}
FT_LOCAL_DEF( FT_Error )
T42_Size_Init( FT_Size size ) /* T42_Size */
{
T42_Size t42size = (T42_Size)size;
FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );
t42size->ttsize = ttsize;
FT_Activate_Size( ttsize );
return error;
}
FT_LOCAL_DEF( FT_Error )
T42_Size_Request( FT_Size t42size, /* T42_Size */
FT_Size_Request req )
{
T42_Size size = (T42_Size)t42size;
T42_Face face = (T42_Face)t42size->face;
FT_Error error;
FT_Activate_Size( size->ttsize );
error = FT_Request_Size( face->ttf_face, req );
if ( !error )
t42size->metrics = face->ttf_face->size->metrics;
return error;
}
FT_LOCAL_DEF( FT_Error )
T42_Size_Select( FT_Size t42size, /* T42_Size */
FT_ULong strike_index )
{
T42_Size size = (T42_Size)t42size;
T42_Face face = (T42_Face)t42size->face;
FT_Error error;
FT_Activate_Size( size->ttsize );
error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
if ( !error )
t42size->metrics = face->ttf_face->size->metrics;
return error;
}
FT_LOCAL_DEF( void )
T42_Size_Done( FT_Size t42size ) /* T42_Size */
{
T42_Size size = (T42_Size)t42size;
FT_Face face = t42size->face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
if ( node )
{
FT_Done_Size( size->ttsize );
size->ttsize = NULL;
}
}
FT_LOCAL_DEF( FT_Error )
T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Face face = t42slot->face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot ttslot;
FT_Error error = FT_Err_Ok;
if ( !face->glyph )
{
/* First glyph slot for this face */
slot->ttslot = t42face->ttf_face->glyph;
}
else
{
error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
slot->ttslot = ttslot;
}
return error;
}
FT_LOCAL_DEF( void )
T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Done_GlyphSlot( slot->ttslot );
}
static void
t42_glyphslot_clear( FT_GlyphSlot slot )
{
/* free bitmap if needed */
ft_glyphslot_free_bitmap( slot );
/* clear all public fields in the glyph slot */
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
FT_ZERO( &slot->bitmap );
slot->bitmap_left = 0;
slot->bitmap_top = 0;
slot->num_subglyphs = 0;
slot->subglyphs = NULL;
slot->control_data = NULL;
slot->control_len = 0;
slot->other = NULL;
slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
}
FT_LOCAL_DEF( FT_Error )
T42_GlyphSlot_Load( FT_GlyphSlot glyph,
FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph;
T42_Size t42size = (T42_Size)size;
T42_Face t42face = (T42_Face)size->face;
FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index ));
/* map T42 glyph index to embedded TTF's glyph index */
glyph_index = (FT_UInt)ft_strtol(
(const char *)t42face->type1.charstrings[glyph_index],
NULL, 10 );
t42_glyphslot_clear( t42slot->ttslot );
error = ttclazz->load_glyph( t42slot->ttslot,
t42size->ttsize,
glyph_index,
load_flags | FT_LOAD_NO_BITMAP );
if ( !error )
{
glyph->metrics = t42slot->ttslot->metrics;
glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;
glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;
glyph->format = t42slot->ttslot->format;
glyph->outline = t42slot->ttslot->outline;
glyph->bitmap = t42slot->ttslot->bitmap;
glyph->bitmap_left = t42slot->ttslot->bitmap_left;
glyph->bitmap_top = t42slot->ttslot->bitmap_top;
glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;
glyph->subglyphs = t42slot->ttslot->subglyphs;
glyph->control_data = t42slot->ttslot->control_data;
glyph->control_len = t42slot->ttslot->control_len;
}
return error;
}
/* END */

View File

@ -1,124 +0,0 @@
/***************************************************************************/
/* */
/* t42objs.h */
/* */
/* Type 42 objects manager (specification). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef T42OBJS_H_
#define T42OBJS_H_
#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
#include FT_INTERNAL_TYPE1_TYPES_H
#include "t42types.h"
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DRIVER_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
/* Type42 size */
typedef struct T42_SizeRec_
{
FT_SizeRec root;
FT_Size ttsize;
} T42_SizeRec, *T42_Size;
/* Type42 slot */
typedef struct T42_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_GlyphSlot ttslot;
} T42_GlyphSlotRec, *T42_GlyphSlot;
/* Type 42 driver */
typedef struct T42_DriverRec_
{
FT_DriverRec root;
FT_Driver_Class ttclazz;
} T42_DriverRec, *T42_Driver;
/* */
FT_LOCAL( FT_Error )
T42_Face_Init( FT_Stream stream,
FT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
T42_Face_Done( FT_Face face );
FT_LOCAL( FT_Error )
T42_Size_Init( FT_Size size );
FT_LOCAL( FT_Error )
T42_Size_Request( FT_Size size,
FT_Size_Request req );
FT_LOCAL( FT_Error )
T42_Size_Select( FT_Size size,
FT_ULong strike_index );
FT_LOCAL( void )
T42_Size_Done( FT_Size size );
FT_LOCAL( FT_Error )
T42_GlyphSlot_Init( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
T42_GlyphSlot_Load( FT_GlyphSlot glyph,
FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags );
FT_LOCAL( void )
T42_GlyphSlot_Done( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
T42_Driver_Init( FT_Module module );
FT_LOCAL( void )
T42_Driver_Done( FT_Module module );
/* */
FT_END_HEADER
#endif /* T42OBJS_H_ */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,91 +0,0 @@
/***************************************************************************/
/* */
/* t42parse.h */
/* */
/* Type 42 font parser (specification). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef T42PARSE_H_
#define T42PARSE_H_
#include "t42objs.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H
FT_BEGIN_HEADER
typedef struct T42_ParserRec_
{
PS_ParserRec root;
FT_Stream stream;
FT_Byte* base_dict;
FT_Long base_len;
FT_Bool in_memory;
} T42_ParserRec, *T42_Parser;
typedef struct T42_Loader_
{
T42_ParserRec parser; /* parser used to read the stream */
FT_Int num_chars; /* number of characters in encoding */
PS_TableRec encoding_table; /* PS_Table used to store the */
/* encoding character names */
FT_Int num_glyphs;
PS_TableRec glyph_names;
PS_TableRec charstrings;
PS_TableRec swap_table; /* For moving .notdef glyph to index 0. */
} T42_LoaderRec, *T42_Loader;
FT_LOCAL( FT_Error )
t42_parser_init( T42_Parser parser,
FT_Stream stream,
FT_Memory memory,
PSAux_Service psaux );
FT_LOCAL( void )
t42_parser_done( T42_Parser parser );
FT_LOCAL( FT_Error )
t42_parse_dict( T42_Face face,
T42_Loader loader,
FT_Byte* base,
FT_Long size );
FT_LOCAL( void )
t42_loader_init( T42_Loader loader,
T42_Face face );
FT_LOCAL( void )
t42_loader_done( T42_Loader loader );
/* */
FT_END_HEADER
#endif /* T42PARSE_H_ */
/* END */

View File

@ -1,57 +0,0 @@
/***************************************************************************/
/* */
/* t42types.h */
/* */
/* Type 42 font data types (specification only). */
/* */
/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef T42TYPES_H_
#define T42TYPES_H_
#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
#include FT_INTERNAL_TYPE1_TYPES_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
typedef struct T42_FaceRec_
{
FT_FaceRec root;
T1_FontRec type1;
const void* psnames;
const void* psaux;
#if 0
const void* afm_data;
#endif
FT_Byte* ttf_data;
FT_Long ttf_size;
FT_Face ttf_face;
FT_CharMapRec charmaprecs[2];
FT_CharMap charmaps[2];
PS_UnicodesRec unicode_map;
} T42_FaceRec, *T42_Face;
FT_END_HEADER
#endif /* T42TYPES_H_ */
/* END */