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 phantom poi


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][clean-gxvar] [truetype/GX] Clean up phantom point accounting.
Date: Sat, 18 Jun 2022 03:35:56 +0000

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

Commits:

  • c7fd0b97
    by Alexei Podtelezhnikov at 2022-06-17T23:32:56-04:00
    [truetype/GX] Clean up phantom point accounting.
    
    This formalizes that the phantom points appended in the outline
    do not increase its point count, nor are they tagged or included
    in any additional contours.  Only their coordinates are stored.
    They are counted in the glyph zone, however.
    
    * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Infer `n_points`
    from the outline size plus four phantom points.
    * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Remove this
    argument.
    * src/truetype/ttgload.c (tt_prepare_zone): Add phantom four.
    (TT_Process_Simple_Glyph, load_truetype_glyph): Update all callers.
    

3 changed files:

Changes:

  • src/truetype/ttgload.c
    ... ... @@ -801,7 +801,7 @@
    801 801
                        FT_UInt       start_point,
    
    802 802
                        FT_UInt       start_contour )
    
    803 803
       {
    
    804
    -    zone->n_points    = (FT_UShort)load->outline.n_points -
    
    804
    +    zone->n_points    = (FT_UShort)load->outline.n_points + 4 -
    
    805 805
                               (FT_UShort)start_point;
    
    806 806
         zone->n_contours  = load->outline.n_contours -
    
    807 807
                               (FT_Short)start_contour;
    
    ... ... @@ -970,11 +970,6 @@
    970 970
         outline->points[n_points + 2] = loader->pp3;
    
    971 971
         outline->points[n_points + 3] = loader->pp4;
    
    972 972
     
    
    973
    -    outline->tags[n_points    ] = 0;
    
    974
    -    outline->tags[n_points + 1] = 0;
    
    975
    -    outline->tags[n_points + 2] = 0;
    
    976
    -    outline->tags[n_points + 3] = 0;
    
    977
    -
    
    978 973
         n_points += 4;
    
    979 974
     
    
    980 975
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    ... ... @@ -987,8 +982,7 @@
    987 982
           /* Deltas apply to the unscaled data. */
    
    988 983
           error = TT_Vary_Apply_Glyph_Deltas( loader,
    
    989 984
                                               outline,
    
    990
    -                                          unrounded,
    
    991
    -                                          (FT_UInt)n_points );
    
    985
    +                                          unrounded );
    
    992 986
           if ( error )
    
    993 987
             goto Exit;
    
    994 988
         }
    
    ... ... @@ -1000,7 +994,7 @@
    1000 994
           tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
    
    1001 995
     
    
    1002 996
           FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
    
    1003
    -                     loader->zone.n_points + 4 );
    
    997
    +                     loader->zone.n_points );
    
    1004 998
         }
    
    1005 999
     
    
    1006 1000
         {
    
    ... ... @@ -1142,11 +1136,7 @@
    1142 1136
         }
    
    1143 1137
     
    
    1144 1138
         if ( IS_HINTED( loader->load_flags ) )
    
    1145
    -    {
    
    1146
    -      loader->zone.n_points += 4;
    
    1147
    -
    
    1148 1139
           error = TT_Hint_Glyph( loader, 0 );
    
    1149
    -    }
    
    1150 1140
     
    
    1151 1141
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    1152 1142
       Exit:
    
    ... ... @@ -1359,11 +1349,6 @@
    1359 1349
         outline->points[outline->n_points + 2] = loader->pp3;
    
    1360 1350
         outline->points[outline->n_points + 3] = loader->pp4;
    
    1361 1351
     
    
    1362
    -    outline->tags[outline->n_points    ] = 0;
    
    1363
    -    outline->tags[outline->n_points + 1] = 0;
    
    1364
    -    outline->tags[outline->n_points + 2] = 0;
    
    1365
    -    outline->tags[outline->n_points + 3] = 0;
    
    1366
    -
    
    1367 1352
     #ifdef TT_USE_BYTECODE_INTERPRETER
    
    1368 1353
     
    
    1369 1354
         {
    
    ... ... @@ -1422,11 +1407,9 @@
    1422 1407
     
    
    1423 1408
         /* Some points are likely touched during execution of  */
    
    1424 1409
         /* instructions on components.  So let's untouch them. */
    
    1425
    -    for ( i = 0; i < loader->zone.n_points; i++ )
    
    1410
    +    for ( i = 0; i < loader->zone.n_points - 4; i++ )
    
    1426 1411
           loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
    
    1427 1412
     
    
    1428
    -    loader->zone.n_points += 4;
    
    1429
    -
    
    1430 1413
         return TT_Hint_Glyph( loader, 1 );
    
    1431 1414
       }
    
    1432 1415
     
    
    ... ... @@ -1747,35 +1730,27 @@
    1747 1730
             /* a small outline structure with four elements for */
    
    1748 1731
             /* communication with `TT_Vary_Apply_Glyph_Deltas'  */
    
    1749 1732
             FT_Vector   points[4];
    
    1750
    -        char        tags[4]     = { 1, 1, 1, 1 };
    
    1751
    -        short       contours[4] = { 0, 1, 2, 3 };
    
    1752 1733
             FT_Outline  outline;
    
    1753 1734
     
    
    1754 1735
             /* unrounded values */
    
    1755 1736
             FT_Vector  unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
    
    1756 1737
     
    
    1757 1738
     
    
    1758
    -        points[0].x = loader->pp1.x;
    
    1759
    -        points[0].y = loader->pp1.y;
    
    1760
    -        points[1].x = loader->pp2.x;
    
    1761
    -        points[1].y = loader->pp2.y;
    
    1762
    -
    
    1763
    -        points[2].x = loader->pp3.x;
    
    1764
    -        points[2].y = loader->pp3.y;
    
    1765
    -        points[3].x = loader->pp4.x;
    
    1766
    -        points[3].y = loader->pp4.y;
    
    1739
    +        points[0] = loader->pp1;
    
    1740
    +        points[1] = loader->pp2;
    
    1741
    +        points[2] = loader->pp3;
    
    1742
    +        points[3] = loader->pp4;
    
    1767 1743
     
    
    1768
    -        outline.n_points   = 4;
    
    1769
    -        outline.n_contours = 4;
    
    1744
    +        outline.n_points   = 0;
    
    1745
    +        outline.n_contours = 0;
    
    1770 1746
             outline.points     = points;
    
    1771
    -        outline.tags       = tags;
    
    1772
    -        outline.contours   = contours;
    
    1747
    +        outline.tags       = NULL;
    
    1748
    +        outline.contours   = NULL;
    
    1773 1749
     
    
    1774 1750
             /* this must be done before scaling */
    
    1775 1751
             error = TT_Vary_Apply_Glyph_Deltas( loader,
    
    1776 1752
                                                 &outline,
    
    1777
    -                                            unrounded,
    
    1778
    -                                            (FT_UInt)outline.n_points );
    
    1753
    +                                            unrounded );
    
    1779 1754
             if ( error )
    
    1780 1755
               goto Exit;
    
    1781 1756
           }
    
    ... ... @@ -1925,17 +1900,16 @@
    1925 1900
     
    
    1926 1901
             /* construct an outline structure for              */
    
    1927 1902
             /* communication with `TT_Vary_Apply_Glyph_Deltas' */
    
    1928
    -        outline.n_points   = (short)( gloader->current.num_subglyphs + 4 );
    
    1929
    -        outline.n_contours = outline.n_points;
    
    1903
    +        outline.n_contours = outline.n_points = limit;
    
    1930 1904
     
    
    1931 1905
             outline.points   = NULL;
    
    1932 1906
             outline.tags     = NULL;
    
    1933 1907
             outline.contours = NULL;
    
    1934 1908
     
    
    1935
    -        if ( FT_NEW_ARRAY( points, outline.n_points )    ||
    
    1936
    -             FT_NEW_ARRAY( tags, outline.n_points )      ||
    
    1937
    -             FT_NEW_ARRAY( contours, outline.n_points )  ||
    
    1938
    -             FT_NEW_ARRAY( unrounded, outline.n_points ) )
    
    1909
    +        if ( FT_NEW_ARRAY( points, limit + 4 )    ||
    
    1910
    +             FT_NEW_ARRAY( tags, limit + 4 )      ||
    
    1911
    +             FT_NEW_ARRAY( contours, limit + 4 )  ||
    
    1912
    +             FT_NEW_ARRAY( unrounded, limit + 4 ) )
    
    1939 1913
               goto Exit1;
    
    1940 1914
     
    
    1941 1915
             subglyph = gloader->current.subglyphs;
    
    ... ... @@ -1951,28 +1925,10 @@
    1951 1925
               contours[i] = i;
    
    1952 1926
             }
    
    1953 1927
     
    
    1954
    -        points[i].x = loader->pp1.x;
    
    1955
    -        points[i].y = loader->pp1.y;
    
    1956
    -        tags[i]     = 1;
    
    1957
    -        contours[i] = i;
    
    1958
    -
    
    1959
    -        i++;
    
    1960
    -        points[i].x = loader->pp2.x;
    
    1961
    -        points[i].y = loader->pp2.y;
    
    1962
    -        tags[i]     = 1;
    
    1963
    -        contours[i] = i;
    
    1964
    -
    
    1965
    -        i++;
    
    1966
    -        points[i].x = loader->pp3.x;
    
    1967
    -        points[i].y = loader->pp3.y;
    
    1968
    -        tags[i]     = 1;
    
    1969
    -        contours[i] = i;
    
    1970
    -
    
    1971
    -        i++;
    
    1972
    -        points[i].x = loader->pp4.x;
    
    1973
    -        points[i].y = loader->pp4.y;
    
    1974
    -        tags[i]     = 1;
    
    1975
    -        contours[i] = i;
    
    1928
    +        points[i++] = loader->pp1;
    
    1929
    +        points[i++] = loader->pp2;
    
    1930
    +        points[i++] = loader->pp3;
    
    1931
    +        points[i  ] = loader->pp4;
    
    1976 1932
     
    
    1977 1933
             outline.points   = points;
    
    1978 1934
             outline.tags     = tags;
    
    ... ... @@ -1980,11 +1936,9 @@
    1980 1936
     
    
    1981 1937
             /* this call provides additional offsets */
    
    1982 1938
             /* for each component's translation      */
    
    1983
    -        if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
    
    1984
    -                             loader,
    
    1985
    -                             &outline,
    
    1986
    -                             unrounded,
    
    1987
    -                             (FT_UInt)outline.n_points ) ) )
    
    1939
    +        if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
    
    1940
    +                                                       &outline,
    
    1941
    +                                                       unrounded ) ) )
    
    1988 1942
               goto Exit1;
    
    1989 1943
     
    
    1990 1944
             subglyph = gloader->current.subglyphs;
    

  • src/truetype/ttgxvar.c
    ... ... @@ -3839,25 +3839,20 @@
    3839 3839
        *     An array with `n_points' elements that is filled with unrounded
    
    3840 3840
        *     point coordinates (in 26.6 format).
    
    3841 3841
        *
    
    3842
    -   * @Input
    
    3843
    -   *   n_points ::
    
    3844
    -   *     The number of the points in the glyph, including
    
    3845
    -   *     phantom points.
    
    3846
    -   *
    
    3847 3842
        * @Return:
    
    3848 3843
        *   FreeType error code.  0 means success.
    
    3849 3844
        */
    
    3850 3845
       FT_LOCAL_DEF( FT_Error )
    
    3851 3846
       TT_Vary_Apply_Glyph_Deltas( TT_Loader    loader,
    
    3852 3847
                                   FT_Outline*  outline,
    
    3853
    -                              FT_Vector*   unrounded,
    
    3854
    -                              FT_UInt      n_points )
    
    3848
    +                              FT_Vector*   unrounded )
    
    3855 3849
       {
    
    3856 3850
         FT_Error   error;
    
    3857 3851
         TT_Face    face = loader->face;
    
    3858 3852
         FT_Stream  stream = face->root.stream;
    
    3859 3853
         FT_Memory  memory = stream->memory;
    
    3860 3854
         FT_UInt    glyph_index = loader->glyph_index;
    
    3855
    +    FT_UInt    n_points = (FT_UInt)outline->n_points + 4;
    
    3861 3856
     
    
    3862 3857
         FT_Vector*  points_org = NULL;  /* coordinates in 16.16 format */
    
    3863 3858
         FT_Vector*  points_out = NULL;  /* coordinates in 16.16 format */
    

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


  • reply via email to

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