summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/type42/t42objs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/type42/t42objs.c')
-rw-r--r--src/3rdparty/freetype/src/type42/t42objs.c135
1 files changed, 89 insertions, 46 deletions
diff --git a/src/3rdparty/freetype/src/type42/t42objs.c b/src/3rdparty/freetype/src/type42/t42objs.c
index 9081ffc6d2..915e81fe74 100644
--- a/src/3rdparty/freetype/src/type42/t42objs.c
+++ b/src/3rdparty/freetype/src/type42/t42objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 42 objects manager (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
+/* Copyright 2002-2009, 2011, 2013 */
/* by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,7 @@
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_LIST_H
+#include FT_TRUETYPE_IDS_H
#undef FT_COMPONENT
@@ -46,6 +47,12 @@
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,
@@ -60,7 +67,9 @@
if ( type1->font_type != 42 )
{
- error = T42_Err_Unknown_File_Format;
+ FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
+ type1->font_type ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -71,7 +80,7 @@
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
@@ -90,7 +99,6 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
- FT_Byte* char_name;
FT_Byte* glyph_name;
@@ -106,6 +114,9 @@
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";
@@ -151,11 +162,12 @@
FT_LOCAL_DEF( FT_Error )
T42_Face_Init( FT_Stream stream,
- T42_Face face,
+ 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;
@@ -165,7 +177,6 @@
FT_UNUSED( num_params );
FT_UNUSED( params );
- FT_UNUSED( face_index );
FT_UNUSED( stream );
@@ -178,6 +189,14 @@
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 );
@@ -192,7 +211,7 @@
if ( face_index > 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
- error = T42_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -205,9 +224,9 @@
root->num_charmaps = 0;
root->face_index = 0;
- root->face_flags = FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES;
+ 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;
@@ -273,7 +292,9 @@
FT_Open_Args args;
- args.flags = FT_OPEN_MEMORY;
+ 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;
@@ -320,7 +341,7 @@
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@@ -330,39 +351,43 @@
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
- FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ 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 = 7;
+ 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 = 0;
+ 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 = 1;
+ 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 = 2;
+ 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 = 3;
+ charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
clazz = cmap_classes->unicode;
break;
@@ -371,7 +396,7 @@
}
if ( clazz )
- FT_CMap_New( clazz, NULL, &charmap, NULL );
+ error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
@@ -386,8 +411,9 @@
FT_LOCAL_DEF( void )
- T42_Face_Done( T42_Face face )
+ T42_Face_Done( FT_Face t42face )
{
+ T42_Face face = (T42_Face)t42face;
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
@@ -455,36 +481,44 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T42_Driver_Init( T42_Driver driver )
+ T42_Driver_Init( FT_Module module ) /* T42_Driver */
{
- FT_Module ttmodule;
+ T42_Driver driver = (T42_Driver)module;
+ FT_Module ttmodule;
- ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
+ 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 T42_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( void )
- T42_Driver_Done( T42_Driver driver )
+ T42_Driver_Done( FT_Module module )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
}
FT_LOCAL_DEF( FT_Error )
- T42_Size_Init( T42_Size size )
+ T42_Size_Init( FT_Size size ) /* T42_Size */
{
- FT_Face face = size->root.face;
+ T42_Size t42size = (T42_Size)size;
+ FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
- FT_Error error = T42_Err_Ok;
+ FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );
- size->ttsize = ttsize;
+ t42size->ttsize = ttsize;
FT_Activate_Size( ttsize );
@@ -493,10 +527,11 @@
FT_LOCAL_DEF( FT_Error )
- T42_Size_Request( T42_Size size,
+ T42_Size_Request( FT_Size t42size, /* T42_Size */
FT_Size_Request req )
{
- T42_Face face = (T42_Face)size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ T42_Face face = (T42_Face)t42size->face;
FT_Error error;
@@ -504,17 +539,18 @@
error = FT_Request_Size( face->ttf_face, req );
if ( !error )
- ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
+ t42size->metrics = face->ttf_face->size->metrics;
return error;
}
FT_LOCAL_DEF( FT_Error )
- T42_Size_Select( T42_Size size,
+ T42_Size_Select( FT_Size t42size, /* T42_Size */
FT_ULong strike_index )
{
- T42_Face face = (T42_Face)size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ T42_Face face = (T42_Face)t42size->face;
FT_Error error;
@@ -522,7 +558,7 @@
error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
if ( !error )
- ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
+ t42size->metrics = face->ttf_face->size->metrics;
return error;
@@ -530,9 +566,10 @@
FT_LOCAL_DEF( void )
- T42_Size_Done( T42_Size size )
+ T42_Size_Done( FT_Size t42size ) /* T42_Size */
{
- FT_Face face = size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ FT_Face face = t42size->face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
@@ -547,12 +584,13 @@
FT_LOCAL_DEF( FT_Error )
- T42_GlyphSlot_Init( T42_GlyphSlot slot )
+ T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
- FT_Face face = slot->root.face;
- T42_Face t42face = (T42_Face)face;
- FT_GlyphSlot ttslot;
- FT_Error error = T42_Err_Ok;
+ 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 == NULL )
@@ -571,8 +609,11 @@
FT_LOCAL_DEF( void )
- T42_GlyphSlot_Done( T42_GlyphSlot slot )
+ T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
+ T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
+
+
FT_Done_GlyphSlot( slot->ttslot );
}
@@ -614,6 +655,8 @@
FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
+ FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index ));
+
t42_glyphslot_clear( t42slot->ttslot );
error = ttclazz->load_glyph( t42slot->ttslot,
t42size->ttsize,