summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pfr/pfrobjs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pfr/pfrobjs.c')
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c
index 918e7fd496..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-2020 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,
@@ -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 );