diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2013-03-26 08:57:05 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-01 12:03:55 +0200 |
commit | 6845a4fb0147117e8517d66f18792ca7acdbe06e (patch) | |
tree | 68e35417b79989a7af8a4ea8c0d282b84dbe0a6e /src/3rdparty/freetype/src/type1 | |
parent | 0fcadcca3d0842354de07ffaa8c622e607aab22c (diff) |
Update bundled FreeType sources to 2.3.12
Most important changes:
* SFNT cmap 13 table format support;
* fixed glitches when rasterizing stretched TTF (xsize!=ysize);
* various fixes in Type1, CFF, and PCF drivers
Change-Id: Ib9e2210ffbd0daa2fdbf518ea87f4be502de6b48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/freetype/src/type1')
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1afm.c | 22 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1driver.h | 4 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1gload.c | 94 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1load.c | 58 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1objs.c | 14 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/type1/t1parse.c | 36 |
6 files changed, 127 insertions, 101 deletions
diff --git a/src/3rdparty/freetype/src/type1/t1afm.c b/src/3rdparty/freetype/src/type1/t1afm.c index 5aea58820e..ef343901a4 100644 --- a/src/3rdparty/freetype/src/type1/t1afm.c +++ b/src/3rdparty/freetype/src/type1/t1afm.c @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -50,13 +50,17 @@ /* read a glyph name and return the equivalent glyph index */ static FT_Int t1_get_index( const char* name, - FT_UInt len, + FT_Offset len, void* user_data ) { T1_Font type1 = (T1_Font)user_data; FT_Int n; + /* PS string/name length must be < 16-bit */ + if ( len > 0xFFFFU ) + return 0; + for ( n = 0; n < type1->num_glyphs; n++ ) { char* gname = (char*)type1->glyph_names[n]; @@ -281,13 +285,15 @@ { t1_font->font_bbox = fi->FontBBox; - t1_face->bbox.xMin = fi->FontBBox.xMin >> 16; - t1_face->bbox.yMin = fi->FontBBox.yMin >> 16; - t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFFU ) >> 16; - t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFFU ) >> 16; + t1_face->bbox.xMin = fi->FontBBox.xMin >> 16; + t1_face->bbox.yMin = fi->FontBBox.yMin >> 16; + /* no `U' suffix here to 0xFFFF! */ + t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFF ) >> 16; + t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFF ) >> 16; - t1_face->ascender = (FT_Short)( ( fi->Ascender + 0x8000U ) >> 16 ); - t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000U ) >> 16 ); + /* no `U' suffix here to 0x8000! */ + t1_face->ascender = (FT_Short)( ( fi->Ascender + 0x8000 ) >> 16 ); + t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000 ) >> 16 ); if ( fi->NumKernPair ) { diff --git a/src/3rdparty/freetype/src/type1/t1driver.h b/src/3rdparty/freetype/src/type1/t1driver.h index ad429440de..9fecbeb0f8 100644 --- a/src/3rdparty/freetype/src/type1/t1driver.h +++ b/src/3rdparty/freetype/src/type1/t1driver.h @@ -26,6 +26,10 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_PIC +#error "this module does not support PIC yet" +#endif + FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class; diff --git a/src/3rdparty/freetype/src/type1/t1gload.c b/src/3rdparty/freetype/src/type1/t1gload.c index c3ac13f59f..f3fad4f5df 100644 --- a/src/3rdparty/freetype/src/type1/t1gload.c +++ b/src/3rdparty/freetype/src/type1/t1gload.c @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,6 +18,7 @@ #include <ft2build.h> #include "t1gload.h" +#include FT_INTERNAL_CALC_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_OUTLINE_H @@ -62,6 +63,11 @@ T1_Font type1 = &face->type1; FT_Error error = T1_Err_Ok; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Incremental_InterfaceRec *inc = + face->root.internal->incremental_interface; +#endif + decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; @@ -70,10 +76,9 @@ /* For incremental fonts get the character data using the */ /* callback function. */ - if ( face->root.internal->incremental_interface ) - error = face->root.internal->incremental_interface->funcs->get_glyph_data( - face->root.internal->incremental_interface->object, - glyph_index, char_string ); + if ( inc ) + error = inc->funcs->get_glyph_data( inc->object, + glyph_index, char_string ); else #endif /* FT_CONFIG_OPTION_INCREMENTAL */ @@ -92,22 +97,22 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts can optionally override the metrics. */ - if ( !error && face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs->get_glyph_metrics ) + if ( !error && inc && inc->funcs->get_glyph_metrics ) { FT_Incremental_MetricsRec metrics; - metrics.bearing_x = decoder->builder.left_bearing.x; - metrics.bearing_y = decoder->builder.left_bearing.y; - metrics.advance = decoder->builder.advance.x; - error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( - face->root.internal->incremental_interface->object, - glyph_index, FALSE, &metrics ); - decoder->builder.left_bearing.x = metrics.bearing_x; - decoder->builder.left_bearing.y = metrics.bearing_y; - decoder->builder.advance.x = metrics.advance; - decoder->builder.advance.y = 0; + metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x ); + metrics.bearing_y = 0; + metrics.advance = FIXED_TO_INT( decoder->builder.advance.x ); + metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y ); + + error = inc->funcs->get_glyph_metrics( inc->object, + glyph_index, FALSE, &metrics ); + + decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x ); + decoder->builder.advance.x = INT_TO_FIXED( metrics.advance ); + decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v ); } #endif /* FT_CONFIG_OPTION_INCREMENTAL */ @@ -215,8 +220,6 @@ FT_UInt nn; FT_Error error; - FT_UNUSED( load_flags ); - if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { @@ -252,7 +255,7 @@ { error = T1_Parse_Glyph( &decoder, first + nn ); if ( !error ) - advances[nn] = decoder.builder.advance.x; + advances[nn] = FIXED_TO_INT( decoder.builder.advance.x ); else advances[nn] = 0; } @@ -284,7 +287,12 @@ #endif +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( glyph_index >= (FT_UInt)face->root.num_glyphs && + !face->root.internal->incremental_interface ) +#else if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ { error = T1_Err_Invalid_Argument; goto Exit; @@ -370,11 +378,14 @@ FT_Slot_Internal internal = glyph->root.internal; - glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; - glyph->root.metrics.horiAdvance = decoder.builder.advance.x; - internal->glyph_matrix = font_matrix; - internal->glyph_delta = font_offset; - internal->glyph_transformed = 1; + glyph->root.metrics.horiBearingX = + FIXED_TO_INT( decoder.builder.left_bearing.x ); + glyph->root.metrics.horiAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); + + internal->glyph_matrix = font_matrix; + internal->glyph_delta = font_offset; + internal->glyph_transformed = 1; } else { @@ -384,14 +395,26 @@ /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.builder.advance.x; - glyph->root.linearHoriAdvance = decoder.builder.advance.x; + metrics->horiAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); + glyph->root.linearHoriAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); glyph->root.internal->glyph_transformed = 0; - /* make up vertical ones */ - metrics->vertAdvance = ( face->type1.font_bbox.yMax - - face->type1.font_bbox.yMin ) >> 16; - glyph->root.linearVertAdvance = metrics->vertAdvance; + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) + { + /* make up vertical ones */ + metrics->vertAdvance = ( face->type1.font_bbox.yMax - + face->type1.font_bbox.yMin ) >> 16; + glyph->root.linearVertAdvance = metrics->vertAdvance; + } + else + { + metrics->vertAdvance = + FIXED_TO_INT( decoder.builder.advance.y ); + glyph->root.linearVertAdvance = + FIXED_TO_INT( decoder.builder.advance.y ); + } glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; @@ -451,9 +474,12 @@ metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; - /* make up vertical ones */ - ft_synthesize_vertical_metrics( metrics, - metrics->vertAdvance ); + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) + { + /* make up vertical ones */ + ft_synthesize_vertical_metrics( metrics, + metrics->vertAdvance ); + } } /* Set control data to the glyph charstrings. Note that this is */ diff --git a/src/3rdparty/freetype/src/type1/t1load.c b/src/3rdparty/freetype/src/type1/t1load.c index 06e72cca68..d867e942c9 100644 --- a/src/3rdparty/freetype/src/type1/t1load.c +++ b/src/3rdparty/freetype/src/type1/t1load.c @@ -65,6 +65,7 @@ #include FT_CONFIG_CONFIG_H #include FT_MULTIPLE_MASTERS_H #include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_CALC_H #include "t1load.h" #include "t1errors.h" @@ -213,10 +214,6 @@ } -#define FT_INT_TO_FIXED( a ) ( (a) << 16 ) -#define FT_FIXED_TO_INT( a ) ( FT_RoundFix( a ) >> 16 ) - - /*************************************************************************/ /* */ /* Given a normalized (blend) coordinate, figure out the design */ @@ -230,7 +227,7 @@ if ( ncv <= axismap->blend_points[0] ) - return FT_INT_TO_FIXED( axismap->design_points[0] ); + return INT_TO_FIXED( axismap->design_points[0] ); for ( j = 1; j < axismap->num_points; ++j ) { @@ -241,7 +238,7 @@ axismap->blend_points[j] - axismap->blend_points[j - 1] ); - return FT_INT_TO_FIXED( axismap->design_points[j - 1] ) + + return INT_TO_FIXED( axismap->design_points[j - 1] ) + FT_MulDiv( t, axismap->design_points[j] - axismap->design_points[j - 1], @@ -249,7 +246,7 @@ } } - return FT_INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] ); + return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] ); } @@ -331,8 +328,8 @@ for ( i = 0 ; i < mmaster.num_axis; ++i ) { mmvar->axis[i].name = mmaster.axis[i].name; - mmvar->axis[i].minimum = FT_INT_TO_FIXED( mmaster.axis[i].minimum); - mmvar->axis[i].maximum = FT_INT_TO_FIXED( mmaster.axis[i].maximum); + mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum); + mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum); mmvar->axis[i].def = ( mmvar->axis[i].minimum + mmvar->axis[i].maximum ) / 2; /* Does not apply. But this value is in range */ @@ -502,7 +499,7 @@ if ( num_coords <= 4 && num_coords > 0 ) { for ( i = 0; i < num_coords; ++i ) - lcoords[i] = FT_FIXED_TO_INT( coords[i] ); + lcoords[i] = FIXED_TO_INT( coords[i] ); error = T1_Set_MM_Design( face, num_coords, lcoords ); } @@ -654,8 +651,8 @@ } if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS ) { - FT_ERROR(( "parse_blend_design_positions:" )); - FT_ERROR(( " incorrect number of designs: %d\n", + FT_ERROR(( "parse_blend_design_positions:" + " incorrect number of designs: %d\n", num_designs )); error = T1_Err_Invalid_File_Format; goto Exit; @@ -687,8 +684,8 @@ { if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS ) { - FT_ERROR(( "parse_blend_design_positions:" )); - FT_ERROR(( " invalid number of axes: %d\n", + FT_ERROR(( "parse_blend_design_positions:" + " invalid number of axes: %d\n", n_axis )); error = T1_Err_Invalid_File_Format; goto Exit; @@ -842,8 +839,8 @@ } if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS ) { - FT_ERROR(( "parse_weight_vector:" )); - FT_ERROR(( " incorrect number of designs: %d\n", + FT_ERROR(( "parse_weight_vector:" + " incorrect number of designs: %d\n", num_designs )); error = T1_Err_Invalid_File_Format; goto Exit; @@ -859,9 +856,9 @@ else if ( blend->num_designs != (FT_UInt)num_designs ) { FT_ERROR(( "parse_weight_vector:" - " /BlendDesignPosition and /WeightVector have\n" )); - FT_ERROR(( " " - " different number of elements!\n" )); + " /BlendDesignPosition and /WeightVector have\n" + " " + " different number of elements\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } @@ -1143,7 +1140,7 @@ cur = parser->root.cursor; if ( cur >= limit ) { - FT_ERROR(( "parse_encoding: out of bounds!\n" )); + FT_ERROR(( "parse_encoding: out of bounds\n" )); parser->root.error = T1_Err_Invalid_File_Format; return; } @@ -2156,7 +2153,7 @@ #endif if ( !loader.charstrings.init ) { - FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face!\n" )); + FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" )); error = T1_Err_Invalid_File_Format; } @@ -2185,8 +2182,8 @@ /* the index is then stored in type1.encoding.char_index, and */ /* a the name to type1.encoding.char_name */ - min_char = +32000; - max_char = -32000; + min_char = 0; + max_char = 0; charcode = 0; for ( ; charcode < loader.encoding_table.max_elems; charcode++ ) @@ -2212,25 +2209,14 @@ { if ( charcode < min_char ) min_char = charcode; - if ( charcode > max_char ) - max_char = charcode; + if ( charcode >= max_char ) + max_char = charcode + 1; } break; } } } - /* - * Yes, this happens: Certain PDF-embedded fonts have only a - * `.notdef' glyph defined! - */ - - if ( min_char > max_char ) - { - min_char = 0; - max_char = loader.encoding_table.max_elems; - } - type1->encoding.code_first = min_char; type1->encoding.code_last = max_char; type1->encoding.num_chars = loader.num_chars; diff --git a/src/3rdparty/freetype/src/type1/t1objs.c b/src/3rdparty/freetype/src/type1/t1objs.c index 2f90dd62f6..b1de687196 100644 --- a/src/3rdparty/freetype/src/type1/t1objs.c +++ b/src/3rdparty/freetype/src/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,6 +17,7 @@ #include <ft2build.h> +#include FT_INTERNAL_CALC_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_IDS_H @@ -440,10 +441,11 @@ root->num_fixed_sizes = 0; root->available_sizes = 0; - root->bbox.xMin = type1->font_bbox.xMin >> 16; - root->bbox.yMin = type1->font_bbox.yMin >> 16; - root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFFU ) >> 16; - root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFFU ) >> 16; + root->bbox.xMin = type1->font_bbox.xMin >> 16; + root->bbox.yMin = type1->font_bbox.yMin >> 16; + /* no `U' suffix here to 0xFFFF! */ + root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16; + root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16; /* Set units_per_EM if we didn't set it in parse_font_matrix. */ if ( !root->units_per_EM ) @@ -467,7 +469,7 @@ /* in case of error, keep the standard width */ if ( !error ) - root->max_advance_width = (FT_Short)max_advance; + root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance ); else error = T1_Err_Ok; /* clear error */ } diff --git a/src/3rdparty/freetype/src/type1/t1parse.c b/src/3rdparty/freetype/src/type1/t1parse.c index 36f5c82c86..2a762279fd 100644 --- a/src/3rdparty/freetype/src/type1/t1parse.c +++ b/src/3rdparty/freetype/src/type1/t1parse.c @@ -4,7 +4,7 @@ /* */ /* Type 1 parser (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -35,7 +35,6 @@ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_CALC_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_POSTSCRIPT_AUX_H @@ -298,8 +297,8 @@ /* and allocate private dictionary buffer */ if ( parser->private_len == 0 ) { - FT_ERROR(( "T1_Get_Private_Dict:" )); - FT_ERROR(( " invalid private dictionary section\n" )); + FT_ERROR(( "T1_Get_Private_Dict:" + " invalid private dictionary section\n" )); error = T1_Err_Invalid_File_Format; goto Fail; } @@ -354,8 +353,8 @@ cur++; if ( cur >= limit ) { - FT_ERROR(( "T1_Get_Private_Dict:" )); - FT_ERROR(( " could not find `eexec' keyword\n" )); + FT_ERROR(( "T1_Get_Private_Dict:" + " could not find `eexec' keyword\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } @@ -398,18 +397,21 @@ T1_Skip_PS_Token( parser ); cur = parser->root.cursor; - if ( *cur == '\r' ) - { - cur++; - if ( *cur == '\n' ) - cur++; - } - else if ( *cur == '\n' ) - cur++; - else + + /* according to the Type1 spec, the first cipher byte must not be */ + /* an ASCII whitespace character code (blank, tab, carriage return */ + /* or line feed). We have seen Type 1 fonts with two line feed */ + /* characters... So skip now all whitespace character codes. */ + while ( cur < limit && + ( *cur == ' ' || + *cur == '\t' || + *cur == '\r' || + *cur == '\n' ) ) + ++cur; + if ( cur >= limit ) { - FT_ERROR(( "T1_Get_Private_Dict:" )); - FT_ERROR(( " `eexec' not properly terminated\n" )); + FT_ERROR(( "T1_Get_Private_Dict:" + " `eexec' not properly terminated\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } |