summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pfr
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pfr')
-rw-r--r--src/3rdparty/freetype/src/pfr/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/pfr/module.mk2
-rw-r--r--src/3rdparty/freetype/src/pfr/pfr.c11
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.c18
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.c41
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrerror.h10
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrgload.c67
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrgload.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrload.c190
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrload.h23
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.c45
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrsbit.c221
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrsbit.h11
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrtypes.h122
-rw-r--r--src/3rdparty/freetype/src/pfr/rules.mk2
18 files changed, 499 insertions, 298 deletions
diff --git a/src/3rdparty/freetype/src/pfr/Jamfile b/src/3rdparty/freetype/src/pfr/Jamfile
index c5b35be870..cb55a7ee89 100644
--- a/src/3rdparty/freetype/src/pfr/Jamfile
+++ b/src/3rdparty/freetype/src/pfr/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/pfr Jamfile
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/pfr/module.mk b/src/3rdparty/freetype/src/pfr/module.mk
index 3f5a47e888..27fec8e5f6 100644
--- a/src/3rdparty/freetype/src/pfr/module.mk
+++ b/src/3rdparty/freetype/src/pfr/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/pfr/pfr.c b/src/3rdparty/freetype/src/pfr/pfr.c
index 96e67300a5..1760882fcd 100644
--- a/src/3rdparty/freetype/src/pfr/pfr.c
+++ b/src/3rdparty/freetype/src/pfr/pfr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR driver component. */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -15,15 +15,16 @@
/* */
/***************************************************************************/
-#define FT_MAKE_OPTION_SINGLE_OBJECT
+#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
-#include "pfrload.c"
-#include "pfrgload.c"
#include "pfrcmap.c"
-#include "pfrobjs.c"
#include "pfrdrivr.c"
+#include "pfrgload.c"
+#include "pfrload.c"
+#include "pfrobjs.c"
#include "pfrsbit.c"
+
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c
index 88ff55a806..60643780a1 100644
--- a/src/3rdparty/freetype/src/pfr/pfrcmap.c
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR cmap handling (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -130,7 +130,7 @@
}
if ( gchar->char_code < char_code )
- min = mid+1;
+ min = mid + 1;
else
max = mid;
}
@@ -161,12 +161,16 @@
{
sizeof ( PFR_CMapRec ),
- (FT_CMap_InitFunc) pfr_cmap_init,
- (FT_CMap_DoneFunc) pfr_cmap_done,
- (FT_CMap_CharIndexFunc)pfr_cmap_char_index,
- (FT_CMap_CharNextFunc) pfr_cmap_char_next,
+ (FT_CMap_InitFunc) pfr_cmap_init, /* init */
+ (FT_CMap_DoneFunc) pfr_cmap_done, /* done */
+ (FT_CMap_CharIndexFunc)pfr_cmap_char_index, /* char_index */
+ (FT_CMap_CharNextFunc) pfr_cmap_char_next, /* char_next */
- NULL, NULL, NULL, NULL, NULL
+ (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
+ (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
+ (FT_CMap_VariantListFunc) NULL, /* variant_list */
+ (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
+ (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.h b/src/3rdparty/freetype/src/pfr/pfrcmap.h
index 87e1e5b942..c70a0c83c5 100644
--- a/src/3rdparty/freetype/src/pfr/pfrcmap.h
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR cmap handling (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRCMAP_H__
-#define __PFRCMAP_H__
+#ifndef PFRCMAP_H_
+#define PFRCMAP_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRCMAP_H__ */
+#endif /* PFRCMAP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.c b/src/3rdparty/freetype/src/pfr/pfrdrivr.c
index 875374889c..6c7e50128a 100644
--- a/src/3rdparty/freetype/src/pfr/pfrdrivr.c
+++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR driver interface (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -139,9 +139,9 @@
static
const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
{
- pfr_get_metrics,
- pfr_face_get_kerning,
- pfr_get_advance
+ pfr_get_metrics, /* get_metrics */
+ pfr_face_get_kerning, /* get_kerning */
+ pfr_get_advance /* get_advance */
};
@@ -181,31 +181,32 @@
0x10000L,
0x20000L,
- NULL,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- pfr_get_service
+ NULL, /* FT_Module_Constructor module_init */
+ NULL, /* FT_Module_Destructor module_done */
+ pfr_get_service /* FT_Module_Requester get_interface */
},
sizeof ( PFR_FaceRec ),
sizeof ( PFR_SizeRec ),
sizeof ( PFR_SlotRec ),
- pfr_face_init,
- pfr_face_done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- pfr_slot_init,
- pfr_slot_done,
+ pfr_face_init, /* FT_Face_InitFunc init_face */
+ pfr_face_done, /* FT_Face_DoneFunc done_face */
+ NULL, /* FT_Size_InitFunc init_size */
+ NULL, /* FT_Size_DoneFunc done_size */
+ pfr_slot_init, /* FT_Slot_InitFunc init_slot */
+ pfr_slot_done, /* FT_Slot_DoneFunc done_slot */
- pfr_slot_load,
+ pfr_slot_load, /* FT_Slot_LoadFunc load_glyph */
- pfr_get_kerning,
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
- 0, /* FT_Size_RequestFunc */
- 0, /* FT_Size_SelectFunc */
+ pfr_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
+
+ NULL, /* FT_Size_RequestFunc request_size */
+ NULL, /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.h b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
index b5be4709c8..cab852789b 100644
--- a/src/3rdparty/freetype/src/pfr/pfrdrivr.h
+++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
@@ -4,7 +4,7 @@
/* */
/* High-level Type PFR driver interface (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRDRIVR_H__
-#define __PFRDRIVR_H__
+#ifndef PFRDRIVR_H_
+#define PFRDRIVR_H_
#include <ft2build.h>
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRDRIVR_H__ */
+#endif /* PFRDRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrerror.h b/src/3rdparty/freetype/src/pfr/pfrerror.h
index 978e7b2d34..7027c818e8 100644
--- a/src/3rdparty/freetype/src/pfr/pfrerror.h
+++ b/src/3rdparty/freetype/src/pfr/pfrerror.h
@@ -4,7 +4,7 @@
/* */
/* PFR error codes (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __PFRERROR_H__
-#define __PFRERROR_H__
+#ifndef PFRERROR_H_
+#define PFRERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PFR_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __PFRERROR_H__ */
+#endif /* PFRERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c
index 88df06a03d..b7990196b6 100644
--- a/src/3rdparty/freetype/src/pfr/pfrgload.c
+++ b/src/3rdparty/freetype/src/pfr/pfrgload.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR glyph loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -92,8 +92,8 @@
if ( outline->n_contours > 0 )
first = outline->contours[outline->n_contours - 1];
- /* if the last point falls on the same location than the first one */
- /* we need to delete it */
+ /* if the last point falls on the same location as the first one */
+ /* we need to delete it */
if ( last > first )
{
FT_Vector* p1 = outline->points + first;
@@ -215,8 +215,10 @@
/* check that there is space for a new contour and a new point */
error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
if ( !error )
+ {
/* add new start point */
error = pfr_glyph_line_to( glyph, to );
+ }
return error;
}
@@ -304,8 +306,8 @@
glyph->y_control = glyph->x_control + x_count;
- mask = 0;
- x = 0;
+ mask = 0;
+ x = 0;
for ( i = 0; i < count; i++ )
{
@@ -331,10 +333,10 @@
mask >>= 1;
}
- /* XXX: for now we ignore the secondary stroke and edge definitions */
- /* since we don't want to support native PFR hinting */
- /* */
- if ( flags & PFR_GLYPH_EXTRA_ITEMS )
+ /* XXX: we ignore the secondary stroke and edge definitions */
+ /* since we don't support native PFR hinting */
+ /* */
+ if ( flags & PFR_GLYPH_SINGLE_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
if ( error )
@@ -366,27 +368,27 @@
switch ( format >> 4 )
{
- case 0: /* end glyph */
+ case 0: /* end glyph */
FT_TRACE6(( "- end glyph" ));
args_count = 0;
break;
- case 1: /* general line operation */
+ case 1: /* general line operation */
FT_TRACE6(( "- general line" ));
goto Line1;
- case 4: /* move to inside contour */
+ case 4: /* move to inside contour */
FT_TRACE6(( "- move to inside" ));
goto Line1;
- case 5: /* move to outside contour */
+ case 5: /* move to outside contour */
FT_TRACE6(( "- move to outside" ));
Line1:
args_format = format_low;
args_count = 1;
break;
- case 2: /* horizontal line to */
+ case 2: /* horizontal line to */
FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
if ( format_low >= x_count )
goto Failure;
@@ -396,7 +398,7 @@
args_count = 0;
break;
- case 3: /* vertical line to */
+ case 3: /* vertical line to */
FT_TRACE6(( "- vertical line to cy.%d", format_low ));
if ( format_low >= y_count )
goto Failure;
@@ -406,19 +408,19 @@
args_count = 0;
break;
- case 6: /* horizontal to vertical curve */
+ case 6: /* horizontal to vertical curve */
FT_TRACE6(( "- hv curve " ));
args_format = 0xB8E;
args_count = 3;
break;
- case 7: /* vertical to horizontal curve */
+ case 7: /* vertical to horizontal curve */
FT_TRACE6(( "- vh curve" ));
args_format = 0xE2B;
args_count = 3;
break;
- default: /* general curve to */
+ default: /* general curve to */
FT_TRACE6(( "- general curve" ));
args_count = 4;
args_format = format_low;
@@ -439,14 +441,14 @@
{
case 0: /* 8-bit index */
PFR_CHECK( 1 );
- idx = PFR_NEXT_BYTE( p );
+ idx = PFR_NEXT_BYTE( p );
if ( idx >= x_count )
goto Failure;
cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", idx ));
break;
- case 1: /* 16-bit value */
+ case 1: /* 16-bit absolute value */
PFR_CHECK( 2 );
cur->x = PFR_NEXT_SHORT( p );
FT_TRACE7(( " x.%d", cur->x ));
@@ -516,22 +518,22 @@
/* */
switch ( format >> 4 )
{
- case 0: /* end glyph => EXIT */
+ case 0: /* end glyph => EXIT */
pfr_glyph_end( glyph );
goto Exit;
- case 1: /* line operations */
+ case 1: /* line operations */
case 2:
case 3:
error = pfr_glyph_line_to( glyph, pos );
goto Test_Error;
- case 4: /* move to inside contour */
- case 5: /* move to outside contour */
+ case 4: /* move to inside contour */
+ case 5: /* move to outside contour */
error = pfr_glyph_move_to( glyph, pos );
goto Test_Error;
- default: /* curve operations */
+ default: /* curve operations */
error = pfr_glyph_curve_to( glyph, pos, pos + 1, pos + 2 );
Test_Error: /* test error condition */
@@ -577,10 +579,11 @@
/* ignore extra items when present */
/* */
- if ( flags & PFR_GLYPH_EXTRA_ITEMS )
+ if ( flags & PFR_GLYPH_COMPOUND_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
/* we can't rely on the FT_GlyphLoader to load sub-glyphs, because */
@@ -753,8 +756,10 @@
count = glyph->num_subs - old_count;
- FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
- count, offset ));
+ FT_TRACE4(( "compound glyph with %d element%s (offset %lu):\n",
+ count,
+ count == 1 ? "" : "s",
+ offset ));
/* now, load each individual glyph */
for ( n = 0; n < count; n++ )
@@ -807,7 +812,9 @@
/* proceed to next sub-glyph */
}
- FT_TRACE4(( "end compound glyph with %d elements\n", count ));
+ FT_TRACE4(( "end compound glyph with %d element%s\n",
+ count,
+ count == 1 ? "" : "s" ));
}
else
{
diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.h b/src/3rdparty/freetype/src/pfr/pfrgload.h
index c7c8da15a1..01f48d7706 100644
--- a/src/3rdparty/freetype/src/pfr/pfrgload.h
+++ b/src/3rdparty/freetype/src/pfr/pfrgload.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR glyph loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRGLOAD_H__
-#define __PFRGLOAD_H__
+#ifndef PFRGLOAD_H_
+#define PFRGLOAD_H_
#include "pfrtypes.h"
@@ -43,7 +43,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRGLOAD_H__ */
+#endif /* PFRGLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrload.c b/src/3rdparty/freetype/src/pfr/pfrload.c
index ec7311df56..2776da462a 100644
--- a/src/3rdparty/freetype/src/pfr/pfrload.c
+++ b/src/3rdparty/freetype/src/pfr/pfrload.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,93 @@
#define FT_COMPONENT trace_pfr
+ /*
+ * The overall structure of a PFR file is as follows.
+ *
+ * PFR header
+ * 58 bytes (contains nPhysFonts)
+ *
+ * Logical font directory (size at most 2^16 bytes)
+ * 2 bytes (nLogFonts)
+ * + nLogFonts * 5 bytes
+ *
+ * ==> nLogFonts <= 13106
+ *
+ * Logical font section (size at most 2^24 bytes)
+ * nLogFonts * logFontRecord
+ *
+ * logFontRecord (size at most 2^16 bytes)
+ * 12 bytes (fontMatrix)
+ * + 1 byte (flags)
+ * + 0-5 bytes (depending on `flags')
+ * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
+ * + 5 bytes (physical font info)
+ * + 0-1 bytes (depending on PFR header)
+ *
+ * ==> minimum size 18 bytes
+ *
+ * Physical font section (size at most 2^24 bytes)
+ * nPhysFonts * (physFontRecord
+ * + nBitmapSizes * nBmapChars * bmapCharRecord)
+ *
+ * physFontRecord (size at most 2^24 bytes)
+ * 14 bytes (font info)
+ * + 1 byte (flags)
+ * + 0-2 (depending on `flags')
+ * + 0-? (structure too complicated to be shown here; depending on
+ * `flags'; contains `nBitmapSizes' and `nBmapChars')
+ * + 3 bytes (nAuxBytes)
+ * + nAuxBytes
+ * + 1 byte (nBlueValues)
+ * + 2 * nBlueValues
+ * + 6 bytes (hinting data)
+ * + 2 bytes (nCharacters)
+ * + nCharacters * (4-10 bytes) (depending on `flags')
+ *
+ * ==> minimum size 27 bytes
+ *
+ * bmapCharRecord
+ * 4-7 bytes
+ *
+ * Glyph program strings (three possible types: simpleGps, compoundGps,
+ * and bitmapGps; size at most 2^24 bytes)
+ * simpleGps (size at most 2^16 bytes)
+ * 1 byte (flags)
+ * 1-2 bytes (n[XY]orus, depending on `flags')
+ * 0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus')
+ * 0-? (structure too complicated to be shown here; depending on
+ * `flags')
+ * 1-? glyph data (faintly resembling PS Type 1 charstrings)
+ *
+ * ==> minimum size 3 bytes
+ *
+ * compoundGps (size at most 2^16 bytes)
+ * 1 byte (nElements <= 63, flags)
+ * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
+ * + nElements * (6-14 bytes)
+ *
+ * bitmapGps (size at most 2^16 bytes)
+ * 1 byte (flags)
+ * 3-13 bytes (position info, depending on `flags')
+ * 0-? bitmap data
+ *
+ * ==> minimum size 4 bytes
+ *
+ * PFR trailer
+ * 8 bytes
+ *
+ *
+ * ==> minimum size of a valid PFR:
+ * 58 (header)
+ * + 2 (nLogFonts)
+ * + 27 (1 physFontRecord)
+ * + 8 (trailer)
+ * -----
+ * 95 bytes
+ *
+ */
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -75,7 +162,8 @@
if ( extra->type == item_type )
{
error = extra->parser( p, p + item_size, item_data );
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
break;
}
@@ -183,7 +271,8 @@
{
result = 0;
}
- return result;
+
+ return result;
}
@@ -206,8 +295,25 @@
FT_UInt result = 0;
- if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( count ) )
+ if ( FT_STREAM_SEEK( section_offset ) ||
+ FT_READ_USHORT( count ) )
+ goto Exit;
+
+ /* check maximum value and a rough minimum size: */
+ /* - no more than 13106 log fonts */
+ /* - we need 5 bytes for a log header record */
+ /* - we need at least 18 bytes for a log font record */
+ /* - the overall size is at least 95 bytes plus the */
+ /* log header and log font records */
+ if ( count > ( ( 1 << 16 ) - 2 ) / 5 ||
+ 2 + count * 5 >= stream->size - section_offset ||
+ 95 + count * ( 5 + 18 ) >= stream->size )
+ {
+ FT_ERROR(( "pfr_log_font_count:"
+ " invalid number of logical fonts\n" ));
+ error = FT_THROW( Invalid_Table );
goto Exit;
+ }
result = count;
@@ -254,13 +360,14 @@
FT_UInt local;
- if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_FRAME_ENTER( size ) )
goto Exit;
p = stream->cursor;
limit = p + size;
- PFR_CHECK(13);
+ PFR_CHECK( 13 );
log_font->matrix[0] = PFR_NEXT_LONG( p );
log_font->matrix[1] = PFR_NEXT_LONG( p );
@@ -276,7 +383,7 @@
if ( flags & PFR_LOG_2BYTE_STROKE )
local++;
- if ( (flags & PFR_LINE_JOIN_MASK) == PFR_LINE_JOIN_MITER )
+ if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER )
local += 3;
}
if ( flags & PFR_LOG_BOLD )
@@ -308,10 +415,11 @@
if ( flags & PFR_LOG_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
}
- PFR_CHECK(5);
+ PFR_CHECK( 5 );
log_font->phys_size = PFR_NEXT_USHORT( p );
log_font->phys_offset = PFR_NEXT_ULONG( p );
if ( size_increment )
@@ -358,7 +466,7 @@
PFR_CHECK( 5 );
- p += 3; /* skip bctSize */
+ p += 3; /* skip bctSize */
flags0 = PFR_NEXT_BYTE( p );
count = PFR_NEXT_BYTE( p );
@@ -434,12 +542,12 @@
}
- /* Load font ID. This is a so-called "unique" name that is rather
- * long and descriptive (like "Tiresias ScreenFont v7.51").
+ /* Load font ID. This is a so-called `unique' name that is rather
+ * long and descriptive (like `Tiresias ScreenFont v7.51').
*
* Note that a PFR font's family name is contained in an *undocumented*
- * string of the "auxiliary data" portion of a physical font record. This
- * may also contain the "real" style name!
+ * string of the `auxiliary data' portion of a physical font record. This
+ * may also contain the `real' style name!
*
* If no family name is present, the font ID is used instead for the
* family.
@@ -454,7 +562,7 @@
FT_UInt len = (FT_UInt)( limit - p );
- if ( phy_font->font_id != NULL )
+ if ( phy_font->font_id )
goto Exit;
if ( FT_ALLOC( phy_font->font_id, len + 1 ) )
@@ -481,7 +589,7 @@
FT_Memory memory = phy_font->memory;
- if ( phy_font->vertical.stem_snaps != NULL )
+ if ( phy_font->vertical.stem_snaps )
goto Exit;
PFR_CHECK( 1 );
@@ -507,7 +615,7 @@
Too_Short:
error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_exta_item_load_stem_snaps:"
+ FT_ERROR(( "pfr_extra_item_load_stem_snaps:"
" invalid stem snaps table\n" ));
goto Exit;
}
@@ -525,8 +633,6 @@
FT_Memory memory = phy_font->memory;
- FT_TRACE2(( "pfr_extra_item_load_kerning_pairs()\n" ));
-
if ( FT_NEW( item ) )
goto Exit;
@@ -612,7 +718,6 @@
}
-
static const PFR_ExtraItemRec pfr_phy_font_extra_items[] =
{
{ 1, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_bitmap_info },
@@ -623,7 +728,8 @@
};
- /* Loads a name from the auxiliary data. Since this extracts undocumented
+ /*
+ * Load a name from the auxiliary data. Since this extracts undocumented
* strings from the font file, we need to be careful here.
*/
static FT_Error
@@ -637,12 +743,14 @@
FT_UInt n, ok;
+ if ( *astring )
+ FT_FREE( *astring );
+
if ( len > 0 && p[len - 1] == 0 )
len--;
- /* check that each character is ASCII for making sure not to
- load garbage
- */
+ /* check that each character is ASCII */
+ /* for making sure not to load garbage */
ok = ( len > 0 );
for ( n = 0; n < len; n++ )
if ( p[n] < 32 || p[n] > 127 )
@@ -659,6 +767,7 @@
FT_MEM_COPY( result, p, len );
result[len] = 0;
}
+
Exit:
*astring = result;
return error;
@@ -729,7 +838,8 @@
phy_font->kern_items = NULL;
phy_font->kern_items_tail = &phy_font->kern_items;
- if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_FRAME_ENTER( size ) )
goto Exit;
phy_font->cursor = stream->cursor;
@@ -757,16 +867,16 @@
/* load the extra items when present */
if ( flags & PFR_PHY_EXTRA_ITEMS )
{
- error = pfr_extra_items_parse( &p, limit,
- pfr_phy_font_extra_items, phy_font );
+ error = pfr_extra_items_parse( &p, limit,
+ pfr_phy_font_extra_items, phy_font );
if ( error )
goto Fail;
}
- /* In certain fonts, the auxiliary bytes contain interesting */
- /* information. These are not in the specification but can be */
- /* guessed by looking at the content of a few PFR0 fonts. */
+ /* In certain fonts, the auxiliary bytes contain interesting */
+ /* information. These are not in the specification but can be */
+ /* guessed by looking at the content of a few PFR0 fonts. */
PFR_CHECK( 3 );
num_aux = PFR_NEXT_ULONG( p );
@@ -776,7 +886,7 @@
FT_Byte* q2;
- PFR_CHECK( num_aux );
+ PFR_CHECK_SIZE( num_aux );
p += num_aux;
while ( num_aux > 0 )
@@ -797,9 +907,8 @@
switch ( type )
{
case 1:
- /* this seems to correspond to the font's family name,
- * padded to 16-bits with one zero when necessary
- */
+ /* this seems to correspond to the font's family name, padded to */
+ /* an even number of bytes with a zero byte appended if needed */
error = pfr_aux_name_load( q, length - 4U, memory,
&phy_font->family_name );
if ( error )
@@ -817,9 +926,8 @@
break;
case 3:
- /* this seems to correspond to the font's style name,
- * padded to 16-bits with one zero when necessary
- */
+ /* this seems to correspond to the font's style name, padded to */
+ /* an even number of bytes with a zero byte appended if needed */
error = pfr_aux_name_load( q, length - 4U, memory,
&phy_font->style_name );
if ( error )
@@ -867,9 +975,6 @@
phy_font->num_chars = count = PFR_NEXT_USHORT( p );
phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor );
- if ( FT_NEW_ARRAY( phy_font->chars, count ) )
- goto Fail;
-
Size = 1 + 1 + 2;
if ( flags & PFR_PHY_2BYTE_CHARCODE )
Size += 1;
@@ -886,7 +991,10 @@
if ( flags & PFR_PHY_3BYTE_GPS_OFFSET )
Size += 1;
- PFR_CHECK( count * Size );
+ PFR_CHECK_SIZE( count * Size );
+
+ if ( FT_NEW_ARRAY( phy_font->chars, count ) )
+ goto Fail;
for ( n = 0; n < count; n++ )
{
diff --git a/src/3rdparty/freetype/src/pfr/pfrload.h b/src/3rdparty/freetype/src/pfr/pfrload.h
index 0a512346b6..36e809a762 100644
--- a/src/3rdparty/freetype/src/pfr/pfrload.h
+++ b/src/3rdparty/freetype/src/pfr/pfrload.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRLOAD_H__
-#define __PFRLOAD_H__
+#ifndef PFRLOAD_H_
+#define PFRLOAD_H_
#include "pfrobjs.h"
#include FT_INTERNAL_STREAM_H
@@ -25,14 +25,19 @@
FT_BEGIN_HEADER
+ /* some size checks should be always done (mainly to prevent */
+ /* excessive allocation for malformed data), ... */
+#define PFR_CHECK_SIZE( x ) do \
+ { \
+ if ( p + (x) > limit ) \
+ goto Too_Short; \
+ } while ( 0 )
+
+ /* ... and some only if intensive checking is explicitly requested */
#ifdef PFR_CONFIG_NO_CHECKS
#define PFR_CHECK( x ) do { } while ( 0 )
#else
-#define PFR_CHECK( x ) do \
- { \
- if ( p + (x) > limit ) \
- goto Too_Short; \
- } while ( 0 )
+#define PFR_CHECK PFR_CHECK_SIZE
#endif
#define PFR_NEXT_BYTE( p ) FT_NEXT_BYTE( p )
@@ -112,7 +117,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRLOAD_H__ */
+#endif /* PFRLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c
index b854b00ba8..737b97b5ff 100644
--- a/src/3rdparty/freetype/src/pfr/pfrobjs.c
+++ b/src/3rdparty/freetype/src/pfr/pfrobjs.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -118,9 +118,11 @@
/* load the face */
error = pfr_log_font_load(
- &face->log_font, stream, (FT_UInt)( face_index & 0xFFFF ),
- face->header.log_dir_offset,
- FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
+ &face->log_font,
+ stream,
+ (FT_UInt)( face_index & 0xFFFF ),
+ face->header.log_dir_offset,
+ FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
if ( error )
goto Exit;
@@ -141,8 +143,8 @@
pfrface->face_flags |= FT_FACE_FLAG_SCALABLE;
- /* if all characters point to the same gps_offset 0, we */
- /* assume that the font only contains bitmaps */
+ /* if gps_offset == 0 for all characters, we */
+ /* assume that the font only contains bitmaps */
{
FT_UInt nn;
@@ -164,7 +166,7 @@
}
}
- if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
+ if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
pfrface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( phy_font->flags & PFR_PHY_VERTICAL )
@@ -178,16 +180,16 @@
if ( phy_font->num_kern_pairs > 0 )
pfrface->face_flags |= FT_FACE_FLAG_KERNING;
- /* If no family name was found in the "undocumented" auxiliary
+ /* If no family name was found in the `undocumented' auxiliary
* data, use the font ID instead. This sucks but is better than
* nothing.
*/
pfrface->family_name = phy_font->family_name;
- if ( pfrface->family_name == NULL )
+ if ( !pfrface->family_name )
pfrface->family_name = phy_font->font_id;
/* note that the style name can be NULL in certain PFR fonts,
- * probably meaning "Regular"
+ * probably meaning `Regular'
*/
pfrface->style_name = phy_font->style_name;
@@ -262,15 +264,9 @@
charmap.encoding = FT_ENCODING_UNICODE;
error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( pfrface->num_charmaps )
- pfrface->charmap = pfrface->charmaps[0];
-#endif
}
- /* check whether we've loaded any kerning pairs */
+ /* check whether we have loaded any kerning pairs */
if ( phy_font->num_kern_pairs )
pfrface->face_flags |= FT_FACE_FLAG_KERNING;
}
@@ -340,8 +336,12 @@
/* try to load an embedded bitmap */
if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 )
{
- error = pfr_slot_load_bitmap( slot, size, gindex );
- if ( error == 0 )
+ error = pfr_slot_load_bitmap(
+ slot,
+ size,
+ gindex,
+ ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
+ if ( !error )
goto Exit;
}
@@ -402,7 +402,7 @@
pfrslot->linearHoriAdvance = metrics->horiAdvance;
pfrslot->linearVertAdvance = metrics->vertAdvance;
- /* make-up vertical metrics(?) */
+ /* make up vertical metrics(?) */
metrics->vertBearingX = 0;
metrics->vertBearingY = 0;
@@ -522,8 +522,8 @@
FT_UInt probe = power * size;
FT_UInt extra = count - power;
FT_Byte* base = stream->cursor;
- FT_Bool twobytes = FT_BOOL( item->flags & 1 );
- FT_Bool twobyte_adj = FT_BOOL( item->flags & 2 );
+ FT_Bool twobytes = FT_BOOL( item->flags & PFR_KERN_2BYTE_CHAR );
+ FT_Bool twobyte_adj = FT_BOOL( item->flags & PFR_KERN_2BYTE_ADJ );
FT_Byte* p;
FT_UInt32 cpair;
@@ -596,4 +596,5 @@
return error;
}
+
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.h b/src/3rdparty/freetype/src/pfr/pfrobjs.h
index e990b45a0a..59c709f58d 100644
--- a/src/3rdparty/freetype/src/pfr/pfrobjs.h
+++ b/src/3rdparty/freetype/src/pfr/pfrobjs.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFROBJS_H__
-#define __PFROBJS_H__
+#ifndef PFROBJS_H_
+#define PFROBJS_H_
#include "pfrtypes.h"
@@ -90,7 +90,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFROBJS_H__ */
+#endif /* PFROBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.c b/src/3rdparty/freetype/src/pfr/pfrsbit.c
index bb5df5c9f9..ba909ddca7 100644
--- a/src/3rdparty/freetype/src/pfr/pfrsbit.c
+++ b/src/3rdparty/freetype/src/pfr/pfrsbit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,11 +37,11 @@
typedef struct PFR_BitWriter_
{
- FT_Byte* line; /* current line start */
- FT_Int pitch; /* line size in bytes */
- FT_UInt width; /* width in pixels/bits */
- FT_UInt rows; /* number of remaining rows to scan */
- FT_UInt total; /* total number of bits to draw */
+ FT_Byte* line; /* current line start */
+ FT_Int pitch; /* line size in bytes */
+ FT_UInt width; /* width in pixels/bits */
+ FT_UInt rows; /* number of remaining rows to scan */
+ FT_UInt total; /* total number of bits to draw */
} PFR_BitWriterRec, *PFR_BitWriter;
@@ -277,49 +277,99 @@
pfr_lookup_bitmap_data( FT_Byte* base,
FT_Byte* limit,
FT_UInt count,
- FT_UInt flags,
+ FT_UInt* flags,
FT_UInt char_code,
FT_ULong* found_offset,
FT_ULong* found_size )
{
- FT_UInt left, right, char_len;
- FT_Bool two = FT_BOOL( flags & 1 );
+ FT_UInt min, max, char_len;
+ FT_Bool two = FT_BOOL( *flags & PFR_BITMAP_2BYTE_CHARCODE );
FT_Byte* buff;
char_len = 4;
- if ( two ) char_len += 1;
- if ( flags & 2 ) char_len += 1;
- if ( flags & 4 ) char_len += 1;
+ if ( two )
+ char_len += 1;
+ if ( *flags & PFR_BITMAP_2BYTE_SIZE )
+ char_len += 1;
+ if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
+ char_len += 1;
+
+ if ( !( *flags & PFR_BITMAP_CHARCODES_VALIDATED ) )
+ {
+ FT_Byte* p;
+ FT_Byte* lim;
+ FT_UInt code;
+ FT_Long prev_code;
- left = 0;
- right = count;
- while ( left < right )
- {
- FT_UInt middle, code;
+ *flags |= PFR_BITMAP_VALID_CHARCODES;
+ prev_code = -1;
+ lim = base + count * char_len;
+ if ( lim > limit )
+ {
+ FT_TRACE0(( "pfr_lookup_bitmap_data:"
+ " number of bitmap records too large,\n"
+ " "
+ " thus ignoring all bitmaps in this strike\n" ));
+ *flags &= ~PFR_BITMAP_VALID_CHARCODES;
+ }
+ else
+ {
+ /* check whether records are sorted by code */
+ for ( p = base; p < lim; p += char_len )
+ {
+ if ( two )
+ code = FT_PEEK_USHORT( p );
+ else
+ code = *p;
- middle = ( left + right ) >> 1;
- buff = base + middle * char_len;
+ if ( (FT_Long)code <= prev_code )
+ {
+ FT_TRACE0(( "pfr_lookup_bitmap_data:"
+ " bitmap records are not sorted,\n"
+ " "
+ " thus ignoring all bitmaps in this strike\n" ));
+ *flags &= ~PFR_BITMAP_VALID_CHARCODES;
+ break;
+ }
- /* check that we are not outside of the table -- */
- /* this is possible with broken fonts... */
- if ( buff + char_len > limit )
- goto Fail;
+ prev_code = code;
+ }
+ }
+
+ *flags |= PFR_BITMAP_CHARCODES_VALIDATED;
+ }
+
+ /* ignore bitmaps in case table is not valid */
+ /* (this might be sanitized, but PFR is dead...) */
+ if ( !( *flags & PFR_BITMAP_VALID_CHARCODES ) )
+ goto Fail;
+
+ min = 0;
+ max = count;
+
+ /* binary search */
+ while ( min < max )
+ {
+ FT_UInt mid, code;
+
+
+ mid = ( min + max ) >> 1;
+ buff = base + mid * char_len;
if ( two )
code = PFR_NEXT_USHORT( buff );
else
code = PFR_NEXT_BYTE( buff );
- if ( code == char_code )
- goto Found_It;
-
- if ( code < char_code )
- left = middle;
+ if ( char_code < code )
+ max = mid;
+ else if ( char_code > code )
+ min = mid + 1;
else
- right = middle;
+ goto Found_It;
}
Fail:
@@ -329,20 +379,20 @@
return;
Found_It:
- if ( flags & 2 )
+ if ( *flags & PFR_BITMAP_2BYTE_SIZE )
*found_size = PFR_NEXT_USHORT( buff );
else
*found_size = PFR_NEXT_BYTE( buff );
- if ( flags & 4 )
+ if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
*found_offset = PFR_NEXT_ULONG( buff );
else
*found_offset = PFR_NEXT_USHORT( buff );
}
- /* load bitmap metrics. "*padvance" must be set to the default value */
- /* before calling this function... */
+ /* load bitmap metrics. `*padvance' must be set to the default value */
+ /* before calling this function */
/* */
static FT_Error
pfr_load_bitmap_metrics( FT_Byte** pdata,
@@ -357,7 +407,6 @@
{
FT_Error error = FT_Err_Ok;
FT_Byte flags;
- FT_Char c;
FT_Byte b;
FT_Byte* p = *pdata;
FT_Long xpos, ypos, advance;
@@ -377,9 +426,9 @@
{
case 0:
PFR_CHECK( 1 );
- c = PFR_NEXT_INT8( p );
- xpos = c >> 4;
- ypos = ( (FT_Char)( c << 4 ) ) >> 4;
+ b = PFR_NEXT_BYTE( p );
+ xpos = (FT_Char)b >> 4;
+ ypos = ( (FT_Char)( b << 4 ) ) >> 4;
break;
case 1:
@@ -445,7 +494,7 @@
case 1:
PFR_CHECK( 1 );
- advance = PFR_NEXT_INT8( p ) << 8;
+ advance = PFR_NEXT_INT8( p ) * 256;
break;
case 2:
@@ -510,8 +559,7 @@
break;
default:
- FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" ));
- error = FT_THROW( Invalid_File_Format );
+ ;
}
}
@@ -530,7 +578,8 @@
FT_LOCAL( FT_Error )
pfr_slot_load_bitmap( PFR_Slot glyph,
PFR_Size size,
- FT_UInt glyph_index )
+ FT_UInt glyph_index,
+ FT_Bool metrics_only )
{
FT_Error error;
PFR_Face face = (PFR_Face) glyph->root.face;
@@ -544,7 +593,7 @@
character = &phys->chars[glyph_index];
- /* Look-up a bitmap strike corresponding to the current */
+ /* look up a bitmap strike corresponding to the current */
/* character dimensions */
{
FT_UInt n;
@@ -555,9 +604,7 @@
{
if ( strike->x_ppm == (FT_UInt)size->root.metrics.x_ppem &&
strike->y_ppm == (FT_UInt)size->root.metrics.y_ppem )
- {
goto Found_Strike;
- }
strike++;
}
@@ -568,17 +615,20 @@
Found_Strike:
- /* Now lookup the glyph's position within the file */
+ /* now look up the glyph's position within the file */
{
FT_UInt char_len;
char_len = 4;
- if ( strike->flags & 1 ) char_len += 1;
- if ( strike->flags & 2 ) char_len += 1;
- if ( strike->flags & 4 ) char_len += 1;
-
- /* Access data directly in the frame to speed lookups */
+ if ( strike->flags & PFR_BITMAP_2BYTE_CHARCODE )
+ char_len += 1;
+ if ( strike->flags & PFR_BITMAP_2BYTE_SIZE )
+ char_len += 1;
+ if ( strike->flags & PFR_BITMAP_3BYTE_OFFSET )
+ char_len += 1;
+
+ /* access data directly in the frame to speed lookups */
if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) ||
FT_FRAME_ENTER( char_len * strike->num_bitmaps ) )
goto Exit;
@@ -586,7 +636,7 @@
pfr_lookup_bitmap_data( stream->cursor,
stream->limit,
strike->num_bitmaps,
- strike->flags,
+ &strike->flags,
character->char_code,
&gps_offset,
&gps_size );
@@ -595,7 +645,7 @@
if ( gps_size == 0 )
{
- /* Could not find a bitmap program string for this glyph */
+ /* could not find a bitmap program string for this glyph */
error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -617,8 +667,8 @@
glyph->root.linearHoriAdvance = advance;
- /* compute default advance, i.e., scaled advance. This can be */
- /* overridden in the bitmap header of certain glyphs. */
+ /* compute default advance, i.e., scaled advance; this can be */
+ /* overridden in the bitmap header of certain glyphs */
advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8,
character->advance,
(FT_Long)phys->metrics_resolution );
@@ -633,6 +683,55 @@
&xpos, &ypos,
&xsize, &ysize,
&advance, &format );
+ if ( error )
+ goto Exit1;
+
+ /*
+ * Before allocating the target bitmap, we check whether the given
+ * bitmap dimensions are valid, depending on the image format.
+ *
+ * Format 0: We have a stream of pixels (with 8 pixels per byte).
+ *
+ * (xsize * ysize + 7) / 8 <= gps_size
+ *
+ * Format 1: Run-length encoding; the high nibble holds the number of
+ * white bits, the low nibble the number of black bits. In
+ * other words, a single byte can represent at most 15
+ * pixels.
+ *
+ * xsize * ysize <= 15 * gps_size
+ *
+ * Format 2: Run-length encoding; the high byte holds the number of
+ * white bits, the low byte the number of black bits. In
+ * other words, two bytes can represent at most 255 pixels.
+ *
+ * xsize * ysize <= 255 * (gps_size + 1) / 2
+ */
+ switch ( format )
+ {
+ case 0:
+ if ( ( (FT_ULong)xsize * ysize + 7 ) / 8 > gps_size )
+ error = FT_THROW( Invalid_Table );
+ break;
+ case 1:
+ if ( (FT_ULong)xsize * ysize > 15 * gps_size )
+ error = FT_THROW( Invalid_Table );
+ break;
+ case 2:
+ if ( (FT_ULong)xsize * ysize > 255 * ( ( gps_size + 1 ) / 2 ) )
+ error = FT_THROW( Invalid_Table );
+ break;
+ default:
+ FT_ERROR(( "pfr_slot_load_bitmap: invalid image type\n" ));
+ error = FT_THROW( Invalid_Table );
+ }
+
+ if ( error )
+ {
+ if ( FT_ERR_EQ( error, Invalid_Table ) )
+ FT_ERROR(( "pfr_slot_load_bitmap: invalid bitmap dimensions\n" ));
+ goto Exit1;
+ }
/*
* XXX: on 16bit systems we return an error for huge bitmaps
@@ -666,8 +765,8 @@
/* XXX: needs casts to fit FT_Glyph_Metrics.{width|height} */
glyph->root.metrics.width = (FT_Pos)xsize << 6;
glyph->root.metrics.height = (FT_Pos)ysize << 6;
- glyph->root.metrics.horiBearingX = xpos << 6;
- glyph->root.metrics.horiBearingY = ypos << 6;
+ glyph->root.metrics.horiBearingX = xpos * 64;
+ glyph->root.metrics.horiBearingY = ypos * 64;
glyph->root.metrics.horiAdvance = FT_PIX_ROUND( ( advance >> 2 ) );
glyph->root.metrics.vertBearingX = - glyph->root.metrics.width >> 1;
glyph->root.metrics.vertBearingY = 0;
@@ -677,6 +776,9 @@
glyph->root.bitmap_left = (FT_Int)xpos;
glyph->root.bitmap_top = (FT_Int)( ypos + (FT_Long)ysize );
+ if ( metrics_only )
+ goto Exit1;
+
/* Allocate and read bitmap data */
{
FT_ULong len = (FT_ULong)glyph->root.bitmap.pitch * ysize;
@@ -684,17 +786,17 @@
error = ft_glyphslot_alloc_bitmap( &glyph->root, len );
if ( !error )
- {
error = pfr_load_bitmap_bits(
p,
stream->limit,
format,
- FT_BOOL(face->header.color_flags & 2),
+ FT_BOOL( face->header.color_flags &
+ PFR_FLAG_INVERT_BITMAP ),
&glyph->root.bitmap );
- }
}
}
+ Exit1:
FT_FRAME_EXIT();
}
@@ -702,4 +804,5 @@
return error;
}
+
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.h b/src/3rdparty/freetype/src/pfr/pfrsbit.h
index 0db2cd5ebd..07b27bc06c 100644
--- a/src/3rdparty/freetype/src/pfr/pfrsbit.h
+++ b/src/3rdparty/freetype/src/pfr/pfrsbit.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRSBIT_H__
-#define __PFRSBIT_H__
+#ifndef PFRSBIT_H_
+#define PFRSBIT_H_
#include "pfrobjs.h"
@@ -26,11 +26,12 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
pfr_slot_load_bitmap( PFR_Slot glyph,
PFR_Size size,
- FT_UInt glyph_index );
+ FT_UInt glyph_index,
+ FT_Bool metrics_only );
FT_END_HEADER
-#endif /* __PFR_SBIT_H__ */
+#endif /* PFRSBIT_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrtypes.h b/src/3rdparty/freetype/src/pfr/pfrtypes.h
index 5ffb1b14ee..058d6aadc9 100644
--- a/src/3rdparty/freetype/src/pfr/pfrtypes.h
+++ b/src/3rdparty/freetype/src/pfr/pfrtypes.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR data structures (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRTYPES_H__
-#define __PFRTYPES_H__
+#ifndef PFRTYPES_H_
+#define PFRTYPES_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -69,12 +69,8 @@ FT_BEGIN_HEADER
/* used in `color_flags' field of the PFR_Header */
- typedef enum PFR_HeaderFlags_
- {
- PFR_FLAG_BLACK_PIXEL = 1,
- PFR_FLAG_INVERT_BITMAP = 2
-
- } PFR_HeaderFlags;
+#define PFR_FLAG_BLACK_PIXEL 0x01U
+#define PFR_FLAG_INVERT_BITMAP 0x02U
/************************************************************************/
@@ -96,36 +92,27 @@ FT_BEGIN_HEADER
} PFR_LogFontRec, *PFR_LogFont;
- typedef enum PFR_LogFlags_
- {
- PFR_LOG_EXTRA_ITEMS = 0x40,
- PFR_LOG_2BYTE_BOLD = 0x20,
- PFR_LOG_BOLD = 0x10,
- PFR_LOG_2BYTE_STROKE = 8,
- PFR_LOG_STROKE = 4,
- PFR_LINE_JOIN_MASK = 3
+#define PFR_LINE_JOIN_MITER 0x00U
+#define PFR_LINE_JOIN_ROUND 0x01U
+#define PFR_LINE_JOIN_BEVEL 0x02U
+#define PFR_LINE_JOIN_MASK ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL )
- } PFR_LogFlags;
-
-
- typedef enum PFR_LineJoinFlags_
- {
- PFR_LINE_JOIN_MITER = 0,
- PFR_LINE_JOIN_ROUND = 1,
- PFR_LINE_JOIN_BEVEL = 2
-
- } PFR_LineJoinFlags;
+#define PFR_LOG_STROKE 0x04U
+#define PFR_LOG_2BYTE_STROKE 0x08U
+#define PFR_LOG_BOLD 0x10U
+#define PFR_LOG_2BYTE_BOLD 0x20U
+#define PFR_LOG_EXTRA_ITEMS 0x40U
/************************************************************************/
- typedef enum PFR_BitmapFlags_
- {
- PFR_BITMAP_3BYTE_OFFSET = 4,
- PFR_BITMAP_2BYTE_SIZE = 2,
- PFR_BITMAP_2BYTE_CHARCODE = 1
+#define PFR_BITMAP_2BYTE_CHARCODE 0x01U
+#define PFR_BITMAP_2BYTE_SIZE 0x02U
+#define PFR_BITMAP_3BYTE_OFFSET 0x04U
- } PFR_BitmapFlags;
+ /*not part of the specification but used for implementation */
+#define PFR_BITMAP_CHARCODES_VALIDATED 0x40U
+#define PFR_BITMAP_VALID_CHARCODES 0x80U
typedef struct PFR_BitmapCharRec_
@@ -137,15 +124,11 @@ FT_BEGIN_HEADER
} PFR_BitmapCharRec, *PFR_BitmapChar;
- typedef enum PFR_StrikeFlags_
- {
- PFR_STRIKE_2BYTE_COUNT = 0x10,
- PFR_STRIKE_3BYTE_OFFSET = 0x08,
- PFR_STRIKE_3BYTE_SIZE = 0x04,
- PFR_STRIKE_2BYTE_YPPM = 0x02,
- PFR_STRIKE_2BYTE_XPPM = 0x01
-
- } PFR_StrikeFlags;
+#define PFR_STRIKE_2BYTE_XPPM 0x01U
+#define PFR_STRIKE_2BYTE_YPPM 0x02U
+#define PFR_STRIKE_3BYTE_SIZE 0x04U
+#define PFR_STRIKE_3BYTE_OFFSET 0x08U
+#define PFR_STRIKE_2BYTE_COUNT 0x10U
typedef struct PFR_StrikeRec_
@@ -266,38 +249,29 @@ FT_BEGIN_HEADER
} PFR_PhyFontRec, *PFR_PhyFont;
- typedef enum PFR_PhyFlags_
- {
- PFR_PHY_EXTRA_ITEMS = 0x80,
- PFR_PHY_3BYTE_GPS_OFFSET = 0x20,
- PFR_PHY_2BYTE_GPS_SIZE = 0x10,
- PFR_PHY_ASCII_CODE = 0x08,
- PFR_PHY_PROPORTIONAL = 0x04,
- PFR_PHY_2BYTE_CHARCODE = 0x02,
- PFR_PHY_VERTICAL = 0x01
-
- } PFR_PhyFlags;
+#define PFR_PHY_VERTICAL 0x01U
+#define PFR_PHY_2BYTE_CHARCODE 0x02U
+#define PFR_PHY_PROPORTIONAL 0x04U
+#define PFR_PHY_ASCII_CODE 0x08U
+#define PFR_PHY_2BYTE_GPS_SIZE 0x10U
+#define PFR_PHY_3BYTE_GPS_OFFSET 0x20U
+#define PFR_PHY_EXTRA_ITEMS 0x80U
- typedef enum PFR_KernFlags_
- {
- PFR_KERN_2BYTE_CHAR = 0x01,
- PFR_KERN_2BYTE_ADJ = 0x02
-
- } PFR_KernFlags;
+#define PFR_KERN_2BYTE_CHAR 0x01U
+#define PFR_KERN_2BYTE_ADJ 0x02U
/************************************************************************/
- typedef enum PFR_GlyphFlags_
- {
- PFR_GLYPH_IS_COMPOUND = 0x80,
- PFR_GLYPH_EXTRA_ITEMS = 0x08,
- PFR_GLYPH_1BYTE_XYCOUNT = 0x04,
- PFR_GLYPH_XCOUNT = 0x02,
- PFR_GLYPH_YCOUNT = 0x01
+#define PFR_GLYPH_YCOUNT 0x01U
+#define PFR_GLYPH_XCOUNT 0x02U
+#define PFR_GLYPH_1BYTE_XYCOUNT 0x04U
+
+#define PFR_GLYPH_SINGLE_EXTRA_ITEMS 0x08U
+#define PFR_GLYPH_COMPOUND_EXTRA_ITEMS 0x40U
- } PFR_GlyphFlags;
+#define PFR_GLYPH_IS_COMPOUND 0x80U
/* controlled coordinate */
@@ -321,14 +295,10 @@ FT_BEGIN_HEADER
} PFR_SubGlyphRec, *PFR_SubGlyph;
- typedef enum PFR_SubgGlyphFlags_
- {
- PFR_SUBGLYPH_3BYTE_OFFSET = 0x80,
- PFR_SUBGLYPH_2BYTE_SIZE = 0x40,
- PFR_SUBGLYPH_YSCALE = 0x20,
- PFR_SUBGLYPH_XSCALE = 0x10
-
- } PFR_SubGlyphFlags;
+#define PFR_SUBGLYPH_XSCALE 0x10U
+#define PFR_SUBGLYPH_YSCALE 0x20U
+#define PFR_SUBGLYPH_2BYTE_SIZE 0x40U
+#define PFR_SUBGLYPH_3BYTE_OFFSET 0x80U
typedef struct PFR_GlyphRec_
@@ -356,7 +326,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRTYPES_H__ */
+#endif /* PFRTYPES_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/rules.mk b/src/3rdparty/freetype/src/pfr/rules.mk
index e665460103..3acb795696 100644
--- a/src/3rdparty/freetype/src/pfr/rules.mk
+++ b/src/3rdparty/freetype/src/pfr/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,