summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pcf
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pcf')
-rw-r--r--src/3rdparty/freetype/src/pcf/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/pcf/README4
-rw-r--r--src/3rdparty/freetype/src/pcf/pcf.c8
-rw-r--r--src/3rdparty/freetype/src/pcf/pcf.h20
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.c259
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.h6
-rw-r--r--src/3rdparty/freetype/src/pcf/pcferror.h8
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.c470
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.h6
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfutil.h6
10 files changed, 607 insertions, 182 deletions
diff --git a/src/3rdparty/freetype/src/pcf/Jamfile b/src/3rdparty/freetype/src/pcf/Jamfile
index f4789ea625..7b92b12ddc 100644
--- a/src/3rdparty/freetype/src/pcf/Jamfile
+++ b/src/3rdparty/freetype/src/pcf/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/pcf Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/pcf/README b/src/3rdparty/freetype/src/pcf/README
index 10eff15fbe..09ea970eda 100644
--- a/src/3rdparty/freetype/src/pcf/README
+++ b/src/3rdparty/freetype/src/pcf/README
@@ -41,8 +41,8 @@ value given as argument into the corresponding glyph number.
Known problems
**************
-- dealing explicitly with encodings breaks the uniformity of freetype2
- api.
+- dealing explicitly with encodings breaks the uniformity of FreeType 2
+ API.
- except for encodings properties, client applications have no
visibility of the PCF_Face object. This means that applications
diff --git a/src/3rdparty/freetype/src/pcf/pcf.c b/src/3rdparty/freetype/src/pcf/pcf.c
index 11d5b7b2a0..8ffd6e280b 100644
--- a/src/3rdparty/freetype/src/pcf/pcf.c
+++ b/src/3rdparty/freetype/src/pcf/pcf.c
@@ -26,11 +26,11 @@ THE SOFTWARE.
#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-
#include <ft2build.h>
-#include "pcfutil.c"
-#include "pcfread.c"
+
#include "pcfdrivr.c"
+#include "pcfread.c"
+#include "pcfutil.c"
+
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcf.h b/src/3rdparty/freetype/src/pcf/pcf.h
index c0da503412..f0390cb1eb 100644
--- a/src/3rdparty/freetype/src/pcf/pcf.h
+++ b/src/3rdparty/freetype/src/pcf/pcf.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCF_H__
-#define __PCF_H__
+#ifndef PCF_H_
+#define PCF_H_
#include <ft2build.h>
@@ -163,6 +163,15 @@ FT_BEGIN_HEADER
} PCF_FaceRec, *PCF_Face;
+ typedef struct PCF_DriverRec_
+ {
+ FT_DriverRec root;
+
+ FT_Bool no_long_family_names;
+
+ } PCF_DriverRec, *PCF_Driver;
+
+
/* macros for pcf font format */
#define LSBFirst 0
@@ -226,12 +235,13 @@ FT_BEGIN_HEADER
#define GLYPHPADOPTIONS 4 /* I'm not sure about this */
FT_LOCAL( FT_Error )
- pcf_load_font( FT_Stream,
- PCF_Face );
+ pcf_load_font( FT_Stream stream,
+ PCF_Face face,
+ FT_Long face_index );
FT_END_HEADER
-#endif /* __PCF_H__ */
+#endif /* PCF_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c
index 8d2ed7cf4d..0119d94853 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c
+++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.c
@@ -49,6 +49,8 @@ THE SOFTWARE.
#include FT_SERVICE_BDF_H
#include FT_SERVICE_FONT_FORMAT_H
+#include FT_SERVICE_PROPERTIES_H
+#include FT_DRIVER_H
/*************************************************************************/
@@ -271,7 +273,7 @@ THE SOFTWARE.
FT_TRACE2(( "PCF driver\n" ));
- error = pcf_load_font( stream, face );
+ error = pcf_load_font( stream, face, face_index );
if ( error )
{
PCF_Face_Done( pcfface );
@@ -286,6 +288,7 @@ THE SOFTWARE.
/* this didn't work, try gzip support! */
+ FT_TRACE2(( " ... try gzip stream\n" ));
error2 = FT_Stream_OpenGzip( &face->comp_stream, stream );
if ( FT_ERR_EQ( error2, Unimplemented_Feature ) )
goto Fail;
@@ -301,6 +304,7 @@ THE SOFTWARE.
/* this didn't work, try LZW support! */
+ FT_TRACE2(( " ... try LZW stream\n" ));
error3 = FT_Stream_OpenLZW( &face->comp_stream, stream );
if ( FT_ERR_EQ( error3, Unimplemented_Feature ) )
goto Fail;
@@ -316,6 +320,7 @@ THE SOFTWARE.
/* this didn't work, try Bzip2 support! */
+ FT_TRACE2(( " ... try Bzip2 stream\n" ));
error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream );
if ( FT_ERR_EQ( error4, Unimplemented_Feature ) )
goto Fail;
@@ -332,7 +337,7 @@ THE SOFTWARE.
stream = pcfface->stream;
- error = pcf_load_font( stream, face );
+ error = pcf_load_font( stream, face, face_index );
if ( error )
goto Fail;
@@ -351,7 +356,9 @@ THE SOFTWARE.
* an invalid argument error when the font could be
* opened by the specified driver.
*/
- if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
+ if ( face_index < 0 )
+ goto Exit;
+ else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
{
FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
PCF_Face_Done( pcfface );
@@ -380,7 +387,11 @@ THE SOFTWARE.
if ( !ft_strcmp( s, "10646" ) ||
( !ft_strcmp( s, "8859" ) &&
!ft_strcmp( face->charset_encoding, "1" ) ) )
- unicode_charmap = 1;
+ unicode_charmap = 1;
+ /* another name for ASCII */
+ else if ( !ft_strcmp( s, "646.1991" ) &&
+ !ft_strcmp( face->charset_encoding, "IRV" ) )
+ unicode_charmap = 1;
}
}
@@ -402,12 +413,6 @@ THE SOFTWARE.
}
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( pcfface->num_charmaps )
- pcfface->charmap = pcfface->charmaps[0];
-#endif
}
}
@@ -490,8 +495,6 @@ THE SOFTWARE.
PCF_Metric metric;
FT_ULong bytes;
- FT_UNUSED( load_flags );
-
FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
@@ -521,11 +524,6 @@ THE SOFTWARE.
bitmap->num_grays = 1;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
- FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n",
- PCF_BIT_ORDER( face->bitmapsFormat ),
- PCF_BYTE_ORDER( face->bitmapsFormat ),
- PCF_GLYPH_PAD( face->bitmapsFormat ) ));
-
switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) )
{
case 1:
@@ -548,6 +546,24 @@ THE SOFTWARE.
return FT_THROW( Invalid_File_Format );
}
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ slot->bitmap_left = metric->leftSideBearing;
+ slot->bitmap_top = metric->ascent;
+
+ slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 );
+ slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 );
+ slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 );
+ slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing -
+ metric->leftSideBearing ) * 64 );
+ slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
+
+ ft_synthesize_vertical_metrics( &slot->metrics,
+ ( face->accel.fontAscent +
+ face->accel.fontDescent ) * 64 );
+
+ if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
+ goto Exit;
+
/* XXX: to do: are there cases that need repadding the bitmap? */
bytes = (FT_ULong)bitmap->pitch * bitmap->rows;
@@ -580,21 +596,6 @@ THE SOFTWARE.
}
}
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = metric->leftSideBearing;
- slot->bitmap_top = metric->ascent;
-
- slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 );
- slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 );
- slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 );
- slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing -
- metric->leftSideBearing ) * 64 );
- slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
-
- ft_synthesize_vertical_metrics( &slot->metrics,
- ( face->accel.fontAscent +
- face->accel.fontDescent ) * 64 );
-
Exit:
return error;
}
@@ -615,7 +616,7 @@ THE SOFTWARE.
prop = pcf_find_property( face, prop_name );
- if ( prop != NULL )
+ if ( prop )
{
if ( prop->isString )
{
@@ -624,19 +625,23 @@ THE SOFTWARE.
}
else
{
- if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
+ if ( prop->value.l > 0x7FFFFFFFL ||
+ prop->value.l < ( -1 - 0x7FFFFFFFL ) )
{
- FT_TRACE1(( "pcf_get_bdf_property: " ));
- FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
+ FT_TRACE1(( "pcf_get_bdf_property:" ));
+ FT_TRACE1(( " too large integer 0x%x is truncated\n" ));
}
- /* Apparently, the PCF driver loads all properties as signed integers!
- * This really doesn't seem to be a problem, because this is
- * sufficient for any meaningful values.
+
+ /*
+ * The PCF driver loads all properties as signed integers.
+ * This really doesn't seem to be a problem, because this is
+ * sufficient for any meaningful values.
*/
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = (FT_Int32)prop->value.l;
}
- return 0;
+
+ return FT_Err_Ok;
}
return FT_THROW( Invalid_Argument );
@@ -651,17 +656,127 @@ THE SOFTWARE.
*acharset_encoding = face->charset_encoding;
*acharset_registry = face->charset_registry;
- return 0;
+ return FT_Err_Ok;
}
static const FT_Service_BDFRec pcf_service_bdf =
{
- (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id,
- (FT_BDF_GetPropertyFunc) pcf_get_bdf_property
+ (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id, /* get_charset_id */
+ (FT_BDF_GetPropertyFunc) pcf_get_bdf_property /* get_property */
};
+ /*
+ * PROPERTY SERVICE
+ *
+ */
+ static FT_Error
+ pcf_property_set( FT_Module module, /* PCF_Driver */
+ const char* property_name,
+ const void* value,
+ FT_Bool value_is_string )
+ {
+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
+
+ FT_Error error = FT_Err_Ok;
+ PCF_Driver driver = (PCF_Driver)module;
+
+#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+ FT_UNUSED( value_is_string );
+#endif
+
+
+ if ( !ft_strcmp( property_name, "no-long-family-names" ) )
+ {
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+ if ( value_is_string )
+ {
+ const char* s = (const char*)value;
+ long lfn = ft_strtol( s, NULL, 10 );
+
+
+ if ( lfn == 0 )
+ driver->no_long_family_names = 0;
+ else if ( lfn == 1 )
+ driver->no_long_family_names = 1;
+ else
+ return FT_THROW( Invalid_Argument );
+ }
+ else
+#endif
+ {
+ FT_Bool* no_long_family_names = (FT_Bool*)value;
+
+
+ driver->no_long_family_names = *no_long_family_names;
+ }
+
+ return error;
+ }
+
+#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+ FT_UNUSED( module );
+ FT_UNUSED( value );
+ FT_UNUSED( value_is_string );
+#ifndef FT_DEBUG_LEVEL_TRACE
+ FT_UNUSED( property_name );
+#endif
+
+#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+ FT_TRACE0(( "pcf_property_set: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ static FT_Error
+ pcf_property_get( FT_Module module, /* PCF_Driver */
+ const char* property_name,
+ const void* value )
+ {
+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
+
+ FT_Error error = FT_Err_Ok;
+ PCF_Driver driver = (PCF_Driver)module;
+
+
+ if ( !ft_strcmp( property_name, "no-long-family-names" ) )
+ {
+ FT_Bool no_long_family_names = driver->no_long_family_names;
+ FT_Bool* val = (FT_Bool*)value;
+
+
+ *val = no_long_family_names;
+
+ return error;
+ }
+
+#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+ FT_UNUSED( module );
+ FT_UNUSED( value );
+#ifndef FT_DEBUG_LEVEL_TRACE
+ FT_UNUSED( property_name );
+#endif
+
+#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+ FT_TRACE0(( "pcf_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ pcf_service_properties,
+
+ (FT_Properties_SetFunc)pcf_property_set, /* set_property */
+ (FT_Properties_GetFunc)pcf_property_get ) /* get_property */
+
+
/*
*
* SERVICE LIST
@@ -672,6 +787,7 @@ THE SOFTWARE.
{
{ FT_SERVICE_ID_BDF, &pcf_service_bdf },
{ FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF },
+ { FT_SERVICE_ID_PROPERTIES, &pcf_service_properties },
{ NULL, NULL }
};
@@ -686,44 +802,67 @@ THE SOFTWARE.
}
+ FT_CALLBACK_DEF( FT_Error )
+ pcf_driver_init( FT_Module module ) /* PCF_Driver */
+ {
+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
+ PCF_Driver driver = (PCF_Driver)module;
+
+
+ driver->no_long_family_names = 0;
+#else
+ FT_UNUSED( module );
+#endif
+
+ return FT_Err_Ok;
+ }
+
+
+ FT_CALLBACK_DEF( void )
+ pcf_driver_done( FT_Module module ) /* PCF_Driver */
+ {
+ FT_UNUSED( module );
+ }
+
+
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pcf_driver_class =
{
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_NO_OUTLINES,
- sizeof ( FT_DriverRec ),
+ sizeof ( PCF_DriverRec ),
"pcf",
0x10000L,
0x20000L,
- 0,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- pcf_driver_requester
+ pcf_driver_init, /* FT_Module_Constructor module_init */
+ pcf_driver_done, /* FT_Module_Destructor module_done */
+ pcf_driver_requester /* FT_Module_Requester get_interface */
},
sizeof ( PCF_FaceRec ),
sizeof ( FT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
- PCF_Face_Init,
- PCF_Face_Done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- 0, /* FT_Slot_InitFunc */
- 0, /* FT_Slot_DoneFunc */
+ PCF_Face_Init, /* FT_Face_InitFunc init_face */
+ PCF_Face_Done, /* FT_Face_DoneFunc done_face */
+ NULL, /* FT_Size_InitFunc init_size */
+ NULL, /* FT_Size_DoneFunc done_size */
+ NULL, /* FT_Slot_InitFunc init_slot */
+ NULL, /* FT_Slot_DoneFunc done_slot */
- PCF_Glyph_Load,
+ PCF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- PCF_Size_Request,
- PCF_Size_Select
+ PCF_Size_Request, /* FT_Size_RequestFunc request_size */
+ PCF_Size_Select /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.h b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
index 54614951b5..29d30497cd 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.h
+++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFDRIVR_H__
-#define __PCFDRIVR_H__
+#ifndef PCFDRIVR_H_
+#define PCFDRIVR_H_
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
@@ -42,7 +42,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFDRIVR_H__ */
+#endif /* PCFDRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcferror.h b/src/3rdparty/freetype/src/pcf/pcferror.h
index e51fff8ea6..add8ef2230 100644
--- a/src/3rdparty/freetype/src/pcf/pcferror.h
+++ b/src/3rdparty/freetype/src/pcf/pcferror.h
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __PCFERROR_H__
-#define __PCFERROR_H__
+#ifndef PCFERROR_H_
+#define PCFERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PCF_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __PCFERROR_H__ */
+#endif /* PCFERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c
index afa1480771..537da0dc79 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.c
+++ b/src/3rdparty/freetype/src/pcf/pcfread.c
@@ -50,8 +50,15 @@ THE SOFTWARE.
#ifdef FT_DEBUG_LEVEL_TRACE
static const char* const tableNames[] =
{
- "prop", "accl", "mtrcs", "bmps", "imtrcs",
- "enc", "swidth", "names", "accel"
+ "properties",
+ "accelerators",
+ "metrics",
+ "bitmaps",
+ "ink metrics",
+ "encodings",
+ "swidths",
+ "glyph names",
+ "BDF accelerators"
};
#endif
@@ -102,13 +109,27 @@ THE SOFTWARE.
FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
return FT_THROW( Cannot_Open_Resource );
- if ( toc->version != PCF_FILE_VERSION ||
- toc->count > FT_ARRAY_MAX( face->toc.tables ) ||
- toc->count == 0 )
+ if ( toc->version != PCF_FILE_VERSION ||
+ toc->count == 0 )
return FT_THROW( Invalid_File_Format );
+ if ( stream->size < 16 )
+ return FT_THROW( Invalid_File_Format );
+
+ /* we need 16 bytes per TOC entry, */
+ /* and there can be most 9 tables */
+ if ( toc->count > ( stream->size >> 4 ) ||
+ toc->count > 9 )
+ {
+ FT_TRACE0(( "pcf_read_TOC: adjusting number of tables"
+ " (from %d to %d)\n",
+ toc->count,
+ FT_MIN( stream->size >> 4, 9 ) ));
+ toc->count = FT_MIN( stream->size >> 4, 9 );
+ }
+
if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
- return FT_THROW( Out_Of_Memory );
+ return error;
tables = face->toc.tables;
for ( n = 0; n < toc->count; n++ )
@@ -221,8 +242,8 @@ THE SOFTWARE.
if ( tables[i].type == (FT_UInt)( 1 << j ) )
name = tableNames[j];
- FT_TRACE4(( " %d: type=%s, format=0x%X, "
- "size=%ld (0x%lX), offset=%ld (0x%lX)\n",
+ FT_TRACE4(( " %d: type=%s, format=0x%X,"
+ " size=%ld (0x%lX), offset=%ld (0x%lX)\n",
i, name,
tables[i].format,
tables[i].size, tables[i].size,
@@ -308,7 +329,7 @@ THE SOFTWARE.
/* parsing normal metrics */
- fields = PCF_BYTE_ORDER( format ) == MSBFirst
+ fields = ( PCF_BYTE_ORDER( format ) == MSBFirst )
? pcf_metric_msb_header
: pcf_metric_header;
@@ -332,6 +353,17 @@ THE SOFTWARE.
metric->attributes = 0;
}
+ FT_TRACE5(( " width=%d,"
+ " lsb=%d, rsb=%d,"
+ " ascent=%d, descent=%d,"
+ " attributes=%d\n",
+ metric->characterWidth,
+ metric->leftSideBearing,
+ metric->rightSideBearing,
+ metric->ascent,
+ metric->descent,
+ metric->attributes ));
+
Exit:
return error;
}
@@ -431,7 +463,7 @@ THE SOFTWARE.
int i;
- for ( i = 0 ; i < face->nprops && !found; i++ )
+ for ( i = 0; i < face->nprops && !found; i++ )
{
if ( !ft_strcmp( properties[i].name, prop ) )
found = 1;
@@ -450,7 +482,7 @@ THE SOFTWARE.
{
PCF_ParseProperty props = NULL;
PCF_Property properties = NULL;
- FT_ULong nprops, i;
+ FT_ULong nprops, orig_nprops, i;
FT_ULong format, size;
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
@@ -470,32 +502,43 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
- FT_TRACE4(( "pcf_get_properties:\n" ));
-
- FT_TRACE4(( " format = %ld\n", format ));
+ FT_TRACE4(( "pcf_get_properties:\n"
+ " format: 0x%lX (%s)\n",
+ format,
+ PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
goto Bail;
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( nprops );
+ (void)FT_READ_ULONG( orig_nprops );
else
- (void)FT_READ_ULONG_LE( nprops );
+ (void)FT_READ_ULONG_LE( orig_nprops );
if ( error )
goto Bail;
- FT_TRACE4(( " nprop = %d (truncate %d props)\n",
- (int)nprops, nprops - (FT_ULong)(int)nprops ));
-
- nprops = (FT_ULong)(int)nprops;
+ FT_TRACE4(( " number of properties: %ld\n", orig_nprops ));
/* rough estimate */
- if ( nprops > size / PCF_PROPERTY_SIZE )
+ if ( orig_nprops > size / PCF_PROPERTY_SIZE )
{
error = FT_THROW( Invalid_Table );
goto Bail;
}
+ /* as a heuristic limit to avoid excessive allocation in */
+ /* gzip bombs (i.e., very small, invalid input data that */
+ /* pretends to expand to an insanely large file) we only */
+ /* load the first 256 properties */
+ if ( orig_nprops > 256 )
+ {
+ FT_TRACE0(( "pcf_get_properties:"
+ " only loading first 256 properties\n" ));
+ nprops = 256;
+ }
+ else
+ nprops = orig_nprops;
+
face->nprops = (int)nprops;
if ( FT_NEW_ARRAY( props, nprops ) )
@@ -515,14 +558,23 @@ THE SOFTWARE.
}
}
+ /* this skip will only work if we really have an extremely large */
+ /* number of properties; it will fail for fake data, avoiding an */
+ /* unnecessarily large allocation later on */
+ if ( FT_STREAM_SKIP( ( orig_nprops - nprops ) * PCF_PROPERTY_SIZE ) )
+ {
+ error = FT_THROW( Invalid_Stream_Skip );
+ goto Bail;
+ }
+
/* pad the property array */
/* */
/* clever here - nprops is the same as the number of odd-units read, */
/* as only isStringProp are odd length (Keith Packard) */
/* */
- if ( nprops & 3 )
+ if ( orig_nprops & 3 )
{
- i = 4 - ( nprops & 3 );
+ i = 4 - ( orig_nprops & 3 );
if ( FT_STREAM_SKIP( i ) )
{
error = FT_THROW( Invalid_Stream_Skip );
@@ -537,15 +589,24 @@ THE SOFTWARE.
if ( error )
goto Bail;
- FT_TRACE4(( " string_size = %ld\n", string_size ));
+ FT_TRACE4(( " string size: %ld\n", string_size ));
/* rough estimate */
- if ( string_size > size - nprops * PCF_PROPERTY_SIZE )
+ if ( string_size > size - orig_nprops * PCF_PROPERTY_SIZE )
{
error = FT_THROW( Invalid_Table );
goto Bail;
}
+ /* the strings in the `strings' array are PostScript strings, */
+ /* which can have a maximum length of 65536 characters each */
+ if ( string_size > 16777472 ) /* 256 * (65536 + 1) */
+ {
+ FT_TRACE0(( "pcf_get_properties:"
+ " loading only 16777472 bytes of strings array\n" ));
+ string_size = 16777472;
+ }
+
/* allocate one more byte so that we have a final null byte */
if ( FT_NEW_ARRAY( strings, string_size + 1 ) )
goto Bail;
@@ -559,6 +620,7 @@ THE SOFTWARE.
face->properties = properties;
+ FT_TRACE4(( "\n" ));
for ( i = 0; i < nprops; i++ )
{
FT_Long name_offset = props[i].name;
@@ -621,7 +683,7 @@ THE SOFTWARE.
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
PCF_Metric metrics = NULL;
- FT_ULong nmetrics, i;
+ FT_ULong nmetrics, orig_nmetrics, i;
error = pcf_seek_to_table_type( stream,
@@ -636,6 +698,13 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
+ FT_TRACE4(( "pcf_get_metrics:\n"
+ " format: 0x%lX (%s, %s)\n",
+ format,
+ PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
+ PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ?
+ "compressed" : "uncompressed" ));
+
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
!PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) )
return FT_THROW( Invalid_File_Format );
@@ -643,61 +712,70 @@ THE SOFTWARE.
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( nmetrics );
+ (void)FT_READ_ULONG( orig_nmetrics );
else
- (void)FT_READ_ULONG_LE( nmetrics );
+ (void)FT_READ_ULONG_LE( orig_nmetrics );
}
else
{
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_USHORT( nmetrics );
+ (void)FT_READ_USHORT( orig_nmetrics );
else
- (void)FT_READ_USHORT_LE( nmetrics );
+ (void)FT_READ_USHORT_LE( orig_nmetrics );
}
if ( error )
return FT_THROW( Invalid_File_Format );
- face->nmetrics = nmetrics;
-
- if ( !nmetrics )
- return FT_THROW( Invalid_Table );
-
- FT_TRACE4(( "pcf_get_metrics:\n" ));
-
- FT_TRACE4(( " number of metrics: %d\n", nmetrics ));
+ FT_TRACE4(( " number of metrics: %ld\n", orig_nmetrics ));
/* rough estimate */
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
- if ( nmetrics > size / PCF_METRIC_SIZE )
+ if ( orig_nmetrics > size / PCF_METRIC_SIZE )
return FT_THROW( Invalid_Table );
}
else
{
- if ( nmetrics > size / PCF_COMPRESSED_METRIC_SIZE )
+ if ( orig_nmetrics > size / PCF_COMPRESSED_METRIC_SIZE )
return FT_THROW( Invalid_Table );
}
+ if ( !orig_nmetrics )
+ return FT_THROW( Invalid_Table );
+
+ /* PCF is a format from ancient times; Unicode was in its */
+ /* infancy, and widely used two-byte character sets for CJK */
+ /* scripts (Big 5, GB 2312, JIS X 0208, etc.) did have at most */
+ /* 15000 characters. Even the more exotic CNS 11643 and CCCII */
+ /* standards, which were essentially three-byte character sets, */
+ /* provided less then 65536 assigned characters. */
+ /* */
+ /* While technically possible to have a larger number of glyphs */
+ /* in PCF files, we thus limit the number to 65536. */
+ if ( orig_nmetrics > 65536 )
+ {
+ FT_TRACE0(( "pcf_get_metrics:"
+ " only loading first 65536 metrics\n" ));
+ nmetrics = 65536;
+ }
+ else
+ nmetrics = orig_nmetrics;
+
+ face->nmetrics = nmetrics;
+
if ( FT_NEW_ARRAY( face->metrics, nmetrics ) )
- return FT_THROW( Out_Of_Memory );
+ return error;
metrics = face->metrics;
+
+ FT_TRACE4(( "\n" ));
for ( i = 0; i < nmetrics; i++, metrics++ )
{
+ FT_TRACE5(( " idx %ld:", i ));
error = pcf_get_metric( stream, format, metrics );
metrics->bits = 0;
- FT_TRACE5(( " idx %d: width=%d, "
- "lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
- i,
- metrics->characterWidth,
- metrics->leftSideBearing,
- metrics->rightSideBearing,
- metrics->ascent,
- metrics->descent,
- metrics->attributes ));
-
if ( error )
break;
@@ -705,7 +783,7 @@ THE SOFTWARE.
/* compute a glyph's bitmap dimensions, thus setting them to zero in */
/* case of an error disables this particular glyph only */
if ( metrics->rightSideBearing < metrics->leftSideBearing ||
- metrics->ascent + metrics->descent < 0 )
+ metrics->ascent < -metrics->descent )
{
metrics->characterWidth = 0;
metrics->leftSideBearing = 0;
@@ -735,7 +813,7 @@ THE SOFTWARE.
FT_Long* offsets = NULL;
FT_Long bitmapSizes[GLYPHPADOPTIONS];
FT_ULong format, size;
- FT_ULong nbitmaps, i, sizebitmaps = 0;
+ FT_ULong nbitmaps, orig_nbitmaps, i, sizebitmaps = 0;
error = pcf_seek_to_table_type( stream,
@@ -753,18 +831,42 @@ THE SOFTWARE.
format = FT_GET_ULONG_LE();
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- nbitmaps = FT_GET_ULONG();
+ orig_nbitmaps = FT_GET_ULONG();
else
- nbitmaps = FT_GET_ULONG_LE();
+ orig_nbitmaps = FT_GET_ULONG_LE();
FT_Stream_ExitFrame( stream );
+ FT_TRACE4(( "pcf_get_bitmaps:\n"
+ " format: 0x%lX\n"
+ " (%s, %s,\n"
+ " padding=%d bit%s, scanning=%d bit%s)\n",
+ format,
+ PCF_BYTE_ORDER( format ) == MSBFirst
+ ? "most significant byte first"
+ : "least significant byte first",
+ PCF_BIT_ORDER( format ) == MSBFirst
+ ? "most significant bit first"
+ : "least significant bit first",
+ 8 << PCF_GLYPH_PAD_INDEX( format ),
+ ( 8 << PCF_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s",
+ 8 << PCF_SCAN_UNIT_INDEX( format ),
+ ( 8 << PCF_SCAN_UNIT_INDEX( format ) ) == 1 ? "" : "s" ));
+
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
return FT_THROW( Invalid_File_Format );
- FT_TRACE4(( "pcf_get_bitmaps:\n" ));
+ FT_TRACE4(( " number of bitmaps: %ld\n", orig_nbitmaps ));
- FT_TRACE4(( " number of bitmaps: %d\n", nbitmaps ));
+ /* see comment in `pcf_get_metrics' */
+ if ( orig_nbitmaps > 65536 )
+ {
+ FT_TRACE0(( "pcf_get_bitmaps:"
+ " only loading first 65536 bitmaps\n" ));
+ nbitmaps = 65536;
+ }
+ else
+ nbitmaps = orig_nbitmaps;
if ( nbitmaps != face->nmetrics )
return FT_THROW( Invalid_File_Format );
@@ -772,6 +874,7 @@ THE SOFTWARE.
if ( FT_NEW_ARRAY( offsets, nbitmaps ) )
return error;
+ FT_TRACE5(( "\n" ));
for ( i = 0; i < nbitmaps; i++ )
{
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
@@ -779,7 +882,7 @@ THE SOFTWARE.
else
(void)FT_READ_LONG_LE( offsets[i] );
- FT_TRACE5(( " bitmap %d: offset %ld (0x%lX)\n",
+ FT_TRACE5(( " bitmap %ld: offset %ld (0x%lX)\n",
i, offsets[i], offsets[i] ));
}
if ( error )
@@ -796,17 +899,19 @@ THE SOFTWARE.
sizebitmaps = (FT_ULong)bitmapSizes[PCF_GLYPH_PAD_INDEX( format )];
- FT_TRACE4(( " padding %d implies a size of %ld\n",
- i, bitmapSizes[i] ));
+ FT_TRACE4(( " %ld-bit padding implies a size of %ld\n",
+ 8 << i, bitmapSizes[i] ));
}
- FT_TRACE4(( " %d bitmaps, padding index %ld\n",
+ FT_TRACE4(( " %ld bitmaps, using %ld-bit padding\n",
nbitmaps,
- PCF_GLYPH_PAD_INDEX( format ) ));
- FT_TRACE4(( " bitmap size = %d\n", sizebitmaps ));
+ 8 << PCF_GLYPH_PAD_INDEX( format ) ));
+ FT_TRACE4(( " bitmap size: %ld\n", sizebitmaps ));
FT_UNUSED( sizebitmaps ); /* only used for debugging */
+ /* right now, we only check the bitmap offsets; */
+ /* actual bitmaps are only loaded on demand */
for ( i = 0; i < nbitmaps; i++ )
{
/* rough estimate */
@@ -814,7 +919,7 @@ THE SOFTWARE.
( (FT_ULong)offsets[i] > size ) )
{
FT_TRACE0(( "pcf_get_bitmaps:"
- " invalid offset to bitmap data of glyph %d\n", i ));
+ " invalid offset to bitmap data of glyph %ld\n", i ));
}
else
face->metrics[i].bits = stream->pos + (FT_ULong)offsets[i];
@@ -838,7 +943,7 @@ THE SOFTWARE.
int firstCol, lastCol;
int firstRow, lastRow;
FT_ULong nencoding;
- int encodingOffset;
+ FT_UShort encodingOffset;
int i, j;
FT_ULong k;
PCF_Encoding encoding = NULL;
@@ -878,10 +983,20 @@ THE SOFTWARE.
FT_Stream_ExitFrame( stream );
+ FT_TRACE4(( "pcf_get_encodings:\n"
+ " format: 0x%lX (%s)\n",
+ format,
+ PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
+
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
return FT_THROW( Invalid_File_Format );
- /* sanity checks */
+ FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n"
+ " firstRow 0x%X, lastRow 0x%X\n",
+ firstCol, lastCol,
+ firstRow, lastRow ));
+
+ /* sanity checks; we limit numbers of rows and columns to 256 */
if ( firstCol < 0 ||
firstCol > lastCol ||
lastCol > 0xFF ||
@@ -890,35 +1005,36 @@ THE SOFTWARE.
lastRow > 0xFF )
return FT_THROW( Invalid_Table );
- FT_TRACE4(( "pdf_get_encodings:\n" ));
-
- FT_TRACE4(( " firstCol %d, lastCol %d, firstRow %d, lastRow %d\n",
- firstCol, lastCol, firstRow, lastRow ));
-
nencoding = (FT_ULong)( lastCol - firstCol + 1 ) *
(FT_ULong)( lastRow - firstRow + 1 );
if ( FT_NEW_ARRAY( encoding, nencoding ) )
- return FT_THROW( Out_Of_Memory );
+ return error;
error = FT_Stream_EnterFrame( stream, 2 * nencoding );
if ( error )
goto Bail;
+ FT_TRACE5(( "\n" ));
+
k = 0;
for ( i = firstRow; i <= lastRow; i++ )
{
for ( j = firstCol; j <= lastCol; j++ )
{
+ /* X11's reference implementation uses the equivalent to */
+ /* `FT_GET_SHORT', however PCF fonts with more than 32768 */
+ /* characters (e.g. `unifont.pcf') clearly show that an */
+ /* unsigned value is needed. */
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- encodingOffset = FT_GET_SHORT();
+ encodingOffset = FT_GET_USHORT();
else
- encodingOffset = FT_GET_SHORT_LE();
+ encodingOffset = FT_GET_USHORT_LE();
- if ( encodingOffset > -1 )
+ if ( encodingOffset != 0xFFFFU )
{
encoding[k].enc = i * 256 + j;
- encoding[k].glyph = (FT_UShort)encodingOffset;
+ encoding[k].glyph = encodingOffset;
FT_TRACE5(( " code %d (0x%04X): idx %d\n",
encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
@@ -1009,6 +1125,15 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
+ FT_TRACE4(( "pcf_get_accel%s:\n"
+ " format: 0x%lX (%s, %s)\n",
+ type == PCF_BDF_ACCELERATORS ? " (getting BDF accelerators)"
+ : "",
+ format,
+ PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
+ PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ?
+ "accelerated" : "not accelerated" ));
+
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
!PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
goto Bail;
@@ -1024,12 +1149,43 @@ THE SOFTWARE.
goto Bail;
}
+ FT_TRACE5(( " noOverlap=%s, constantMetrics=%s,"
+ " terminalFont=%s, constantWidth=%s\n"
+ " inkInside=%s, inkMetrics=%s, drawDirection=%s\n"
+ " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n",
+ accel->noOverlap ? "yes" : "no",
+ accel->constantMetrics ? "yes" : "no",
+ accel->terminalFont ? "yes" : "no",
+ accel->constantWidth ? "yes" : "no",
+ accel->inkInside ? "yes" : "no",
+ accel->inkMetrics ? "yes" : "no",
+ accel->drawDirection ? "RTL" : "LTR",
+ accel->fontAscent,
+ accel->fontDescent,
+ accel->maxOverlap ));
+
+ /* sanity checks */
+ if ( FT_ABS( accel->fontAscent ) > 0x7FFF )
+ {
+ accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %d\n",
+ accel->fontAscent ));
+ }
+ if ( FT_ABS( accel->fontDescent ) > 0x7FFF )
+ {
+ accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "pfc_get_accel: clamping font descent to value %d\n",
+ accel->fontDescent ));
+ }
+
+ FT_TRACE5(( " minbounds:" ));
error = pcf_get_metric( stream,
format & ( ~PCF_FORMAT_MASK ),
&(accel->minbounds) );
if ( error )
goto Bail;
+ FT_TRACE5(( " maxbounds:" ));
error = pcf_get_metric( stream,
format & ( ~PCF_FORMAT_MASK ),
&(accel->maxbounds) );
@@ -1038,12 +1194,14 @@ THE SOFTWARE.
if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
{
+ FT_TRACE5(( " ink minbounds:" ));
error = pcf_get_metric( stream,
format & ( ~PCF_FORMAT_MASK ),
&(accel->ink_minbounds) );
if ( error )
goto Bail;
+ FT_TRACE5(( " ink maxbounds:" ));
error = pcf_get_metric( stream,
format & ( ~PCF_FORMAT_MASK ),
&(accel->ink_maxbounds) );
@@ -1052,7 +1210,7 @@ THE SOFTWARE.
}
else
{
- accel->ink_minbounds = accel->minbounds; /* I'm not sure about this */
+ accel->ink_minbounds = accel->minbounds;
accel->ink_maxbounds = accel->maxbounds;
}
@@ -1141,7 +1299,7 @@ THE SOFTWARE.
len = lengths[nn];
- if ( src == NULL )
+ if ( !src )
continue;
/* separate elements with a space */
@@ -1173,8 +1331,10 @@ THE SOFTWARE.
FT_LOCAL_DEF( FT_Error )
pcf_load_font( FT_Stream stream,
- PCF_Face face )
+ PCF_Face face,
+ FT_Long face_index )
{
+ FT_Face root = FT_FACE( face );
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;
@@ -1184,6 +1344,13 @@ THE SOFTWARE.
if ( error )
goto Exit;
+ root->num_faces = 1;
+ root->face_index = 0;
+
+ /* If we are performing a simple font format check, exit immediately. */
+ if ( face_index < 0 )
+ return FT_Err_Ok;
+
error = pcf_get_properties( stream, face );
if ( error )
goto Exit;
@@ -1226,13 +1393,9 @@ THE SOFTWARE.
/* now construct the face object */
{
- FT_Face root = FT_FACE( face );
PCF_Property prop;
- root->num_faces = 1;
- root->face_index = 0;
-
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_FAST_GLYPHS;
@@ -1240,14 +1403,81 @@ THE SOFTWARE.
if ( face->accel.constantWidth )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
- if ( ( error = pcf_interpret_style( face ) ) != 0 )
- goto Exit;
+ if ( FT_SET_ERROR( pcf_interpret_style( face ) ) )
+ goto Exit;
prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop && prop->isString )
{
- if ( FT_STRDUP( root->family_name, prop->value.atom ) )
- goto Exit;
+
+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
+
+ PCF_Driver driver = (PCF_Driver)FT_FACE_DRIVER( face );
+
+
+ if ( !driver->no_long_family_names )
+ {
+ /* Prepend the foundry name plus a space to the family name. */
+ /* There are many fonts just called `Fixed' which look */
+ /* completely different, and which have nothing to do with each */
+ /* other. When selecting `Fixed' in KDE or Gnome one gets */
+ /* results that appear rather random, the style changes often if */
+ /* one changes the size and one cannot select some fonts at all. */
+ /* */
+ /* We also check whether we have `wide' characters; all put */
+ /* together, we get family names like `Sony Fixed' or `Misc */
+ /* Fixed Wide'. */
+
+ PCF_Property foundry_prop, point_size_prop, average_width_prop;
+
+ int l = ft_strlen( prop->value.atom ) + 1;
+ int wide = 0;
+
+
+ foundry_prop = pcf_find_property( face, "FOUNDRY" );
+ point_size_prop = pcf_find_property( face, "POINT_SIZE" );
+ average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
+
+ if ( point_size_prop && average_width_prop )
+ {
+ if ( average_width_prop->value.l >= point_size_prop->value.l )
+ {
+ /* This font is at least square shaped or even wider */
+ wide = 1;
+ l += ft_strlen( " Wide" );
+ }
+ }
+
+ if ( foundry_prop && foundry_prop->isString )
+ {
+ l += ft_strlen( foundry_prop->value.atom ) + 1;
+
+ if ( FT_NEW_ARRAY( root->family_name, l ) )
+ goto Exit;
+
+ ft_strcpy( root->family_name, foundry_prop->value.atom );
+ ft_strcat( root->family_name, " " );
+ ft_strcat( root->family_name, prop->value.atom );
+ }
+ else
+ {
+ if ( FT_NEW_ARRAY( root->family_name, l ) )
+ goto Exit;
+
+ ft_strcpy( root->family_name, prop->value.atom );
+ }
+
+ if ( wide )
+ ft_strcat( root->family_name, " Wide" );
+ }
+ else
+
+#endif /* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+ {
+ if ( FT_STRDUP( root->family_name, prop->value.atom ) )
+ goto Exit;
+ }
}
else
root->family_name = NULL;
@@ -1270,7 +1500,7 @@ THE SOFTWARE.
FT_Short resolution_x = 0, resolution_y = 0;
- FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
+ FT_ZERO( bsize );
/* for simplicity, we take absolute values of integer properties */
@@ -1282,8 +1512,16 @@ THE SOFTWARE.
if ( face->accel.fontAscent + face->accel.fontDescent < 0 )
FT_TRACE0(( "pcf_load_font: negative height\n" ));
#endif
- bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
- face->accel.fontDescent ) );
+ if ( FT_ABS( face->accel.fontAscent +
+ face->accel.fontDescent ) > 0x7FFF )
+ {
+ bsize->height = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping height to value %d\n",
+ bsize->height ));
+ }
+ else
+ bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
+ face->accel.fontDescent ) );
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( prop )
@@ -1292,10 +1530,20 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative average width\n" ));
#endif
- bsize->width = FT_ABS( (FT_Short)( ( prop->value.l ) + 5 ) / 10 );
+ if ( ( FT_ABS( prop->value.l ) > 0x7FFFL * 10 - 5 ) )
+ {
+ bsize->width = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping average width to value %d\n",
+ bsize->width ));
+ }
+ else
+ bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) );
}
else
+ {
+ /* this is a heuristical value */
bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
+ }
prop = pcf_find_property( face, "POINT_SIZE" );
if ( prop )
@@ -1305,9 +1553,16 @@ THE SOFTWARE.
FT_TRACE0(( "pcf_load_font: negative point size\n" ));
#endif
/* convert from 722.7 decipoints to 72 points per inch */
- bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
- 64 * 7200,
- 72270L );
+ if ( FT_ABS( prop->value.l ) > 0x504C2L ) /* 0x7FFF * 72270/7200 */
+ {
+ bsize->size = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping point size to value %d\n",
+ bsize->size ));
+ }
+ else
+ bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
+ 64 * 7200,
+ 72270L );
}
prop = pcf_find_property( face, "PIXEL_SIZE" );
@@ -1317,7 +1572,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative pixel size\n" ));
#endif
- bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ bsize->y_ppem = 0x7FFF << 6;
+ FT_TRACE0(( "pcf_load_font: clamping pixel size to value %d\n",
+ bsize->y_ppem ));
+ }
+ else
+ bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
}
prop = pcf_find_property( face, "RESOLUTION_X" );
@@ -1327,7 +1589,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative X resolution\n" ));
#endif
- resolution_x = FT_ABS( (FT_Short)prop->value.l );
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ resolution_x = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping X resolution to value %d\n",
+ resolution_x ));
+ }
+ else
+ resolution_x = FT_ABS( (FT_Short)prop->value.l );
}
prop = pcf_find_property( face, "RESOLUTION_Y" );
@@ -1337,7 +1606,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative Y resolution\n" ));
#endif
- resolution_y = FT_ABS( (FT_Short)prop->value.l );
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ resolution_y = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping Y resolution to value %d\n",
+ resolution_y ));
+ }
+ else
+ resolution_y = FT_ABS( (FT_Short)prop->value.l );
}
if ( bsize->y_ppem == 0 )
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.h b/src/3rdparty/freetype/src/pcf/pcfread.h
index c9524f1346..bed30e5030 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.h
+++ b/src/3rdparty/freetype/src/pcf/pcfread.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFREAD_H__
-#define __PCFREAD_H__
+#ifndef PCFREAD_H_
+#define PCFREAD_H_
#include <ft2build.h>
@@ -39,7 +39,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFREAD_H__ */
+#endif /* PCFREAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfutil.h b/src/3rdparty/freetype/src/pcf/pcfutil.h
index ce10fb541d..be986e756b 100644
--- a/src/3rdparty/freetype/src/pcf/pcfutil.h
+++ b/src/3rdparty/freetype/src/pcf/pcfutil.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFUTIL_H__
-#define __PCFUTIL_H__
+#ifndef PCFUTIL_H_
+#define PCFUTIL_H_
#include <ft2build.h>
@@ -49,7 +49,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFUTIL_H__ */
+#endif /* PCFUTIL_H_ */
/* END */