Alexei Podtelezhnikov pushed to branch clean-gxvar at FreeType / FreeType
Commits:
-
a94b275c
by Alexei Podtelezhnikov at 2022-06-16T22:48:25-04:00
-
8bbb1c77
by Alexei Podtelezhnikov at 2022-06-17T13:43:45-04:00
3 changed files:
Changes:
... | ... | @@ -987,8 +987,7 @@ |
987 | 987 | /* Deltas apply to the unscaled data. */
|
988 | 988 | error = TT_Vary_Apply_Glyph_Deltas( loader,
|
989 | 989 | outline,
|
990 | - unrounded,
|
|
991 | - (FT_UInt)n_points );
|
|
990 | + unrounded );
|
|
992 | 991 | if ( error )
|
993 | 992 | goto Exit;
|
994 | 993 | }
|
... | ... | @@ -1747,8 +1746,6 @@ |
1747 | 1746 | /* a small outline structure with four elements for */
|
1748 | 1747 | /* communication with `TT_Vary_Apply_Glyph_Deltas' */
|
1749 | 1748 | FT_Vector points[4];
|
1750 | - char tags[4] = { 1, 1, 1, 1 };
|
|
1751 | - short contours[4] = { 0, 1, 2, 3 };
|
|
1752 | 1749 | FT_Outline outline;
|
1753 | 1750 | |
1754 | 1751 | /* unrounded values */
|
... | ... | @@ -1765,29 +1762,18 @@ |
1765 | 1762 | points[3].x = loader->pp4.x;
|
1766 | 1763 | points[3].y = loader->pp4.y;
|
1767 | 1764 | |
1768 | - outline.n_points = 4;
|
|
1769 | - outline.n_contours = 4;
|
|
1765 | + outline.n_points = 0;
|
|
1766 | + outline.n_contours = 0;
|
|
1770 | 1767 | outline.points = points;
|
1771 | - outline.tags = tags;
|
|
1772 | - outline.contours = contours;
|
|
1768 | + outline.tags = NULL;
|
|
1769 | + outline.contours = NULL;
|
|
1773 | 1770 | |
1774 | 1771 | /* this must be done before scaling */
|
1775 | 1772 | error = TT_Vary_Apply_Glyph_Deltas( loader,
|
1776 | 1773 | &outline,
|
1777 | - unrounded,
|
|
1778 | - (FT_UInt)outline.n_points );
|
|
1774 | + unrounded );
|
|
1779 | 1775 | if ( error )
|
1780 | 1776 | goto Exit;
|
1781 | - |
|
1782 | - loader->pp1.x = points[0].x;
|
|
1783 | - loader->pp1.y = points[0].y;
|
|
1784 | - loader->pp2.x = points[1].x;
|
|
1785 | - loader->pp2.y = points[1].y;
|
|
1786 | - |
|
1787 | - loader->pp3.x = points[2].x;
|
|
1788 | - loader->pp3.y = points[2].y;
|
|
1789 | - loader->pp4.x = points[3].x;
|
|
1790 | - loader->pp4.y = points[3].y;
|
|
1791 | 1777 | }
|
1792 | 1778 | |
1793 | 1779 | #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
... | ... | @@ -1935,17 +1921,16 @@ |
1935 | 1921 | |
1936 | 1922 | /* construct an outline structure for */
|
1937 | 1923 | /* communication with `TT_Vary_Apply_Glyph_Deltas' */
|
1938 | - outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
|
|
1939 | - outline.n_contours = outline.n_points;
|
|
1924 | + outline.n_contours = outline.n_points = limit;
|
|
1940 | 1925 | |
1941 | 1926 | outline.points = NULL;
|
1942 | 1927 | outline.tags = NULL;
|
1943 | 1928 | outline.contours = NULL;
|
1944 | 1929 | |
1945 | - if ( FT_NEW_ARRAY( points, outline.n_points ) ||
|
|
1946 | - FT_NEW_ARRAY( tags, outline.n_points ) ||
|
|
1947 | - FT_NEW_ARRAY( contours, outline.n_points ) ||
|
|
1948 | - FT_NEW_ARRAY( unrounded, outline.n_points ) )
|
|
1930 | + if ( FT_NEW_ARRAY( points, limit + 4 ) ||
|
|
1931 | + FT_NEW_ARRAY( tags, limit + 4 ) ||
|
|
1932 | + FT_NEW_ARRAY( contours, limit + 4 ) ||
|
|
1933 | + FT_NEW_ARRAY( unrounded, limit + 4 ) )
|
|
1949 | 1934 | goto Exit1;
|
1950 | 1935 | |
1951 | 1936 | subglyph = gloader->current.subglyphs;
|
... | ... | @@ -1963,26 +1948,18 @@ |
1963 | 1948 | |
1964 | 1949 | points[i].x = loader->pp1.x;
|
1965 | 1950 | points[i].y = loader->pp1.y;
|
1966 | - tags[i] = 1;
|
|
1967 | - contours[i] = i;
|
|
1968 | 1951 | |
1969 | 1952 | i++;
|
1970 | 1953 | points[i].x = loader->pp2.x;
|
1971 | 1954 | points[i].y = loader->pp2.y;
|
1972 | - tags[i] = 1;
|
|
1973 | - contours[i] = i;
|
|
1974 | 1955 | |
1975 | 1956 | i++;
|
1976 | 1957 | points[i].x = loader->pp3.x;
|
1977 | 1958 | points[i].y = loader->pp3.y;
|
1978 | - tags[i] = 1;
|
|
1979 | - contours[i] = i;
|
|
1980 | 1959 | |
1981 | 1960 | i++;
|
1982 | 1961 | points[i].x = loader->pp4.x;
|
1983 | 1962 | points[i].y = loader->pp4.y;
|
1984 | - tags[i] = 1;
|
|
1985 | - contours[i] = i;
|
|
1986 | 1963 | |
1987 | 1964 | outline.points = points;
|
1988 | 1965 | outline.tags = tags;
|
... | ... | @@ -1990,11 +1967,9 @@ |
1990 | 1967 | |
1991 | 1968 | /* this call provides additional offsets */
|
1992 | 1969 | /* for each component's translation */
|
1993 | - if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
|
|
1994 | - loader,
|
|
1995 | - &outline,
|
|
1996 | - unrounded,
|
|
1997 | - (FT_UInt)outline.n_points ) ) )
|
|
1970 | + if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
|
|
1971 | + &outline,
|
|
1972 | + unrounded ) ) )
|
|
1998 | 1973 | goto Exit1;
|
1999 | 1974 | |
2000 | 1975 | subglyph = gloader->current.subglyphs;
|
... | ... | @@ -2008,16 +1983,6 @@ |
2008 | 1983 | }
|
2009 | 1984 | }
|
2010 | 1985 | |
2011 | - loader->pp1.x = points[i + 0].x;
|
|
2012 | - loader->pp1.y = points[i + 0].y;
|
|
2013 | - loader->pp2.x = points[i + 1].x;
|
|
2014 | - loader->pp2.y = points[i + 1].y;
|
|
2015 | - |
|
2016 | - loader->pp3.x = points[i + 2].x;
|
|
2017 | - loader->pp3.y = points[i + 2].y;
|
|
2018 | - loader->pp4.x = points[i + 3].x;
|
|
2019 | - loader->pp4.y = points[i + 3].y;
|
|
2020 | - |
|
2021 | 1986 | Exit1:
|
2022 | 1987 | FT_FREE( outline.points );
|
2023 | 1988 | FT_FREE( outline.tags );
|
... | ... | @@ -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 */
|
... | ... | @@ -4177,36 +4172,8 @@ |
4177 | 4172 | FT_Pos point_delta_y = points_out[j].y - points_org[j].y;
|
4178 | 4173 | |
4179 | 4174 | |
4180 | - if ( j < n_points - 4 )
|
|
4181 | - {
|
|
4182 | - point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4183 | - point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
|
4184 | - }
|
|
4185 | - else
|
|
4186 | - {
|
|
4187 | - /* To avoid double adjustment of advance width or height, */
|
|
4188 | - /* adjust phantom points only if there is no HVAR or VVAR */
|
|
4189 | - /* support, respectively. */
|
|
4190 | - if ( j == ( n_points - 4 ) &&
|
|
4191 | - !( face->variation_support &
|
|
4192 | - TT_FACE_FLAG_VAR_LSB ) )
|
|
4193 | - point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4194 | - |
|
4195 | - else if ( j == ( n_points - 3 ) &&
|
|
4196 | - !( face->variation_support &
|
|
4197 | - TT_FACE_FLAG_VAR_HADVANCE ) )
|
|
4198 | - point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4199 | - |
|
4200 | - else if ( j == ( n_points - 2 ) &&
|
|
4201 | - !( face->variation_support &
|
|
4202 | - TT_FACE_FLAG_VAR_TSB ) )
|
|
4203 | - point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
|
4204 | - |
|
4205 | - else if ( j == ( n_points - 1 ) &&
|
|
4206 | - !( face->variation_support &
|
|
4207 | - TT_FACE_FLAG_VAR_VADVANCE ) )
|
|
4208 | - point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
|
4209 | - }
|
|
4175 | + point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4176 | + point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
|
4210 | 4177 | |
4211 | 4178 | #ifdef FT_DEBUG_LEVEL_TRACE
|
4212 | 4179 | if ( point_delta_x || point_delta_y )
|
... | ... | @@ -4253,14 +4220,25 @@ |
4253 | 4220 | outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
|
4254 | 4221 | }
|
4255 | 4222 | |
4256 | - /* recalculate linear horizontal and vertical advances */
|
|
4257 | - /* if we don't have HVAR and VVAR, respectively */
|
|
4223 | + /* To avoid double adjustment of advance width or height, */
|
|
4224 | + /* adjust phantom points only if there is no HVAR or VVAR */
|
|
4225 | + /* support, respectively. */
|
|
4226 | + if ( !( face->variation_support & TT_FACE_FLAG_VAR_LSB ) )
|
|
4227 | + loader->pp1 = outline->points[n_points - 4];
|
|
4258 | 4228 | if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
|
4229 | + {
|
|
4230 | + loader->pp2 = outline->points[n_points - 3];
|
|
4259 | 4231 | loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
|
4260 | 4232 | unrounded[n_points - 4].x ) / 64;
|
4233 | + }
|
|
4234 | + if ( !( face->variation_support & TT_FACE_FLAG_VAR_TSB ) )
|
|
4235 | + loader->pp3 = outline->points[n_points - 2];
|
|
4261 | 4236 | if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
|
4237 | + {
|
|
4238 | + loader->pp4 = outline->points[n_points - 1];
|
|
4262 | 4239 | loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].y -
|
4263 | 4240 | unrounded[n_points - 2].y ) / 64;
|
4241 | + }
|
|
4264 | 4242 | |
4265 | 4243 | Fail3:
|
4266 | 4244 | FT_FREE( point_deltas_x );
|
... | ... | @@ -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,
|