freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] * src/ftmulti.c (Process_Event):


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] * src/ftmulti.c (Process_Event): Miscellaneous tweaks.
Date: Sun, 12 Feb 2023 12:25:52 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • 24f20f39
    by Alexei Podtelezhnikov at 2023-02-11T22:06:15-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 or halving it. Round all large-range
    coordinates, not just MM. Wrap the coordinates around.
    

1 changed file:

Changes:

  • src/ftmulti.c
    ... ... @@ -110,7 +110,7 @@
    110 110
       static FT_Fixed      requested_pos[MAX_MM_AXES];
    
    111 111
       static unsigned int  requested_cnt =  0;
    
    112 112
       static unsigned int  used_num_axis =  0;
    
    113
    -  static int           increment     = 20;  /* for axes */
    
    113
    +  static double        increment     = 0.025;  /* for axes */
    
    114 114
     
    
    115 115
       /*
    
    116 116
        * We use the following arrays to support both the display of all axes and
    
    ... ... @@ -390,7 +390,7 @@
    390 390
         unsigned int  i;
    
    391 391
     
    
    392 392
     
    
    393
    -    start_x = 20 * 8;
    
    393
    +    start_x = 18 * 8;
    
    394 394
         start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
    
    395 395
         step_y  = size->metrics.y_ppem + 10;
    
    396 396
     
    
    ... ... @@ -453,7 +453,7 @@
    453 453
         const unsigned char*  p;
    
    454 454
     
    
    455 455
     
    
    456
    -    start_x = 20 * 8;
    
    456
    +    start_x = 18 * 8;
    
    457 457
         start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
    
    458 458
         step_y  = size->metrics.y_ppem + 10;
    
    459 459
     
    
    ... ... @@ -603,7 +603,7 @@
    603 603
       Process_Event( void )
    
    604 604
       {
    
    605 605
         grEvent       event;
    
    606
    -    int           i;
    
    606
    +    double        i;
    
    607 607
         unsigned int  axis;
    
    608 608
     
    
    609 609
     
    
    ... ... @@ -682,14 +682,13 @@
    682 682
         /* MM-related keys */
    
    683 683
     
    
    684 684
         case grKEY( '+' ):
    
    685
    -      /* value 100 is arbitrary */
    
    686
    -      if ( increment < 100 )
    
    687
    -        increment += 1;
    
    685
    +      if ( increment < 0.1 )
    
    686
    +        increment *= 2.0;
    
    688 687
           break;
    
    689 688
     
    
    690 689
         case grKEY( '-' ):
    
    691
    -      if ( increment > 1 )
    
    692
    -        increment -= 1;
    
    690
    +      if ( increment > 0.01 )
    
    691
    +        increment *= 0.5;
    
    693 692
           break;
    
    694 693
     
    
    695 694
         case grKEY( 'a' ):
    
    ... ... @@ -793,7 +792,7 @@
    793 792
         if ( axis < num_shown_axes )
    
    794 793
         {
    
    795 794
           FT_Var_Axis*  a;
    
    796
    -      FT_Fixed      pos;
    
    795
    +      FT_Fixed      pos, rng;
    
    797 796
           unsigned int  n;
    
    798 797
     
    
    799 798
     
    
    ... ... @@ -801,6 +800,7 @@
    801 800
           axis = (unsigned int)shown_axes[axis];
    
    802 801
     
    
    803 802
           a   = multimaster->axis + axis;
    
    803
    +      rng = a->maximum - a->minimum;
    
    804 804
           pos = design_pos[axis];
    
    805 805
     
    
    806 806
           /*
    
    ... ... @@ -809,16 +809,17 @@
    809 809
            * for mac fonts, which have a range of ~3.  And it's rather extreme
    
    810 810
            * for optical size even in PS.
    
    811 811
            */
    
    812
    -      pos += FT_MulDiv( i, a->maximum - a->minimum, 1000 );
    
    812
    +      pos += (FT_Fixed)( i * rng );
    
    813 813
           if ( pos < a->minimum )
    
    814
    -        pos = a->minimum;
    
    815
    -      if ( pos > a->maximum )
    
    816 814
             pos = a->maximum;
    
    815
    +      if ( pos > a->maximum )
    
    816
    +        pos = a->minimum;
    
    817 817
     
    
    818
    -      /* for MM fonts, round the design coordinates to integers,         */
    
    818
    +      /* for MM fonts or large ranges, round the design coordinates      */
    
    819 819
           /* otherwise round to two decimal digits to make the PS name short */
    
    820
    -      if ( !FT_IS_SFNT( face ) )
    
    821
    -        pos = FT_RoundFix( pos );
    
    820
    +      if ( !FT_IS_SFNT( face ) || rng > 0x200000 )
    
    821
    +        pos = i > 0 ? FT_CeilFix( pos )
    
    822
    +                    : FT_FloorFix( pos );
    
    822 823
           else
    
    823 824
           {
    
    824 825
             double  x;
    
    ... ... @@ -1173,7 +1174,7 @@
    1173 1174
             grWriteCellString( bit, 0, 2 * HEADER_HEIGHT, Header, fore_color );
    
    1174 1175
     
    
    1175 1176
             strbuf_reset( header );
    
    1176
    -        strbuf_format( header, "axes (\361 %.1f%%):", increment / 10.0 );
    
    1177
    +        strbuf_format( header, "axes (\361 %.1f%%):", 100.0 * increment );
    
    1177 1178
             grWriteCellString( bit, 0, 4 * HEADER_HEIGHT, Header, fore_color );
    
    1178 1179
             for ( n = 0; n < num_shown_axes; n++ )
    
    1179 1180
             {
    
    ... ... @@ -1181,11 +1182,14 @@
    1181 1182
     
    
    1182 1183
     
    
    1183 1184
               strbuf_reset( header );
    
    1184
    -          strbuf_format( header, "%c %.50s%s: %.02f",
    
    1185
    +          strbuf_format( header, "%c %.50s%s:",
    
    1185 1186
                              n + 'A',
    
    1186 1187
                              multimaster->axis[axis].name,
    
    1187
    -                         hidden[axis] ? "*" : "",
    
    1188
    -                         design_pos[axis] / 65536.0 );
    
    1188
    +                         hidden[axis] ? "*" : "" );
    
    1189
    +          if ( design_pos[axis] & 0xFFFF )
    
    1190
    +            strbuf_format( header, "% .2f", design_pos[axis] / 65536.0 );
    
    1191
    +          else
    
    1192
    +            strbuf_format( header,   "% d", design_pos[axis] / 65536 );
    
    1189 1193
               grWriteCellString( bit, 0, (int)( n + 5 ) * HEADER_HEIGHT,
    
    1190 1194
                                  Header, fore_color );
    
    1191 1195
             }
    


  • reply via email to

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