Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 128760 | Differences between
and this patch

Collapse All | Expand All

(-)freetype2/include/freetype/internal/ftobjs.h (+7 lines)
Lines 452-457 FT_BEGIN_HEADER Link Here
452
 /* */
452
 /* */
453
453
454
 /*
454
 /*
455
  * grid-fit slot->metrics
456
  */
457
  FT_BASE( void )
458
  ft_glyphslot_grid_fit_metrics( FT_GlyphSlot  slot );
459
460
461
 /*
455
  * Free the bitmap of a given glyphslot when needed
462
  * Free the bitmap of a given glyphslot when needed
456
  * (i.e., only when it was allocated with ft_glyphslot_alloc_bitmap).
463
  * (i.e., only when it was allocated with ft_glyphslot_alloc_bitmap).
457
  */
464
  */
(-)freetype2/src/base/ftobjs.c (+23 lines)
Lines 251-256 Link Here
251
251
252
252
253
  FT_BASE_DEF( void )
253
  FT_BASE_DEF( void )
254
  ft_glyphslot_grid_fit_metrics( FT_GlyphSlot  slot )
255
  {
256
    FT_Pos  tmp;
257
258
259
    tmp = FT_PIX_CEIL( slot->metrics.horiBearingX + slot->metrics.width );
260
    slot->metrics.horiBearingX = FT_PIX_FLOOR( slot->metrics.horiBearingX );
261
    slot->metrics.width        = tmp - slot->metrics.horiBearingX;
262
263
    tmp = FT_PIX_FLOOR( slot->metrics.horiBearingY - slot->metrics.height );
264
    slot->metrics.horiBearingY = FT_PIX_CEIL( slot->metrics.horiBearingY );
265
    slot->metrics.height       = slot->metrics.horiBearingY - tmp;
266
267
    slot->metrics.horiAdvance  = FT_PIX_ROUND( slot->metrics.horiAdvance );
268
269
    slot->metrics.vertBearingX = FT_PIX_FLOOR( slot->metrics.vertBearingX );
270
    /* note that vertBearingY should be floor'ed */
271
    slot->metrics.vertBearingY = FT_PIX_FLOOR( slot->metrics.vertBearingY );
272
    slot->metrics.vertAdvance  = FT_PIX_ROUND( slot->metrics.vertAdvance );
273
  }
274
275
276
  FT_BASE_DEF( void )
254
  ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
277
  ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
255
                           FT_Byte*      buffer )
278
                           FT_Byte*      buffer )
256
  {
279
  {
(-)freetype2/src/base/ftoutln.c (+1 lines)
Lines 683-688 Link Here
683
    if ( !outline )
683
    if ( !outline )
684
      return FT_Err_Invalid_Argument;
684
      return FT_Err_Invalid_Argument;
685
685
686
    strength /= 2;
686
    if ( strength == 0 )
687
    if ( strength == 0 )
687
      return FT_Err_Ok;
688
      return FT_Err_Ok;
688
689
(-)freetype2/src/base/ftsynth.c (-3 / +6 lines)
Lines 81-93 Link Here
81
81
82
    /* some reasonable strength */
82
    /* some reasonable strength */
83
    xstr = FT_MulFix( face->units_per_EM,
83
    xstr = FT_MulFix( face->units_per_EM,
84
                      face->size->metrics.y_scale ) / 42;
84
                      face->size->metrics.y_scale ) / 24;
85
    ystr = xstr;
85
    ystr = xstr;
86
86
87
    if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
87
    if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
88
    {
88
    {
89
      error = FT_Outline_Embolden( &slot->outline, xstr );
89
      error = FT_Outline_Embolden( &slot->outline, xstr );
90
      xstr = xstr * 4;  /* according to the documentation */
90
91
      /* this is more than enough for most glyphs;                         */
92
      /* if you need accurate values, you have to call FT_Outline_Get_CBox */
93
      xstr = xstr * 2;
91
      ystr = xstr;
94
      ystr = xstr;
92
    }
95
    }
93
    else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
96
    else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
Lines 122-129 Link Here
122
    /* modify the metrics accordingly */
125
    /* modify the metrics accordingly */
123
    if ( !error )
126
    if ( !error )
124
    {
127
    {
128
      /* assume the layout is horizontal */
125
      slot->advance.x += xstr;
129
      slot->advance.x += xstr;
126
      slot->advance.y += ystr;
127
130
128
      slot->metrics.width        += xstr;
131
      slot->metrics.width        += xstr;
129
      slot->metrics.height       += ystr;
132
      slot->metrics.height       += ystr;
(-)freetype2/src/cff/cffgload.c (-27 / +8 lines)
Lines 2510-2520 Link Here
2510
        glyph->root.linearHoriAdvance           = decoder.glyph_width;
2510
        glyph->root.linearHoriAdvance           = decoder.glyph_width;
2511
        glyph->root.internal->glyph_transformed = 0;
2511
        glyph->root.internal->glyph_transformed = 0;
2512
2512
2513
        /* make up vertical metrics */
2513
        /* make up vertical ones */
2514
        metrics->vertBearingX = 0;
2515
        metrics->vertBearingY = 0;
2516
        metrics->vertAdvance  = 0;
2514
        metrics->vertAdvance  = 0;
2517
2518
        glyph->root.linearVertAdvance = 0;
2515
        glyph->root.linearVertAdvance = 0;
2519
2516
2520
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
2517
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
Lines 2559-2600 Link Here
2559
              vec->y = FT_MulFix( vec->y, y_scale );
2556
              vec->y = FT_MulFix( vec->y, y_scale );
2560
            }
2557
            }
2561
2558
2562
          FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
2563
2564
          /* Then scale the metrics */
2559
          /* Then scale the metrics */
2565
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
2560
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
2566
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
2561
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
2567
2568
          metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
2569
          metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
2570
2571
          if ( hinting )
2572
          {
2573
            metrics->horiAdvance  = FT_PIX_ROUND( metrics->horiAdvance );
2574
            metrics->vertAdvance  = FT_PIX_ROUND( metrics->vertAdvance );
2575
2576
            metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX );
2577
            metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY );
2578
          }
2579
        }
2562
        }
2580
2563
2581
        /* compute the other metrics */
2564
        /* compute the other metrics */
2582
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
2565
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
2583
2566
2584
        /* grid fit the bounding box if necessary */
2585
        if ( hinting )
2586
        {
2587
          cbox.xMin &= -64;
2588
          cbox.yMin &= -64;
2589
          cbox.xMax  = ( cbox.xMax + 63 ) & -64;
2590
          cbox.yMax  = ( cbox.yMax + 63 ) & -64;
2591
        }
2592
2593
        metrics->width  = cbox.xMax - cbox.xMin;
2567
        metrics->width  = cbox.xMax - cbox.xMin;
2594
        metrics->height = cbox.yMax - cbox.yMin;
2568
        metrics->height = cbox.yMax - cbox.yMin;
2595
2569
2596
        metrics->horiBearingX = cbox.xMin;
2570
        metrics->horiBearingX = cbox.xMin;
2597
        metrics->horiBearingY = cbox.yMax;
2571
        metrics->horiBearingY = cbox.yMax;
2572
2573
        /* make up vertical ones */
2574
        metrics->vertBearingX = 0;
2575
        metrics->vertBearingY = 0;
2576
2577
        if ( hinting )
2578
          ft_glyphslot_grid_fit_metrics( &glyph->root );
2598
      }
2579
      }
2599
    }
2580
    }
2600
2581
(-)freetype2/src/cid/cidgload.c (-27 / +9 lines)
Lines 358-369 Link Here
358
        cidglyph->linearHoriAdvance           = decoder.builder.advance.x;
358
        cidglyph->linearHoriAdvance           = decoder.builder.advance.x;
359
        cidglyph->internal->glyph_transformed = 0;
359
        cidglyph->internal->glyph_transformed = 0;
360
360
361
        /* make up vertical metrics */
361
        /* make up vertical ones */
362
        metrics->vertBearingX = 0;
363
        metrics->vertBearingY = 0;
364
        metrics->vertAdvance  = 0;
362
        metrics->vertAdvance  = 0;
365
366
        cidglyph->linearVertAdvance = 0;
363
        cidglyph->linearVertAdvance = 0;
364
367
        cidglyph->format            = FT_GLYPH_FORMAT_OUTLINE;
365
        cidglyph->format            = FT_GLYPH_FORMAT_OUTLINE;
368
366
369
        if ( size && cidsize->metrics.y_ppem < 24 )
367
        if ( size && cidsize->metrics.y_ppem < 24 )
Lines 403-444 Link Here
403
              vec->y = FT_MulFix( vec->y, y_scale );
401
              vec->y = FT_MulFix( vec->y, y_scale );
404
            }
402
            }
405
403
406
          FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
407
408
          /* Then scale the metrics */
404
          /* Then scale the metrics */
409
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
405
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
410
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
406
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
411
412
          metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
413
          metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
414
415
          if ( hinting )
416
          {
417
            metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance );
418
            metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance );
419
420
            metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX );
421
            metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY );
422
          }
423
        }
407
        }
424
408
425
        /* compute the other metrics */
409
        /* compute the other metrics */
426
        FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
410
        FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
427
411
428
        /* grid fit the bounding box if necessary */
429
        if ( hinting )
430
        {
431
          cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
432
          cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
433
          cbox.xMax = FT_PIX_CEIL( cbox.xMax );
434
          cbox.yMax = FT_PIX_CEIL( cbox.yMax );
435
        }
436
437
        metrics->width  = cbox.xMax - cbox.xMin;
412
        metrics->width  = cbox.xMax - cbox.xMin;
438
        metrics->height = cbox.yMax - cbox.yMin;
413
        metrics->height = cbox.yMax - cbox.yMin;
439
414
440
        metrics->horiBearingX = cbox.xMin;
415
        metrics->horiBearingX = cbox.xMin;
441
        metrics->horiBearingY = cbox.yMax;
416
        metrics->horiBearingY = cbox.yMax;
417
418
        /* make up vertical ones */
419
        metrics->vertBearingX = 0;
420
        metrics->vertBearingY = 0;
421
422
        if ( hinting )
423
          ft_glyphslot_grid_fit_metrics( cidglyph );
442
      }
424
      }
443
    }
425
    }
444
426
(-)freetype2/src/sfnt/ttsbit.c (-1 / +1 lines)
Lines 1501-1507 Link Here
1501
      /* some heuristic values */
1501
      /* some heuristic values */
1502
1502
1503
      metrics->vertBearingX = (FT_Char)(-metrics->width / 2 );
1503
      metrics->vertBearingX = (FT_Char)(-metrics->width / 2 );
1504
      metrics->vertBearingY = (FT_Char)( advance / 10 );
1504
      metrics->vertBearingY = (FT_Char)( ( advance - metrics->height ) / 2 );
1505
      metrics->vertAdvance  = (FT_Char)( advance * 12 / 10 );
1505
      metrics->vertAdvance  = (FT_Char)( advance * 12 / 10 );
1506
    }
1506
    }
1507
1507
(-)freetype2/src/truetype/ttdriver.c (-26 / +19 lines)
Lines 167-206 Link Here
167
                  FT_UInt     horz_resolution,
167
                  FT_UInt     horz_resolution,
168
                  FT_UInt     vert_resolution )
168
                  FT_UInt     vert_resolution )
169
  {
169
  {
170
    TT_Size           size     = (TT_Size)ttsize;
170
    TT_Size           size    = (TT_Size)ttsize;
171
    FT_Size_Metrics*  metrics  = &size->root.metrics;
171
    FT_Size_Metrics*  metrics = &size->metrics;
172
    FT_Size_Metrics*  metrics2 = &size->metrics;
172
    TT_Face           face    = (TT_Face)size->root.face;
173
    TT_Face           face     = (TT_Face)size->root.face;
174
    FT_Long           dim_x, dim_y;
175
173
176
174
177
    *metrics2 = *metrics;
175
    /* copy the result from base layer */
176
    *metrics = size->root.metrics;
178
177
179
    /* This bit flag, when set, indicates that the pixel size must be */
178
    /* This bit flag, when set, indicates that the pixel size must be */
180
    /* truncated to an integer.  Nearly all TrueType fonts have this  */
179
    /* rounded to integer.  Nearly all TrueType fonts have this  bit  */
181
    /* bit set, as hinting won't work really well otherwise.          */
180
    /* set, as hinting won't work really well otherwise.              */
182
    /*                                                                */
181
    /*                                                                */
183
    if ( ( face->header.Flags & 8 ) != 0 )
182
    if ( ( face->header.Flags & 8 ) != 0 )
184
    {
183
    {
185
     /* we need to use rounding in the following computations. Otherwise,
184
      FT_Long  dim_x, dim_y;
186
      * the resulting hinted outlines will be very slightly distorted
187
      */
188
      dim_x = ( ( char_width  * horz_resolution + (36+32*72) ) / 72 ) & ~63;
189
      dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & ~63;
190
    }
191
    else
192
    {
193
      dim_x = ( ( char_width  * horz_resolution + 36 ) / 72 );
194
      dim_y = ( ( char_height * vert_resolution + 36 ) / 72 );
195
    }
196
185
197
    /* we only modify "metrics2", not "metrics", so these changes have */
186
      dim_x = ( char_width  * horz_resolution + 36 ) / 72;
198
    /* no effect on the result of the auto-hinter when it is used      */
187
      dim_y = ( char_height * vert_resolution + 36 ) / 72;
199
    /*                                                                 */
188
200
    metrics2->x_ppem  = (FT_UShort)( dim_x >> 6 );
189
      dim_x = FT_PIX_ROUND(dim_x);
201
    metrics2->y_ppem  = (FT_UShort)( dim_y >> 6 );
190
      dim_y = FT_PIX_ROUND(dim_y);
202
    metrics2->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
191
203
    metrics2->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
192
      metrics->x_ppem  = (FT_UShort)( dim_x >> 6 );
193
      metrics->y_ppem  = (FT_UShort)( dim_y >> 6 );
194
      metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
195
      metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
196
    }
204
197
205
    size->ttmetrics.valid = FALSE;
198
    size->ttmetrics.valid = FALSE;
206
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
199
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
(-)freetype2/src/truetype/ttgload.c (-51 / +32 lines)
Lines 1707-1721 Link Here
1707
      FT_Outline_Translate( &glyph->outline, -loader->pp1.x, 0 );
1707
      FT_Outline_Translate( &glyph->outline, -loader->pp1.x, 0 );
1708
1708
1709
      FT_Outline_Get_CBox( &glyph->outline, &bbox );
1709
      FT_Outline_Get_CBox( &glyph->outline, &bbox );
1710
1711
      if ( IS_HINTED( loader->load_flags ) )
1712
      {
1713
        /* grid-fit the bounding box */
1714
        bbox.xMin = FT_PIX_FLOOR( bbox.xMin );
1715
        bbox.yMin = FT_PIX_FLOOR( bbox.yMin );
1716
        bbox.xMax = FT_PIX_CEIL( bbox.xMax );
1717
        bbox.yMax = FT_PIX_CEIL( bbox.yMax );
1718
      }
1719
    }
1710
    }
1720
    else
1711
    else
1721
      bbox = loader->bbox;
1712
      bbox = loader->bbox;
Lines 1744-1753 Link Here
1744
    glyph->metrics.horiBearingY = bbox.yMax;
1735
    glyph->metrics.horiBearingY = bbox.yMax;
1745
    glyph->metrics.horiAdvance  = loader->pp2.x - loader->pp1.x;
1736
    glyph->metrics.horiAdvance  = loader->pp2.x - loader->pp1.x;
1746
1737
1747
    /* don't forget to hint the advance when we need to */
1748
    if ( IS_HINTED( loader->load_flags ) )
1749
      glyph->metrics.horiAdvance = FT_PIX_ROUND( glyph->metrics.horiAdvance );
1750
1751
    /* Now take care of vertical metrics.  In the case where there is    */
1738
    /* Now take care of vertical metrics.  In the case where there is    */
1752
    /* no vertical information within the font (relatively common), make */
1739
    /* no vertical information within the font (relatively common), make */
1753
    /* up some metrics by `hand'...                                      */
1740
    /* up some metrics by `hand'...                                      */
Lines 1765-1805 Link Here
1765
      if ( face->vertical_info &&
1752
      if ( face->vertical_info &&
1766
           face->vertical.number_Of_VMetrics > 0 )
1753
           face->vertical.number_Of_VMetrics > 0 )
1767
      {
1754
      {
1768
        advance_height = (FT_UShort)( loader->pp4.y - loader->pp3.y );
1755
        top_bearing = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
1769
        top_bearing    = (FT_Short)( loader->pp3.y - bbox.yMax );
1756
                                           y_scale );
1757
1758
        if ( loader->pp3.y <= loader->pp4.y )
1759
          advance_height = 0;
1760
        else
1761
          advance_height = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
1762
                                                 y_scale );
1770
      }
1763
      }
1771
      else
1764
      else
1772
      {
1765
      {
1773
        /* Make up the distances from the horizontal header.   */
1766
        FT_Short  max_height, height;
1767
1768
1769
        /* XXX Compute top side bearing and advance height in  */
1770
        /*     Get_VMetrics instead of here.                   */
1774
1771
1775
        /* NOTE: The OS/2 values are the only `portable' ones, */
1772
        /* NOTE: The OS/2 values are the only `portable' ones, */
1776
        /*       which is why we use them, if there is an OS/2 */
1773
        /*       which is why we use them, if there is an OS/2 */
1777
        /*       table in the font.  Otherwise, we use the     */
1774
        /*       table in the font.  Otherwise, we use the     */
1778
        /*       values defined in the horizontal header.      */
1775
        /*       values defined in the horizontal header.      */
1779
        /*                                                     */
1776
1780
        /* NOTE2: The sTypoDescender is negative, which is why */
1777
        height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin, y_scale );
1781
        /*        we compute the baseline-to-baseline distance */
1782
        /*        here with:                                   */
1783
        /*             ascender - descender + linegap          */
1784
        /*                                                     */
1785
        /* NOTE3: This is different from what MS's rasterizer  */
1786
        /*        appears to do when getting default values    */
1787
        /*        for the vertical phantom points.  We leave   */
1788
        /*        the old code untouched, but relying on       */
1789
        /*        phantom points alone might be reasonable     */
1790
        /*        (i.e., removing the `if' above).             */
1791
        if ( face->os2.version != 0xFFFFU )
1778
        if ( face->os2.version != 0xFFFFU )
1792
        {
1779
        {
1793
          top_bearing    = (FT_Short)( face->os2.sTypoLineGap / 2 );
1780
          /* sTypoDescender is negative */
1794
          advance_height = (FT_UShort)( face->os2.sTypoAscender -
1781
          max_height     = (FT_Short)(face->os2.sTypoAscender -
1795
                                        face->os2.sTypoDescender +
1782
                                      face->os2.sTypoDescender);
1796
                                        face->os2.sTypoLineGap );
1783
1784
          top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
1785
          advance_height = (FT_UShort)( max_height + face->os2.sTypoLineGap );
1797
        }
1786
        }
1798
        else
1787
        else
1799
        {
1788
        {
1800
          top_bearing    = (FT_Short)( face->horizontal.Line_Gap / 2 );
1789
          max_height = (FT_Short)(face->horizontal.Ascender +
1801
          advance_height = (FT_UShort)( face->horizontal.Ascender  +
1790
                                  face->horizontal.Descender);
1802
                                        face->horizontal.Descender +
1791
1792
          top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
1793
          advance_height = (FT_UShort)( max_height +
1803
                                        face->horizontal.Line_Gap );
1794
                                        face->horizontal.Line_Gap );
1804
        }
1795
        }
1805
      }
1796
      }
Lines 1817-1823 Link Here
1817
1808
1818
        metrics.bearing_x = 0;
1809
        metrics.bearing_x = 0;
1819
        metrics.bearing_y = top_bearing;
1810
        metrics.bearing_y = top_bearing;
1820
        metrics.advance = advance_height;
1811
        metrics.advance   = advance_height;
1821
        error =
1812
        error =
1822
          face->root.internal->incremental_interface->funcs->get_glyph_metrics(
1813
          face->root.internal->incremental_interface->funcs->get_glyph_metrics(
1823
            face->root.internal->incremental_interface->object,
1814
            face->root.internal->incremental_interface->object,
Lines 1834-1853 Link Here
1834
1825
1835
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
1826
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
1836
1827
1837
      /* We must adjust the top_bearing value from the bounding box given */
1838
      /* in the glyph header to the bounding box calculated with          */
1839
      /* FT_Get_Outline_CBox().                                           */
1840
1841
      /* scale the metrics */
1828
      /* scale the metrics */
1842
      if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
1829
      if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
1843
      {
1830
      {
1844
        top     = FT_MulFix( top_bearing + loader->bbox.yMax, y_scale )
1831
        top     = FT_MulFix( top_bearing, y_scale );
1845
                    - bbox.yMax;
1846
        advance = FT_MulFix( advance_height, y_scale );
1832
        advance = FT_MulFix( advance_height, y_scale );
1847
      }
1833
      }
1848
      else
1834
      else
1849
      {
1835
      {
1850
        top     = top_bearing + loader->bbox.yMax - bbox.yMax;
1836
        top     = top_bearing;
1851
        advance = advance_height;
1837
        advance = advance_height;
1852
      }
1838
      }
1853
1839
Lines 1860-1873 Link Here
1860
      /*                                                               */
1846
      /*                                                               */
1861
      left = ( bbox.xMin - bbox.xMax ) / 2;
1847
      left = ( bbox.xMin - bbox.xMax ) / 2;
1862
1848
1863
      /* grid-fit them if necessary */
1864
      if ( IS_HINTED( loader->load_flags ) )
1865
      {
1866
        left    = FT_PIX_FLOOR( left );
1867
        top     = FT_PIX_CEIL( top );
1868
        advance = FT_PIX_ROUND( advance );
1869
      }
1870
1871
      glyph->metrics.vertBearingX = left;
1849
      glyph->metrics.vertBearingX = left;
1872
      glyph->metrics.vertBearingY = top;
1850
      glyph->metrics.vertBearingY = top;
1873
      glyph->metrics.vertAdvance  = advance;
1851
      glyph->metrics.vertAdvance  = advance;
Lines 1889-1894 Link Here
1889
    /* set glyph dimensions */
1867
    /* set glyph dimensions */
1890
    glyph->metrics.width  = bbox.xMax - bbox.xMin;
1868
    glyph->metrics.width  = bbox.xMax - bbox.xMin;
1891
    glyph->metrics.height = bbox.yMax - bbox.yMin;
1869
    glyph->metrics.height = bbox.yMax - bbox.yMin;
1870
1871
    if ( IS_HINTED( loader->load_flags ) )
1872
      ft_glyphslot_grid_fit_metrics( glyph );
1892
1873
1893
    return 0;
1874
    return 0;
1894
  }
1875
  }
(-)freetype2/src/truetype/ttobjs.c (-151 / +191 lines)
Lines 121-139 Link Here
121
    FT_Error  error;
121
    FT_Error  error;
122
122
123
123
124
    if ( maxPoints > 0 )
125
      maxPoints += 2;
126
127
    FT_MEM_ZERO( zone, sizeof ( *zone ) );
124
    FT_MEM_ZERO( zone, sizeof ( *zone ) );
128
    zone->memory = memory;
125
    zone->memory = memory;
129
126
130
    if ( FT_NEW_ARRAY( zone->org,      maxPoints * 2 ) ||
127
    if ( FT_NEW_ARRAY( zone->org,      maxPoints   ) ||
131
         FT_NEW_ARRAY( zone->cur,      maxPoints * 2 ) ||
128
         FT_NEW_ARRAY( zone->cur,      maxPoints   ) ||
132
         FT_NEW_ARRAY( zone->tags,     maxPoints     ) ||
129
         FT_NEW_ARRAY( zone->tags,     maxPoints   ) ||
133
         FT_NEW_ARRAY( zone->contours, maxContours   ) )
130
         FT_NEW_ARRAY( zone->contours, maxContours ) )
134
    {
131
    {
135
      tt_glyphzone_done( zone );
132
      tt_glyphzone_done( zone );
136
    }
133
    }
134
    else
135
    {
136
      zone->max_points = maxPoints;
137
      zone->max_contours = maxContours;
138
    }
137
139
138
    return error;
140
    return error;
139
  }
141
  }
Lines 318-323 Link Here
318
  /*                                                                       */
320
  /*                                                                       */
319
  /*************************************************************************/
321
  /*************************************************************************/
320
322
323
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
324
  /*************************************************************************/
325
  /*                                                                       */
326
  /* <Function>                                                            */
327
  /*    tt_size_run_fpgm                                                   */
328
  /*                                                                       */
329
  /* <Description>                                                         */
330
  /*    Run the font program                                               */
331
  /*                                                                       */
332
  /* <Input>                                                               */
333
  /*    size :: A handle to the size object.                               */
334
  /*                                                                       */
335
  /* <Return>                                                              */
336
  /*    FreeType error code.  0 means success.                             */
337
  /*                                                                       */
338
  FT_LOCAL_DEF( FT_Error )
339
  tt_size_run_fpgm( TT_Size  size )
340
  {
341
    TT_Face         face = (TT_Face)size->root.face;
342
    TT_ExecContext  exec;
343
    FT_Error        error;
344
345
346
    /* debugging instances have their own context */
347
    if ( size->debug )
348
      exec = size->context;
349
    else
350
      exec = TT_New_Context( face );
351
352
    if ( !exec )
353
      return TT_Err_Could_Not_Find_Context;
354
355
    TT_Load_Context( exec, face, size );
356
357
    exec->callTop   = 0;
358
    exec->top       = 0;
359
360
    exec->period    = 64;
361
    exec->phase     = 0;
362
    exec->threshold = 0;
363
364
    exec->instruction_trap = FALSE;
365
    exec->F_dot_P = 0x10000L;
366
367
    {
368
      FT_Size_Metrics*  metrics    = &exec->metrics;
369
      TT_Size_Metrics*  tt_metrics = &exec->tt_metrics;
370
371
372
      metrics->x_ppem   = 0;
373
      metrics->y_ppem   = 0;
374
      metrics->x_scale  = 0;
375
      metrics->y_scale  = 0;
376
377
      tt_metrics->ppem  = 0;
378
      tt_metrics->scale = 0;
379
      tt_metrics->ratio = 0x10000L;
380
    }
381
382
    /* allow font program execution */
383
    TT_Set_CodeRange( exec,
384
                      tt_coderange_font,
385
                      face->font_program,
386
                      face->font_program_size );
387
388
    /* disable CVT and glyph programs coderange */
389
    TT_Clear_CodeRange( exec, tt_coderange_cvt );
390
    TT_Clear_CodeRange( exec, tt_coderange_glyph );
391
392
    if ( face->font_program_size > 0 )
393
    {
394
      error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
395
396
      if ( !error )
397
        error = face->interpreter( exec );
398
    }
399
    else
400
      error = TT_Err_Ok;
401
402
    if ( !error )
403
      TT_Save_Context( exec, size );
404
405
    if ( !size->debug )
406
      TT_Done_Context( exec );
407
408
    return error;
409
  }
410
411
412
  /*************************************************************************/
413
  /*                                                                       */
414
  /* <Function>                                                            */
415
  /*    tt_size_run_prep                                                   */
416
  /*                                                                       */
417
  /* <Description>                                                         */
418
  /*    Run the control value program                                      */
419
  /*                                                                       */
420
  /* <Input>                                                               */
421
  /*    size :: A handle to the size object.                               */
422
  /*                                                                       */
423
  /* <Return>                                                              */
424
  /*    FreeType error code.  0 means success.                             */
425
  /*                                                                       */
426
  FT_LOCAL_DEF( FT_Error )
427
  tt_size_run_prep( TT_Size  size )
428
  {
429
    TT_Face         face = (TT_Face)size->root.face;
430
    TT_ExecContext  exec;
431
    FT_Error        error;
432
433
434
    /* debugging instances have their own context */
435
    if ( size->debug )
436
      exec = size->context;
437
    else
438
      exec = TT_New_Context( face );
439
440
    if ( !exec )
441
      return TT_Err_Could_Not_Find_Context;
442
443
    TT_Load_Context( exec, face, size );
444
445
    exec->callTop = 0;
446
    exec->top     = 0;
447
448
    exec->instruction_trap = FALSE;
449
450
    TT_Set_CodeRange( exec,
451
                      tt_coderange_cvt,
452
                      face->cvt_program,
453
                      face->cvt_program_size );
454
455
    TT_Clear_CodeRange( exec, tt_coderange_glyph );
456
457
    if ( face->cvt_program_size > 0 )
458
    {
459
      error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
460
461
      if ( !error && !size->debug )
462
        error = face->interpreter( exec );
463
    }
464
    else
465
      error = TT_Err_Ok;
466
467
    /* save as default graphics state */
468
    size->GS = exec->GS;
469
470
    TT_Save_Context( exec, size );
471
472
    if ( !size->debug )
473
      TT_Done_Context( exec );
474
475
    return error;
476
  }
477
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
478
321
479
322
  /*************************************************************************/
480
  /*************************************************************************/
323
  /*                                                                       */
481
  /*                                                                       */
Lines 338-352 Link Here
338
  {
496
  {
339
    TT_Size   size  = (TT_Size)ttsize;
497
    TT_Size   size  = (TT_Size)ttsize;
340
    FT_Error  error = TT_Err_Ok;
498
    FT_Error  error = TT_Err_Ok;
341
342
343
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
499
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
344
345
    TT_Face    face   = (TT_Face)size->root.face;
500
    TT_Face    face   = (TT_Face)size->root.face;
346
    FT_Memory  memory = face->root.memory;
501
    FT_Memory  memory = face->root.memory;
347
    FT_Int     i;
502
    FT_Int     i;
348
503
349
    TT_ExecContext  exec;
350
    FT_UShort       n_twilight;
504
    FT_UShort       n_twilight;
351
    TT_MaxProfile*  maxp = &face->max_profile;
505
    TT_MaxProfile*  maxp = &face->max_profile;
352
506
Lines 387-403 Link Here
387
         FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
541
         FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
388
         FT_NEW_ARRAY( size->cvt,              size->cvt_size             ) ||
542
         FT_NEW_ARRAY( size->cvt,              size->cvt_size             ) ||
389
         FT_NEW_ARRAY( size->storage,          size->storage_size         ) )
543
         FT_NEW_ARRAY( size->storage,          size->storage_size         ) )
544
    {
545
      tt_size_done( ttsize );
390
546
391
      goto Fail_Memory;
547
      return error;
548
    }
392
549
393
    /* reserve twilight zone */
550
    /* reserve twilight zone */
394
    n_twilight = maxp->maxTwilightPoints;
551
    n_twilight = maxp->maxTwilightPoints;
552
553
    /* there are 4 phantom points (do we need this?) */
554
    n_twilight += 4;
555
395
    error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
556
    error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
396
    if ( error )
557
    if ( error )
397
      goto Fail_Memory;
558
    {
559
      tt_size_done( ttsize );
560
561
      return error;
562
    }
398
563
399
    size->twilight.n_points = n_twilight;
564
    size->twilight.n_points = n_twilight;
400
565
566
    size->GS = tt_default_graphics_state;
567
401
    /* set `face->interpreter' according to the debug hook present */
568
    /* set `face->interpreter' according to the debug hook present */
402
    {
569
    {
403
      FT_Library  library = face->root.driver->root.library;
570
      FT_Library  library = face->root.driver->root.library;
Lines 409-503 Link Here
409
        face->interpreter = (TT_Interpreter)TT_RunIns;
576
        face->interpreter = (TT_Interpreter)TT_RunIns;
410
    }
577
    }
411
578
412
    /* Fine, now execute the font program! */
579
    /* Fine, now run the font program! */
413
    exec = size->context;
580
    error = tt_size_run_fpgm( size );
414
    /* size objects used during debugging have their own context */
415
    if ( !size->debug )
416
      exec = TT_New_Context( face );
417
418
    if ( !exec )
419
    {
420
      error = TT_Err_Could_Not_Find_Context;
421
      goto Fail_Memory;
422
    }
423
424
    size->GS = tt_default_graphics_state;
425
    TT_Load_Context( exec, face, size );
426
427
    exec->callTop   = 0;
428
    exec->top       = 0;
429
430
    exec->period    = 64;
431
    exec->phase     = 0;
432
    exec->threshold = 0;
433
434
    {
435
      FT_Size_Metrics*  metrics    = &exec->metrics;
436
      TT_Size_Metrics*  tt_metrics = &exec->tt_metrics;
437
438
439
      metrics->x_ppem   = 0;
440
      metrics->y_ppem   = 0;
441
      metrics->x_scale  = 0;
442
      metrics->y_scale  = 0;
443
444
      tt_metrics->ppem  = 0;
445
      tt_metrics->scale = 0;
446
      tt_metrics->ratio = 0x10000L;
447
    }
448
581
449
    exec->instruction_trap = FALSE;
582
    if ( error )
450
583
      tt_size_done( ttsize );
451
    exec->cvtSize = size->cvt_size;
452
    exec->cvt     = size->cvt;
453
454
    exec->F_dot_P = 0x10000L;
455
456
    /* allow font program execution */
457
    TT_Set_CodeRange( exec,
458
                      tt_coderange_font,
459
                      face->font_program,
460
                      face->font_program_size );
461
462
    /* disable CVT and glyph programs coderange */
463
    TT_Clear_CodeRange( exec, tt_coderange_cvt );
464
    TT_Clear_CodeRange( exec, tt_coderange_glyph );
465
466
    if ( face->font_program_size > 0 )
467
    {
468
      error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
469
      if ( !error )
470
        error = face->interpreter( exec );
471
472
      if ( error )
473
        goto Fail_Exec;
474
    }
475
    else
476
      error = TT_Err_Ok;
477
478
    TT_Save_Context( exec, size );
479
480
    if ( !size->debug )
481
      TT_Done_Context( exec );
482
584
483
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
585
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
484
586
485
    size->ttmetrics.valid = FALSE;
587
    size->ttmetrics.valid = FALSE;
486
    return error;
487
488
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
489
490
  Fail_Exec:
491
    if ( !size->debug )
492
      TT_Done_Context( exec );
493
494
  Fail_Memory:
495
588
496
    tt_size_done( ttsize );
497
    return error;
589
    return error;
498
499
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
500
501
  }
590
  }
502
591
503
592
Lines 516-524 Link Here
516
  tt_size_done( FT_Size  ttsize )           /* TT_Size */
605
  tt_size_done( FT_Size  ttsize )           /* TT_Size */
517
  {
606
  {
518
    TT_Size    size = (TT_Size)ttsize;
607
    TT_Size    size = (TT_Size)ttsize;
519
520
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
608
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
521
522
    FT_Memory  memory = size->root.face->memory;
609
    FT_Memory  memory = size->root.face->memory;
523
610
524
611
Lines 625-634 Link Here
625
#endif
712
#endif
626
713
627
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
714
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
628
629
    {
715
    {
630
      TT_ExecContext  exec;
716
      FT_UInt  i;
631
      FT_UInt         i, j;
632
717
633
718
634
      /* Scale the cvt values to the new ppem.          */
719
      /* Scale the cvt values to the new ppem.          */
Lines 637-648 Link Here
637
        size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
722
        size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
638
723
639
      /* All twilight points are originally zero */
724
      /* All twilight points are originally zero */
640
      for ( j = 0; j < (FT_UInt)size->twilight.n_points; j++ )
725
      for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
641
      {
726
      {
642
        size->twilight.org[j].x = 0;
727
        size->twilight.org[i].x = 0;
643
        size->twilight.org[j].y = 0;
728
        size->twilight.org[i].y = 0;
644
        size->twilight.cur[j].x = 0;
729
        size->twilight.cur[i].x = 0;
645
        size->twilight.cur[j].y = 0;
730
        size->twilight.cur[i].y = 0;
646
      }
731
      }
647
732
648
      /* clear storage area */
733
      /* clear storage area */
Lines 651-703 Link Here
651
736
652
      size->GS = tt_default_graphics_state;
737
      size->GS = tt_default_graphics_state;
653
738
654
      /* get execution context and run prep program */
739
      error = tt_size_run_prep( size );
655
      if ( size->debug )
656
        exec = size->context;
657
      else
658
        exec = TT_New_Context( face );
659
      /* debugging instances have their own context */
660
661
      if ( !exec )
662
        return TT_Err_Could_Not_Find_Context;
663
664
      TT_Load_Context( exec, face, size );
665
666
      TT_Set_CodeRange( exec,
667
                        tt_coderange_cvt,
668
                        face->cvt_program,
669
                        face->cvt_program_size );
670
671
      TT_Clear_CodeRange( exec, tt_coderange_glyph );
672
673
      exec->instruction_trap = FALSE;
674
675
      exec->top     = 0;
676
      exec->callTop = 0;
677
678
      if ( face->cvt_program_size > 0 )
679
      {
680
        error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
681
        if ( error )
682
          goto End;
683
684
        if ( !size->debug )
685
          error = face->interpreter( exec );
686
      }
687
      else
688
        error = TT_Err_Ok;
689
690
      size->GS = exec->GS;
691
      /* save default graphics state */
692
693
    End:
694
      TT_Save_Context( exec, size );
695
696
      if ( !size->debug )
697
        TT_Done_Context( exec );
698
      /* debugging instances keep their context */
699
    }
740
    }
700
701
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
741
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
702
742
703
    if ( !error )
743
    if ( !error )
(-)freetype2/src/truetype/ttobjs.h (-1 / +12 lines)
Lines 316-322 FT_BEGIN_HEADER Link Here
316
  {
316
  {
317
    FT_SizeRec         root;
317
    FT_SizeRec         root;
318
318
319
    FT_Size_Metrics    metrics; /* slightly different from the root metrics */
319
    /* we have our own copy of metrics so that we can modify */
320
    /* it without affecting auto-hinting (when used)         */
321
    FT_Size_Metrics    metrics;
322
320
    TT_Size_Metrics    ttmetrics;
323
    TT_Size_Metrics    ttmetrics;
321
324
322
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
325
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
Lines 413-418 FT_BEGIN_HEADER Link Here
413
416
414
  FT_LOCAL( void )
417
  FT_LOCAL( void )
415
  tt_size_done( FT_Size  ttsize );          /* TT_Size */
418
  tt_size_done( FT_Size  ttsize );          /* TT_Size */
419
420
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
421
  FT_LOCAL( FT_Error )
422
  tt_size_run_fpgm( TT_Size  size );
423
424
  FT_LOCAL( FT_Error )
425
  tt_size_run_prep( TT_Size  size );
426
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
416
427
417
  FT_LOCAL( FT_Error )
428
  FT_LOCAL( FT_Error )
418
  tt_size_reset( TT_Size  size );
429
  tt_size_reset( TT_Size  size );
(-)freetype2/src/type1/t1gload.c (-28 / +8 lines)
Lines 315-325 Link Here
315
        glyph->root.linearHoriAdvance           = decoder.builder.advance.x;
315
        glyph->root.linearHoriAdvance           = decoder.builder.advance.x;
316
        glyph->root.internal->glyph_transformed = 0;
316
        glyph->root.internal->glyph_transformed = 0;
317
317
318
        /* make up vertical metrics */
318
        metrics->vertAdvance          = 0;
319
        metrics->vertBearingX = 0;
320
        metrics->vertBearingY = 0;
321
        metrics->vertAdvance  = 0;
322
323
        glyph->root.linearVertAdvance = 0;
319
        glyph->root.linearVertAdvance = 0;
324
320
325
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
321
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
Lines 363-404 Link Here
363
              vec->y = FT_MulFix( vec->y, y_scale );
359
              vec->y = FT_MulFix( vec->y, y_scale );
364
            }
360
            }
365
361
366
          FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
367
368
          /* Then scale the metrics */
362
          /* Then scale the metrics */
369
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
363
          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
370
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
364
          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
371
372
          metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
373
          metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
374
375
          if ( hinting )
376
          {
377
            metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance );
378
            metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance );
379
380
            metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX );
381
            metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY );
382
          }
383
        }
365
        }
384
366
385
        /* compute the other metrics */
367
        /* compute the other metrics */
386
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
368
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
387
369
388
        /* grid fit the bounding box if necessary */
389
        if ( hinting )
390
        {
391
          cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
392
          cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
393
          cbox.xMax = FT_PIX_CEIL( cbox.xMax );
394
          cbox.yMax = FT_PIX_CEIL( cbox.yMax );
395
        }
396
397
        metrics->width  = cbox.xMax - cbox.xMin;
370
        metrics->width  = cbox.xMax - cbox.xMin;
398
        metrics->height = cbox.yMax - cbox.yMin;
371
        metrics->height = cbox.yMax - cbox.yMin;
399
372
400
        metrics->horiBearingX = cbox.xMin;
373
        metrics->horiBearingX = cbox.xMin;
401
        metrics->horiBearingY = cbox.yMax;
374
        metrics->horiBearingY = cbox.yMax;
375
376
        /* make up vertical ones */
377
        metrics->vertBearingX = 0;
378
        metrics->vertBearingY = 0;
379
380
        if ( hinting )
381
          ft_glyphslot_grid_fit_metrics( &glyph->root );
402
      }
382
      }
403
383
404
      /* Set control data to the glyph charstrings.  Note that this is */
384
      /* Set control data to the glyph charstrings.  Note that this is */

Return to bug 128760