freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] 2 commits: [psaux] Improve tracing.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] 2 commits: [psaux] Improve tracing.
Date: Thu, 14 Dec 2023 06:18:35 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 6f2bf6a5
    by Skef Iterum at 2023-12-14T06:55:33+01:00
    [psaux] Improve tracing.
    
    * src/psaux/psintrp.c (cf2_doBlend, cf2_interpT2CharString [cf2_cmdBLEND]):
    Show blended values.
    
  • 8eab5110
    by Skef Iterum at 2023-12-14T07:17:01+01:00
    [CFF] Extract `BlueValues` as `Fixed` rather than `Int`.
    
    This is a follow-up to commit 26a7f047,
    
      [cff] Make blend operator work with floats in private dicts.
    
    which addressed the 'party baseline' bug.  However, the reporting user
    indicated that the default location and some other points in design space
    rendered OK, but other points in design space still had problems.  The most
    obvious issue being that the x-heights of lower-case letters did not align;
    see
    
      https://github.com/adobe-fonts/source-serif/issues/121#issuecomment-1773794136
    
    After some analysis we determined that this was due to an interaction
    between `BlueValue` rounding and the zone-based algorithm.  In short, for a
    point to be considered in a zone it must fall within the bounds of the zone.
    (There is a slop factor in some cases, but only a very small one.)  In the
    Adobe-contributed side of the code, point values are not integer-rounded,
    instead they're kept as (some form of) fixed.  Rounding just the `BlueValues`
    means that points that need to be considered within a zone will fall outside
    of it at some points in design space.
    
    The majority of this patch changes the storage and parsing of `BlueValues`
    to keep them as `FT_Fixed`.  No significant code changes were needed because
    the values are converted to `Fixed` anyway when stored in `CF_BlueRec`.  No
    attempt was made to address problems in the older pshinter code beyond
    converting the values from `FT_Fixed` to `FT_Short` when copying the private
    dictionary.  (However, as the point values are also rounded in that code,
    the problem is much less likely to occur, although inconsistency between
    rounding and truncation could cause an analogous problem.)
    
    * include/freetype/internal/cfftypes.h (CFF_PrivateRec): Use `FT_Fixed` for
    `blue_values`, `other_blues`, `family_blues`, and `family_other_blues`.
    
    * src/cff/cffload.c (cff_blend_doBlend): Updated.
    
    * src/cff/cffobjs.c (CFF_fixedToInt): New macro.
    (cff_make_private_dict): Use it.
    
    * src/cff/cffparse.h (cff_kind_delta_fixed): New enum value.
    
    * src/cff/cffparse.c (do_fixed): Updated.
    (CFF_FIELD_DELTA, CFF_FIELD_DELTA_FIXED, CFF_DELTA_KIND): New set of macros,
    replacing `CFF_FIELD_DELTA`.
    (cff_parser_run): Updated to handle fixed-float deltas.
    
    * src/cff/cfftoken.h: Updated to use `CFF_FIELD_DELTA_FIXED` for blue
    values.
    
    * src/psaux/psblues.c (cf2_blueToFixed): Removed, no longer needed.
    (cf2_blues_init): Updated.
    
    * src/pxaux/psft.c, src/pxaux/psft.h (cf2_getBlueValues, cf2_getOtherBlues,
    cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated signatures.
    
    * src/psaux/psobjs.c (t1_make_subfont): Updated.
    

11 changed files:

Changes:

  • include/freetype/internal/cfftypes.h
    ... ... @@ -248,10 +248,10 @@ FT_BEGIN_HEADER
    248 248
         FT_Byte   num_family_blues;
    
    249 249
         FT_Byte   num_family_other_blues;
    
    250 250
     
    
    251
    -    FT_Pos    blue_values[14];
    
    252
    -    FT_Pos    other_blues[10];
    
    253
    -    FT_Pos    family_blues[14];
    
    254
    -    FT_Pos    family_other_blues[10];
    
    251
    +    FT_Fixed  blue_values[14];
    
    252
    +    FT_Fixed  other_blues[10];
    
    253
    +    FT_Fixed  family_blues[14];
    
    254
    +    FT_Fixed  family_other_blues[10];
    
    255 255
     
    
    256 256
         FT_Fixed  blue_scale;
    
    257 257
         FT_Pos    blue_shift;
    

  • src/cff/cffload.c
    ... ... @@ -1379,10 +1379,10 @@
    1379 1379
           /* opcode in both CFF and CFF2 DICTs.  See `cff_parse_num' for    */
    
    1380 1380
           /* decode of this, which rounds to an integer.                    */
    
    1381 1381
           *subFont->blend_top++ = 255;
    
    1382
    -      *subFont->blend_top++ = (FT_Byte)( sum >> 24 );
    
    1383
    -      *subFont->blend_top++ = (FT_Byte)( sum >> 16 );
    
    1384
    -      *subFont->blend_top++ = (FT_Byte)( sum >>  8 );
    
    1385
    -      *subFont->blend_top++ = (FT_Byte)sum;
    
    1382
    +      *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 24 );
    
    1383
    +      *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 16 );
    
    1384
    +      *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >>  8 );
    
    1385
    +      *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum );
    
    1386 1386
         }
    
    1387 1387
     
    
    1388 1388
         /* leave only numBlends results on parser stack */
    

  • src/cff/cffobjs.c
    ... ... @@ -42,6 +42,8 @@
    42 42
     #include <freetype/internal/psaux.h>
    
    43 43
     #include <freetype/internal/services/svcfftl.h>
    
    44 44
     
    
    45
    +#define CFF_fixedToInt( x )                          \
    
    46
    +          ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
    
    45 47
     
    
    46 48
       /**************************************************************************
    
    47 49
        *
    
    ... ... @@ -124,19 +126,20 @@
    124 126
     
    
    125 127
         count = priv->num_blue_values = cpriv->num_blue_values;
    
    126 128
         for ( n = 0; n < count; n++ )
    
    127
    -      priv->blue_values[n] = (FT_Short)cpriv->blue_values[n];
    
    129
    +      priv->blue_values[n] = CFF_fixedToInt( cpriv->blue_values[n] );
    
    128 130
     
    
    129 131
         count = priv->num_other_blues = cpriv->num_other_blues;
    
    130 132
         for ( n = 0; n < count; n++ )
    
    131
    -      priv->other_blues[n] = (FT_Short)cpriv->other_blues[n];
    
    133
    +      priv->other_blues[n] = CFF_fixedToInt( cpriv->other_blues[n] );
    
    132 134
     
    
    133 135
         count = priv->num_family_blues = cpriv->num_family_blues;
    
    134 136
         for ( n = 0; n < count; n++ )
    
    135
    -      priv->family_blues[n] = (FT_Short)cpriv->family_blues[n];
    
    137
    +      priv->family_blues[n] = CFF_fixedToInt( cpriv->family_blues[n] );
    
    136 138
     
    
    137 139
         count = priv->num_family_other_blues = cpriv->num_family_other_blues;
    
    138 140
         for ( n = 0; n < count; n++ )
    
    139
    -      priv->family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
    
    141
    +      priv->family_other_blues[n] =
    
    142
    +        CFF_fixedToInt( cpriv->family_other_blues[n] );
    
    140 143
     
    
    141 144
         priv->blue_scale = cpriv->blue_scale;
    
    142 145
         priv->blue_shift = (FT_Int)cpriv->blue_shift;
    

  • src/cff/cffparse.c
    ... ... @@ -501,10 +501,10 @@
    501 501
           return cff_parse_real( *d, parser->limit, scaling, NULL );
    
    502 502
         else if ( **d == 255 )
    
    503 503
         {
    
    504
    -      FT_Fixed val = ( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
    
    505
    -                         ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
    
    506
    -                         ( (FT_UInt32)*( d[0] + 3 ) <<  8 ) |
    
    507
    -                           (FT_UInt32)*( d[0] + 4 )         ) );
    
    504
    +      FT_Fixed val = (FT_Int32)( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
    
    505
    +                                   ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
    
    506
    +                                   ( (FT_UInt32)*( d[0] + 3 ) <<  8 ) |
    
    507
    +                                     (FT_UInt32)*( d[0] + 4 )         ) );
    
    508 508
     
    
    509 509
           if ( scaling )
    
    510 510
           {
    
    ... ... @@ -1031,10 +1031,14 @@
    1031 1031
               CFF_FIELD( code, name, id, cff_kind_string )
    
    1032 1032
     #define CFF_FIELD_BOOL( code, name, id )             \
    
    1033 1033
               CFF_FIELD( code, name, id, cff_kind_bool )
    
    1034
    +#define CFF_FIELD_DELTA( code, name, max, id )                        \
    
    1035
    +          CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta )
    
    1036
    +#define CFF_FIELD_DELTA_FIXED( code, name, max, id )                        \
    
    1037
    +          CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta_fixed )
    
    1034 1038
     
    
    1035 1039
     
    
    1036 1040
     #undef  CFF_FIELD
    
    1037
    -#undef  CFF_FIELD_DELTA
    
    1041
    +#undef  CFF_FIELD_DELTA_KIND
    
    1038 1042
     
    
    1039 1043
     
    
    1040 1044
     #ifndef FT_DEBUG_LEVEL_TRACE
    
    ... ... @@ -1067,15 +1071,15 @@
    1067 1071
                 NULL, 0, 0                    \
    
    1068 1072
               },
    
    1069 1073
     
    
    1070
    -#define CFF_FIELD_DELTA( code, name, max, id ) \
    
    1071
    -          {                                    \
    
    1072
    -            cff_kind_delta,                    \
    
    1073
    -            code | CFFCODE,                    \
    
    1074
    -            FT_FIELD_OFFSET( name ),           \
    
    1075
    -            FT_FIELD_SIZE_DELTA( name ),       \
    
    1076
    -            NULL,                              \
    
    1077
    -            max,                               \
    
    1078
    -            FT_FIELD_OFFSET( num_ ## name )    \
    
    1074
    +#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
    
    1075
    +          {                                               \
    
    1076
    +            kind,                                         \
    
    1077
    +            code | CFFCODE,                               \
    
    1078
    +            FT_FIELD_OFFSET( name ),                      \
    
    1079
    +            FT_FIELD_SIZE_DELTA( name ),                  \
    
    1080
    +            NULL,                                         \
    
    1081
    +            max,                                          \
    
    1082
    +            FT_FIELD_OFFSET( num_ ## name )               \
    
    1079 1083
               },
    
    1080 1084
     
    
    1081 1085
       static const CFF_Field_Handler  cff_field_handlers[] =
    
    ... ... @@ -1121,16 +1125,16 @@
    1121 1125
                 id                            \
    
    1122 1126
               },
    
    1123 1127
     
    
    1124
    -#define CFF_FIELD_DELTA( code, name, max, id ) \
    
    1125
    -          {                                    \
    
    1126
    -            cff_kind_delta,                    \
    
    1127
    -            code | CFFCODE,                    \
    
    1128
    -            FT_FIELD_OFFSET( name ),           \
    
    1129
    -            FT_FIELD_SIZE_DELTA( name ),       \
    
    1130
    -            NULL,                              \
    
    1131
    -            max,                               \
    
    1132
    -            FT_FIELD_OFFSET( num_ ## name ),   \
    
    1133
    -            id                                 \
    
    1128
    +#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
    
    1129
    +          {                                               \
    
    1130
    +            kind,                                         \
    
    1131
    +            code | CFFCODE,                               \
    
    1132
    +            FT_FIELD_OFFSET( name ),                      \
    
    1133
    +            FT_FIELD_SIZE_DELTA( name ),                  \
    
    1134
    +            NULL,                                         \
    
    1135
    +            max,                                          \
    
    1136
    +            FT_FIELD_OFFSET( num_ ## name ),              \
    
    1137
    +            id                                            \
    
    1134 1138
               },
    
    1135 1139
     
    
    1136 1140
       static const CFF_Field_Handler  cff_field_handlers[] =
    
    ... ... @@ -1356,7 +1360,8 @@
    1356 1360
     
    
    1357 1361
                 /* check that we have enough arguments -- except for */
    
    1358 1362
                 /* delta encoded arrays, which can be empty          */
    
    1359
    -            if ( field->kind != cff_kind_delta && num_args < 1 )
    
    1363
    +            if ( field->kind != cff_kind_delta                       &&
    
    1364
    +                 field->kind != cff_kind_delta_fixed && num_args < 1 )
    
    1360 1365
                   goto Stack_Underflow;
    
    1361 1366
     
    
    1362 1367
                 switch ( field->kind )
    
    ... ... @@ -1471,6 +1476,38 @@
    1471 1476
                   }
    
    1472 1477
                   break;
    
    1473 1478
     
    
    1479
    +            case cff_kind_delta_fixed:
    
    1480
    +              {
    
    1481
    +                FT_Byte*   qcount = (FT_Byte*)parser->object +
    
    1482
    +                                      field->count_offset;
    
    1483
    +
    
    1484
    +                FT_Byte**  data = parser->stack;
    
    1485
    +
    
    1486
    +
    
    1487
    +                if ( num_args > field->array_max )
    
    1488
    +                  num_args = field->array_max;
    
    1489
    +
    
    1490
    +                FT_TRACE4(( " [" ));
    
    1491
    +
    
    1492
    +                /* store count */
    
    1493
    +                *qcount = (FT_Byte)num_args;
    
    1494
    +
    
    1495
    +                val = 0;
    
    1496
    +                while ( num_args > 0 )
    
    1497
    +                {
    
    1498
    +                  val = ADD_LONG( val, cff_parse_fixed( parser, data++ ) );
    
    1499
    +                  *(FT_Long*)q = val;
    
    1500
    +
    
    1501
    +                  FT_TRACE4(( " %f\n", (double)val / 65536 ));
    
    1502
    +
    
    1503
    +                  q += field->size;
    
    1504
    +                  num_args--;
    
    1505
    +                }
    
    1506
    +
    
    1507
    +                FT_TRACE4(( "]\n" ));
    
    1508
    +              }
    
    1509
    +              break;
    
    1510
    +
    
    1474 1511
                 default:  /* callback or blend */
    
    1475 1512
                   error = field->reader( parser );
    
    1476 1513
                   if ( error )
    

  • src/cff/cffparse.h
    ... ... @@ -107,6 +107,7 @@ FT_BEGIN_HEADER
    107 107
         cff_kind_string,
    
    108 108
         cff_kind_bool,
    
    109 109
         cff_kind_delta,
    
    110
    +    cff_kind_delta_fixed,
    
    110 111
         cff_kind_callback,
    
    111 112
         cff_kind_blend,
    
    112 113
     
    

  • src/cff/cfftoken.h
    ... ... @@ -80,26 +80,26 @@
    80 80
     #undef  CFFCODE
    
    81 81
     #define CFFCODE       CFF_CODE_PRIVATE
    
    82 82
     
    
    83
    -  CFF_FIELD_DELTA     ( 6,     blue_values, 14,        "BlueValues" )
    
    84
    -  CFF_FIELD_DELTA     ( 7,     other_blues, 10,        "OtherBlues" )
    
    85
    -  CFF_FIELD_DELTA     ( 8,     family_blues, 14,       "FamilyBlues" )
    
    86
    -  CFF_FIELD_DELTA     ( 9,     family_other_blues, 10, "FamilyOtherBlues" )
    
    87
    -  CFF_FIELD_FIXED_1000( 0x109, blue_scale,             "BlueScale" )
    
    88
    -  CFF_FIELD_NUM       ( 0x10A, blue_shift,             "BlueShift" )
    
    89
    -  CFF_FIELD_NUM       ( 0x10B, blue_fuzz,              "BlueFuzz" )
    
    90
    -  CFF_FIELD_NUM       ( 10,    standard_width,         "StdHW" )
    
    91
    -  CFF_FIELD_NUM       ( 11,    standard_height,        "StdVW" )
    
    92
    -  CFF_FIELD_DELTA     ( 0x10C, snap_widths, 13,        "StemSnapH" )
    
    93
    -  CFF_FIELD_DELTA     ( 0x10D, snap_heights, 13,       "StemSnapV" )
    
    94
    -  CFF_FIELD_BOOL      ( 0x10E, force_bold,             "ForceBold" )
    
    95
    -  CFF_FIELD_FIXED     ( 0x10F, force_bold_threshold,   "ForceBoldThreshold" )
    
    96
    -  CFF_FIELD_NUM       ( 0x110, lenIV,                  "lenIV" )
    
    97
    -  CFF_FIELD_NUM       ( 0x111, language_group,         "LanguageGroup" )
    
    98
    -  CFF_FIELD_FIXED     ( 0x112, expansion_factor,       "ExpansionFactor" )
    
    99
    -  CFF_FIELD_NUM       ( 0x113, initial_random_seed,    "initialRandomSeed" )
    
    100
    -  CFF_FIELD_NUM       ( 19,    local_subrs_offset,     "Subrs" )
    
    101
    -  CFF_FIELD_NUM       ( 20,    default_width,          "defaultWidthX" )
    
    102
    -  CFF_FIELD_NUM       ( 21,    nominal_width,          "nominalWidthX" )
    
    83
    +  CFF_FIELD_DELTA_FIXED( 6,     blue_values, 14,        "BlueValues" )
    
    84
    +  CFF_FIELD_DELTA_FIXED( 7,     other_blues, 10,        "OtherBlues" )
    
    85
    +  CFF_FIELD_DELTA_FIXED( 8,     family_blues, 14,       "FamilyBlues" )
    
    86
    +  CFF_FIELD_DELTA_FIXED( 9,     family_other_blues, 10, "FamilyOtherBlues" )
    
    87
    +  CFF_FIELD_FIXED_1000 ( 0x109, blue_scale,             "BlueScale" )
    
    88
    +  CFF_FIELD_NUM        ( 0x10A, blue_shift,             "BlueShift" )
    
    89
    +  CFF_FIELD_NUM        ( 0x10B, blue_fuzz,              "BlueFuzz" )
    
    90
    +  CFF_FIELD_NUM        ( 10,    standard_width,         "StdHW" )
    
    91
    +  CFF_FIELD_NUM        ( 11,    standard_height,        "StdVW" )
    
    92
    +  CFF_FIELD_DELTA      ( 0x10C, snap_widths, 13,        "StemSnapH" )
    
    93
    +  CFF_FIELD_DELTA      ( 0x10D, snap_heights, 13,       "StemSnapV" )
    
    94
    +  CFF_FIELD_BOOL       ( 0x10E, force_bold,             "ForceBold" )
    
    95
    +  CFF_FIELD_FIXED      ( 0x10F, force_bold_threshold,   "ForceBoldThreshold" )
    
    96
    +  CFF_FIELD_NUM        ( 0x110, lenIV,                  "lenIV" )
    
    97
    +  CFF_FIELD_NUM        ( 0x111, language_group,         "LanguageGroup" )
    
    98
    +  CFF_FIELD_FIXED      ( 0x112, expansion_factor,       "ExpansionFactor" )
    
    99
    +  CFF_FIELD_NUM        ( 0x113, initial_random_seed,    "initialRandomSeed" )
    
    100
    +  CFF_FIELD_NUM        ( 19,    local_subrs_offset,     "Subrs" )
    
    101
    +  CFF_FIELD_NUM        ( 20,    default_width,          "defaultWidthX" )
    
    102
    +  CFF_FIELD_NUM        ( 21,    nominal_width,          "nominalWidthX" )
    
    103 103
     
    
    104 104
     
    
    105 105
     #undef  FT_STRUCTURE
    
    ... ... @@ -129,22 +129,22 @@
    129 129
     #undef  CFFCODE
    
    130 130
     #define CFFCODE       CFF2_CODE_PRIVATE
    
    131 131
     
    
    132
    -  CFF_FIELD_DELTA     ( 6,     blue_values, 14,        "BlueValues" )
    
    133
    -  CFF_FIELD_DELTA     ( 7,     other_blues, 10,        "OtherBlues" )
    
    134
    -  CFF_FIELD_DELTA     ( 8,     family_blues, 14,       "FamilyBlues" )
    
    135
    -  CFF_FIELD_DELTA     ( 9,     family_other_blues, 10, "FamilyOtherBlues" )
    
    136
    -  CFF_FIELD_FIXED_1000( 0x109, blue_scale,             "BlueScale" )
    
    137
    -  CFF_FIELD_NUM       ( 0x10A, blue_shift,             "BlueShift" )
    
    138
    -  CFF_FIELD_NUM       ( 0x10B, blue_fuzz,              "BlueFuzz" )
    
    139
    -  CFF_FIELD_NUM       ( 10,    standard_width,         "StdHW" )
    
    140
    -  CFF_FIELD_NUM       ( 11,    standard_height,        "StdVW" )
    
    141
    -  CFF_FIELD_DELTA     ( 0x10C, snap_widths, 13,        "StemSnapH" )
    
    142
    -  CFF_FIELD_DELTA     ( 0x10D, snap_heights, 13,       "StemSnapV" )
    
    143
    -  CFF_FIELD_NUM       ( 0x111, language_group,         "LanguageGroup" )
    
    144
    -  CFF_FIELD_FIXED     ( 0x112, expansion_factor,       "ExpansionFactor" )
    
    145
    -  CFF_FIELD_CALLBACK  ( 22,    vsindex,                "vsindex" )
    
    146
    -  CFF_FIELD_BLEND     ( 23,                            "blend" )
    
    147
    -  CFF_FIELD_NUM       ( 19,    local_subrs_offset,     "Subrs" )
    
    132
    +  CFF_FIELD_DELTA_FIXED( 6,     blue_values, 14,        "BlueValues" )
    
    133
    +  CFF_FIELD_DELTA_FIXED( 7,     other_blues, 10,        "OtherBlues" )
    
    134
    +  CFF_FIELD_DELTA_FIXED( 8,     family_blues, 14,       "FamilyBlues" )
    
    135
    +  CFF_FIELD_DELTA_FIXED( 9,     family_other_blues, 10, "FamilyOtherBlues" )
    
    136
    +  CFF_FIELD_FIXED_1000 ( 0x109, blue_scale,             "BlueScale" )
    
    137
    +  CFF_FIELD_NUM        ( 0x10A, blue_shift,             "BlueShift" )
    
    138
    +  CFF_FIELD_NUM        ( 0x10B, blue_fuzz,              "BlueFuzz" )
    
    139
    +  CFF_FIELD_NUM        ( 10,    standard_width,         "StdHW" )
    
    140
    +  CFF_FIELD_NUM        ( 11,    standard_height,        "StdVW" )
    
    141
    +  CFF_FIELD_DELTA      ( 0x10C, snap_widths, 13,        "StemSnapH" )
    
    142
    +  CFF_FIELD_DELTA      ( 0x10D, snap_heights, 13,       "StemSnapV" )
    
    143
    +  CFF_FIELD_NUM        ( 0x111, language_group,         "LanguageGroup" )
    
    144
    +  CFF_FIELD_FIXED      ( 0x112, expansion_factor,       "ExpansionFactor" )
    
    145
    +  CFF_FIELD_CALLBACK   ( 22,    vsindex,                "vsindex" )
    
    146
    +  CFF_FIELD_BLEND      ( 23,                            "blend" )
    
    147
    +  CFF_FIELD_NUM        ( 19,    local_subrs_offset,     "Subrs" )
    
    148 148
     
    
    149 149
     
    
    150 150
     /* END */

  • src/psaux/psblues.c
    ... ... @@ -54,14 +54,6 @@
    54 54
     #define FT_COMPONENT  cf2blues
    
    55 55
     
    
    56 56
     
    
    57
    -  /*
    
    58
    -   * For blue values, the FreeType parser produces an array of integers,
    
    59
    -   * while the Adobe CFF engine produces an array of fixed.
    
    60
    -   * Define a macro to convert FreeType to fixed.
    
    61
    -   */
    
    62
    -#define cf2_blueToFixed( x )  cf2_intToFixed( x )
    
    63
    -
    
    64
    -
    
    65 57
       FT_LOCAL_DEF( void )
    
    66 58
       cf2_blues_init( CF2_Blues  blues,
    
    67 59
                       CF2_Font   font )
    
    ... ... @@ -78,10 +70,10 @@
    78 70
         size_t  numFamilyBlues;
    
    79 71
         size_t  numFamilyOtherBlues;
    
    80 72
     
    
    81
    -    FT_Pos*  blueValues;
    
    82
    -    FT_Pos*  otherBlues;
    
    83
    -    FT_Pos*  familyBlues;
    
    84
    -    FT_Pos*  familyOtherBlues;
    
    73
    +    FT_Fixed*  blueValues;
    
    74
    +    FT_Fixed*  otherBlues;
    
    75
    +    FT_Fixed*  familyBlues;
    
    76
    +    FT_Fixed*  familyOtherBlues;
    
    85 77
     
    
    86 78
         size_t     i;
    
    87 79
         CF2_Fixed  emBoxBottom, emBoxTop;
    
    ... ... @@ -138,13 +130,13 @@
    138 130
           emBoxTop    = CF2_ICF_Top;
    
    139 131
         }
    
    140 132
     
    
    141
    -    if ( cf2_getLanguageGroup( decoder ) == 1                   &&
    
    142
    -         ( numBlueValues == 0                                 ||
    
    143
    -           ( numBlueValues == 4                             &&
    
    144
    -             cf2_blueToFixed( blueValues[0] ) < emBoxBottom &&
    
    145
    -             cf2_blueToFixed( blueValues[1] ) < emBoxBottom &&
    
    146
    -             cf2_blueToFixed( blueValues[2] ) > emBoxTop    &&
    
    147
    -             cf2_blueToFixed( blueValues[3] ) > emBoxTop    ) ) )
    
    133
    +    if ( cf2_getLanguageGroup( decoder ) == 1     &&
    
    134
    +         ( numBlueValues == 0                   ||
    
    135
    +           ( numBlueValues == 4               &&
    
    136
    +             blueValues[0] < emBoxBottom      &&
    
    137
    +             blueValues[1] < emBoxBottom      &&
    
    138
    +             blueValues[2] > emBoxTop         &&
    
    139
    +             blueValues[3] > emBoxTop         ) ) )
    
    148 140
         {
    
    149 141
           /*
    
    150 142
            * Construct hint edges suitable for synthetic ghost hints at top
    
    ... ... @@ -189,10 +181,8 @@
    189 181
         /* bottom zones                                                      */
    
    190 182
         for ( i = 0; i < numBlueValues; i += 2 )
    
    191 183
         {
    
    192
    -      blues->zone[blues->count].csBottomEdge =
    
    193
    -        cf2_blueToFixed( blueValues[i] );
    
    194
    -      blues->zone[blues->count].csTopEdge =
    
    195
    -        cf2_blueToFixed( blueValues[i + 1] );
    
    184
    +      blues->zone[blues->count].csBottomEdge = blueValues[i];
    
    185
    +      blues->zone[blues->count].csTopEdge    = blueValues[i + 1];
    
    196 186
     
    
    197 187
           zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
    
    198 188
                                   blues->zone[blues->count].csBottomEdge );
    
    ... ... @@ -238,10 +228,8 @@
    238 228
     
    
    239 229
         for ( i = 0; i < numOtherBlues; i += 2 )
    
    240 230
         {
    
    241
    -      blues->zone[blues->count].csBottomEdge =
    
    242
    -        cf2_blueToFixed( otherBlues[i] );
    
    243
    -      blues->zone[blues->count].csTopEdge =
    
    244
    -        cf2_blueToFixed( otherBlues[i + 1] );
    
    231
    +      blues->zone[blues->count].csBottomEdge = otherBlues[i];
    
    232
    +      blues->zone[blues->count].csTopEdge    = otherBlues[i + 1];
    
    245 233
     
    
    246 234
           zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
    
    247 235
                                   blues->zone[blues->count].csBottomEdge );
    
    ... ... @@ -299,7 +287,7 @@
    299 287
             for ( j = 0; j < numFamilyOtherBlues; j += 2 )
    
    300 288
             {
    
    301 289
               /* top edge */
    
    302
    -          flatFamilyEdge = cf2_blueToFixed( familyOtherBlues[j + 1] );
    
    290
    +          flatFamilyEdge = familyOtherBlues[j + 1];
    
    303 291
     
    
    304 292
               diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
    
    305 293
     
    
    ... ... @@ -317,7 +305,7 @@
    317 305
             if ( numFamilyBlues >= 2 )
    
    318 306
             {
    
    319 307
               /* top edge */
    
    320
    -          flatFamilyEdge = cf2_blueToFixed( familyBlues[1] );
    
    308
    +          flatFamilyEdge = familyBlues[1];
    
    321 309
     
    
    322 310
               diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
    
    323 311
     
    
    ... ... @@ -337,7 +325,7 @@
    337 325
             for ( j = 2; j < numFamilyBlues; j += 2 )
    
    338 326
             {
    
    339 327
               /* bottom edge */
    
    340
    -          flatFamilyEdge = cf2_blueToFixed( familyBlues[j] );
    
    328
    +          flatFamilyEdge = familyBlues[j];
    
    341 329
     
    
    342 330
               /* adjust edges of top zone upward by twice darkening amount */
    
    343 331
               flatFamilyEdge += 2 * font->darkenY;      /* bottom edge */
    

  • src/psaux/psft.c
    ... ... @@ -566,12 +566,12 @@
    566 566
       FT_LOCAL_DEF( void )
    
    567 567
       cf2_getBlueValues( PS_Decoder*  decoder,
    
    568 568
                          size_t*      count,
    
    569
    -                     FT_Pos*     *data )
    
    569
    +                     FT_Fixed*   *data )
    
    570 570
       {
    
    571 571
         FT_ASSERT( decoder && decoder->current_subfont );
    
    572 572
     
    
    573 573
         *count = decoder->current_subfont->private_dict.num_blue_values;
    
    574
    -    *data  = (FT_Pos*)
    
    574
    +    *data  = (FT_Fixed*)
    
    575 575
                    &decoder->current_subfont->private_dict.blue_values;
    
    576 576
       }
    
    577 577
     
    
    ... ... @@ -579,12 +579,12 @@
    579 579
       FT_LOCAL_DEF( void )
    
    580 580
       cf2_getOtherBlues( PS_Decoder*  decoder,
    
    581 581
                          size_t*      count,
    
    582
    -                     FT_Pos*     *data )
    
    582
    +                     FT_Fixed*   *data )
    
    583 583
       {
    
    584 584
         FT_ASSERT( decoder && decoder->current_subfont );
    
    585 585
     
    
    586 586
         *count = decoder->current_subfont->private_dict.num_other_blues;
    
    587
    -    *data  = (FT_Pos*)
    
    587
    +    *data  = (FT_Fixed*)
    
    588 588
                    &decoder->current_subfont->private_dict.other_blues;
    
    589 589
       }
    
    590 590
     
    
    ... ... @@ -592,12 +592,12 @@
    592 592
       FT_LOCAL_DEF( void )
    
    593 593
       cf2_getFamilyBlues( PS_Decoder*  decoder,
    
    594 594
                           size_t*      count,
    
    595
    -                      FT_Pos*     *data )
    
    595
    +                      FT_Fixed*   *data )
    
    596 596
       {
    
    597 597
         FT_ASSERT( decoder && decoder->current_subfont );
    
    598 598
     
    
    599 599
         *count = decoder->current_subfont->private_dict.num_family_blues;
    
    600
    -    *data  = (FT_Pos*)
    
    600
    +    *data  = (FT_Fixed*)
    
    601 601
                    &decoder->current_subfont->private_dict.family_blues;
    
    602 602
       }
    
    603 603
     
    
    ... ... @@ -605,12 +605,12 @@
    605 605
       FT_LOCAL_DEF( void )
    
    606 606
       cf2_getFamilyOtherBlues( PS_Decoder*  decoder,
    
    607 607
                                size_t*      count,
    
    608
    -                           FT_Pos*     *data )
    
    608
    +                           FT_Fixed*   *data )
    
    609 609
       {
    
    610 610
         FT_ASSERT( decoder && decoder->current_subfont );
    
    611 611
     
    
    612 612
         *count = decoder->current_subfont->private_dict.num_family_other_blues;
    
    613
    -    *data  = (FT_Pos*)
    
    613
    +    *data  = (FT_Fixed*)
    
    614 614
                    &decoder->current_subfont->private_dict.family_other_blues;
    
    615 615
       }
    
    616 616
     
    

  • src/psaux/psft.h
    ... ... @@ -92,19 +92,19 @@ FT_BEGIN_HEADER
    92 92
       FT_LOCAL( void )
    
    93 93
       cf2_getBlueValues( PS_Decoder*  decoder,
    
    94 94
                          size_t*      count,
    
    95
    -                     FT_Pos*     *data );
    
    95
    +                     FT_Fixed*   *data );
    
    96 96
       FT_LOCAL( void )
    
    97 97
       cf2_getOtherBlues( PS_Decoder*  decoder,
    
    98 98
                          size_t*      count,
    
    99
    -                     FT_Pos*     *data );
    
    99
    +                     FT_Fixed*   *data );
    
    100 100
       FT_LOCAL( void )
    
    101 101
       cf2_getFamilyBlues( PS_Decoder*  decoder,
    
    102 102
                           size_t*      count,
    
    103
    -                      FT_Pos*     *data );
    
    103
    +                      FT_Fixed*   *data );
    
    104 104
       FT_LOCAL( void )
    
    105 105
       cf2_getFamilyOtherBlues( PS_Decoder*  decoder,
    
    106 106
                                size_t*      count,
    
    107
    -                           FT_Pos*     *data );
    
    107
    +                           FT_Fixed*   *data );
    
    108 108
     
    
    109 109
       FT_LOCAL( CF2_Int )
    
    110 110
       cf2_getLanguageGroup( PS_Decoder*  decoder );
    

  • src/psaux/psintrp.c
    ... ... @@ -429,6 +429,8 @@
    429 429
         base  = cf2_stack_count( opStack ) - numOperands;
    
    430 430
         delta = base + numBlends;
    
    431 431
     
    
    432
    +    FT_TRACE6(( " (" ));
    
    433
    +
    
    432 434
         for ( i = 0; i < numBlends; i++ )
    
    433 435
         {
    
    434 436
           const CF2_Fixed*  weight = &blend->BV[1];
    
    ... ... @@ -443,10 +445,14 @@
    443 445
                                         cf2_stack_getReal( opStack,
    
    444 446
                                                            delta++ ) ) );
    
    445 447
     
    
    448
    +      FT_TRACE6(( "%f ", (float) sum / 65536 ));
    
    449
    +
    
    446 450
           /* store blended result  */
    
    447 451
           cf2_stack_setReal( opStack, i + base, sum );
    
    448 452
         }
    
    449 453
     
    
    454
    +    FT_TRACE6(( "blended)\n" ));
    
    455
    +
    
    450 456
         /* leave only `numBlends' results on stack */
    
    451 457
         cf2_stack_pop( opStack, numOperands - numBlends );
    
    452 458
       }
    
    ... ... @@ -735,7 +741,7 @@
    735 741
               FT_UInt  numBlends;
    
    736 742
     
    
    737 743
     
    
    738
    -          FT_TRACE4(( " blend\n" ));
    
    744
    +          FT_TRACE4(( " blend" ));
    
    739 745
     
    
    740 746
               if ( !font->isCFF2 )
    
    741 747
                 break;    /* clear stack & ignore */
    

  • src/psaux/psobjs.c
    ... ... @@ -2463,19 +2463,20 @@
    2463 2463
     
    
    2464 2464
         count = cpriv->num_blue_values = priv->num_blue_values;
    
    2465 2465
         for ( n = 0; n < count; n++ )
    
    2466
    -      cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n];
    
    2466
    +      cpriv->blue_values[n] = cf2_intToFixed( priv->blue_values[n] );
    
    2467 2467
     
    
    2468 2468
         count = cpriv->num_other_blues = priv->num_other_blues;
    
    2469 2469
         for ( n = 0; n < count; n++ )
    
    2470
    -      cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n];
    
    2470
    +      cpriv->other_blues[n] = cf2_intToFixed( priv->other_blues[n] );
    
    2471 2471
     
    
    2472 2472
         count = cpriv->num_family_blues = priv->num_family_blues;
    
    2473 2473
         for ( n = 0; n < count; n++ )
    
    2474
    -      cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n];
    
    2474
    +      cpriv->family_blues[n] = cf2_intToFixed( priv->family_blues[n] );
    
    2475 2475
     
    
    2476 2476
         count = cpriv->num_family_other_blues = priv->num_family_other_blues;
    
    2477 2477
         for ( n = 0; n < count; n++ )
    
    2478
    -      cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n];
    
    2478
    +      cpriv->family_other_blues[n] =
    
    2479
    +        cf2_intToFixed( priv->family_other_blues[n] );
    
    2479 2480
     
    
    2480 2481
         cpriv->blue_scale = priv->blue_scale;
    
    2481 2482
         cpriv->blue_shift = (FT_Pos)priv->blue_shift;
    


  • reply via email to

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