freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] 2 commits: [truetype] Clean up zeroing


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] 2 commits: [truetype] Clean up zeroing and local variables.
Date: Sat, 18 Mar 2023 03:42:47 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • ef636696
    by Alexei Podtelezhnikov at 2023-03-17T23:25:45-04:00
    [truetype] Clean up zeroing and local variables.
    
    * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Avoid zeroing.
    (load_truetype_glyph): Avoid zeroing and clean local variables.
    
  • 8fc6df10
    by Alexei Podtelezhnikov at 2023-03-17T23:35:10-04:00
    * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Use for-loop.
    
    Even though we never call `TT_Load_Simple_Glyph` with zero contours,
    out of abundance of precaution, let's handle this case properly.
    

1 changed file:

Changes:

  • src/truetype/ttgload.c
    ... ... @@ -388,7 +388,7 @@
    388 388
         cont_limit = cont + n_contours;
    
    389 389
     
    
    390 390
         last = -1;
    
    391
    -    do
    
    391
    +    for ( ; cont < cont_limit; cont++ )
    
    392 392
         {
    
    393 393
           *cont = FT_NEXT_SHORT( p );
    
    394 394
     
    
    ... ... @@ -396,7 +396,7 @@
    396 396
             goto Invalid_Outline;
    
    397 397
     
    
    398 398
           last = *cont;
    
    399
    -    } while ( ++cont < cont_limit );
    
    399
    +    }
    
    400 400
     
    
    401 401
         n_points = last + 1;
    
    402 402
     
    
    ... ... @@ -938,7 +938,7 @@
    938 938
     
    
    939 939
         if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) )
    
    940 940
         {
    
    941
    -      if ( FT_NEW_ARRAY( unrounded, n_points ) )
    
    941
    +      if ( FT_QNEW_ARRAY( unrounded, n_points ) )
    
    942 942
             goto Exit;
    
    943 943
     
    
    944 944
           /* Deltas apply to the unscaled data. */
    
    ... ... @@ -1839,10 +1839,7 @@
    1839 1839
             short        i, limit;
    
    1840 1840
             FT_SubGlyph  subglyph;
    
    1841 1841
     
    
    1842
    -        FT_Outline  outline;
    
    1843
    -        FT_Vector*  points    = NULL;
    
    1844
    -        char*       tags      = NULL;
    
    1845
    -        short*      contours  = NULL;
    
    1842
    +        FT_Outline  outline = { 0, 0, NULL, NULL, NULL, 0 };
    
    1846 1843
             FT_Vector*  unrounded = NULL;
    
    1847 1844
     
    
    1848 1845
     
    
    ... ... @@ -1850,18 +1847,14 @@
    1850 1847
     
    
    1851 1848
             /* construct an outline structure for              */
    
    1852 1849
             /* communication with `TT_Vary_Apply_Glyph_Deltas' */
    
    1853
    -        outline.n_contours = outline.n_points = limit;
    
    1854
    -
    
    1855
    -        outline.points   = NULL;
    
    1856
    -        outline.tags     = NULL;
    
    1857
    -        outline.contours = NULL;
    
    1858
    -
    
    1859
    -        if ( FT_NEW_ARRAY( points, limit + 4 )    ||
    
    1860
    -             FT_NEW_ARRAY( tags, limit + 4 )      ||
    
    1861
    -             FT_NEW_ARRAY( contours, limit + 4 )  ||
    
    1862
    -             FT_NEW_ARRAY( unrounded, limit + 4 ) )
    
    1850
    +        if ( FT_QNEW_ARRAY( outline.points, limit + 4 ) ||
    
    1851
    +             FT_QNEW_ARRAY( outline.tags, limit )       ||
    
    1852
    +             FT_QNEW_ARRAY( outline.contours, limit )   ||
    
    1853
    +             FT_QNEW_ARRAY( unrounded, limit + 4 )      )
    
    1863 1854
               goto Exit1;
    
    1864 1855
     
    
    1856
    +        outline.n_contours = outline.n_points = limit;
    
    1857
    +
    
    1865 1858
             subglyph = gloader->current.subglyphs;
    
    1866 1859
     
    
    1867 1860
             for ( i = 0; i < limit; i++, subglyph++ )
    
    ... ... @@ -1869,20 +1862,16 @@
    1869 1862
               /* applying deltas for anchor points doesn't make sense, */
    
    1870 1863
               /* but we don't have to specially check this since       */
    
    1871 1864
               /* unused delta values are zero anyways                  */
    
    1872
    -          points[i].x = subglyph->arg1;
    
    1873
    -          points[i].y = subglyph->arg2;
    
    1874
    -          tags[i]     = 1;
    
    1875
    -          contours[i] = i;
    
    1865
    +          outline.points[i].x = subglyph->arg1;
    
    1866
    +          outline.points[i].y = subglyph->arg2;
    
    1867
    +          outline.tags[i]     = ON_CURVE_POINT;
    
    1868
    +          outline.contours[i] = i;
    
    1876 1869
             }
    
    1877 1870
     
    
    1878
    -        points[i++] = loader->pp1;
    
    1879
    -        points[i++] = loader->pp2;
    
    1880
    -        points[i++] = loader->pp3;
    
    1881
    -        points[i  ] = loader->pp4;
    
    1882
    -
    
    1883
    -        outline.points   = points;
    
    1884
    -        outline.tags     = tags;
    
    1885
    -        outline.contours = contours;
    
    1871
    +        outline.points[i++] = loader->pp1;
    
    1872
    +        outline.points[i++] = loader->pp2;
    
    1873
    +        outline.points[i++] = loader->pp3;
    
    1874
    +        outline.points[i  ] = loader->pp4;
    
    1886 1875
     
    
    1887 1876
             /* this call provides additional offsets */
    
    1888 1877
             /* for each component's translation      */
    
    ... ... @@ -1897,8 +1886,8 @@
    1897 1886
             {
    
    1898 1887
               if ( subglyph->flags & ARGS_ARE_XY_VALUES )
    
    1899 1888
               {
    
    1900
    -            subglyph->arg1 = (FT_Int16)points[i].x;
    
    1901
    -            subglyph->arg2 = (FT_Int16)points[i].y;
    
    1889
    +            subglyph->arg1 = (FT_Int16)outline.points[i].x;
    
    1890
    +            subglyph->arg2 = (FT_Int16)outline.points[i].y;
    
    1902 1891
               }
    
    1903 1892
             }
    
    1904 1893
     
    


  • reply via email to

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