freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][dev/wl/VF-info] 2 commits: [ftdump] Show


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype-demos][dev/wl/VF-info] 2 commits: [ftdump] Show more variation font info.
Date: Fri, 28 Apr 2023 20:27:29 +0000

Werner Lemberg pushed to branch dev/wl/VF-info at FreeType / FreeType Demo Programs

Commits:

  • 1082ccc3
    by Werner Lemberg at 2023-04-28T22:20:28+02:00
    [ftdump] Show more variation font info.
    
    * src/ftdump.c (Print_MM_Axes): Rename to...
    (Print_MM_Info): ...this.
    Show Variation Font PostScript name prefix.
    Show named instances.
    
  • 4c9b8b35
    by Werner Lemberg at 2023-04-28T22:22:34+02:00
    * src/ftdump.c (Print_Sfnt_Tables): Insert spaces between bytes.
    

1 changed file:

Changes:

  • src/ftdump.c
    ... ... @@ -560,7 +560,7 @@
    560 560
           else
    
    561 561
             continue;
    
    562 562
     
    
    563
    -      printf( "  %2lu: %c%c%c%c %02X%02X%02X%02X...\n", i,
    
    563
    +      printf( "  %2lu: %c%c%c%c   %02X %02X %02X %02X ...\n", i,
    
    564 564
                                        (FT_Char)( tag >> 24 ),
    
    565 565
                                        (FT_Char)( tag >> 16 ),
    
    566 566
                                        (FT_Char)( tag >>  8 ),
    
    ... ... @@ -746,10 +746,11 @@
    746 746
     
    
    747 747
     
    
    748 748
       static void
    
    749
    -  Print_MM_Axes( FT_Face  face )
    
    749
    +  Print_MM_Info( FT_Face  face )
    
    750 750
       {
    
    751 751
         FT_MM_Var*       mm;
    
    752 752
         FT_Multi_Master  dummy;
    
    753
    +    FT_SfntName      name;
    
    753 754
         FT_UInt          is_GX, i;
    
    754 755
     
    
    755 756
     
    
    ... ... @@ -764,34 +765,134 @@
    764 765
           return;
    
    765 766
         }
    
    766 767
     
    
    767
    -    printf( "%s axes\n", is_GX ? "GX" : "MM" );
    
    768
    +    printf( "%s info\n", is_GX ? "GX" : "MM" );
    
    769
    +
    
    770
    +    printf( "  axes (%u)\n", mm->num_axis );
    
    768 771
     
    
    769 772
         for ( i = 0; i < mm->num_axis; i++ )
    
    770 773
         {
    
    771
    -      FT_SfntName  name;
    
    772
    -
    
    773
    -
    
    774 774
           name.string = NULL;
    
    775 775
     
    
    776 776
           if ( is_GX )
    
    777 777
             get_english_name_entry( face, mm->axis[i].strid, &name );
    
    778 778
     
    
    779
    +      printf( "    %u: ", i );
    
    779 780
           if ( name.string )
    
    780 781
           {
    
    781 782
             if ( name.platform_id == TT_PLATFORM_MACINTOSH )
    
    782
    -          put_ascii( name.string, name.string_len, 3 );
    
    783
    +          put_ascii( name.string, name.string_len, 0 );
    
    783 784
             else
    
    784
    -          put_unicode_be16( name.string, name.string_len, 3, utf8 );
    
    785
    +          put_unicode_be16( name.string, name.string_len, 0, utf8 );
    
    785 786
           }
    
    786 787
           else
    
    787
    -        printf( "   %s", mm->axis[i].name );
    
    788
    +        printf( "%s", mm->axis[i].name );
    
    788 789
     
    
    789
    -      printf( ": [%g;%g], default %g\n",
    
    790
    +      printf( ", [%g;%g], default %g\n",
    
    790 791
                   mm->axis[i].minimum / 65536.0,
    
    791 792
                   mm->axis[i].maximum / 65536.0,
    
    792 793
                   mm->axis[i].def / 65536.0 );
    
    793 794
         }
    
    794 795
     
    
    796
    +    if ( is_GX )
    
    797
    +    {
    
    798
    +      FT_Fixed*    coords;
    
    799
    +      const char*  ps_name;
    
    800
    +
    
    801
    +      FT_Long              instance_count;
    
    802
    +      FT_UInt              default_named_instance;
    
    803
    +      FT_Var_Named_Style*  named_styles;
    
    804
    +
    
    805
    +
    
    806
    +      /* Show Variation PostScript Name Prefix. */
    
    807
    +
    
    808
    +      coords = (FT_Fixed*)malloc( mm->num_axis * sizeof ( FT_Fixed ) );
    
    809
    +      if ( coords == NULL )
    
    810
    +        return;
    
    811
    +
    
    812
    +      /* We temporarily activate variation font handling.  Because we */
    
    813
    +      /* use the default axes, the now retrieved PS name is identical */
    
    814
    +      /* to the PS name prefix.                                       */
    
    815
    +      FT_Get_Var_Design_Coordinates( face, mm->num_axis, coords );
    
    816
    +      FT_Set_Var_Design_Coordinates( face, mm->num_axis, coords );
    
    817
    +
    
    818
    +      ps_name = FT_Get_Postscript_Name( face );
    
    819
    +      if ( ps_name == NULL )
    
    820
    +        ps_name = "UNAVAILABLE";
    
    821
    +
    
    822
    +      printf( "\n"
    
    823
    +              "  VF PS name prefix: %s\n", ps_name );
    
    824
    +
    
    825
    +      /* Switch off variation font handling. */
    
    826
    +      FT_Set_Var_Design_Coordinates( face, 0, NULL );
    
    827
    +
    
    828
    +      free( coords );
    
    829
    +
    
    830
    +
    
    831
    +      /* Show named instances. */
    
    832
    +
    
    833
    +      instance_count = face->style_flags >> 16;
    
    834
    +      named_styles   = mm->namedstyle;
    
    835
    +
    
    836
    +      FT_Get_Default_Named_Instance( face, &default_named_instance );
    
    837
    +      default_named_instance--;   /* `named_styles` is a zero-based array */
    
    838
    +
    
    839
    +      printf( "\n" );
    
    840
    +      printf( "  named instances (%lu)\n", instance_count );
    
    841
    +
    
    842
    +      for ( i = 0; i < instance_count; i++ )
    
    843
    +      {
    
    844
    +        int        pos;
    
    845
    +        FT_UInt    j;
    
    846
    +        FT_Bool    semicolon;
    
    847
    +        FT_Fixed*  c;
    
    848
    +
    
    849
    +
    
    850
    +        /* Since FreeType starts the instance numbering with value 1 */
    
    851
    +        /* in `face_index` we report the same here for consistency.  */
    
    852
    +        pos = printf( "    %u: ", i + 1);
    
    853
    +
    
    854
    +        name.string = NULL;
    
    855
    +        get_english_name_entry( face, named_styles[i].strid, &name );
    
    856
    +        if ( name.string )
    
    857
    +        {
    
    858
    +          if ( name.platform_id == TT_PLATFORM_MACINTOSH )
    
    859
    +            put_ascii( name.string, name.string_len, 0 );
    
    860
    +          else
    
    861
    +            put_unicode_be16( name.string, name.string_len, 0, utf8 );
    
    862
    +        }
    
    863
    +        else
    
    864
    +          printf( "UNAVAILABLE" );
    
    865
    +        printf( "%s\n", i == default_named_instance ? " (default)" : "" );
    
    866
    +
    
    867
    +        name.string = NULL;
    
    868
    +        get_english_name_entry( face, named_styles[i].psid, &name );
    
    869
    +        printf( "%*s   PS: ", pos, "" );
    
    870
    +        if ( name.string )
    
    871
    +        {
    
    872
    +          if ( name.platform_id == TT_PLATFORM_MACINTOSH )
    
    873
    +            put_ascii( name.string, name.string_len, 0 );
    
    874
    +          else
    
    875
    +            put_unicode_be16( name.string, name.string_len, 0, utf8 );
    
    876
    +        }
    
    877
    +        else
    
    878
    +          printf( "UNAVAILABLE" );
    
    879
    +        printf( "\n" );
    
    880
    +
    
    881
    +        semicolon = 0;
    
    882
    +        c         = named_styles[i].coords;
    
    883
    +
    
    884
    +        printf( "%*scoord: (", pos, "" );
    
    885
    +        for ( j = 0; j < mm->num_axis; j++ )
    
    886
    +        {
    
    887
    +          printf( "%s%g", semicolon ? ";" : "", c[j] / 65536.0);
    
    888
    +          semicolon = 1;
    
    889
    +        }
    
    890
    +        printf( ")\n" );
    
    891
    +      }
    
    892
    +
    
    893
    +      printf( "\n" );
    
    894
    +    }
    
    895
    +
    
    795 896
         FT_Done_MM_Var( face->glyph->library, mm );
    
    796 897
       }
    
    797 898
     
    
    ... ... @@ -1360,7 +1461,7 @@
    1360 1461
           if ( FT_HAS_MULTIPLE_MASTERS( face ) )
    
    1361 1462
           {
    
    1362 1463
             printf( "\n" );
    
    1363
    -        Print_MM_Axes( face );
    
    1464
    +        Print_MM_Info( face );
    
    1364 1465
           }
    
    1365 1466
     
    
    1366 1467
           FT_Done_Face( face );
    


  • reply via email to

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