summaryrefslogtreecommitdiff
path: root/freetype/src/smooth
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2019-11-26 14:39:02 +0000
committerChris Liddell <chris.liddell@artifex.com>2019-11-26 17:51:31 +0000
commit79ac3f84060fbd5447219264ab0bcf89c7caa2cf (patch)
treeeb80c656c8302f91fc140e4a23db608ef207ba0d /freetype/src/smooth
parent36cbd382b160ee4951d1911f85a4fa0723dd8db3 (diff)
downloadghostpdl-79ac3f84060fbd5447219264ab0bcf89c7caa2cf.tar.gz
Update Freetype to 2.4.10
Plus makefile updates to support it Bug 701288: Handle SEAC ligature glyph metrics correctly. As originally intended, a Type 1 SEAC charstring would be used for an accented glyph (like an a-caron, or u-umlaut) where the advance with of the SEAC glyph is the same as that of the 'base' glyph ('a' or 'u'). It this case, it is not uncommon for the SEAC to skip using an (H)SBW op code and rely on the one from the base glyph. But out of spec fonts also use SEAC glyphs ligature glyphs (like 'oe' or 'fi'), and in those cases the overall advance width is greater than that of the 'base' glyph. In this case, we have to allow for the SEAC glyph having included an (H)SBW and if it has, retain those values, rather than those from the base glyph. Rename file and make file change to match Avoids file name clash with freetype 2.4.10 Work around a change in the zlib API for 1.2.11 where it's used in the Freetype/zlib interface debugging code.
Diffstat (limited to 'freetype/src/smooth')
-rw-r--r--freetype/src/smooth/Jamfile2
-rw-r--r--freetype/src/smooth/ftgrays.c724
-rw-r--r--freetype/src/smooth/ftgrays.h49
-rw-r--r--freetype/src/smooth/ftsmerrs.h48
-rw-r--r--freetype/src/smooth/ftsmooth.c127
-rw-r--r--freetype/src/smooth/ftsmooth.h32
-rw-r--r--freetype/src/smooth/ftspic.c118
-rw-r--r--freetype/src/smooth/ftspic.h75
-rw-r--r--freetype/src/smooth/module.mk2
-rw-r--r--freetype/src/smooth/rules.mk5
-rw-r--r--freetype/src/smooth/smooth.c33
11 files changed, 482 insertions, 733 deletions
diff --git a/freetype/src/smooth/Jamfile b/freetype/src/smooth/Jamfile
index 9957d5e91..6ca1cede9 100644
--- a/freetype/src/smooth/Jamfile
+++ b/freetype/src/smooth/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/smooth Jamfile
#
-# Copyright 2001-2018 by
+# Copyright (C) 2001-2019 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/freetype/src/smooth/ftgrays.c b/freetype/src/smooth/ftgrays.c
index 803a19e41..fd357a50f 100644
--- a/freetype/src/smooth/ftgrays.c
+++ b/freetype/src/smooth/ftgrays.c
@@ -1,94 +1,102 @@
-/***************************************************************************/
-/* */
-/* ftgrays.c */
-/* */
-/* A new `perfect' anti-aliasing renderer (body). */
-/* */
-/* Copyright 2000-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
- /*************************************************************************/
- /* */
- /* This file can be compiled without the rest of the FreeType engine, by */
- /* defining the STANDALONE_ macro when compiling it. You also need to */
- /* put the files `ftgrays.h' and `ftimage.h' into the current */
- /* compilation directory. Typically, you could do something like */
- /* */
- /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */
- /* */
- /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */
- /* same directory */
- /* */
- /* - compile `ftgrays' with the STANDALONE_ macro defined, as in */
- /* */
- /* cc -c -DSTANDALONE_ ftgrays.c */
- /* */
- /* The renderer can be initialized with a call to */
- /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */
- /* with a call to `ft_gray_raster.raster_render'. */
- /* */
- /* See the comments and documentation in the file `ftimage.h' for more */
- /* details on how the raster works. */
- /* */
- /*************************************************************************/
-
- /*************************************************************************/
- /* */
- /* This is a new anti-aliasing scan-converter for FreeType 2. The */
- /* algorithm used here is _very_ different from the one in the standard */
- /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */
- /* coverage of the outline on each pixel cell. */
- /* */
- /* It is based on ideas that I initially found in Raph Levien's */
- /* excellent LibArt graphics library (see http://www.levien.com/libart */
- /* for more information, though the web pages do not tell anything */
- /* about the renderer; you'll have to dive into the source code to */
- /* understand how it works). */
- /* */
- /* Note, however, that this is a _very_ different implementation */
- /* compared to Raph's. Coverage information is stored in a very */
- /* different way, and I don't use sorted vector paths. Also, it doesn't */
- /* use floating point values. */
- /* */
- /* This renderer has the following advantages: */
- /* */
- /* - It doesn't need an intermediate bitmap. Instead, one can supply a */
- /* callback function that will be called by the renderer to draw gray */
- /* spans on any target surface. You can thus do direct composition on */
- /* any kind of bitmap, provided that you give the renderer the right */
- /* callback. */
- /* */
- /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */
- /* each pixel cell. */
- /* */
- /* - It performs a single pass on the outline (the `standard' FT2 */
- /* renderer makes two passes). */
- /* */
- /* - It can easily be modified to render to _any_ number of gray levels */
- /* cheaply. */
- /* */
- /* - For small (< 20) pixel sizes, it is faster than the standard */
- /* renderer. */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+/****************************************************************************
+ *
+ * ftgrays.c
+ *
+ * A new `perfect' anti-aliasing renderer (body).
+ *
+ * Copyright (C) 2000-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+ /**************************************************************************
+ *
+ * This file can be compiled without the rest of the FreeType engine, by
+ * defining the STANDALONE_ macro when compiling it. You also need to
+ * put the files `ftgrays.h' and `ftimage.h' into the current
+ * compilation directory. Typically, you could do something like
+ *
+ * - copy `src/smooth/ftgrays.c' (this file) to your current directory
+ *
+ * - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the
+ * same directory
+ *
+ * - compile `ftgrays' with the STANDALONE_ macro defined, as in
+ *
+ * cc -c -DSTANDALONE_ ftgrays.c
+ *
+ * The renderer can be initialized with a call to
+ * `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated
+ * with a call to `ft_gray_raster.raster_render'.
+ *
+ * See the comments and documentation in the file `ftimage.h' for more
+ * details on how the raster works.
+ *
+ */
+
+ /**************************************************************************
+ *
+ * This is a new anti-aliasing scan-converter for FreeType 2. The
+ * algorithm used here is _very_ different from the one in the standard
+ * `ftraster' module. Actually, `ftgrays' computes the _exact_
+ * coverage of the outline on each pixel cell by straight segments.
+ *
+ * It is based on ideas that I initially found in Raph Levien's
+ * excellent LibArt graphics library (see https://www.levien.com/libart
+ * for more information, though the web pages do not tell anything
+ * about the renderer; you'll have to dive into the source code to
+ * understand how it works).
+ *
+ * Note, however, that this is a _very_ different implementation
+ * compared to Raph's. Coverage information is stored in a very
+ * different way, and I don't use sorted vector paths. Also, it doesn't
+ * use floating point values.
+ *
+ * Bézier segments are flattened by splitting them until their deviation
+ * from straight line becomes much smaller than a pixel. Therefore, the
+ * pixel coverage by a Bézier curve is calculated approximately. To
+ * estimate the deviation, we use the distance from the control point
+ * to the conic chord centre or the cubic chord trisection. These
+ * distances vanish fast after each split. In the conic case, they vanish
+ * predictably and the number of necessary splits can be calculated.
+ *
+ * This renderer has the following advantages:
+ *
+ * - It doesn't need an intermediate bitmap. Instead, one can supply a
+ * callback function that will be called by the renderer to draw gray
+ * spans on any target surface. You can thus do direct composition on
+ * any kind of bitmap, provided that you give the renderer the right
+ * callback.
+ *
+ * - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on
+ * each pixel cell by straight segments.
+ *
+ * - It performs a single pass on the outline (the `standard' FT2
+ * renderer makes two passes).
+ *
+ * - It can easily be modified to render to _any_ number of gray levels
+ * cheaply.
+ *
+ * - For small (< 80) pixel sizes, it is faster than the standard
+ * renderer.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_smooth
+#define FT_COMPONENT smooth
#ifdef STANDALONE_
@@ -112,9 +120,9 @@
/*
- * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
- * algorithm. We use alpha = 1, beta = 3/8, giving us results with a
- * largest error less than 7% compared to the exact value.
+ * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
+ * algorithm. We use alpha = 1, beta = 3/8, giving us results with a
+ * largest error less than 7% compared to the exact value.
*/
#define FT_HYPOT( x, y ) \
( x = FT_ABS( x ), \
@@ -222,10 +230,10 @@ typedef ptrdiff_t FT_PtrDist;
#endif
#define FT_THROW( e ) \
- ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
+ ( FT_Throw( FT_ERR_CAT( ErrRaster_, e ), \
__LINE__, \
__FILE__ ) | \
- FT_ERR_CAT( ErrRaster, e ) )
+ FT_ERR_CAT( ErrRaster_, e ) )
#else /* !FT_DEBUG_LEVEL_TRACE */
@@ -279,8 +287,6 @@ typedef ptrdiff_t FT_PtrDist;
#include "ftsmerrs.h"
-#include "ftspic.h"
-
#define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
#define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
@@ -329,17 +335,9 @@ typedef ptrdiff_t FT_PtrDist;
/* must be at least 6 bits! */
#define PIXEL_BITS 8
-#undef FLOOR
-#undef CEILING
-#undef TRUNC
-#undef SCALED
-
#define ONE_PIXEL ( 1 << PIXEL_BITS )
-#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
-#define SUBPIXELS( x ) ( (TPos)(x) * ONE_PIXEL )
-#define FLOOR( x ) ( (x) & -ONE_PIXEL )
-#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL )
-#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL )
+#define TRUNC( x ) (TCoord)( (x) >> PIXEL_BITS )
+#define FRACT( x ) (TCoord)( (x) & ( ONE_PIXEL - 1 ) )
#if PIXEL_BITS >= 6
#define UPSCALE( x ) ( (x) * ( ONE_PIXEL >> 6 ) )
@@ -390,15 +388,15 @@ typedef ptrdiff_t FT_PtrDist;
#define FT_UDIVPREP( c, b ) \
long b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \
: 0
-#define FT_UDIV( a, b ) \
- ( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \
- ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) )
+#define FT_UDIV( a, b ) \
+ (TCoord)( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \
+ ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) )
- /*************************************************************************/
- /* */
- /* TYPE DEFINITIONS */
- /* */
+ /**************************************************************************
+ *
+ * TYPE DEFINITIONS
+ */
/* don't change the following types to FT_Int or FT_Pos, since we might */
/* need to define them to "float" or "double" when experimenting with */
@@ -434,6 +432,9 @@ typedef ptrdiff_t FT_PtrDist;
#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
#endif
+ /* FT_Span buffer size for direct rendering only */
+#define FT_MAX_GRAY_SPANS 10
+
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `structure was padded due to */
@@ -467,6 +468,8 @@ typedef ptrdiff_t FT_PtrDist;
FT_Raster_Span_Func render_span;
void* render_span_data;
+ FT_Span spans[FT_MAX_GRAY_SPANS];
+ int num_spans;
} gray_TWorker, *gray_PWorker;
@@ -516,10 +519,10 @@ typedef ptrdiff_t FT_PtrDist;
#endif /* FT_DEBUG_LEVEL_TRACE */
- /*************************************************************************/
- /* */
- /* Record the current cell in the table. */
- /* */
+ /**************************************************************************
+ *
+ * Record the current cell in the linked list.
+ */
static void
gray_record_cell( RAS_ARG )
{
@@ -528,10 +531,9 @@ typedef ptrdiff_t FT_PtrDist;
pcell = &ras.ycells[ras.ey - ras.min_ey];
- for (;;)
+ while ( ( cell = *pcell ) )
{
- cell = *pcell;
- if ( !cell || cell->x > x )
+ if ( cell->x > x )
break;
if ( cell->x == x )
@@ -561,10 +563,10 @@ typedef ptrdiff_t FT_PtrDist;
}
- /*************************************************************************/
- /* */
- /* Set the current cell to a new position. */
- /* */
+ /**************************************************************************
+ *
+ * Set the current cell to a new position.
+ */
static void
gray_set_cell( RAS_ARG_ TCoord ex,
TCoord ey )
@@ -579,16 +581,13 @@ typedef ptrdiff_t FT_PtrDist;
/* Note that if a cell is to the left of the clipping region, it is */
/* actually set to the (min_ex-1) horizontal position. */
- if ( ex < ras.min_ex )
- ex = ras.min_ex - 1;
-
/* record the current one if it is valid and substantial */
if ( !ras.invalid && ( ras.area || ras.cover ) )
gray_record_cell( RAS_VAR );
ras.area = 0;
ras.cover = 0;
- ras.ex = ex;
+ ras.ex = FT_MAX( ex, ras.min_ex - 1 );
ras.ey = ey;
ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey ||
@@ -598,10 +597,10 @@ typedef ptrdiff_t FT_PtrDist;
#ifndef FT_LONG64
- /*************************************************************************/
- /* */
- /* Render a scanline as one or more cells. */
- /* */
+ /**************************************************************************
+ *
+ * Render a scanline as one or more cells.
+ */
static void
gray_render_scanline( RAS_ARG_ TCoord ey,
TPos x1,
@@ -624,8 +623,8 @@ typedef ptrdiff_t FT_PtrDist;
return;
}
- fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
- fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
+ fx1 = FRACT( x1 );
+ fx2 = FRACT( x2 );
/* everything is located in a single cell. That is easy! */
/* */
@@ -652,6 +651,9 @@ typedef ptrdiff_t FT_PtrDist;
dx = -dx;
}
+ /* the fractional part of y-delta is mod/dx. It is essential to */
+ /* keep track of its accumulation for accurate rendering. */
+ /* XXX: y-delta and x-delta below should be related. */
FT_DIV_MOD( TCoord, p, dx, delta, mod );
ras.area += (TArea)( ( fx1 + first ) * delta );
@@ -696,10 +698,10 @@ typedef ptrdiff_t FT_PtrDist;
}
- /*************************************************************************/
- /* */
- /* Render a given line as a series of scanlines. */
- /* */
+ /**************************************************************************
+ *
+ * Render a given line as a series of scanlines.
+ */
static void
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
@@ -717,8 +719,8 @@ typedef ptrdiff_t FT_PtrDist;
( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
goto End;
- fy1 = (TCoord)( ras.y - SUBPIXELS( ey1 ) );
- fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
+ fy1 = FRACT( ras.y );
+ fy2 = FRACT( to_y );
/* everything is on a single scanline */
if ( ey1 == ey2 )
@@ -734,7 +736,7 @@ typedef ptrdiff_t FT_PtrDist;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
- TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 );
+ TCoord two_fx = FRACT( ras.x ) << 1;
TArea area;
@@ -789,6 +791,8 @@ typedef ptrdiff_t FT_PtrDist;
dy = -dy;
}
+ /* the fractional part of x-delta is mod/dy. It is essential to */
+ /* keep track of its accumulation for accurate rendering. */
FT_DIV_MOD( TCoord, p, dy, delta, mod );
x = ras.x + delta;
@@ -837,16 +841,17 @@ typedef ptrdiff_t FT_PtrDist;
#else
- /*************************************************************************/
- /* */
- /* Render a straight line across multiple cells in any direction. */
- /* */
+ /**************************************************************************
+ *
+ * Render a straight line across multiple cells in any direction.
+ */
static void
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
- TPos dx, dy, fx1, fy1, fx2, fy2;
- TCoord ex1, ex2, ey1, ey2;
+ TPos dx, dy;
+ TCoord fx1, fy1, fx2, fy2;
+ TCoord ex1, ey1, ex2, ey2;
ey1 = TRUNC( ras.y );
@@ -860,8 +865,8 @@ typedef ptrdiff_t FT_PtrDist;
ex1 = TRUNC( ras.x );
ex2 = TRUNC( to_x );
- fx1 = ras.x - SUBPIXELS( ex1 );
- fy1 = ras.y - SUBPIXELS( ey1 );
+ fx1 = FRACT( ras.x );
+ fy1 = FRACT( ras.y );
dx = to_x - ras.x;
dy = to_y - ras.y;
@@ -870,8 +875,8 @@ typedef ptrdiff_t FT_PtrDist;
;
else if ( dy == 0 ) /* ex1 != ex2 */ /* any horizontal line */
{
- ex1 = ex2;
- gray_set_cell( RAS_VAR_ ex1, ey1 );
+ gray_set_cell( RAS_VAR_ ex2, ey2 );
+ goto End;
}
else if ( dx == 0 )
{
@@ -898,7 +903,7 @@ typedef ptrdiff_t FT_PtrDist;
}
else /* any other line */
{
- TPos prod = dx * fy1 - dy * fx1;
+ TPos prod = dx * (TPos)fy1 - dy * (TPos)fx1;
FT_UDIVPREP( ex1 != ex2, dx );
FT_UDIVPREP( ey1 != ey2, dy );
@@ -912,7 +917,7 @@ typedef ptrdiff_t FT_PtrDist;
prod - dx * ONE_PIXEL > 0 ) /* left */
{
fx2 = 0;
- fy2 = (TPos)FT_UDIV( -prod, -dx );
+ fy2 = FT_UDIV( -prod, -dx );
prod -= dy * ONE_PIXEL;
ras.cover += ( fy2 - fy1 );
ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
@@ -924,7 +929,7 @@ typedef ptrdiff_t FT_PtrDist;
prod - dx * ONE_PIXEL + dy * ONE_PIXEL > 0 ) /* up */
{
prod -= dx * ONE_PIXEL;
- fx2 = (TPos)FT_UDIV( -prod, dy );
+ fx2 = FT_UDIV( -prod, dy );
fy2 = ONE_PIXEL;
ras.cover += ( fy2 - fy1 );
ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
@@ -937,7 +942,7 @@ typedef ptrdiff_t FT_PtrDist;
{
prod += dy * ONE_PIXEL;
fx2 = ONE_PIXEL;
- fy2 = (TPos)FT_UDIV( prod, dx );
+ fy2 = FT_UDIV( prod, dx );
ras.cover += ( fy2 - fy1 );
ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
fx1 = 0;
@@ -947,7 +952,7 @@ typedef ptrdiff_t FT_PtrDist;
else /* ( prod + dy * ONE_PIXEL < 0 &&
prod > 0 ) down */
{
- fx2 = (TPos)FT_UDIV( prod, -dy );
+ fx2 = FT_UDIV( prod, -dy );
fy2 = 0;
prod += dx * ONE_PIXEL;
ras.cover += ( fy2 - fy1 );
@@ -961,8 +966,8 @@ typedef ptrdiff_t FT_PtrDist;
} while ( ex1 != ex2 || ey1 != ey2 );
}
- fx2 = to_x - SUBPIXELS( ex2 );
- fy2 = to_y - SUBPIXELS( ey2 );
+ fx2 = FRACT( to_x );
+ fy2 = FRACT( to_y );
ras.cover += ( fy2 - fy1 );
ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
@@ -981,16 +986,18 @@ typedef ptrdiff_t FT_PtrDist;
base[4].x = base[2].x;
- b = base[1].x;
- a = base[3].x = ( base[2].x + b ) / 2;
- b = base[1].x = ( base[0].x + b ) / 2;
- base[2].x = ( a + b ) / 2;
+ a = base[0].x + base[1].x;
+ b = base[1].x + base[2].x;
+ base[3].x = b >> 1;
+ base[2].x = ( a + b ) >> 2;
+ base[1].x = a >> 1;
base[4].y = base[2].y;
- b = base[1].y;
- a = base[3].y = ( base[2].y + b ) / 2;
- b = base[1].y = ( base[0].y + b ) / 2;
- base[2].y = ( a + b ) / 2;
+ a = base[0].y + base[1].y;
+ b = base[1].y + base[2].y;
+ base[3].y = b >> 1;
+ base[2].y = ( a + b ) >> 2;
+ base[1].y = a >> 1;
}
@@ -1044,12 +1051,11 @@ typedef ptrdiff_t FT_PtrDist;
/* many times as there are trailing zeros in the counter. */
do
{
- split = 1;
- while ( ( draw & split ) == 0 )
+ split = draw & ( -draw ); /* isolate the rightmost 1-bit */
+ while ( ( split >>= 1 ) )
{
gray_split_conic( arc );
arc += 2;
- split <<= 1;
}
gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
@@ -1062,28 +1068,32 @@ typedef ptrdiff_t FT_PtrDist;
static void
gray_split_cubic( FT_Vector* base )
{
- TPos a, b, c, d;
+ TPos a, b, c;
base[6].x = base[3].x;
- c = base[1].x;
- d = base[2].x;
- base[1].x = a = ( base[0].x + c ) / 2;
- base[5].x = b = ( base[3].x + d ) / 2;
- c = ( c + d ) / 2;
- base[2].x = a = ( a + c ) / 2;
- base[4].x = b = ( b + c ) / 2;
- base[3].x = ( a + b ) / 2;
+ a = base[0].x + base[1].x;
+ b = base[1].x + base[2].x;
+ c = base[2].x + base[3].x;
+ base[5].x = c >> 1;
+ c += b;
+ base[4].x = c >> 2;
+ base[1].x = a >> 1;
+ a += b;
+ base[2].x = a >> 2;
+ base[3].x = ( a + c ) >> 3;
base[6].y = base[3].y;
- c = base[1].y;
- d = base[2].y;
- base[1].y = a = ( base[0].y + c ) / 2;
- base[5].y = b = ( base[3].y + d ) / 2;
- c = ( c + d ) / 2;
- base[2].y = a = ( a + c ) / 2;
- base[4].y = b = ( b + c ) / 2;
- base[3].y = ( a + b ) / 2;
+ a = base[0].y + base[1].y;
+ b = base[1].y + base[2].y;
+ c = base[2].y + base[3].y;
+ base[5].y = c >> 1;
+ c += b;
+ base[4].y = c >> 2;
+ base[1].y = a >> 1;
+ a += b;
+ base[2].y = a >> 2;
+ base[3].y = ( a + c ) >> 3;
}
@@ -1094,9 +1104,6 @@ typedef ptrdiff_t FT_PtrDist;
{
FT_Vector bez_stack[16 * 3 + 1]; /* enough to accommodate bisections */
FT_Vector* arc = bez_stack;
- TPos dx, dy, dx_, dy_;
- TPos dx1, dy1, dx2, dy2;
- TPos L, s, s_limit;
arc[0].x = UPSCALE( to->x );
@@ -1125,45 +1132,13 @@ typedef ptrdiff_t FT_PtrDist;
for (;;)
{
- /* Decide whether to split or draw. See `Rapid Termination */
- /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
- /* F. Hain, at */
- /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */
-
- /* dx and dy are x and y components of the P0-P3 chord vector. */
- dx = dx_ = arc[3].x - arc[0].x;
- dy = dy_ = arc[3].y - arc[0].y;
-
- L = FT_HYPOT( dx_, dy_ );
-
- /* Avoid possible arithmetic overflow below by splitting. */
- if ( L > 32767 )
- goto Split;
-
- /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
- s_limit = L * (TPos)( ONE_PIXEL / 6 );
-
- /* s is L * the perpendicular distance from P1 to the line P0-P3. */
- dx1 = arc[1].x - arc[0].x;
- dy1 = arc[1].y - arc[0].y;
- s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx1 ), MUL_LONG( dx, dy1 ) ) );
-
- if ( s > s_limit )
- goto Split;
-
- /* s is L * the perpendicular distance from P2 to the line P0-P3. */
- dx2 = arc[2].x - arc[0].x;
- dy2 = arc[2].y - arc[0].y;
- s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx2 ), MUL_LONG( dx, dy2 ) ) );
-
- if ( s > s_limit )
- goto Split;
-
- /* Split super curvy segments where the off points are so far
- from the chord that the angles P0-P1-P3 or P0-P2-P3 become
- acute as detected by appropriate dot products. */
- if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 ||
- dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 )
+ /* with each split, control points quickly converge towards */
+ /* chord trisection points and the vanishing distances below */
+ /* indicate when the segment is flat enough to draw */
+ if ( FT_ABS( 2 * arc[0].x - 3 * arc[1].x + arc[3].x ) > ONE_PIXEL / 2 ||
+ FT_ABS( 2 * arc[0].y - 3 * arc[1].y + arc[3].y ) > ONE_PIXEL / 2 ||
+ FT_ABS( arc[0].x - 3 * arc[2].x + 2 * arc[3].x ) > ONE_PIXEL / 2 ||
+ FT_ABS( arc[0].y - 3 * arc[2].y + 2 * arc[3].y ) > ONE_PIXEL / 2 )
goto Split;
gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
@@ -1238,8 +1213,6 @@ typedef ptrdiff_t FT_PtrDist;
{
/* scale the coverage from 0..(ONE_PIXEL*ONE_PIXEL*2) to 0..256 */
coverage >>= PIXEL_BITS * 2 + 1 - 8;
- if ( coverage < 0 )
- coverage = -coverage - 1;
/* compute the line's coverage depending on the outline fill rule */
if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
@@ -1249,23 +1222,30 @@ typedef ptrdiff_t FT_PtrDist;
if ( coverage >= 256 )
coverage = 511 - coverage;
}
- else
+ else /* default non-zero winding rule */
{
- /* normal non-zero winding rule */
+ if ( coverage < 0 )
+ coverage = ~coverage; /* the same as -coverage - 1 */
+
if ( coverage >= 256 )
coverage = 255;
}
- if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
+ if ( ras.num_spans >= 0 ) /* for FT_RASTER_FLAG_DIRECT only */
{
- FT_Span span;
+ FT_Span* span = ras.spans + ras.num_spans++;
- span.x = (short)x;
- span.len = (unsigned short)acount;
- span.coverage = (unsigned char)coverage;
+ span->x = (short)x;
+ span->len = (unsigned short)acount;
+ span->coverage = (unsigned char)coverage;
- ras.render_span( y, 1, &span, ras.render_span_data );
+ if ( ras.num_spans == FT_MAX_GRAY_SPANS )
+ {
+ /* flush the span buffer and reset the count */
+ ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data );
+ ras.num_spans = 0;
+ }
}
else
{
@@ -1279,14 +1259,29 @@ typedef ptrdiff_t FT_PtrDist;
*/
switch ( acount )
{
- case 7: *q++ = c;
- case 6: *q++ = c;
- case 5: *q++ = c;
- case 4: *q++ = c;
- case 3: *q++ = c;
- case 2: *q++ = c;
- case 1: *q = c;
- case 0: break;
+ case 7:
+ *q++ = c;
+ /* fall through */
+ case 6:
+ *q++ = c;
+ /* fall through */
+ case 5:
+ *q++ = c;
+ /* fall through */
+ case 4:
+ *q++ = c;
+ /* fall through */
+ case 3:
+ *q++ = c;
+ /* fall through */
+ case 2:
+ *q++ = c;
+ /* fall through */
+ case 1:
+ *q = c;
+ /* fall through */
+ case 0:
+ break;
default:
FT_MEM_SET( q, c, acount );
}
@@ -1324,53 +1319,63 @@ typedef ptrdiff_t FT_PtrDist;
if ( cover != 0 )
gray_hline( RAS_VAR_ x, y, cover, ras.max_ex - x );
+
+ if ( ras.num_spans > 0 ) /* for FT_RASTER_FLAG_DIRECT only */
+ {
+ /* flush the span buffer and reset the count */
+ ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data );
+ ras.num_spans = 0;
+ }
}
}
#ifdef STANDALONE_
- /*************************************************************************/
- /* */
- /* The following functions should only compile in stand-alone mode, */
- /* i.e., when building this component without the rest of FreeType. */
- /* */
- /*************************************************************************/
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Decompose */
- /* */
- /* <Description> */
- /* Walk over an outline's structure to decompose it into individual */
- /* segments and Bézier arcs. This function is also able to emit */
- /* `move to' and `close to' operations to indicate the start and end */
- /* of new contours in the outline. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the source target. */
- /* */
- /* func_interface :: A table of `emitters', i.e., function pointers */
- /* called during decomposition to indicate path */
- /* operations. */
- /* */
- /* <InOut> */
- /* user :: A typeless pointer which is passed to each */
- /* emitter during the decomposition. It can be */
- /* used to store the state during the */
- /* decomposition. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * The following functions should only compile in stand-alone mode,
+ * i.e., when building this component without the rest of FreeType.
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @Function:
+ * FT_Outline_Decompose
+ *
+ * @Description:
+ * Walk over an outline's structure to decompose it into individual
+ * segments and Bézier arcs. This function is also able to emit
+ * `move to' and `close to' operations to indicate the start and end
+ * of new contours in the outline.
+ *
+ * @Input:
+ * outline ::
+ * A pointer to the source target.
+ *
+ * func_interface ::
+ * A table of `emitters', i.e., function pointers
+ * called during decomposition to indicate path
+ * operations.
+ *
+ * @InOut:
+ * user ::
+ * A typeless pointer which is passed to each
+ * emitter during the decomposition. It can be
+ * used to store the state during the
+ * decomposition.
+ *
+ * @Return:
+ * Error code. 0 means success.
+ */
static int
FT_Outline_Decompose( const FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
void* user )
{
#undef SCALED
-#define SCALED( x ) ( ( (x) << shift ) - delta )
+#define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
FT_Vector v_last;
FT_Vector v_control;
@@ -1610,81 +1615,6 @@ typedef ptrdiff_t FT_PtrDist;
return FT_THROW( Invalid_Outline );
}
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Get_CBox */
- /* */
- /* <Description> */
- /* Return an outline's `control box'. The control box encloses all */
- /* the outline's points, including Bézier control points. Though it */
- /* coincides with the exact bounding box for most glyphs, it can be */
- /* slightly larger in some situations (like when rotating an outline */
- /* that contains Bézier outside arcs). */
- /* */
- /* Computing the control box is very fast, while getting the bounding */
- /* box can take much more time as it needs to walk over all segments */
- /* and arcs in the outline. To get the latter, you can use the */
- /* `ftbbox' component, which is dedicated to this single task. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the source outline descriptor. */
- /* */
- /* <Output> */
- /* acbox :: The outline's control box. */
- /* */
- /* <Note> */
- /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
- /* */
-
- static void
- FT_Outline_Get_CBox( const FT_Outline* outline,
- FT_BBox *acbox )
- {
- TPos xMin, yMin, xMax, yMax;
-
-
- if ( outline && acbox )
- {
- if ( outline->n_points == 0 )
- {
- xMin = 0;
- yMin = 0;
- xMax = 0;
- yMax = 0;
- }
- else
- {
- FT_Vector* vec = outline->points;
- FT_Vector* limit = vec + outline->n_points;
-
-
- xMin = xMax = vec->x;
- yMin = yMax = vec->y;
- vec++;
-
- for ( ; vec < limit; vec++ )
- {
- TPos x, y;
-
-
- x = vec->x;
- if ( x < xMin ) xMin = x;
- if ( x > xMax ) xMax = x;
-
- y = vec->y;
- if ( y < yMin ) yMin = y;
- if ( y > yMax ) yMax = y;
- }
- }
- acbox->xMin = xMin;
- acbox->xMax = xMax;
- acbox->yMin = yMin;
- acbox->yMax = yMax;
- }
- }
-
#endif /* STANDALONE_ */
@@ -1702,19 +1632,20 @@ typedef ptrdiff_t FT_PtrDist;
static int
- gray_convert_glyph_inner( RAS_ARG )
+ gray_convert_glyph_inner( RAS_ARG,
+ int continued )
{
+ int error;
- volatile int error = 0;
-
-#ifdef FT_CONFIG_OPTION_PIC
- FT_Outline_Funcs func_interface;
- Init_Class_func_interface(&func_interface);
-#endif
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
+ if ( continued )
+ FT_Trace_Disable();
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
+ if ( continued )
+ FT_Trace_Enable();
+
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
@@ -1741,8 +1672,6 @@ typedef ptrdiff_t FT_PtrDist;
{
const TCoord yMin = ras.min_ey;
const TCoord yMax = ras.max_ey;
- const TCoord xMin = ras.min_ex;
- const TCoord xMax = ras.max_ex;
TCell buffer[FT_MAX_GRAY_POOL];
size_t height = (size_t)( yMax - yMin );
@@ -1751,6 +1680,8 @@ typedef ptrdiff_t FT_PtrDist;
TCoord bands[32]; /* enough to accommodate bisections */
TCoord* band;
+ int continued = 0;
+
/* set up vertical bands */
if ( height > n )
@@ -1774,8 +1705,8 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey = FT_MIN( y, yMax );
band = bands;
- band[1] = xMin;
- band[0] = xMax;
+ band[1] = ras.min_ey;
+ band[0] = ras.max_ey;
do
{
@@ -1787,10 +1718,11 @@ typedef ptrdiff_t FT_PtrDist;
ras.num_cells = 0;
ras.invalid = 1;
- ras.min_ex = band[1];
- ras.max_ex = band[0];
+ ras.min_ey = band[1];
+ ras.max_ey = band[0];
- error = gray_convert_glyph_inner( RAS_VAR );
+ error = gray_convert_glyph_inner( RAS_VAR, continued );
+ continued = 1;
if ( !error )
{
@@ -1827,7 +1759,6 @@ typedef ptrdiff_t FT_PtrDist;
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
- FT_BBox cbox, clip;
#ifndef FT_STATIC_RASTER
gray_TWorker worker[1];
@@ -1864,6 +1795,12 @@ typedef ptrdiff_t FT_PtrDist;
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
+ ras.num_spans = 0;
+
+ ras.min_ex = params->clip_box.xMin;
+ ras.min_ey = params->clip_box.yMin;
+ ras.max_ex = params->clip_box.xMax;
+ ras.max_ey = params->clip_box.yMax;
}
else
{
@@ -1888,46 +1825,15 @@ typedef ptrdiff_t FT_PtrDist;
ras.render_span = (FT_Raster_Span_Func)NULL;
ras.render_span_data = NULL;
- }
-
- FT_Outline_Get_CBox( outline, &cbox );
-
- /* reject too large outline coordinates */
- if ( cbox.xMin < -0x1000000L || cbox.xMax > 0x1000000L ||
- cbox.yMin < -0x1000000L || cbox.yMax > 0x1000000L )
- return FT_THROW( Invalid_Outline );
-
- /* truncate the bounding box to integer pixels */
- cbox.xMin = cbox.xMin >> 6;
- cbox.yMin = cbox.yMin >> 6;
- cbox.xMax = ( cbox.xMax + 63 ) >> 6;
- cbox.yMax = ( cbox.yMax + 63 ) >> 6;
+ ras.num_spans = -1; /* invalid */
- /* compute clipping box */
- if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
- {
- /* compute clip box from target pixmap */
- clip.xMin = 0;
- clip.yMin = 0;
- clip.xMax = (FT_Pos)target_map->width;
- clip.yMax = (FT_Pos)target_map->rows;
+ ras.min_ex = 0;
+ ras.min_ey = 0;
+ ras.max_ex = (FT_Pos)target_map->width;
+ ras.max_ey = (FT_Pos)target_map->rows;
}
- else if ( params->flags & FT_RASTER_FLAG_CLIP )
- clip = params->clip_box;
- else
- {
- clip.xMin = -32768L;
- clip.yMin = -32768L;
- clip.xMax = 32767L;
- clip.yMax = 32767L;
- }
-
- /* clip to target bitmap, exit if nothing to do */
- ras.min_ex = FT_MAX( cbox.xMin, clip.xMin );
- ras.min_ey = FT_MAX( cbox.yMin, clip.yMin );
- ras.max_ex = FT_MIN( cbox.xMax, clip.xMax );
- ras.max_ey = FT_MIN( cbox.yMax, clip.yMax );
+ /* exit if nothing to do */
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
return 0;
diff --git a/freetype/src/smooth/ftgrays.h b/freetype/src/smooth/ftgrays.h
index 9e11ca675..e9f9c7a4a 100644
--- a/freetype/src/smooth/ftgrays.h
+++ b/freetype/src/smooth/ftgrays.h
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* ftgrays.h */
-/* */
-/* FreeType smooth renderer declaration */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ftgrays.h
+ *
+ * FreeType smooth renderer declaration
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef FTGRAYS_H_
@@ -28,19 +28,18 @@
#include "ftimage.h"
#else
#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H /* for FT_CONFIG_OPTION_PIC */
#include FT_IMAGE_H
#endif
- /*************************************************************************/
- /* */
- /* To make ftgrays.h independent from configuration files we check */
- /* whether FT_EXPORT_VAR has been defined already. */
- /* */
- /* On some systems and compilers (Win32 mostly), an extra keyword is */
- /* necessary to compile the library as a DLL. */
- /* */
+ /**************************************************************************
+ *
+ * To make ftgrays.h independent from configuration files we check
+ * whether FT_EXPORT_VAR has been defined already.
+ *
+ * On some systems and compilers (Win32 mostly), an extra keyword is
+ * necessary to compile the library as a DLL.
+ */
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) extern x
#endif
diff --git a/freetype/src/smooth/ftsmerrs.h b/freetype/src/smooth/ftsmerrs.h
index 226dc1b00..d52c0dd9e 100644
--- a/freetype/src/smooth/ftsmerrs.h
+++ b/freetype/src/smooth/ftsmerrs.h
@@ -1,27 +1,27 @@
-/***************************************************************************/
-/* */
-/* ftsmerrs.h */
-/* */
-/* smooth renderer error codes (specification only). */
-/* */
-/* Copyright 2001-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* This file is used to define the smooth renderer error enumeration */
- /* constants. */
- /* */
- /*************************************************************************/
+/****************************************************************************
+ *
+ * ftsmerrs.h
+ *
+ * smooth renderer error codes (specification only).
+ *
+ * Copyright (C) 2001-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * This file is used to define the smooth renderer error enumeration
+ * constants.
+ *
+ */
#ifndef FTSMERRS_H_
#define FTSMERRS_H_
diff --git a/freetype/src/smooth/ftsmooth.c b/freetype/src/smooth/ftsmooth.c
index ef176bdf1..cd034d2b4 100644
--- a/freetype/src/smooth/ftsmooth.c
+++ b/freetype/src/smooth/ftsmooth.c
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* ftsmooth.c */
-/* */
-/* Anti-aliasing renderer interface (body). */
-/* */
-/* Copyright 2000-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ftsmooth.c
+ *
+ * Anti-aliasing renderer interface (body).
+ *
+ * Copyright (C) 2000-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#include <ft2build.h>
@@ -22,7 +22,6 @@
#include FT_OUTLINE_H
#include "ftsmooth.h"
#include "ftgrays.h"
-#include "ftspic.h"
#include "ftsmerrs.h"
@@ -31,6 +30,26 @@
static FT_Error
ft_smooth_init( FT_Renderer render )
{
+
+#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+
+ FT_Vector* sub = render->root.library->lcd_geometry;
+
+
+ /* set up default subpixel geometry for striped RGB panels. */
+ sub[0].x = -21;
+ sub[0].y = 0;
+ sub[1].x = 0;
+ sub[1].y = 0;
+ sub[2].x = 21;
+ sub[2].y = 0;
+
+#elif 0 /* or else, once ClearType patents expire */
+
+ FT_Library_SetLcdFilter( render->root.library, FT_LCD_FILTER_DEFAULT );
+
+#endif
+
render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
return 0;
@@ -130,7 +149,11 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- ft_glyphslot_preset_bitmap( slot, mode, origin );
+ if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) )
+ {
+ error = FT_THROW( Raster_Overflow );
+ goto Exit;
+ }
/* allocate new one */
if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
@@ -220,7 +243,7 @@
}
if ( lcd_filter_func )
- lcd_filter_func( bitmap, mode, lcd_weights );
+ lcd_filter_func( bitmap, lcd_weights );
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
@@ -235,33 +258,40 @@
unsigned int width = bitmap->width;
int pitch = bitmap->pitch;
+ FT_Vector* sub = slot->library->lcd_geometry;
- /* Render 3 separate monochrome bitmaps, shifting the outline */
- /* by 1/3 pixel. */
- width /= 3;
- bitmap->buffer += width;
+ /* Render 3 separate monochrome bitmaps, shifting the outline. */
+ width /= 3;
+ FT_Outline_Translate( outline,
+ -sub[0].x,
+ -sub[0].y );
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, -21, 0 );
- x_shift -= 21;
bitmap->buffer += width;
-
+ FT_Outline_Translate( outline,
+ sub[0].x - sub[1].x,
+ sub[0].y - sub[1].y );
error = render->raster_render( render->raster, &params );
+ bitmap->buffer -= width;
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 42, 0 );
- x_shift += 42;
- bitmap->buffer -= 2 * width;
-
+ bitmap->buffer += 2 * width;
+ FT_Outline_Translate( outline,
+ sub[1].x - sub[2].x,
+ sub[1].y - sub[2].y );
error = render->raster_render( render->raster, &params );
+ bitmap->buffer -= 2 * width;
if ( error )
goto Exit;
+ x_shift -= sub[2].x;
+ y_shift -= sub[2].y;
+
/* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */
/* XXX: It is more efficient to render every third byte above. */
@@ -286,34 +316,43 @@
{
int pitch = bitmap->pitch;
+ FT_Vector* sub = slot->library->lcd_geometry;
+
- /* Render 3 separate monochrome bitmaps, shifting the outline */
- /* by 1/3 pixel. Triple the pitch to render on each third row. */
+ /* Render 3 separate monochrome bitmaps, shifting the outline. */
+ /* Notice that the subpixel geometry vectors are rotated. */
+ /* Triple the pitch to render on each third row. */
bitmap->pitch *= 3;
bitmap->rows /= 3;
- bitmap->buffer += pitch;
-
+ FT_Outline_Translate( outline,
+ -sub[0].y,
+ sub[0].x );
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 0, 21 );
- y_shift += 21;
bitmap->buffer += pitch;
-
+ FT_Outline_Translate( outline,
+ sub[0].y - sub[1].y,
+ sub[1].x - sub[0].x );
error = render->raster_render( render->raster, &params );
+ bitmap->buffer -= pitch;
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 0, -42 );
- y_shift -= 42;
- bitmap->buffer -= 2 * pitch;
-
+ bitmap->buffer += 2 * pitch;
+ FT_Outline_Translate( outline,
+ sub[1].y - sub[2].y,
+ sub[2].x - sub[1].x );
error = render->raster_render( render->raster, &params );
+ bitmap->buffer -= 2 * pitch;
if ( error )
goto Exit;
+ x_shift -= sub[2].y;
+ y_shift += sub[2].x;
+
bitmap->pitch /= 3;
bitmap->rows *= 3;
}
@@ -403,7 +442,7 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
- (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */
+ (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
)
@@ -430,7 +469,7 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
- (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */
+ (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
)
@@ -457,7 +496,7 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
- (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */
+ (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
)
diff --git a/freetype/src/smooth/ftsmooth.h b/freetype/src/smooth/ftsmooth.h
index c76ffc503..fbb21a31d 100644
--- a/freetype/src/smooth/ftsmooth.h
+++ b/freetype/src/smooth/ftsmooth.h
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* ftsmooth.h */
-/* */
-/* Anti-aliasing renderer interface (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ftsmooth.h
+ *
+ * Anti-aliasing renderer interface (specification).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef FTSMOOTH_H_
diff --git a/freetype/src/smooth/ftspic.c b/freetype/src/smooth/ftspic.c
deleted file mode 100644
index 10f04cf4c..000000000
--- a/freetype/src/smooth/ftspic.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftspic.c */
-/* */
-/* The FreeType position independent code services for smooth module. */
-/* */
-/* Copyright 2009-2018 by */
-/* Oran Agra and Mickey Gabel. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_INTERNAL_OBJECTS_H
-#include "ftspic.h"
-#include "ftsmerrs.h"
-
-
-#ifdef FT_CONFIG_OPTION_PIC
-
- /* forward declaration of PIC init functions from ftgrays.c */
- void
- FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs );
-
-
- void
- ft_smooth_renderer_class_pic_free( FT_Library library )
- {
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
-
-
- if ( pic_container->smooth )
- {
- SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
-
-
- if ( --container->ref_count )
- return;
-
- FT_FREE( container );
- pic_container->smooth = NULL;
- }
- }
-
-
- FT_Error
- ft_smooth_renderer_class_pic_init( FT_Library library )
- {
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- SmoothPIC* container = NULL;
- FT_Memory memory = library->memory;
-
-
- /* since this function also serve smooth_lcd and smooth_lcdv renderers,
- it implements reference counting */
- if ( pic_container->smooth )
- {
- ((SmoothPIC*)pic_container->smooth)->ref_count++;
- return error;
- }
-
- /* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC( container, sizeof ( *container ) ) )
- return error;
- FT_MEM_SET( container, 0, sizeof ( *container ) );
- pic_container->smooth = container;
-
- container->ref_count = 1;
-
- /* initialize pointer table - */
- /* this is how the module usually expects this data */
- FT_Init_Class_ft_grays_raster( &container->ft_grays_raster );
-
- return error;
- }
-
-
- /* re-route these init and free functions to the above functions */
- FT_Error
- ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
- {
- return ft_smooth_renderer_class_pic_init( library );
- }
-
-
- void
- ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
- {
- ft_smooth_renderer_class_pic_free( library );
- }
-
-
- FT_Error
- ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
- {
- return ft_smooth_renderer_class_pic_init( library );
- }
-
-
- void
- ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
- {
- ft_smooth_renderer_class_pic_free( library );
- }
-
-#endif /* FT_CONFIG_OPTION_PIC */
-
-
-/* END */
diff --git a/freetype/src/smooth/ftspic.h b/freetype/src/smooth/ftspic.h
deleted file mode 100644
index 80fb64cff..000000000
--- a/freetype/src/smooth/ftspic.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftspic.h */
-/* */
-/* The FreeType position independent code services for smooth module. */
-/* */
-/* Copyright 2009-2018 by */
-/* Oran Agra and Mickey Gabel. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef FTSPIC_H_
-#define FTSPIC_H_
-
-
-#include FT_INTERNAL_PIC_H
-
-
-FT_BEGIN_HEADER
-
-#ifndef FT_CONFIG_OPTION_PIC
-
-#define FT_GRAYS_RASTER_GET ft_grays_raster
-
-#else /* FT_CONFIG_OPTION_PIC */
-
- typedef struct SmoothPIC_
- {
- int ref_count;
- FT_Raster_Funcs ft_grays_raster;
-
- } SmoothPIC;
-
-
-#define GET_PIC( lib ) \
- ( (SmoothPIC*)( (lib)->pic_container.smooth ) )
-#define FT_GRAYS_RASTER_GET ( GET_PIC( library )->ft_grays_raster )
-
-
- /* see ftspic.c for the implementation */
- void
- ft_smooth_renderer_class_pic_free( FT_Library library );
-
- void
- ft_smooth_lcd_renderer_class_pic_free( FT_Library library );
-
- void
- ft_smooth_lcdv_renderer_class_pic_free( FT_Library library );
-
- FT_Error
- ft_smooth_renderer_class_pic_init( FT_Library library );
-
- FT_Error
- ft_smooth_lcd_renderer_class_pic_init( FT_Library library );
-
- FT_Error
- ft_smooth_lcdv_renderer_class_pic_init( FT_Library library );
-
-#endif /* FT_CONFIG_OPTION_PIC */
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTSPIC_H_ */
-
-
-/* END */
diff --git a/freetype/src/smooth/module.mk b/freetype/src/smooth/module.mk
index 5b8bc3be3..44b76dfec 100644
--- a/freetype/src/smooth/module.mk
+++ b/freetype/src/smooth/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2018 by
+# Copyright (C) 1996-2019 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/freetype/src/smooth/rules.mk b/freetype/src/smooth/rules.mk
index f30824a36..0153ac24a 100644
--- a/freetype/src/smooth/rules.mk
+++ b/freetype/src/smooth/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2018 by
+# Copyright (C) 1996-2019 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -29,8 +29,7 @@ SMOOTH_COMPILE := $(CC) $(ANSIFLAGS) \
# smooth driver sources (i.e., C files)
#
SMOOTH_DRV_SRC := $(SMOOTH_DIR)/ftgrays.c \
- $(SMOOTH_DIR)/ftsmooth.c \
- $(SMOOTH_DIR)/ftspic.c
+ $(SMOOTH_DIR)/ftsmooth.c
# smooth driver headers
diff --git a/freetype/src/smooth/smooth.c b/freetype/src/smooth/smooth.c
index 5249a8931..9c543d336 100644
--- a/freetype/src/smooth/smooth.c
+++ b/freetype/src/smooth/smooth.c
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* smooth.c */
-/* */
-/* FreeType anti-aliasing rasterer module component (body only). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * smooth.c
+ *
+ * FreeType anti-aliasing rasterer module component (body only).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#define FT_MAKE_OPTION_SINGLE_OBJECT
@@ -21,7 +21,6 @@
#include "ftgrays.c"
#include "ftsmooth.c"
-#include "ftspic.c"
/* END */