freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] 2 commits: [sfnt] Fix handling of PS na


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] 2 commits: [sfnt] Fix handling of PS names for Variation Fonts.
Date: Tue, 25 Apr 2023 09:47:42 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 40676afc
    by Werner Lemberg at 2023-04-25T11:47:18+02:00
    [sfnt] Fix handling of PS names for Variation Fonts.
    
    * src/sfnt/sfdriver.c (get_win_string, get_apple_string): Continue
    construction of string if an invalid character is encountered.
    
    Fixes #1218.
    
  • 0a3836c9
    by Werner Lemberg at 2023-04-25T11:47:18+02:00
    Improve/add source comments and documentation.
    

2 changed files:

Changes:

  • include/freetype/freetype.h
    ... ... @@ -1002,7 +1002,7 @@ FT_BEGIN_HEADER
    1002 1002
        *     Note that the bounding box might be off by (at least) one pixel for
    
    1003 1003
        *     hinted fonts.  See @FT_Size_Metrics for further discussion.
    
    1004 1004
        *
    
    1005
    -   *     Note that the bounding box does not vary in OpenType variable fonts
    
    1005
    +   *     Note that the bounding box does not vary in OpenType variation fonts
    
    1006 1006
        *     and should only be used in relation to the default instance.
    
    1007 1007
        *
    
    1008 1008
        *   units_per_EM ::
    
    ... ... @@ -1090,9 +1090,9 @@ FT_BEGIN_HEADER
    1090 1090
     
    
    1091 1091
         FT_Generic        generic;
    
    1092 1092
     
    
    1093
    -    /*# The following member variables (down to `underline_thickness`) */
    
    1094
    -    /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size    */
    
    1095
    -    /*# for bitmap fonts.                                              */
    
    1093
    +    /* The following member variables (down to `underline_thickness`) */
    
    1094
    +    /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size    */
    
    1095
    +    /* for bitmap fonts.                                              */
    
    1096 1096
         FT_BBox           bbox;
    
    1097 1097
     
    
    1098 1098
         FT_UShort         units_per_EM;
    
    ... ... @@ -1110,7 +1110,7 @@ FT_BEGIN_HEADER
    1110 1110
         FT_Size           size;
    
    1111 1111
         FT_CharMap        charmap;
    
    1112 1112
     
    
    1113
    -    /*@private begin */
    
    1113
    +    /* private fields, internal to FreeType */
    
    1114 1114
     
    
    1115 1115
         FT_Driver         driver;
    
    1116 1116
         FT_Memory         memory;
    
    ... ... @@ -1123,8 +1123,6 @@ FT_BEGIN_HEADER
    1123 1123
     
    
    1124 1124
         FT_Face_Internal  internal;
    
    1125 1125
     
    
    1126
    -    /*@private end */
    
    1127
    -
    
    1128 1126
       } FT_FaceRec;
    
    1129 1127
     
    
    1130 1128
     
    

  • src/sfnt/sfdriver.c
    ... ... @@ -523,15 +523,14 @@
    523 523
               FT_TRACE0(( "get_win_string:"
    
    524 524
                           " Character 0x%X invalid in PS name string\n",
    
    525 525
                           ((unsigned)p[0])*256 + (unsigned)p[1] ));
    
    526
    -        break;
    
    526
    +        continue;
    
    527 527
           }
    
    528 528
         }
    
    529
    -    if ( !len )
    
    530
    -      *r = '\0';
    
    529
    +    *r = '\0';
    
    531 530
     
    
    532 531
         FT_FRAME_EXIT();
    
    533 532
     
    
    534
    -    if ( !len )
    
    533
    +    if ( r != result )
    
    535 534
           return result;
    
    536 535
     
    
    537 536
       get_win_string_error:
    
    ... ... @@ -580,15 +579,14 @@
    580 579
               FT_TRACE0(( "get_apple_string:"
    
    581 580
                           " Character `%c' (0x%X) invalid in PS name string\n",
    
    582 581
                           *p, *p ));
    
    583
    -        break;
    
    582
    +        continue;
    
    584 583
           }
    
    585 584
         }
    
    586
    -    if ( !len )
    
    587
    -      *r = '\0';
    
    585
    +    *r = '\0';
    
    588 586
     
    
    589 587
         FT_FRAME_EXIT();
    
    590 588
     
    
    591
    -    if ( !len )
    
    589
    +    if ( r != result )
    
    592 590
           return result;
    
    593 591
     
    
    594 592
       get_apple_string_error:
    
    ... ... @@ -819,9 +817,9 @@
    819 817
     
    
    820 818
           if ( !found )
    
    821 819
           {
    
    822
    -        /* as a last resort we try the family name; note that this is */
    
    823
    -        /* not in the Adobe TechNote, but GX fonts (which predate the */
    
    824
    -        /* TechNote) benefit from this behaviour                      */
    
    820
    +        /* according to the 'name' documentation in the OpenType   */
    
    821
    +        /* specification the font family name is to be used if the */
    
    822
    +        /* typographic family name is missing, so let's do that    */
    
    825 823
             found = sfnt_get_name_id( face,
    
    826 824
                                       TT_NAME_ID_FONT_FAMILY,
    
    827 825
                                       &win,
    
    ... ... @@ -853,6 +851,10 @@
    853 851
           {
    
    854 852
             FT_TRACE0(( "sfnt_get_var_ps_name:"
    
    855 853
                         " No valid PS name prefix for font instances found\n" ));
    
    854
    +        /* XXX It probably makes sense to never let this fail */
    
    855
    +        /*     since an arbitrary prefix should work, too.    */
    
    856
    +        /*     On the other hand, it is very unlikely that    */
    
    857
    +        /*     we ever reach this code at all.                */
    
    856 858
             return NULL;
    
    857 859
           }
    
    858 860
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]