freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][clean-gxvar] [truetype/GX] Clean up advance adj


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][clean-gxvar] [truetype/GX] Clean up advance adjustment.
Date: Wed, 15 Jun 2022 04:25:09 +0000

Alexei Podtelezhnikov pushed to branch clean-gxvar at FreeType / FreeType

Commits:

  • e94acf35
    by Alexei Podtelezhnikov at 2022-06-15T00:22:17-04:00
    [truetype/GX] Clean up advance adjustment.
    
    * src/truetype/ttgload.c (TT_Process_Simple_Glyph, load_truetype_glyph):
    Move the advance adjustment from here...
    * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here and
    simplify arguments.
    * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Update prototype
    with fewer arguments.
    

3 changed files:

Changes:

  • src/truetype/ttgload.c
    ... ... @@ -985,24 +985,9 @@
    985 985
             goto Exit;
    
    986 986
     
    
    987 987
           /* Deltas apply to the unscaled data. */
    
    988
    -      error = TT_Vary_Apply_Glyph_Deltas( loader->face,
    
    989
    -                                          loader->glyph_index,
    
    988
    +      error = TT_Vary_Apply_Glyph_Deltas( loader,
    
    990 989
                                               outline,
    
    991
    -                                          unrounded,
    
    992
    -                                          (FT_UInt)n_points );
    
    993
    -
    
    994
    -      /* recalculate linear horizontal and vertical advances */
    
    995
    -      /* if we don't have HVAR and VVAR, respectively        */
    
    996
    -
    
    997
    -      /* XXX: change all FreeType modules to store `linear' and `vadvance' */
    
    998
    -      /*      in 26.6 format before the `base' module scales them to 16.16 */
    
    999
    -      if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    
    1000
    -        loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
    
    1001
    -                                       unrounded[n_points - 4].x ) / 64;
    
    1002
    -      if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    
    1003
    -        loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x -
    
    1004
    -                                         unrounded[n_points - 2].x ) / 64;
    
    1005
    -
    
    990
    +                                          unrounded );
    
    1006 991
           if ( error )
    
    1007 992
             goto Exit;
    
    1008 993
         }
    
    ... ... @@ -1779,18 +1764,16 @@
    1779 1764
             points[3].x = loader->pp4.x;
    
    1780 1765
             points[3].y = loader->pp4.y;
    
    1781 1766
     
    
    1782
    -        outline.n_points   = 4;
    
    1783
    -        outline.n_contours = 4;
    
    1767
    +        outline.n_points   = 0;
    
    1768
    +        outline.n_contours = 0;
    
    1784 1769
             outline.points     = points;
    
    1785 1770
             outline.tags       = tags;
    
    1786 1771
             outline.contours   = contours;
    
    1787 1772
     
    
    1788 1773
             /* this must be done before scaling */
    
    1789
    -        error = TT_Vary_Apply_Glyph_Deltas( loader->face,
    
    1790
    -                                            glyph_index,
    
    1774
    +        error = TT_Vary_Apply_Glyph_Deltas( loader,
    
    1791 1775
                                                 &outline,
    
    1792
    -                                            unrounded,
    
    1793
    -                                            (FT_UInt)outline.n_points );
    
    1776
    +                                            unrounded );
    
    1794 1777
             if ( error )
    
    1795 1778
               goto Exit;
    
    1796 1779
     
    
    ... ... @@ -1803,15 +1786,6 @@
    1803 1786
             loader->pp3.y = points[2].y;
    
    1804 1787
             loader->pp4.x = points[3].x;
    
    1805 1788
             loader->pp4.y = points[3].y;
    
    1806
    -
    
    1807
    -        /* recalculate linear horizontal and vertical advances */
    
    1808
    -        /* if we don't have HVAR and VVAR, respectively        */
    
    1809
    -        if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    
    1810
    -          loader->linear = FT_PIX_ROUND( unrounded[1].x -
    
    1811
    -                                         unrounded[0].x ) / 64;
    
    1812
    -        if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    
    1813
    -          loader->vadvance = FT_PIX_ROUND( unrounded[3].x -
    
    1814
    -                                           unrounded[2].x ) / 64;
    
    1815 1789
           }
    
    1816 1790
     
    
    1817 1791
     #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
    
    ... ... @@ -1959,7 +1933,7 @@
    1959 1933
     
    
    1960 1934
             /* construct an outline structure for              */
    
    1961 1935
             /* communication with `TT_Vary_Apply_Glyph_Deltas' */
    
    1962
    -        outline.n_points   = (short)( gloader->current.num_subglyphs + 4 );
    
    1936
    +        outline.n_points   = (short)( gloader->current.num_subglyphs );
    
    1963 1937
             outline.n_contours = outline.n_points;
    
    1964 1938
     
    
    1965 1939
             outline.points   = NULL;
    
    ... ... @@ -2015,11 +1989,9 @@
    2015 1989
             /* this call provides additional offsets */
    
    2016 1990
             /* for each component's translation      */
    
    2017 1991
             if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
    
    2018
    -                             face,
    
    2019
    -                             glyph_index,
    
    1992
    +                             loader,
    
    2020 1993
                                  &outline,
    
    2021
    -                             unrounded,
    
    2022
    -                             (FT_UInt)outline.n_points ) ) )
    
    1994
    +                             unrounded ) ) )
    
    2023 1995
               goto Exit1;
    
    2024 1996
     
    
    2025 1997
             subglyph = gloader->current.subglyphs;
    
    ... ... @@ -2043,17 +2015,6 @@
    2043 2015
             loader->pp4.x = points[i + 3].x;
    
    2044 2016
             loader->pp4.y = points[i + 3].y;
    
    2045 2017
     
    
    2046
    -        /* recalculate linear horizontal and vertical advances */
    
    2047
    -        /* if we don't have HVAR and VVAR, respectively        */
    
    2048
    -        if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    
    2049
    -          loader->linear =
    
    2050
    -            FT_PIX_ROUND( unrounded[outline.n_points - 3].x -
    
    2051
    -                          unrounded[outline.n_points - 4].x ) / 64;
    
    2052
    -        if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    
    2053
    -          loader->vadvance =
    
    2054
    -            FT_PIX_ROUND( unrounded[outline.n_points - 1].x -
    
    2055
    -                          unrounded[outline.n_points - 2].x ) / 64;
    
    2056
    -
    
    2057 2018
           Exit1:
    
    2058 2019
             FT_FREE( outline.points );
    
    2059 2020
             FT_FREE( outline.tags );
    

  • src/truetype/ttgxvar.c
    ... ... @@ -3827,20 +3827,12 @@
    3827 3827
        * @Description:
    
    3828 3828
        *   Apply the appropriate deltas to the current glyph.
    
    3829 3829
        *
    
    3830
    -   * @Input:
    
    3831
    -   *   face ::
    
    3832
    -   *     A handle to the target face object.
    
    3833
    -   *
    
    3834
    -   *   glyph_index ::
    
    3835
    -   *     The index of the glyph being modified.
    
    3836
    -   *
    
    3837
    -   *   n_points ::
    
    3838
    -   *     The number of the points in the glyph, including
    
    3839
    -   *     phantom points.
    
    3840
    -   *
    
    3841 3830
        * @InOut:
    
    3831
    +   *   loader ::
    
    3832
    +   *     A handle to the loader object.
    
    3833
    +   *
    
    3842 3834
        *   outline ::
    
    3843
    -   *     The outline to change.
    
    3835
    +   *     The outline to change, with appended phantom points.
    
    3844 3836
        *
    
    3845 3837
        * @Output:
    
    3846 3838
        *   unrounded ::
    
    ... ... @@ -3851,15 +3843,16 @@
    3851 3843
        *   FreeType error code.  0 means success.
    
    3852 3844
        */
    
    3853 3845
       FT_LOCAL_DEF( FT_Error )
    
    3854
    -  TT_Vary_Apply_Glyph_Deltas( TT_Face      face,
    
    3855
    -                              FT_UInt      glyph_index,
    
    3846
    +  TT_Vary_Apply_Glyph_Deltas( TT_Loader    loader,
    
    3856 3847
                                   FT_Outline*  outline,
    
    3857
    -                              FT_Vector*   unrounded,
    
    3858
    -                              FT_UInt      n_points )
    
    3848
    +                              FT_Vector*   unrounded )
    
    3859 3849
       {
    
    3860 3850
         FT_Error   error;
    
    3851
    +    TT_Face    face = loader->face;
    
    3861 3852
         FT_Stream  stream = face->root.stream;
    
    3862 3853
         FT_Memory  memory = stream->memory;
    
    3854
    +    FT_UInt    glyph_index = loader->glyph_index;
    
    3855
    +    FT_UInt    n_points = (FT_UInt)outline->n_points + 4;
    
    3863 3856
     
    
    3864 3857
         FT_Vector*  points_org = NULL;  /* coordinates in 16.16 format */
    
    3865 3858
         FT_Vector*  points_out = NULL;  /* coordinates in 16.16 format */
    
    ... ... @@ -4255,6 +4248,15 @@
    4255 4248
           outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
    
    4256 4249
         }
    
    4257 4250
     
    
    4251
    +    /* recalculate linear horizontal and vertical advances */
    
    4252
    +    /* if we don't have HVAR and VVAR, respectively        */
    
    4253
    +    if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    
    4254
    +      loader->linear   = FT_PIX_ROUND( unrounded[n_points - 3].x -
    
    4255
    +                                       unrounded[n_points - 4].x ) / 64;
    
    4256
    +    if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    
    4257
    +      loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x -
    
    4258
    +                                       unrounded[n_points - 2].x ) / 64;
    
    4259
    +
    
    4258 4260
       Fail3:
    
    4259 4261
         FT_FREE( point_deltas_x );
    
    4260 4262
         FT_FREE( point_deltas_y );
    

  • src/truetype/ttgxvar.h
    ... ... @@ -361,11 +361,9 @@ FT_BEGIN_HEADER
    361 361
     
    
    362 362
     
    
    363 363
       FT_LOCAL( FT_Error )
    
    364
    -  TT_Vary_Apply_Glyph_Deltas( TT_Face      face,
    
    365
    -                              FT_UInt      glyph_index,
    
    364
    +  TT_Vary_Apply_Glyph_Deltas( TT_Loader    loader,
    
    366 365
                                   FT_Outline*  outline,
    
    367
    -                              FT_Vector*   unrounded,
    
    368
    -                              FT_UInt      n_points );
    
    366
    +                              FT_Vector*   unrounded );
    
    369 367
     
    
    370 368
       FT_LOCAL( FT_Error )
    
    371 369
       tt_hadvance_adjust( TT_Face  face,
    


  • reply via email to

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