aboutsummaryrefslogtreecommitdiff
path: root/freetype/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-04-12 09:53:17 +0000
committermarha <marha@users.sourceforge.net>2010-04-12 09:53:17 +0000
commit29b86f9852b2b7ecc31cdfee56679537e40bc6e2 (patch)
tree1e6ec8ccf2dbf773260a1953b8e13c49f9b7c5f5 /freetype/src
parent529236591df7366479a6fac30b387667678fd1ba (diff)
downloadvcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.gz
vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.bz2
vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.zip
svn merge -r524:HEAD "^/branches/released" .
Diffstat (limited to 'freetype/src')
-rw-r--r--freetype/src/autofit/aflatin.c8
-rw-r--r--freetype/src/autofit/aflatin2.c8
-rw-r--r--freetype/src/base/ftbase.h6
-rw-r--r--freetype/src/base/ftbbox.c6
-rw-r--r--freetype/src/base/ftdbgmem.c2
-rw-r--r--freetype/src/base/ftglyph.c6
-rw-r--r--freetype/src/base/ftinit.c4
-rw-r--r--freetype/src/base/ftobjs.c28
-rw-r--r--freetype/src/base/ftoutln.c8
-rw-r--r--freetype/src/base/ftpatent.c9
-rw-r--r--freetype/src/base/ftstroke.c14
-rw-r--r--freetype/src/base/ftsynth.c4
-rw-r--r--freetype/src/cache/ftcglyph.c4
-rw-r--r--freetype/src/cff/cffdrivr.c5
-rw-r--r--freetype/src/cff/cffgload.c165
-rw-r--r--freetype/src/cff/cffgload.h8
-rw-r--r--freetype/src/cff/cffobjs.c9
-rw-r--r--freetype/src/cff/cffparse.c4
-rw-r--r--freetype/src/cid/cidgload.c19
-rw-r--r--freetype/src/cid/cidobjs.c9
-rw-r--r--freetype/src/cid/cidtoken.h2
-rw-r--r--freetype/src/lzw/ftlzw.c12
-rw-r--r--freetype/src/pfr/pfrsbit.c6
-rw-r--r--freetype/src/psaux/t1decode.c21
-rw-r--r--freetype/src/psnames/psmodule.c3
-rw-r--r--freetype/src/sfnt/sfdriver.c2
-rw-r--r--freetype/src/sfnt/sfobjs.c31
-rw-r--r--freetype/src/sfnt/ttcmap.c9
-rw-r--r--freetype/src/sfnt/ttload.c8
-rw-r--r--freetype/src/tools/apinames.c4
-rw-r--r--freetype/src/truetype/ttdriver.c18
-rw-r--r--freetype/src/truetype/ttgload.c216
-rw-r--r--freetype/src/truetype/ttgxvar.c11
-rw-r--r--freetype/src/type1/t1afm.c18
-rw-r--r--freetype/src/type1/t1gload.c40
-rw-r--r--freetype/src/type1/t1objs.c9
-rw-r--r--freetype/src/type1/t1parse.c21
37 files changed, 497 insertions, 260 deletions
diff --git a/freetype/src/autofit/aflatin.c b/freetype/src/autofit/aflatin.c
index 394fb9789..e6882d5e7 100644
--- a/freetype/src/autofit/aflatin.c
+++ b/freetype/src/autofit/aflatin.c
@@ -402,16 +402,16 @@
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
- FT_UInt i;
- FT_Bool started = 0, same_width = 1;
+ FT_UInt i;
+ FT_Bool started = 0, same_width = 1;
+ FT_Fixed advance, old_advance = 0;
/* check whether all ASCII digits have the same advance width; */
/* digit `0' is 0x30 in all supported charmaps */
for ( i = 0x30; i <= 0x39; i++ )
{
- FT_UInt glyph_index;
- FT_Fixed advance, old_advance = 0;
+ FT_UInt glyph_index;
glyph_index = FT_Get_Char_Index( face, i );
diff --git a/freetype/src/autofit/aflatin2.c b/freetype/src/autofit/aflatin2.c
index 5e2ad48c4..5cbeb296b 100644
--- a/freetype/src/autofit/aflatin2.c
+++ b/freetype/src/autofit/aflatin2.c
@@ -407,16 +407,16 @@
af_latin2_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
- FT_UInt i;
- FT_Bool started = 0, same_width = 1;
+ FT_UInt i;
+ FT_Bool started = 0, same_width = 1;
+ FT_Fixed advance, old_advance = 0;
/* check whether all ASCII digits have the same advance width; */
/* digit `0' is 0x30 in all supported charmaps */
for ( i = 0x30; i <= 0x39; i++ )
{
- FT_UInt glyph_index;
- FT_Fixed advance, old_advance;
+ FT_UInt glyph_index;
glyph_index = FT_Get_Char_Index( face, i );
diff --git a/freetype/src/base/ftbase.h b/freetype/src/base/ftbase.h
index d72cba209..ba39cd8da 100644
--- a/freetype/src/base/ftbase.h
+++ b/freetype/src/base/ftbase.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType private functions used in base module (specification). */
/* */
-/* Copyright 2008 by */
+/* Copyright 2008, 2010 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,7 +29,7 @@ FT_BEGIN_HEADER
/* Assume the stream is sfnt-wrapped PS Type1 or sfnt-wrapped CID-keyed */
/* font, and try to load a face specified by the face_index. */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL( FT_Error )
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
/* Create a new FT_Face given a buffer and a driver name. */
/* From ftmac.c. */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL( FT_Error )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
diff --git a/freetype/src/base/ftbbox.c b/freetype/src/base/ftbbox.c
index cc0ddf4b4..e31de297a 100644
--- a/freetype/src/base/ftbbox.c
+++ b/freetype/src/base/ftbbox.c
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
-/* Copyright 1996-2001, 2002, 2004, 2006 by */
+/* Copyright 1996-2001, 2002, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -140,7 +140,7 @@
/* */
/* <Description> */
/* This function is used as a `conic_to' emitter during */
- /* FT_Raster_Decompose(). It checks a conic Bezier curve with the */
+ /* FT_Outline_Decompose(). It checks a conic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
@@ -507,7 +507,7 @@
/* */
/* <Description> */
/* This function is used as a `cubic_to' emitter during */
- /* FT_Raster_Decompose(). It checks a cubic Bezier curve with the */
+ /* FT_Outline_Decompose(). It checks a cubic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
diff --git a/freetype/src/base/ftdbgmem.c b/freetype/src/base/ftdbgmem.c
index 75154f472..71f589169 100644
--- a/freetype/src/base/ftdbgmem.c
+++ b/freetype/src/base/ftdbgmem.c
@@ -989,7 +989,7 @@
#else /* !FT_DEBUG_MEMORY */
/* ANSI C doesn't like empty source files */
- static const FT_Byte _debug_mem_dummy = 0;
+ typedef int _debug_mem_dummy;
#endif /* !FT_DEBUG_MEMORY */
diff --git a/freetype/src/base/ftglyph.c b/freetype/src/base/ftglyph.c
index 24359cb6c..2da7409af 100644
--- a/freetype/src/base/ftglyph.c
+++ b/freetype/src/base/ftglyph.c
@@ -372,7 +372,7 @@
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
clazz = FT_BITMAP_GLYPH_CLASS_GET;
- /* it it is an outline too */
+ /* if it is an outline */
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
clazz = FT_OUTLINE_GLYPH_CLASS_GET;
@@ -515,6 +515,10 @@
const FT_Glyph_Class* clazz;
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library = FT_GLYPH( glyph )->library;
+#endif
+
/* check argument */
if ( !the_glyph )
diff --git a/freetype/src/base/ftinit.c b/freetype/src/base/ftinit.c
index 20024d40a..4835ffa2d 100644
--- a/freetype/src/base/ftinit.c
+++ b/freetype/src/base/ftinit.c
@@ -115,7 +115,7 @@
FT_Module_Class** classes;
FT_Memory memory;
FT_UInt i;
- BasePIC* pic_container = library->pic_container.base;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
if ( !pic_container->default_module_classes )
return;
@@ -145,7 +145,7 @@
FT_Module_Class** classes;
FT_Module_Class* clazz;
FT_UInt i;
- BasePIC* pic_container = library->pic_container.base;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
memory = library->memory;
pic_container->default_module_classes = 0;
diff --git a/freetype/src/base/ftobjs.c b/freetype/src/base/ftobjs.c
index 66fe5fbf3..ed2ca66a9 100644
--- a/freetype/src/base/ftobjs.c
+++ b/freetype/src/base/ftobjs.c
@@ -4,7 +4,8 @@
/* */
/* The FreeType private base classes (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,7 +38,9 @@
#include FT_SERVICE_KERNING_H
#include FT_SERVICE_TRUETYPE_ENGINE_H
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
#include "ftbase.h"
+#endif
#define GRID_FIT_METRICS
@@ -708,8 +711,8 @@
}
/* compute the linear advance in 16.16 pixels */
- if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
- ( FT_IS_SCALABLE( face ) ) )
+ if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
+ ( FT_IS_SCALABLE( face ) ) )
{
FT_Size_Metrics* metrics = &face->size->metrics;
@@ -739,11 +742,30 @@
renderer, slot,
&internal->transform_matrix,
&internal->transform_delta );
+ else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
+ {
+ /* apply `standard' transformation if no renderer is available */
+ if ( &internal->transform_matrix )
+ FT_Outline_Transform( &slot->outline,
+ &internal->transform_matrix );
+
+ if ( &internal->transform_delta )
+ FT_Outline_Translate( &slot->outline,
+ internal->transform_delta.x,
+ internal->transform_delta.y );
+ }
+
/* transform advance */
FT_Vector_Transform( &slot->advance, &internal->transform_matrix );
}
}
+ FT_TRACE5(( " x advance: %d\n" , slot->advance.x ));
+ FT_TRACE5(( " y advance: %d\n" , slot->advance.y ));
+
+ FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance ));
+ FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance ));
+
/* do we need to render the image now? */
if ( !error &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
diff --git a/freetype/src/base/ftoutln.c b/freetype/src/base/ftoutln.c
index f42dd6f17..93e1e4797 100644
--- a/freetype/src/base/ftoutln.c
+++ b/freetype/src/base/ftoutln.c
@@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -304,9 +304,9 @@
*anoutline = null_outline;
- if ( FT_NEW_ARRAY( anoutline->points, numPoints * 2L ) ||
- FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
- FT_NEW_ARRAY( anoutline->contours, numContours ) )
+ if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
+ FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
+ FT_NEW_ARRAY( anoutline->contours, numContours ) )
goto Fail;
anoutline->n_points = (FT_UShort)numPoints;
diff --git a/freetype/src/base/ftpatent.c b/freetype/src/base/ftpatent.c
index 9957468ad..b7a46d109 100644
--- a/freetype/src/base/ftpatent.c
+++ b/freetype/src/base/ftpatent.c
@@ -5,7 +5,7 @@
/* FreeType API for checking patented TrueType bytecode instructions */
/* (body). */
/* */
-/* Copyright 2007, 2008 by David Turner. */
+/* Copyright 2007, 2008, 2010 by David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -114,7 +114,7 @@
FT_ULong tag )
{
FT_Stream stream = face->stream;
- FT_Error error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Service_SFNT_Table service;
FT_Bool result = FALSE;
@@ -124,13 +124,14 @@
if ( service )
{
FT_UInt i = 0;
- FT_ULong tag_i = 0, offset_i, length_i;
+ FT_ULong tag_i = 0, offset_i = 0, length_i = 0;
+
for ( i = 0; !error && tag_i != tag ; i++ )
error = service->table_info( face, i,
&tag_i, &offset_i, &length_i );
- if ( error ||
+ if ( error ||
FT_STREAM_SEEK( offset_i ) )
goto Exit;
diff --git a/freetype/src/base/ftstroke.c b/freetype/src/base/ftstroke.c
index 3930d8525..20c1d03fc 100644
--- a/freetype/src/base/ftstroke.c
+++ b/freetype/src/base/ftstroke.c
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 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, */
@@ -979,7 +979,8 @@
thcos = FT_Cos( theta );
sigma = FT_MulFix( stroker->miter_limit, thcos );
- if ( sigma >= 0x10000L )
+ /* FT_Sin(x) = 0 for x <= 57 */
+ if ( sigma >= 0x10000L || ft_pos_abs( theta ) <= 57 )
miter = FALSE;
if ( miter ) /* this is a miter (broken angle) */
@@ -1360,7 +1361,7 @@
phi1 = (angle_mid + angle_in ) / 2;
phi2 = (angle_mid + angle_out ) / 2;
length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
- length2 = FT_DivFix( stroker->radius, FT_Cos(theta2) );
+ length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
for ( side = 0; side <= 1; side++ )
{
@@ -1735,13 +1736,10 @@
}
else
{
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
+ /* if both first and last points are conic, */
+ /* start at their middle */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
}
point--;
tags--;
diff --git a/freetype/src/base/ftsynth.c b/freetype/src/base/ftsynth.c
index 5077653c2..4a97e4852 100644
--- a/freetype/src/base/ftsynth.c
+++ b/freetype/src/base/ftsynth.c
@@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -99,8 +99,8 @@
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
- error = FT_Outline_Embolden( &slot->outline, xstr );
/* ignore error */
+ (void)FT_Outline_Embolden( &slot->outline, xstr );
/* this is more than enough for most glyphs; if you need accurate */
/* values, you have to call FT_Outline_Get_CBox */
diff --git a/freetype/src/cache/ftcglyph.c b/freetype/src/cache/ftcglyph.c
index 2f462a2f6..a9ab0c319 100644
--- a/freetype/src/cache/ftcglyph.c
+++ b/freetype/src/cache/ftcglyph.c
@@ -71,8 +71,8 @@
FT_UNUSED( cache );
- return FT_BOOL( gnode->family == gquery->family &&
- gnode->gindex == gquery->gindex );
+ return FT_BOOL( gnode->family == gquery->family &&
+ gnode->gindex == gquery->gindex );
}
diff --git a/freetype/src/cff/cffdrivr.c b/freetype/src/cff/cffdrivr.c
index 5d04cd763..1119613a7 100644
--- a/freetype/src/cff/cffdrivr.c
+++ b/freetype/src/cff/cffdrivr.c
@@ -621,14 +621,15 @@
{
FT_Module sfnt;
FT_Module_Interface result;
- FT_Library library = driver->library;
- FT_UNUSED(library);
result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
if ( result != NULL )
return result;
+ if ( !driver )
+ return NULL;
+
/* we pass our request to the `sfnt' module */
sfnt = FT_Get_Module( driver->library, "sfnt" );
diff --git a/freetype/src/cff/cffgload.c b/freetype/src/cff/cffgload.c
index 8dbc8d9ae..6a10d972e 100644
--- a/freetype/src/cff/cffgload.c
+++ b/freetype/src/cff/cffgload.c
@@ -4,7 +4,8 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -113,6 +114,9 @@
cff_op_closepath,
cff_op_callothersubr,
cff_op_pop,
+ cff_op_seac,
+ cff_op_sbw,
+ cff_op_setcurrentpoint,
/* do not remove */
cff_op_max
@@ -201,7 +205,10 @@
2, /* hsbw */
0,
0,
- 0
+ 0,
+ 5, /* seac */
+ 4, /* sbw */
+ 2 /* setcurrentpoint */
};
@@ -319,17 +326,23 @@
/* subroutines. */
/* */
/* <Input> */
- /* num_subrs :: The number of glyph subroutines. */
+ /* in_charstring_type :: The `CharstringType' value of the top DICT */
+ /* dictionary. */
+ /* */
+ /* num_subrs :: The number of glyph subroutines. */
/* */
/* <Return> */
/* The bias value. */
static FT_Int
- cff_compute_bias( FT_UInt num_subrs )
+ cff_compute_bias( FT_Int in_charstring_type,
+ FT_UInt num_subrs )
{
FT_Int result;
- if ( num_subrs < 1240 )
+ if ( in_charstring_type == 1 )
+ result = 0;
+ else if ( num_subrs < 1240 )
result = 107;
else if ( num_subrs < 33900U )
result = 1131;
@@ -380,9 +393,12 @@
cff_builder_init( &decoder->builder, face, size, slot, hinting );
/* initialize Type2 decoder */
+ decoder->cff = cff;
decoder->num_globals = cff->num_global_subrs;
decoder->globals = cff->global_subrs;
- decoder->globals_bias = cff_compute_bias( decoder->num_globals );
+ decoder->globals_bias = cff_compute_bias(
+ cff->top_font.font_dict.charstring_type,
+ decoder->num_globals );
decoder->hint_mode = hint_mode;
}
@@ -434,7 +450,9 @@
decoder->num_locals = sub->num_local_subrs;
decoder->locals = sub->local_subrs;
- decoder->locals_bias = cff_compute_bias( decoder->num_locals );
+ decoder->locals_bias = cff_compute_bias(
+ decoder->cff->top_font.font_dict.charstring_type,
+ decoder->num_locals );
decoder->glyph_width = sub->private_dict.default_width;
decoder->nominal_width = sub->private_dict.nominal_width;
@@ -677,7 +695,7 @@
data.length = length;
face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object,&data );
+ face->root.internal->incremental_interface->object, &data );
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -693,6 +711,7 @@
static FT_Error
cff_operator_seac( CFF_Decoder* decoder,
+ FT_Pos asb,
FT_Pos adx,
FT_Pos ady,
FT_Int bchar,
@@ -705,6 +724,7 @@
FT_Vector left_bearing, advance;
FT_Byte* charstring;
FT_ULong charstring_len;
+ FT_Pos glyph_width;
if ( decoder->seac )
@@ -713,6 +733,9 @@
return CFF_Err_Syntax_Error;
}
+ adx += decoder->builder.left_bearing.x;
+ ady += decoder->builder.left_bearing.y;
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
@@ -795,16 +818,17 @@
cff_free_glyph_data( face, &charstring, charstring_len );
}
- /* Save the left bearing and width of the base character */
- /* as they will be erased by the next load. */
+ /* Save the left bearing, advance and glyph width of the base */
+ /* character as they will be erased by the next load. */
left_bearing = builder->left_bearing;
advance = builder->advance;
+ glyph_width = decoder->glyph_width;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
- builder->pos_x = adx;
+ builder->pos_x = adx - asb;
builder->pos_y = ady;
/* Now load `achar' on top of the base outline. */
@@ -824,10 +848,11 @@
cff_free_glyph_data( face, &charstring, charstring_len );
}
- /* Restore the left side bearing and advance width */
- /* of the base character. */
+ /* Restore the left side bearing, advance and glyph width */
+ /* of the base character. */
builder->left_bearing = left_bearing;
builder->advance = advance;
+ decoder->glyph_width = glyph_width;
builder->pos_x = 0;
builder->pos_y = 0;
@@ -869,6 +894,8 @@
FT_Pos x, y;
FT_Fixed seed;
FT_Fixed* stack;
+ FT_Int charstring_type =
+ decoder->cff->top_font.font_dict.charstring_type;
T2_Hints_Funcs hinter;
@@ -958,7 +985,8 @@
( (FT_Int32)ip[2] << 8 ) |
ip[3];
ip += 4;
- shift = 0;
+ if ( charstring_type == 2 )
+ shift = 0;
}
if ( decoder->top - stack >= CFF_MAX_OPERANDS )
goto Stack_Overflow;
@@ -1032,6 +1060,12 @@
case 0:
op = cff_op_dotsection;
break;
+ case 1: /* this is actually the Type1 vstem3 operator */
+ op = cff_op_vstem;
+ break;
+ case 2: /* this is actually the Type1 hstem3 operator */
+ op = cff_op_hstem;
+ break;
case 3:
op = cff_op_and;
break;
@@ -1041,6 +1075,12 @@
case 5:
op = cff_op_not;
break;
+ case 6:
+ op = cff_op_seac;
+ break;
+ case 7:
+ op = cff_op_sbw;
+ break;
case 8:
op = cff_op_store;
break;
@@ -1104,6 +1144,9 @@
case 30:
op = cff_op_roll;
break;
+ case 33:
+ op = cff_op_setcurrentpoint;
+ break;
case 34:
op = cff_op_hflex;
break;
@@ -1171,7 +1214,7 @@
op = cff_op_hvcurveto;
break;
default:
- ;
+ break;
}
if ( op == cff_op_unknown )
@@ -1886,6 +1929,21 @@
}
break;
+ case cff_op_seac:
+ FT_TRACE4(( " seac\n" ));
+
+ error = cff_operator_seac( decoder,
+ args[0], args[1], args[2],
+ (FT_Int)( args[3] >> 16 ),
+ (FT_Int)( args[4] >> 16 ) );
+
+ /* add current outline to the glyph slot */
+ FT_GlyphLoader_Add( builder->loader );
+
+ /* return now! */
+ FT_TRACE4(( "\n" ));
+ return error;
+
case cff_op_endchar:
FT_TRACE4(( " endchar\n" ));
@@ -1895,10 +1953,8 @@
/* Save glyph width so that the subglyphs don't overwrite it. */
FT_Pos glyph_width = decoder->glyph_width;
-
error = cff_operator_seac( decoder,
- args[-4],
- args[-3],
+ 0L, args[-4], args[-3],
(FT_Int)( args[-2] >> 16 ),
(FT_Int)( args[-1] >> 16 ) );
@@ -2106,7 +2162,7 @@
FT_TRACE4(( " dup\n" ));
args[1] = args[0];
- args++;
+ args += 2;
break;
case cff_op_put:
@@ -2117,7 +2173,7 @@
FT_TRACE4(( " put\n" ));
- if ( idx >= 0 && idx < decoder->len_buildchar )
+ if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
decoder->buildchar[idx] = val;
}
break;
@@ -2130,7 +2186,7 @@
FT_TRACE4(( " get\n" ));
- if ( idx >= 0 && idx < decoder->len_buildchar )
+ if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
val = decoder->buildchar[idx];
args[0] = val;
@@ -2170,10 +2226,42 @@
FT_TRACE4(( " hsbw (invalid op)\n" ));
- decoder->glyph_width = decoder->nominal_width +
- (args[1] >> 16);
- x = args[0];
- y = 0;
+ decoder->glyph_width = decoder->nominal_width + ( args[1] >> 16 );
+
+ decoder->builder.left_bearing.x = args[0];
+ decoder->builder.left_bearing.y = 0;
+
+ x = decoder->builder.pos_x + args[0];
+ y = decoder->builder.pos_y;
+ args = stack;
+ break;
+
+ case cff_op_sbw:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " sbw (invalid op)\n" ));
+
+ decoder->glyph_width = decoder->nominal_width + ( args[2] >> 16 );
+
+ decoder->builder.left_bearing.x = args[0];
+ decoder->builder.left_bearing.y = args[1];
+
+ x = decoder->builder.pos_x + args[0];
+ y = decoder->builder.pos_y + args[1];
+ args = stack;
+ break;
+
+ case cff_op_setcurrentpoint:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " setcurrentpoint (invalid op)\n" ));
+
+ x = decoder->builder.pos_x + args[0];
+ y = decoder->builder.pos_y + args[1];
args = stack;
break;
@@ -2184,8 +2272,10 @@
FT_TRACE4(( " callothersubr (invalid op)\n" ));
- /* don't modify stack; handle the subr as `unknown' so that */
- /* following `pop' operands use the arguments on stack */
+ /* subsequent `pop' operands should add the arguments, */
+ /* this is the implementation described for `unknown' other */
+ /* subroutines in the Type1 spec. */
+ args -= 2 + ( args[-2] >> 16 );
break;
case cff_op_pop:
@@ -2674,23 +2764,25 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
- if ( !error &&
- face->root.internal->incremental_interface &&
+ if ( !error &&
+ face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->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.bearing_y = 0;
metrics.advance = decoder.builder.advance.x;
+ metrics.advance_v = decoder.builder.advance.y;
+
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;
+ decoder.builder.advance.y = metrics.advance_v;
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -2827,9 +2919,12 @@
if ( has_vertical_info )
metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
- else
- ft_synthesize_vertical_metrics( metrics,
- metrics->vertAdvance );
+ else
+ {
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ ft_synthesize_vertical_metrics( metrics,
+ metrics->vertAdvance );
+ }
}
}
diff --git a/freetype/src/cff/cffgload.h b/freetype/src/cff/cffgload.h
index 5c09ac3c2..ab8d6b222 100644
--- a/freetype/src/cff/cffgload.h
+++ b/freetype/src/cff/cffgload.h
@@ -28,8 +28,9 @@
FT_BEGIN_HEADER
-#define CFF_MAX_OPERANDS 48
-#define CFF_MAX_SUBRS_CALLS 32
+#define CFF_MAX_OPERANDS 48
+#define CFF_MAX_SUBRS_CALLS 32
+#define CFF_MAX_TRANS_ELEMENTS 32
/*************************************************************************/
@@ -137,8 +138,7 @@ FT_BEGIN_HEADER
FT_Bool read_width;
FT_Bool width_only;
FT_Int num_hints;
- FT_Fixed* buildchar;
- FT_Int len_buildchar;
+ FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS];
FT_UInt num_locals;
FT_UInt num_globals;
diff --git a/freetype/src/cff/cffobjs.c b/freetype/src/cff/cffobjs.c
index 55fa950f3..737763092 100644
--- a/freetype/src/cff/cffobjs.c
+++ b/freetype/src/cff/cffobjs.c
@@ -657,10 +657,11 @@
cffface->num_glyphs = cff->charstrings_index.count;
/* set global bbox, as well as EM size */
- cffface->bbox.xMin = dict->font_bbox.xMin >> 16;
- cffface->bbox.yMin = dict->font_bbox.yMin >> 16;
- cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFFU ) >> 16;
- cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFFU ) >> 16;
+ cffface->bbox.xMin = dict->font_bbox.xMin >> 16;
+ cffface->bbox.yMin = dict->font_bbox.yMin >> 16;
+ /* no `U' suffix here to 0xFFFF! */
+ cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFF ) >> 16;
+ cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFF ) >> 16;
cffface->units_per_EM = (FT_UShort)( dict->units_per_em );
diff --git a/freetype/src/cff/cffparse.c b/freetype/src/cff/cffparse.c
index 8174b8234..38ba7d88f 100644
--- a/freetype/src/cff/cffparse.c
+++ b/freetype/src/cff/cffparse.c
@@ -745,8 +745,10 @@
p++;
for (;;)
{
+ /* An unterminated floating point number at the */
+ /* end of a dictionary is invalid but harmless. */
if ( p >= limit )
- goto Syntax_Error;
+ goto Exit;
v = p[0] >> 4;
if ( v == 15 )
break;
diff --git a/freetype/src/cid/cidgload.c b/freetype/src/cid/cidgload.c
index e71206506..313ab9ecd 100644
--- a/freetype/src/cid/cidgload.c
+++ b/freetype/src/cid/cidgload.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -58,6 +58,8 @@
#endif
+ FT_TRACE4(( "cid_load_glyph: glyph index %d\n", glyph_index ));
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using */
@@ -171,16 +173,16 @@
metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
- metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+ 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.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
decoder->builder.advance.x = INT_TO_FIXED( metrics.advance );
- decoder->builder.advance.y = 0;
+ decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -425,9 +427,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 );
+ }
}
Exit:
diff --git a/freetype/src/cid/cidobjs.c b/freetype/src/cid/cidobjs.c
index dc18431f5..15ba96769 100644
--- a/freetype/src/cid/cidobjs.c
+++ b/freetype/src/cid/cidobjs.c
@@ -413,10 +413,11 @@
cidface->num_fixed_sizes = 0;
cidface->available_sizes = 0;
- cidface->bbox.xMin = cid->font_bbox.xMin >> 16;
- cidface->bbox.yMin = cid->font_bbox.yMin >> 16;
- cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
- cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
+ cidface->bbox.xMin = cid->font_bbox.xMin >> 16;
+ cidface->bbox.yMin = cid->font_bbox.yMin >> 16;
+ /* no `U' suffix here to 0xFFFF! */
+ cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFF ) >> 16;
+ cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFF ) >> 16;
if ( !cidface->units_per_EM )
cidface->units_per_EM = 1000;
diff --git a/freetype/src/cid/cidtoken.h b/freetype/src/cid/cidtoken.h
index 94a3657b0..904cb09cf 100644
--- a/freetype/src/cid/cidtoken.h
+++ b/freetype/src/cid/cidtoken.h
@@ -22,7 +22,7 @@
#define T1CODE T1_FIELD_LOCATION_CID_INFO
T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 )
- T1_FIELD_NUM ( "CIDFontVersion", cid_version, 0 )
+ T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 )
T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 )
T1_FIELD_STRING( "Registry", registry, 0 )
T1_FIELD_STRING( "Ordering", ordering, 0 )
diff --git a/freetype/src/lzw/ftlzw.c b/freetype/src/lzw/ftlzw.c
index 3a0cd3bf8..cb6d1e67a 100644
--- a/freetype/src/lzw/ftlzw.c
+++ b/freetype/src/lzw/ftlzw.c
@@ -8,7 +8,7 @@
/* be used to parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2004, 2005, 2006, 2009 by */
+/* Copyright 2004, 2005, 2006, 2009, 2010 by */
/* Albert Chin-A-Young. */
/* */
/* Based on code in src/gzip/ftgzip.c, Copyright 2004 by */
@@ -122,13 +122,9 @@
zip->pos = 0;
/* check and skip .Z header */
- {
- stream = source;
-
- error = ft_lzw_check_header( source );
- if ( error )
- goto Exit;
- }
+ error = ft_lzw_check_header( source );
+ if ( error )
+ goto Exit;
/* initialize internal lzw variable */
ft_lzwstate_init( lzw, source );
diff --git a/freetype/src/pfr/pfrsbit.c b/freetype/src/pfr/pfrsbit.c
index 5b7f237c2..7f72aaf93 100644
--- a/freetype/src/pfr/pfrsbit.c
+++ b/freetype/src/pfr/pfrsbit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (body). */
/* */
-/* Copyright 2002, 2003, 2006 by */
+/* Copyright 2002, 2003, 2006, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -600,8 +600,8 @@
/* get the bitmap metrics */
{
- FT_Long xpos, ypos, advance;
- FT_UInt xsize, ysize, format;
+ FT_Long xpos = 0, ypos = 0, advance = 0;
+ FT_UInt xsize = 0, ysize = 0, format = 0;
FT_Byte* p;
diff --git a/freetype/src/psaux/t1decode.c b/freetype/src/psaux/t1decode.c
index c79364396..79f73644d 100644
--- a/freetype/src/psaux/t1decode.c
+++ b/freetype/src/psaux/t1decode.c
@@ -4,7 +4,8 @@
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -211,7 +212,12 @@
/* `glyph_names' is set to 0 for CID fonts which do not */
/* include an encoding. How can we deal with these? */
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( decoder->glyph_names == 0 &&
+ !face->root.internal->incremental_interface )
+#else
if ( decoder->glyph_names == 0 )
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
FT_ERROR(( "t1operator_seac:"
" glyph names table not available in this font\n" ));
@@ -1453,12 +1459,20 @@
case op_setcurrentpoint:
FT_TRACE4(( " setcurrentpoint" ));
- /* From the T1 specs, section 6.4: */
+ /* From the T1 specification, section 6.4: */
/* */
/* The setcurrentpoint command is used only in */
/* conjunction with results from OtherSubrs procedures. */
- /* known_othersubr_result_cnt != 0 is already handled above */
+ /* known_othersubr_result_cnt != 0 is already handled */
+ /* above. */
+
+ /* Note, however, that both Ghostscript and Adobe */
+ /* Distiller handle this situation by silently ignoring */
+ /* the inappropriate `setcurrentpoint' instruction. So */
+ /* we do the same. */
+#if 0
+
if ( decoder->flex_state != 1 )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1466,6 +1480,7 @@
goto Syntax_Error;
}
else
+#endif
decoder->flex_state = 0;
break;
diff --git a/freetype/src/psnames/psmodule.c b/freetype/src/psnames/psmodule.c
index ead23399b..0ff231c2b 100644
--- a/freetype/src/psnames/psmodule.c
+++ b/freetype/src/psnames/psmodule.c
@@ -561,8 +561,7 @@
psnames_get_service( FT_Module module,
const char* service_id )
{
- FT_Library library = module->library;
- FT_UNUSED(library);
+ FT_UNUSED( module );
return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
}
diff --git a/freetype/src/sfnt/sfdriver.c b/freetype/src/sfnt/sfdriver.c
index dd08b12bc..669f22ff3 100644
--- a/freetype/src/sfnt/sfdriver.c
+++ b/freetype/src/sfnt/sfdriver.c
@@ -417,8 +417,6 @@
sfnt_get_interface( FT_Module module,
const char* module_interface )
{
- FT_Library library = module->library;
- FT_UNUSED(library);
FT_UNUSED( module );
return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface );
diff --git a/freetype/src/sfnt/sfobjs.c b/freetype/src/sfnt/sfobjs.c
index 0d5ea0ce3..515afc21a 100644
--- a/freetype/src/sfnt/sfobjs.c
+++ b/freetype/src/sfnt/sfobjs.c
@@ -26,6 +26,7 @@
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
+#include FT_SFNT_NAMES_H
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_BDF
@@ -527,13 +528,27 @@
#endif
FT_Bool has_outline;
FT_Bool is_apple_sbit;
+ FT_Bool ignore_preferred_family = FALSE;
+ FT_Bool ignore_preferred_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_UNUSED( face_index );
- FT_UNUSED( num_params );
- FT_UNUSED( params );
+ /* Check parameters */
+
+ {
+ FT_Int i;
+
+
+ for ( i = 0; i < num_params; i++ )
+ {
+ if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY )
+ ignore_preferred_family = TRUE;
+ else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY )
+ ignore_preferred_subfamily = TRUE;
+ }
+ }
/* Load tables */
@@ -722,26 +737,30 @@
/* Foundation (WPF). This flag has been introduced in version */
/* 1.5 of the OpenType specification (May 2008). */
+ face->root.family_name = NULL;
+ face->root.style_name = NULL;
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
{
- GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
+ if ( !ignore_preferred_family )
+ GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
- GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
+ if ( !ignore_preferred_subfamily )
+ GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
else
{
GET_NAME( WWS_FAMILY, &face->root.family_name );
- if ( !face->root.family_name )
+ if ( !face->root.family_name && !ignore_preferred_family )
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name )
+ if ( !face->root.style_name && !ignore_preferred_subfamily )
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
diff --git a/freetype/src/sfnt/ttcmap.c b/freetype/src/sfnt/ttcmap.c
index 47bd18388..e943a47ce 100644
--- a/freetype/src/sfnt/ttcmap.c
+++ b/freetype/src/sfnt/ttcmap.c
@@ -2574,10 +2574,7 @@
}
- FT_CALLBACK_TABLE_DEF
- const TT_CMap_ClassRec tt_cmap13_class_rec =
- {
- {
+ FT_DEFINE_TT_CMAP(tt_cmap13_class_rec,
sizeof ( TT_CMap13Rec ),
(FT_CMap_InitFunc) tt_cmap13_init,
@@ -2586,11 +2583,11 @@
(FT_CMap_CharNextFunc) tt_cmap13_char_next,
NULL, NULL, NULL, NULL, NULL
- },
+ ,
13,
(TT_CMap_ValidateFunc) tt_cmap13_validate,
(TT_CMap_Info_GetFunc) tt_cmap13_get_info
- };
+ )
#endif /* TT_CONFIG_CMAP_FORMAT_13 */
diff --git a/freetype/src/sfnt/ttload.c b/freetype/src/sfnt/ttload.c
index 28b67401a..17c65e551 100644
--- a/freetype/src/sfnt/ttload.c
+++ b/freetype/src/sfnt/ttload.c
@@ -168,10 +168,10 @@
check_table_dir( SFNT_Header sfnt,
FT_Stream stream )
{
- FT_Error error;
- FT_UInt nn, valid_entries = 0;
- FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
- FT_ULong offset = sfnt->offset + 12;
+ FT_Error error;
+ FT_UShort nn, valid_entries = 0;
+ FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
+ FT_ULong offset = sfnt->offset + 12;
static const FT_Frame_Field table_dir_entry_fields[] =
{
diff --git a/freetype/src/tools/apinames.c b/freetype/src/tools/apinames.c
index 19aec500b..7f191e19c 100644
--- a/freetype/src/tools/apinames.c
+++ b/freetype/src/tools/apinames.c
@@ -10,7 +10,7 @@
* accepted if you are using GCC for compilation (and probably by
* other compilers too).
*
- * Author: David Turner, 2005, 2006, 2008
+ * Author: David Turner, 2005, 2006, 2008, 2009
*
* This code is explicitly placed into the public domain.
*
@@ -265,7 +265,7 @@ read_header_file( FILE* file, int verbose )
if ( p > name )
{
if ( verbose )
- fprintf( stderr, ">>> %.*s\n", p-name, name );
+ fprintf( stderr, ">>> %.*s\n", (int)(p - name), name );
names_add( name, p );
}
diff --git a/freetype/src/truetype/ttdriver.c b/freetype/src/truetype/ttdriver.c
index 261135692..c3a7d53ab 100644
--- a/freetype/src/truetype/ttdriver.c
+++ b/freetype/src/truetype/ttdriver.c
@@ -4,7 +4,8 @@
/* */
/* TrueType font driver implementation (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -298,7 +299,15 @@
if ( !size )
return TT_Err_Invalid_Size_Handle;
- if ( !face || glyph_index >= (FT_UInt)face->num_glyphs )
+ if ( !face )
+ return TT_Err_Invalid_Argument;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( glyph_index >= (FT_UInt)face->num_glyphs &&
+ !face->internal->incremental_interface )
+#else
+ if ( glyph_index >= (FT_UInt)face->num_glyphs )
+#endif
return TT_Err_Invalid_Argument;
if ( load_flags & FT_LOAD_NO_HINTING )
@@ -393,16 +402,17 @@
tt_get_interface( FT_Module driver, /* TT_Driver */
const char* tt_interface )
{
- FT_Library library = driver->library;
FT_Module_Interface result;
FT_Module sfntd;
SFNT_Service sfnt;
- FT_UNUSED(library);
result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface );
if ( result != NULL )
return result;
+ if ( !driver )
+ return NULL;
+
/* only return the default interface from the SFNT module */
sfntd = FT_Get_Module( driver->library, "sfnt" );
if ( sfntd )
diff --git a/freetype/src/truetype/ttgload.c b/freetype/src/truetype/ttgload.c
index e660f6d17..b65e827c4 100644
--- a/freetype/src/truetype/ttgload.c
+++ b/freetype/src/truetype/ttgload.c
@@ -4,7 +4,8 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -69,7 +70,7 @@
/* `check' is true, take care of monospaced fonts by returning the */
/* advance width maximum. */
/* */
- FT_LOCAL_DEF(void)
+ FT_LOCAL_DEF( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
FT_Bool check,
@@ -80,6 +81,9 @@
if ( check && face->postscript.isFixedPitch )
*aw = face->horizontal.advance_Width_Max;
+
+ FT_TRACE5(( " advance width (font units): %d\n", *aw ));
+ FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
}
@@ -96,7 +100,7 @@
/* The monospace `check' is probably not meaningful here, but we leave */
/* it in for a consistent interface. */
/* */
- FT_LOCAL_DEF(void)
+ FT_LOCAL_DEF( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
FT_Bool check,
@@ -131,6 +135,91 @@
#endif
+ FT_TRACE5(( " advance height (font units): %d\n", *ah ));
+ FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
+ }
+
+
+ static void
+ tt_get_metrics( TT_Loader loader,
+ FT_UInt glyph_index )
+ {
+ TT_Face face = (TT_Face)loader->face;
+
+ FT_Short left_bearing = 0, top_bearing = 0;
+ FT_UShort advance_width = 0, advance_height = 0;
+
+
+ TT_Get_HMetrics( face, glyph_index,
+ (FT_Bool)!( loader->load_flags &
+ FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+ &left_bearing,
+ &advance_width );
+ TT_Get_VMetrics( face, glyph_index,
+ (FT_Bool)!( loader->load_flags &
+ FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+ &top_bearing,
+ &advance_height );
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+
+ /* If this is an incrementally loaded font check whether there are */
+ /* overriding metrics for this glyph. */
+ if ( face->root.internal->incremental_interface &&
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics )
+ {
+ FT_Incremental_MetricsRec metrics;
+ FT_Error error;
+
+
+ metrics.bearing_x = left_bearing;
+ metrics.bearing_y = 0;
+ metrics.advance = advance_width;
+ metrics.advance_v = 0;
+
+ error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
+ glyph_index, FALSE, &metrics );
+ if ( error )
+ goto Exit;
+
+ left_bearing = (FT_Short)metrics.bearing_x;
+ advance_width = (FT_UShort)metrics.advance;
+
+#if 0
+
+ /* GWW: Do I do the same for vertical metrics? */
+ metrics.bearing_x = 0;
+ metrics.bearing_y = top_bearing;
+ metrics.advance = advance_height;
+
+ error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
+ glyph_index, TRUE, &metrics );
+ if ( error )
+ goto Exit;
+
+ top_bearing = (FT_Short)metrics.bearing_y;
+ advance_height = (FT_UShort)metrics.advance;
+
+#endif /* 0 */
+
+ }
+
+ Exit:
+
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+
+ loader->left_bearing = left_bearing;
+ loader->advance = advance_width;
+ loader->top_bearing = top_bearing;
+ loader->vadvance = advance_height;
+
+ if ( !loader->linear_def )
+ {
+ loader->linear_def = 1;
+ loader->linear = advance_width;
+ }
}
@@ -1102,9 +1191,10 @@
static FT_Error
load_truetype_glyph( TT_Loader loader,
FT_UInt glyph_index,
- FT_UInt recurse_count )
+ FT_UInt recurse_count,
+ FT_Bool header_only )
{
- FT_Error error;
+ FT_Error error = TT_Err_Ok;
FT_Fixed x_scale, y_scale;
FT_ULong offset;
TT_Face face = (TT_Face)loader->face;
@@ -1151,75 +1241,7 @@
y_scale = 0x10000L;
}
- /* get metrics, horizontal and vertical */
- {
- FT_Short left_bearing = 0, top_bearing = 0;
- FT_UShort advance_width = 0, advance_height = 0;
-
-
- TT_Get_HMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
- &left_bearing,
- &advance_width );
- TT_Get_VMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
- &top_bearing,
- &advance_height );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* If this is an incrementally loaded font see if there are */
- /* overriding metrics for this glyph. */
- if ( face->root.internal->incremental_interface &&
- face->root.internal->incremental_interface->funcs->get_glyph_metrics )
- {
- FT_Incremental_MetricsRec metrics;
-
-
- metrics.bearing_x = left_bearing;
- metrics.bearing_y = 0;
- metrics.advance = advance_width;
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
- face->root.internal->incremental_interface->object,
- glyph_index, FALSE, &metrics );
- if ( error )
- goto Exit;
- left_bearing = (FT_Short)metrics.bearing_x;
- advance_width = (FT_UShort)metrics.advance;
-
-#if 0
-
- /* GWW: Do I do the same for vertical metrics? */
- metrics.bearing_x = 0;
- metrics.bearing_y = top_bearing;
- metrics.advance = advance_height;
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
- face->root.internal->incremental_interface->object,
- glyph_index, TRUE, &metrics );
- if ( error )
- goto Exit;
- top_bearing = (FT_Short)metrics.bearing_y;
- advance_height = (FT_UShort)metrics.advance;
-
-#endif /* 0 */
-
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- loader->left_bearing = left_bearing;
- loader->advance = advance_width;
- loader->top_bearing = top_bearing;
- loader->vadvance = advance_height;
-
- if ( !loader->linear_def )
- {
- loader->linear_def = 1;
- loader->linear = advance_width;
- }
- }
+ tt_get_metrics( loader, glyph_index );
/* Set `offset' to the start of the glyph relative to the start of */
/* the `glyf' table, and `byte_len' to the length of the glyph in */
@@ -1257,7 +1279,13 @@
if ( loader->byte_len > 0 )
{
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* for the incremental interface, `glyf_offset' is always zero */
+ if ( !loader->glyf_offset &&
+ !face->root.internal->incremental_interface )
+#else
if ( !loader->glyf_offset )
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
error = TT_Err_Invalid_Table;
@@ -1272,9 +1300,9 @@
opened_frame = 1;
- /* read first glyph header */
+ /* read glyph header first */
error = face->read_glyph_header( loader );
- if ( error )
+ if ( error || header_only )
goto Exit;
}
@@ -1285,6 +1313,9 @@
loader->bbox.yMin = 0;
loader->bbox.yMax = 0;
+ if ( header_only )
+ goto Exit;
+
TT_LOADER_SET_PP( loader );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
@@ -1474,7 +1505,7 @@
num_base_points = gloader->base.outline.n_points;
error = load_truetype_glyph( loader, subglyph->index,
- recurse_count + 1 );
+ recurse_count + 1, FALSE );
if ( error )
goto Exit;
@@ -1697,7 +1728,7 @@
/* scale the metrics */
if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
{
- top = FT_MulFix( top, y_scale );
+ top = FT_MulFix( top, y_scale );
advance = FT_MulFix( advance, y_scale );
}
@@ -1757,6 +1788,7 @@
glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
glyph->format = FT_GLYPH_FORMAT_BITMAP;
+
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
glyph->bitmap_left = metrics.vertBearingX;
@@ -1779,7 +1811,8 @@
tt_loader_init( TT_Loader loader,
TT_Size size,
TT_GlyphSlot glyph,
- FT_Int32 load_flags )
+ FT_Int32 load_flags,
+ FT_Bool glyf_table_only )
{
TT_Face face;
FT_Stream stream;
@@ -1793,7 +1826,7 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
/* load execution context */
- if ( IS_HINTED( load_flags ) )
+ if ( IS_HINTED( load_flags ) && !glyf_table_only )
{
TT_ExecContext exec;
FT_Bool grayscale;
@@ -1874,6 +1907,7 @@
}
/* get face's glyph loader */
+ if ( !glyf_table_only )
{
FT_GlyphLoader gloader = glyph->internal->loader;
@@ -1945,7 +1979,25 @@
{
error = load_sbit_image( size, glyph, glyph_index, load_flags );
if ( !error )
+ {
+ FT_Face root = &face->root;
+
+
+ if ( FT_IS_SCALABLE( root ) )
+ {
+ /* for the bbox we need the header only */
+ (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
+ (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
+ glyph->linearHoriAdvance = loader.linear;
+ glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
+ loader.vadvance;
+ if ( face->postscript.isFixedPitch &&
+ ( load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
+ glyph->linearHoriAdvance = face->horizontal.advance_Width_Max;
+ }
+
return TT_Err_Ok;
+ }
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
@@ -1957,7 +2009,7 @@
if ( load_flags & FT_LOAD_SBITS_ONLY )
return TT_Err_Invalid_Argument;
- error = tt_loader_init( &loader, size, glyph, load_flags );
+ error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
if ( error )
return error;
@@ -1966,7 +2018,7 @@
glyph->outline.flags = 0;
/* main loading loop */
- error = load_truetype_glyph( &loader, glyph_index, 0 );
+ error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
if ( !error )
{
if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
diff --git a/freetype/src/truetype/ttgxvar.c b/freetype/src/truetype/ttgxvar.c
index c395028e8..e1729219b 100644
--- a/freetype/src/truetype/ttgxvar.c
+++ b/freetype/src/truetype/ttgxvar.c
@@ -94,11 +94,8 @@
#define ALL_POINTS (FT_UShort*)( -1 )
- enum
- {
- GX_PT_POINTS_ARE_WORDS = 0x80,
- GX_PT_POINT_RUN_COUNT_MASK = 0x7F
- };
+#define GX_PT_POINTS_ARE_WORDS 0x80
+#define GX_PT_POINT_RUN_COUNT_MASK 0x7F
/*************************************************************************/
@@ -214,9 +211,9 @@
FT_Offset delta_cnt )
{
FT_Short *deltas;
- FT_Int runcnt;
+ FT_UInt runcnt;
FT_Offset i;
- FT_Offset j;
+ FT_UInt j;
FT_Memory memory = stream->memory;
FT_Error error = TT_Err_Ok;
diff --git a/freetype/src/type1/t1afm.c b/freetype/src/type1/t1afm.c
index 25a69f09a..89a2bfb61 100644
--- a/freetype/src/type1/t1afm.c
+++ b/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, */
@@ -58,7 +58,7 @@
/* PS string/name length must be < 16-bit */
- if ( ( len - 0xFFFFU ) > 0 )
+ if ( len > 0xFFFFU )
return 0;
for ( n = 0; n < type1->num_glyphs; n++ )
@@ -285,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/freetype/src/type1/t1gload.c b/freetype/src/type1/t1gload.c
index ef7888a64..f680ad4c4 100644
--- a/freetype/src/type1/t1gload.c
+++ b/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, */
@@ -103,16 +103,16 @@
metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
- metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+ 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.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
decoder->builder.advance.x = INT_TO_FIXED( metrics.advance );
- decoder->builder.advance.y = 0;
+ decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -287,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;
@@ -396,10 +401,20 @@
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;
@@ -459,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/freetype/src/type1/t1objs.c b/freetype/src/type1/t1objs.c
index 061e1f4be..d9d897ffb 100644
--- a/freetype/src/type1/t1objs.c
+++ b/freetype/src/type1/t1objs.c
@@ -441,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 )
diff --git a/freetype/src/type1/t1parse.c b/freetype/src/type1/t1parse.c
index da5065979..75d1419a1 100644
--- a/freetype/src/type1/t1parse.c
+++ b/freetype/src/type1/t1parse.c
@@ -397,15 +397,18 @@
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:"
" `eexec' not properly terminated\n" ));