freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][ftmulti-misc] 3 commits: * src/ftmulti.c


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][ftmulti-misc] 3 commits: * src/ftmulti.c (main): Synchronize options with the others.
Date: Sat, 11 Feb 2023 16:05:29 +0000

Alexei Podtelezhnikov pushed to branch ftmulti-misc at FreeType / FreeType Demo Programs

Commits:

  • 5f4959bd
    by Alexei Podtelezhnikov at 2023-02-11T09:33:05-05:00
    * src/ftmulti.c (main): Synchronize options with the others.
    
  • 195908f4
    by Alexei Podtelezhnikov at 2023-02-11T09:48:09-05:00
    * src/ftmulti.c (Init_Display): Use automatic color depth.
    
  • e65fa83d
    by Alexei Podtelezhnikov at 2023-02-11T11:04:21-05:00
    * src/ftmulti.c (Process_Event): Miscellaneous tweaks.
    
    Set default step at 1/40 which covers most preferable coordinates.
    Adjust the step by doubling of halving it. Round all large-range
    coordinates, not just MM. Wrap the coordinates around.
    

1 changed file:

Changes:

  • src/ftmulti.c
    ... ... @@ -99,7 +99,7 @@
    99 99
     
    
    100 100
       static int  res       = 72;
    
    101 101
     
    
    102
    -  static grColor  fore_color = { 255 };
    
    102
    +  static grColor  fore_color;
    
    103 103
     
    
    104 104
       static int  Fail;
    
    105 105
     
    
    ... ... @@ -112,7 +112,7 @@
    112 112
       static FT_Fixed      requested_pos[MAX_MM_AXES];
    
    113 113
       static unsigned int  requested_cnt =  0;
    
    114 114
       static unsigned int  used_num_axis =  0;
    
    115
    -  static int           increment     = 20;  /* for axes */
    
    115
    +  static double        increment     = 0.025;  /* for axes */
    
    116 116
     
    
    117 117
       /*
    
    118 118
        * We use the following arrays to support both the display of all axes and
    
    ... ... @@ -293,7 +293,7 @@
    293 293
       static void
    
    294 294
       Init_Display( void )
    
    295 295
       {
    
    296
    -    grBitmap  bitmap = { height, width, 0, gr_pixel_mode_gray, 256, NULL };
    
    296
    +    grBitmap  bitmap = { height, width, 0, gr_pixel_mode_none, 256, NULL };
    
    297 297
     
    
    298 298
     
    
    299 299
         grInitDevices();
    
    ... ... @@ -304,6 +304,8 @@
    304 304
     
    
    305 305
         bit = (grBitmap*)surface;
    
    306 306
     
    
    307
    +    fore_color = grFindColor( bit, 255, 255, 255, 255 );  /* white */
    
    308
    +
    
    307 309
         graph_init = 1;
    
    308 310
       }
    
    309 311
     
    
    ... ... @@ -606,7 +608,7 @@
    606 608
       Process_Event( void )
    
    607 609
       {
    
    608 610
         grEvent       event;
    
    609
    -    int           i;
    
    611
    +    double        i;
    
    610 612
         unsigned int  axis;
    
    611 613
     
    
    612 614
     
    
    ... ... @@ -685,14 +687,13 @@
    685 687
         /* MM-related keys */
    
    686 688
     
    
    687 689
         case grKEY( '+' ):
    
    688
    -      /* value 100 is arbitrary */
    
    689
    -      if ( increment < 100 )
    
    690
    -        increment += 1;
    
    690
    +      if ( increment < 0.1 )
    
    691
    +        increment *= 2.0;
    
    691 692
           break;
    
    692 693
     
    
    693 694
         case grKEY( '-' ):
    
    694
    -      if ( increment > 1 )
    
    695
    -        increment -= 1;
    
    695
    +      if ( increment > 0.01 )
    
    696
    +        increment *= 0.5;
    
    696 697
           break;
    
    697 698
     
    
    698 699
         case grKEY( 'a' ):
    
    ... ... @@ -796,7 +797,7 @@
    796 797
         if ( axis < num_shown_axes )
    
    797 798
         {
    
    798 799
           FT_Var_Axis*  a;
    
    799
    -      FT_Fixed      pos;
    
    800
    +      FT_Fixed      pos, rng;
    
    800 801
           unsigned int  n;
    
    801 802
     
    
    802 803
     
    
    ... ... @@ -804,6 +805,7 @@
    804 805
           axis = (unsigned int)shown_axes[axis];
    
    805 806
     
    
    806 807
           a   = multimaster->axis + axis;
    
    808
    +      rng = a->maximum - a->minimum;
    
    807 809
           pos = design_pos[axis];
    
    808 810
     
    
    809 811
           /*
    
    ... ... @@ -812,15 +814,15 @@
    812 814
            * for mac fonts, which have a range of ~3.  And it's rather extreme
    
    813 815
            * for optical size even in PS.
    
    814 816
            */
    
    815
    -      pos += FT_MulDiv( i, a->maximum - a->minimum, 1000 );
    
    817
    +      pos += (FT_Fixed)( i * rng );
    
    816 818
           if ( pos < a->minimum )
    
    817
    -        pos = a->minimum;
    
    818
    -      if ( pos > a->maximum )
    
    819 819
             pos = a->maximum;
    
    820
    +      if ( pos > a->maximum )
    
    821
    +        pos = a->minimum;
    
    820 822
     
    
    821
    -      /* for MM fonts, round the design coordinates to integers,         */
    
    823
    +      /* for MM fonts or large ranges, round the design coordinates      */
    
    822 824
           /* otherwise round to two decimal digits to make the PS name short */
    
    823
    -      if ( !FT_IS_SFNT( face ) )
    
    825
    +      if ( !FT_IS_SFNT( face ) || rng > 0x200000 )
    
    824 826
             pos = FT_RoundFix( pos );
    
    825 827
           else
    
    826 828
           {
    
    ... ... @@ -889,9 +891,7 @@
    889 891
           "  font         The font file(s) to display.\n"
    
    890 892
           "\n" );
    
    891 893
         fprintf( stderr,
    
    892
    -      "  -w W         Set window width to W pixels (default: %dpx).\n"
    
    893
    -      "  -h H         Set window height to H pixels (default: %dpx).\n"
    
    894
    -      "\n",
    
    894
    +      "  -d WxH       Set window dimentions (default: %ux%u).\n",
    
    895 895
                  DIM_X, DIM_Y );
    
    896 896
         fprintf( stderr,
    
    897 897
           "  -e encoding  Specify encoding tag (default: no encoding).\n"
    
    ... ... @@ -899,7 +899,7 @@
    899 899
           "               `ADOB' (Adobe standard), `ADBC' (Adobe custom).\n"
    
    900 900
           "  -r R         Use resolution R dpi (default: 72dpi).\n"
    
    901 901
           "  -f index     Specify first glyph index to display.\n"
    
    902
    -      "  -d \"axis1 axis2 ...\"\n"
    
    902
    +      "  -a \"axis1 axis2 ...\"\n"
    
    903 903
           "               Specify the design coordinates for each\n"
    
    904 904
           "               variation axis at start-up.\n"
    
    905 905
           "\n"
    
    ... ... @@ -973,10 +973,15 @@
    973 973
     
    
    974 974
           switch ( option )
    
    975 975
           {
    
    976
    -      case 'd':
    
    976
    +      case 'a':
    
    977 977
             parse_design_coords( optarg );
    
    978 978
             break;
    
    979 979
     
    
    980
    +      case 'd':
    
    981
    +        if ( sscanf( optarg, "%ux%u", &width, &height ) != 2 )
    
    982
    +          usage( execname );
    
    983
    +        break;
    
    984
    +
    
    980 985
           case 'e':
    
    981 986
             encoding = make_tag( optarg );
    
    982 987
             break;
    
    ... ... @@ -985,12 +990,6 @@
    985 990
             sscanf( optarg, "%i", &first_glyph );
    
    986 991
             break;
    
    987 992
     
    
    988
    -      case 'h':
    
    989
    -        height = atoi( optarg );
    
    990
    -        if ( height < 1 )
    
    991
    -          usage( execname );
    
    992
    -        break;
    
    993
    -
    
    994 993
           case 'r':
    
    995 994
             res = atoi( optarg );
    
    996 995
             if ( res < 1 )
    
    ... ... @@ -1012,12 +1011,6 @@
    1012 1011
             }
    
    1013 1012
             /* break; */
    
    1014 1013
     
    
    1015
    -      case 'w':
    
    1016
    -        width = atoi( optarg );
    
    1017
    -        if ( width < 1 )
    
    1018
    -          usage( execname );
    
    1019
    -        break;
    
    1020
    -
    
    1021 1014
           default:
    
    1022 1015
             usage( execname );
    
    1023 1016
             break;
    
    ... ... @@ -1193,11 +1186,14 @@
    1193 1186
     
    
    1194 1187
     
    
    1195 1188
               strbuf_reset( header );
    
    1196
    -          strbuf_format( header, "%c %.50s%s: %.02f",
    
    1189
    +          strbuf_format( header, "%c %.50s%s:",
    
    1197 1190
                              n + 'A',
    
    1198 1191
                              multimaster->axis[axis].name,
    
    1199
    -                         hidden[axis] ? "*" : "",
    
    1200
    -                         design_pos[axis] / 65536.0 );
    
    1192
    +                         hidden[axis] ? "*" : "" );
    
    1193
    +          if ( design_pos[axis] & 0xFFFF )
    
    1194
    +            strbuf_format( header, "% .2f", design_pos[axis] / 65536.0 );
    
    1195
    +          else
    
    1196
    +            strbuf_format( header,   "% d", design_pos[axis] / 65536 );
    
    1201 1197
               grWriteCellString( bit, 0, (int)( n + 4 ) * HEADER_HEIGHT,
    
    1202 1198
                                  Header, fore_color );
    
    1203 1199
             }
    
    ... ... @@ -1235,7 +1231,7 @@
    1235 1231
                 ptsize,
    
    1236 1232
                 Num,
    
    1237 1233
                 format_str,
    
    1238
    -            increment / 10.0 );
    
    1234
    +            100. * increment );
    
    1239 1235
             }
    
    1240 1236
           }
    
    1241 1237
           else
    


  • reply via email to

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