diff options
Diffstat (limited to 'src/3rdparty/freetype/src/pfr')
-rw-r--r-- | src/3rdparty/freetype/src/pfr/Jamfile | 35 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/module.mk | 2 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfr.c | 3 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrcmap.c | 71 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrcmap.h | 5 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrdrivr.c | 37 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrdrivr.h | 5 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrerror.h | 6 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrgload.c | 16 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrgload.h | 2 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrload.c | 103 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrload.h | 4 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrobjs.c | 49 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrobjs.h | 2 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrsbit.c | 35 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrsbit.h | 2 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/pfrtypes.h | 7 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pfr/rules.mk | 2 |
18 files changed, 188 insertions, 198 deletions
diff --git a/src/3rdparty/freetype/src/pfr/Jamfile b/src/3rdparty/freetype/src/pfr/Jamfile deleted file mode 100644 index fbca8065c4..0000000000 --- a/src/3rdparty/freetype/src/pfr/Jamfile +++ /dev/null @@ -1,35 +0,0 @@ -# FreeType 2 src/pfr Jamfile -# -# Copyright (C) 2002-2019 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - -SubDir FT2_TOP $(FT2_SRC_DIR) pfr ; - -{ - local _sources ; - - if $(FT2_MULTI) - { - _sources = pfrcmap - pfrdrivr - pfrgload - pfrload - pfrobjs - pfrsbit - ; - } - else - { - _sources = pfr ; - } - - Library $(FT2_LIB) : $(_sources).c ; -} - -# end of src/pfr Jamfile diff --git a/src/3rdparty/freetype/src/pfr/module.mk b/src/3rdparty/freetype/src/pfr/module.mk index 30d876d4c8..388a38ed09 100644 --- a/src/3rdparty/freetype/src/pfr/module.mk +++ b/src/3rdparty/freetype/src/pfr/module.mk @@ -3,7 +3,7 @@ # -# Copyright (C) 2002-2019 by +# Copyright (C) 2002-2023 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 6d885ea47f..d3738152dc 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -17,7 +17,6 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#include <ft2build.h> #include "pfrcmap.c" #include "pfrdrivr.c" diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c index bfa1b9ea05..08fe41d54e 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -16,8 +16,7 @@ */ -#include <ft2build.h> -#include FT_INTERNAL_DEBUG_H +#include <freetype/internal/ftdebug.h> #include "pfrcmap.h" #include "pfrobjs.h" @@ -25,17 +24,18 @@ FT_CALLBACK_DEF( FT_Error ) - pfr_cmap_init( PFR_CMap cmap, + pfr_cmap_init( FT_CMap cmap, /* PFR_CMap */ FT_Pointer pointer ) { - FT_Error error = FT_Err_Ok; - PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap ); + PFR_CMap pfrcmap = (PFR_CMap)cmap; + FT_Error error = FT_Err_Ok; + PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap ); FT_UNUSED( pointer ); - cmap->num_chars = face->phy_font.num_chars; - cmap->chars = face->phy_font.chars; + pfrcmap->num_chars = face->phy_font.num_chars; + pfrcmap->chars = face->phy_font.chars; /* just for safety, check that the character entries are correctly */ /* sorted in increasing character code order */ @@ -43,9 +43,9 @@ FT_UInt n; - for ( n = 1; n < cmap->num_chars; n++ ) + for ( n = 1; n < pfrcmap->num_chars; n++ ) { - if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code ) + if ( pfrcmap->chars[n - 1].char_code >= pfrcmap->chars[n].char_code ) { error = FT_THROW( Invalid_Table ); goto Exit; @@ -59,29 +59,30 @@ FT_CALLBACK_DEF( void ) - pfr_cmap_done( PFR_CMap cmap ) + pfr_cmap_done( FT_CMap cmap ) /* PFR_CMap */ { - cmap->chars = NULL; - cmap->num_chars = 0; + PFR_CMap pfrcmap = (PFR_CMap)cmap; + + + pfrcmap->chars = NULL; + pfrcmap->num_chars = 0; } FT_CALLBACK_DEF( FT_UInt ) - pfr_cmap_char_index( PFR_CMap cmap, + pfr_cmap_char_index( FT_CMap cmap, /* PFR_CMap */ FT_UInt32 char_code ) { - FT_UInt min = 0; - FT_UInt max = cmap->num_chars; + PFR_CMap pfrcmap = (PFR_CMap)cmap; + FT_UInt min = 0; + FT_UInt max = pfrcmap->num_chars; + FT_UInt mid = min + ( max - min ) / 2; + PFR_Char gchar; while ( min < max ) { - PFR_Char gchar; - FT_UInt mid; - - - mid = min + ( max - min ) / 2; - gchar = cmap->chars + mid; + gchar = pfrcmap->chars + mid; if ( gchar->char_code == char_code ) return mid + 1; @@ -90,15 +91,21 @@ min = mid + 1; else max = mid; + + /* reasonable prediction in a continuous block */ + mid += char_code - gchar->char_code; + if ( mid >= max || mid < min ) + mid = min + ( max - min ) / 2; } return 0; } - FT_CALLBACK_DEF( FT_UInt32 ) - pfr_cmap_char_next( PFR_CMap cmap, + FT_CALLBACK_DEF( FT_UInt ) + pfr_cmap_char_next( FT_CMap cmap, /* PFR_CMap */ FT_UInt32 *pchar_code ) { + PFR_CMap pfrcmap = (PFR_CMap)cmap; FT_UInt result = 0; FT_UInt32 char_code = *pchar_code + 1; @@ -106,15 +113,14 @@ Restart: { FT_UInt min = 0; - FT_UInt max = cmap->num_chars; - FT_UInt mid; + FT_UInt max = pfrcmap->num_chars; + FT_UInt mid = min + ( max - min ) / 2; PFR_Char gchar; while ( min < max ) { - mid = min + ( ( max - min ) >> 1 ); - gchar = cmap->chars + mid; + gchar = pfrcmap->chars + mid; if ( gchar->char_code == char_code ) { @@ -133,14 +139,19 @@ min = mid + 1; else max = mid; + + /* reasonable prediction in a continuous block */ + mid += char_code - gchar->char_code; + if ( mid >= max || mid < min ) + mid = min + ( max - min ) / 2; } /* we didn't find it, but we have a pair just above it */ char_code = 0; - if ( min < cmap->num_chars ) + if ( min < pfrcmap->num_chars ) { - gchar = cmap->chars + min; + gchar = pfrcmap->chars + min; result = min; if ( result != 0 ) { diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.h b/src/3rdparty/freetype/src/pfr/pfrcmap.h index 1e203a0514..8110f175e8 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -19,8 +19,7 @@ #ifndef PFRCMAP_H_ #define PFRCMAP_H_ -#include <ft2build.h> -#include FT_INTERNAL_OBJECTS_H +#include <freetype/internal/ftobjs.h> #include "pfrtypes.h" diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.c b/src/3rdparty/freetype/src/pfr/pfrdrivr.c index f67eebf118..0048f52411 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -16,11 +16,10 @@ */ -#include <ft2build.h> -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H -#include FT_SERVICE_PFR_H -#include FT_SERVICE_FONT_FORMAT_H +#include <freetype/internal/ftdebug.h> +#include <freetype/internal/ftstream.h> +#include <freetype/internal/services/svpfr.h> +#include <freetype/internal/services/svfntfmt.h> #include "pfrdrivr.h" #include "pfrobjs.h" @@ -28,16 +27,16 @@ FT_CALLBACK_DEF( FT_Error ) - pfr_get_kerning( FT_Face pfrface, /* PFR_Face */ + pfr_get_kerning( FT_Face face, /* PFR_Face */ FT_UInt left, FT_UInt right, FT_Vector *avector ) { - PFR_Face face = (PFR_Face)pfrface; - PFR_PhyFont phys = &face->phy_font; + PFR_Face pfrface = (PFR_Face)face; + PFR_PhyFont phys = &pfrface->phy_font; - (void)pfr_face_get_kerning( pfrface, left, right, avector ); + (void)pfr_face_get_kerning( face, left, right, avector ); /* convert from metrics to outline units when necessary */ if ( phys->outline_resolution != phys->metrics_resolution ) @@ -63,12 +62,12 @@ */ FT_CALLBACK_DEF( FT_Error ) - pfr_get_advance( FT_Face pfrface, /* PFR_Face */ + pfr_get_advance( FT_Face face, /* PFR_Face */ FT_UInt gindex, FT_Pos *anadvance ) { - PFR_Face face = (PFR_Face)pfrface; - FT_Error error = FT_ERR( Invalid_Argument ); + PFR_Face pfrface = (PFR_Face)face; + FT_Error error = FT_ERR( Invalid_Argument ); *anadvance = 0; @@ -78,9 +77,9 @@ gindex--; - if ( face ) + if ( pfrface ) { - PFR_PhyFont phys = &face->phy_font; + PFR_PhyFont phys = &pfrface->phy_font; if ( gindex < phys->num_chars ) @@ -96,16 +95,16 @@ FT_CALLBACK_DEF( FT_Error ) - pfr_get_metrics( FT_Face pfrface, /* PFR_Face */ + pfr_get_metrics( FT_Face face, /* PFR_Face */ FT_UInt *anoutline_resolution, FT_UInt *ametrics_resolution, FT_Fixed *ametrics_x_scale, FT_Fixed *ametrics_y_scale ) { - PFR_Face face = (PFR_Face)pfrface; - PFR_PhyFont phys = &face->phy_font; + PFR_Face pfrface = (PFR_Face)face; + PFR_PhyFont phys = &pfrface->phy_font; FT_Fixed x_scale, y_scale; - FT_Size size = face->root.size; + FT_Size size = pfrface->root.size; if ( anoutline_resolution ) diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.h b/src/3rdparty/freetype/src/pfr/pfrdrivr.h index 33b7b9413f..da14468d42 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -20,8 +20,7 @@ #define PFRDRIVR_H_ -#include <ft2build.h> -#include FT_INTERNAL_DRIVER_H +#include <freetype/internal/ftdrv.h> FT_BEGIN_HEADER diff --git a/src/3rdparty/freetype/src/pfr/pfrerror.h b/src/3rdparty/freetype/src/pfr/pfrerror.h index 4829cfc000..5dfb254d66 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -25,7 +25,7 @@ #ifndef PFRERROR_H_ #define PFRERROR_H_ -#include FT_MODULE_ERRORS_H +#include <freetype/ftmoderr.h> #undef FTERRORS_H_ @@ -33,7 +33,7 @@ #define FT_ERR_PREFIX PFR_Err_ #define FT_ERR_BASE FT_Mod_Err_PFR -#include FT_ERRORS_H +#include <freetype/fterrors.h> #endif /* PFRERROR_H_ */ diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c index 6ef5856a8d..48cf27ec80 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -19,7 +19,7 @@ #include "pfrgload.h" #include "pfrsbit.h" #include "pfrload.h" /* for macro definitions */ -#include FT_INTERNAL_DEBUG_H +#include <freetype/internal/ftdebug.h> #include "pfrerror.h" @@ -42,8 +42,7 @@ { FT_ZERO( glyph ); - glyph->loader = loader; - glyph->path_begun = 0; + glyph->loader = loader; FT_GlyphLoader_Rewind( loader ); } @@ -409,7 +408,7 @@ break; case 6: /* horizontal to vertical curve */ - FT_TRACE6(( "- hv curve " )); + FT_TRACE6(( "- hv curve" )); args_format = 0xB8E; args_count = 3; break; @@ -451,7 +450,7 @@ case 1: /* 16-bit absolute value */ PFR_CHECK( 2 ); cur->x = PFR_NEXT_SHORT( p ); - FT_TRACE7(( " x.%d", cur->x )); + FT_TRACE7(( " x.%ld", cur->x )); break; case 2: /* 8-bit delta */ @@ -481,7 +480,7 @@ case 1: /* 16-bit absolute value */ PFR_CHECK( 2 ); cur->y = PFR_NEXT_SHORT( p ); - FT_TRACE7(( " y.%d", cur->y )); + FT_TRACE7(( " y.%ld", cur->y )); break; case 2: /* 8-bit delta */ @@ -561,8 +560,7 @@ FT_Byte* limit ) { FT_Error error = FT_Err_Ok; - FT_GlyphLoader loader = glyph->loader; - FT_Memory memory = loader->memory; + FT_Memory memory = glyph->loader->memory; PFR_SubGlyph subglyph; FT_UInt flags, i, count, org_count; FT_Int x_pos, y_pos; diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.h b/src/3rdparty/freetype/src/pfr/pfrgload.h index d0e1420b67..92a59bc5db 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/src/pfr/pfrload.c b/src/3rdparty/freetype/src/pfr/pfrload.c index ccf0b7e1f8..856a5942f5 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -17,8 +17,8 @@ #include "pfrload.h" -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H +#include <freetype/internal/ftdebug.h> +#include <freetype/internal/ftstream.h> #include "pfrerror.h" @@ -268,9 +268,7 @@ header->version > 4 || header->header_size < 58 || header->signature2 != 0x0D0A ) /* CR/LF */ - { result = 0; - } return result; } @@ -406,11 +404,9 @@ } if ( flags & PFR_LOG_BOLD ) - { log_font->bold_thickness = ( flags & PFR_LOG_2BYTE_BOLD ) ? PFR_NEXT_SHORT( p ) : PFR_NEXT_BYTE( p ); - } if ( flags & PFR_LOG_EXTRA_ITEMS ) { @@ -453,15 +449,16 @@ /* load bitmap strikes lists */ FT_CALLBACK_DEF( FT_Error ) - pfr_extra_item_load_bitmap_info( FT_Byte* p, - FT_Byte* limit, - PFR_PhyFont phy_font ) + pfr_extra_item_load_bitmap_info( FT_Byte* p, + FT_Byte* limit, + void* phy_font_ ) { - FT_Memory memory = phy_font->memory; - PFR_Strike strike; - FT_UInt flags0; - FT_UInt n, count, size1; - FT_Error error = FT_Err_Ok; + PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_; + FT_Memory memory = phy_font->memory; + PFR_Strike strike; + FT_UInt flags0; + FT_UInt n, count, size1; + FT_Error error = FT_Err_Ok; PFR_CHECK( 5 ); @@ -553,19 +550,20 @@ * family. */ FT_CALLBACK_DEF( FT_Error ) - pfr_extra_item_load_font_id( FT_Byte* p, - FT_Byte* limit, - PFR_PhyFont phy_font ) + pfr_extra_item_load_font_id( FT_Byte* p, + FT_Byte* limit, + void* phy_font_ ) { - FT_Error error = FT_Err_Ok; - FT_Memory memory = phy_font->memory; - FT_UInt len = (FT_UInt)( limit - p ); + PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_; + FT_Error error = FT_Err_Ok; + FT_Memory memory = phy_font->memory; + FT_UInt len = (FT_UInt)( limit - p ); if ( phy_font->font_id ) goto Exit; - if ( FT_ALLOC( phy_font->font_id, len + 1 ) ) + if ( FT_QALLOC( phy_font->font_id, len + 1 ) ) goto Exit; /* copy font ID name, and terminate it for safety */ @@ -579,14 +577,15 @@ /* load stem snap tables */ FT_CALLBACK_DEF( FT_Error ) - pfr_extra_item_load_stem_snaps( FT_Byte* p, - FT_Byte* limit, - PFR_PhyFont phy_font ) + pfr_extra_item_load_stem_snaps( FT_Byte* p, + FT_Byte* limit, + void* phy_font_ ) { - FT_UInt count, num_vert, num_horz; - FT_Int* snaps = NULL; - FT_Error error = FT_Err_Ok; - FT_Memory memory = phy_font->memory; + PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_; + FT_UInt count, num_vert, num_horz; + FT_Int* snaps = NULL; + FT_Error error = FT_Err_Ok; + FT_Memory memory = phy_font->memory; if ( phy_font->vertical.stem_snaps ) @@ -601,10 +600,10 @@ PFR_CHECK( count * 2 ); - if ( FT_NEW_ARRAY( snaps, count ) ) + if ( FT_QNEW_ARRAY( snaps, count ) ) goto Exit; - phy_font->vertical.stem_snaps = snaps; + phy_font->vertical.stem_snaps = snaps; phy_font->horizontal.stem_snaps = snaps + num_vert; for ( ; count > 0; count--, snaps++ ) @@ -621,13 +620,13 @@ } - /* load kerning pair data */ FT_CALLBACK_DEF( FT_Error ) - pfr_extra_item_load_kerning_pairs( FT_Byte* p, - FT_Byte* limit, - PFR_PhyFont phy_font ) + pfr_extra_item_load_kerning_pairs( FT_Byte* p, + FT_Byte* limit, + void* phy_font_ ) { + PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_; PFR_KernItem item = NULL; FT_Error error = FT_Err_Ok; FT_Memory memory = phy_font->memory; @@ -720,10 +719,10 @@ static const PFR_ExtraItemRec pfr_phy_font_extra_items[] = { - { 1, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_bitmap_info }, - { 2, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_font_id }, - { 3, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_stem_snaps }, - { 4, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_kerning_pairs }, + { 1, pfr_extra_item_load_bitmap_info }, + { 2, pfr_extra_item_load_font_id }, + { 3, pfr_extra_item_load_stem_snaps }, + { 4, pfr_extra_item_load_kerning_pairs }, { 0, NULL } }; @@ -761,7 +760,7 @@ if ( ok ) { - if ( FT_ALLOC( result, len + 1 ) ) + if ( FT_QALLOC( result, len + 1 ) ) goto Exit; FT_MEM_COPY( result, p, len ); @@ -857,8 +856,16 @@ phy_font->bbox.yMax = PFR_NEXT_SHORT( p ); phy_font->flags = flags = PFR_NEXT_BYTE( p ); + if ( !phy_font->outline_resolution || + !phy_font->metrics_resolution ) + { + error = FT_THROW( Invalid_Table ); + FT_ERROR(( "pfr_phy_font_load: invalid resolution\n" )); + goto Fail; + } + /* get the standard advance for non-proportional fonts */ - if ( !(flags & PFR_PHY_PROPORTIONAL) ) + if ( !( flags & PFR_PHY_PROPORTIONAL ) ) { PFR_CHECK( 2 ); phy_font->standard_advance = PFR_NEXT_SHORT( p ); @@ -869,14 +876,13 @@ { 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. */ + /* guessed by looking at the content of a few 'PFR0' fonts. */ PFR_CHECK( 3 ); num_aux = PFR_NEXT_ULONG( p ); @@ -953,7 +959,7 @@ PFR_CHECK( count * 2 ); - if ( FT_NEW_ARRAY( phy_font->blue_values, count ) ) + if ( FT_QNEW_ARRAY( phy_font->blue_values, count ) ) goto Fail; for ( n = 0; n < count; n++ ) @@ -975,6 +981,13 @@ phy_font->num_chars = count = PFR_NEXT_USHORT( p ); phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor ); + if ( !phy_font->num_chars ) + { + error = FT_THROW( Invalid_Table ); + FT_ERROR(( "pfr_phy_font_load: no glyphs\n" )); + goto Fail; + } + Size = 1 + 1 + 2; if ( flags & PFR_PHY_2BYTE_CHARCODE ) Size += 1; @@ -993,7 +1006,7 @@ PFR_CHECK_SIZE( count * Size ); - if ( FT_NEW_ARRAY( phy_font->chars, count ) ) + if ( FT_QNEW_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 2e7ffd0127..d7b20a4572 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -20,7 +20,7 @@ #define PFRLOAD_H_ #include "pfrobjs.h" -#include FT_INTERNAL_STREAM_H +#include <freetype/internal/ftstream.h> FT_BEGIN_HEADER diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c index 9765f95c2f..8ef17c6636 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -21,10 +21,10 @@ #include "pfrgload.h" #include "pfrcmap.h" #include "pfrsbit.h" -#include FT_OUTLINE_H -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_CALC_H -#include FT_TRUETYPE_IDS_H +#include <freetype/ftoutln.h> +#include <freetype/internal/ftdebug.h> +#include <freetype/internal/ftcalc.h> +#include <freetype/ttnameid.h> #include "pfrerror.h" @@ -50,14 +50,14 @@ if ( !face ) return; - memory = pfrface->driver->root.memory; + memory = pfrface->memory; /* we don't want dangling pointers */ pfrface->family_name = NULL; pfrface->style_name = NULL; /* finalize the physical font record */ - pfr_phy_font_done( &face->phy_font, FT_FACE_MEMORY( face ) ); + pfr_phy_font_done( &face->phy_font, memory ); /* no need to finalize the logical font or the header */ FT_FREE( pfrface->available_sizes ); @@ -83,7 +83,11 @@ /* load the header and check it */ error = pfr_header_load( &face->header, stream ); if ( error ) + { + FT_TRACE2(( " not a PFR font\n" )); + error = FT_THROW( Unknown_File_Format ); goto Exit; + } if ( !pfr_header_check( &face->header ) ) { @@ -126,14 +130,14 @@ if ( error ) goto Exit; - /* now load the physical font descriptor */ + /* load the physical font descriptor */ error = pfr_phy_font_load( &face->phy_font, stream, face->log_font.phys_offset, face->log_font.phys_size ); if ( error ) goto Exit; - /* now set up all root face fields */ + /* set up all root face fields */ { PFR_PhyFont phy_font = &face->phy_font; @@ -156,7 +160,7 @@ if ( nn == phy_font->num_chars ) { if ( phy_font->num_strikes > 0 ) - pfrface->face_flags = 0; /* not scalable */ + pfrface->face_flags &= ~FT_FACE_FLAG_SCALABLE; else { FT_ERROR(( "pfr_face_init: font doesn't contain glyphs\n" )); @@ -166,7 +170,7 @@ } } - if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 ) + if ( !( phy_font->flags & PFR_PHY_PROPORTIONAL ) ) pfrface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; if ( phy_font->flags & PFR_PHY_VERTICAL ) @@ -203,17 +207,17 @@ pfrface->height = (FT_Short)( ( pfrface->units_per_EM * 12 ) / 10 ); if ( pfrface->height < pfrface->ascender - pfrface->descender ) - pfrface->height = (FT_Short)(pfrface->ascender - pfrface->descender); + pfrface->height = (FT_Short)( pfrface->ascender - pfrface->descender ); if ( phy_font->num_strikes > 0 ) { FT_UInt n, count = phy_font->num_strikes; FT_Bitmap_Size* size; PFR_Strike strike; - FT_Memory memory = pfrface->stream->memory; + FT_Memory memory = pfrface->memory; - if ( FT_NEW_ARRAY( pfrface->available_sizes, count ) ) + if ( FT_QNEW_ARRAY( pfrface->available_sizes, count ) ) goto Exit; size = pfrface->available_sizes; @@ -334,7 +338,7 @@ } /* try to load an embedded bitmap */ - if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 ) + if ( !( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) ) { error = pfr_slot_load_bitmap( slot, @@ -482,17 +486,16 @@ kerning->x = 0; kerning->y = 0; - if ( glyph1 > 0 ) - glyph1--; - - if ( glyph2 > 0 ) - glyph2--; + /* PFR indexing skips .notdef, which becomes UINT_MAX */ + glyph1--; + glyph2--; - /* convert glyph indices to character codes */ - if ( glyph1 > phy_font->num_chars || - glyph2 > phy_font->num_chars ) + /* check the array bounds, .notdef is automatically out */ + if ( glyph1 >= phy_font->num_chars || + glyph2 >= phy_font->num_chars ) goto Exit; + /* convert glyph indices to character codes */ code1 = phy_font->chars[glyph1].char_code; code2 = phy_font->chars[glyph2].char_code; pair = PFR_KERN_INDEX( code1, code2 ); diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.h b/src/3rdparty/freetype/src/pfr/pfrobjs.h index 39cffd07c5..fcf8c38122 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.c b/src/3rdparty/freetype/src/pfr/pfrsbit.c index 00a9616455..46a988e8e3 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -18,8 +18,8 @@ #include "pfrsbit.h" #include "pfrload.h" -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H +#include <freetype/internal/ftdebug.h> +#include <freetype/internal/ftstream.h> #include "pfrerror.h" @@ -282,7 +282,7 @@ FT_ULong* found_offset, FT_ULong* found_size ) { - FT_UInt min, max, char_len; + FT_UInt min, max, mid, char_len; FT_Bool two = FT_BOOL( *flags & PFR_BITMAP_2BYTE_CHARCODE ); FT_Byte* buff; @@ -310,8 +310,8 @@ if ( lim > limit ) { FT_TRACE0(( "pfr_lookup_bitmap_data:" - " number of bitmap records too large,\n" - " " + " number of bitmap records too large,\n" )); + FT_TRACE0(( " " " thus ignoring all bitmaps in this strike\n" )); *flags &= ~PFR_BITMAP_VALID_CHARCODES; } @@ -328,8 +328,8 @@ if ( (FT_Long)code <= prev_code ) { FT_TRACE0(( "pfr_lookup_bitmap_data:" - " bitmap records are not sorted,\n" - " " + " bitmap records are not sorted,\n" )); + FT_TRACE0(( " " " thus ignoring all bitmaps in this strike\n" )); *flags &= ~PFR_BITMAP_VALID_CHARCODES; break; @@ -349,14 +349,14 @@ min = 0; max = count; + mid = min + ( max - min ) / 2; /* binary search */ while ( min < max ) { - FT_UInt mid, code; + FT_UInt code; - mid = ( min + max ) >> 1; buff = base + mid * char_len; if ( two ) @@ -370,6 +370,11 @@ min = mid + 1; else goto Found_It; + + /* reasonable prediction in a continuous block */ + mid += char_code - code; + if ( mid >= max || mid < min ) + mid = min + ( max - min ) / 2; } Fail: @@ -391,7 +396,7 @@ } - /* load bitmap metrics. `*padvance' must be set to the default value */ + /* load bitmap metrics. `*aadvance' must be set to the default value */ /* before calling this function */ /* */ static FT_Error @@ -575,7 +580,7 @@ /*************************************************************************/ /*************************************************************************/ - FT_LOCAL( FT_Error ) + FT_LOCAL_DEF( FT_Error ) pfr_slot_load_bitmap( PFR_Slot glyph, PFR_Size size, FT_UInt glyph_index, @@ -628,7 +633,7 @@ if ( strike->flags & PFR_BITMAP_3BYTE_OFFSET ) char_len += 1; - /* access data directly in the frame to speed lookups */ + /* access data directly in the frame to speed up lookups */ if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) || FT_FRAME_ENTER( char_len * strike->num_bitmaps ) ) goto Exit; @@ -744,8 +749,8 @@ ypos > FT_INT_MAX - (FT_Long)ysize || ypos + (FT_Long)ysize < FT_INT_MIN ) { - FT_TRACE1(( "pfr_slot_load_bitmap:" )); - FT_TRACE1(( "huge bitmap glyph %dx%d over FT_GlyphSlot\n", + FT_TRACE1(( "pfr_slot_load_bitmap:" + " huge bitmap glyph %ldx%ld over FT_GlyphSlot\n", xpos, ypos )); error = FT_THROW( Invalid_Pixel_Size ); } diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.h b/src/3rdparty/freetype/src/pfr/pfrsbit.h index 6568b90943..3e1dba9ae9 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/src/pfr/pfrtypes.h b/src/3rdparty/freetype/src/pfr/pfrtypes.h index 6a5f9d571b..2f8909f062 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 (C) 2002-2019 by + * Copyright (C) 2002-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -19,8 +19,7 @@ #ifndef PFRTYPES_H_ #define PFRTYPES_H_ -#include <ft2build.h> -#include FT_INTERNAL_OBJECTS_H +#include <freetype/internal/ftobjs.h> FT_BEGIN_HEADER @@ -110,7 +109,7 @@ FT_BEGIN_HEADER #define PFR_BITMAP_2BYTE_SIZE 0x02U #define PFR_BITMAP_3BYTE_OFFSET 0x04U - /*not part of the specification but used for implementation */ + /* not part of the specification but used for implementation */ #define PFR_BITMAP_CHARCODES_VALIDATED 0x40U #define PFR_BITMAP_VALID_CHARCODES 0x80U diff --git a/src/3rdparty/freetype/src/pfr/rules.mk b/src/3rdparty/freetype/src/pfr/rules.mk index f14ca699e2..50695fd288 100644 --- a/src/3rdparty/freetype/src/pfr/rules.mk +++ b/src/3rdparty/freetype/src/pfr/rules.mk @@ -3,7 +3,7 @@ # -# Copyright (C) 2002-2019 by +# Copyright (C) 2002-2023 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, |