diff --git a/ChangeLog b/ChangeLog index 0e5ac435a..b118200db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2020-08-05 Alexei Podtelezhnikov + + [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND. + + For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set + FT_OUTLINE_OVERLAP to render them with direct oversampling, which + mitigates artifacts (see 3bb512bc9f62). + + * include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme + with OVERLAP_SIMPLE. + * src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags. + * src/truetype/ttgload.c + (TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE. + (load_truetype_glyph): Retain OVERLAP_COMPOUND. + 2020-08-04 Alexei Podtelezhnikov * src/truetype/ttgload.c (TT_Load_Glyph): More tracing. @@ -244,7 +259,7 @@ [smooth] Introduce direct oversampling for overlaps. - This implements oversampling to metigate artifacts in pixels partially + This implements oversampling to mitigate artifacts in pixels partially covered by overlapping contours. It turns out that the 4x4 oversampling is sufficient but, at least, quadruples the rendering time. The outline has to set FT_OUTLINE_OVERLAP to use this method. diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index 29b907a75..105e09d12 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -438,8 +438,8 @@ FT_BEGIN_HEADER #define FT_OUTLINE_IGNORE_DROPOUTS 0x8 #define FT_OUTLINE_SMART_DROPOUTS 0x10 #define FT_OUTLINE_INCLUDE_STUBS 0x20 +#define FT_OUTLINE_OVERLAP 0x40 -#define FT_OUTLINE_OVERLAP 0x80 #define FT_OUTLINE_HIGH_PRECISION 0x100 #define FT_OUTLINE_SINGLE_PASS 0x200 diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c index faf7d85f8..05fc7692b 100644 --- a/src/base/ftgloadr.c +++ b/src/base/ftgloadr.c @@ -92,6 +92,7 @@ base->outline.n_points = 0; base->outline.n_contours = 0; + base->outline.flags = 0; base->num_subglyphs = 0; *current = *base; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index d2d70a91f..126c1e9f8 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -60,7 +60,7 @@ #define SAME_X 0x10 #define Y_POSITIVE 0x20 /* two meanings depending on Y_SHORT_VECTOR */ #define SAME_Y 0x20 -#define OVERLAP_SIMPLE 0x40 /* we ignore this value */ +#define OVERLAP_SIMPLE 0x40 /* retained as FT_OUTLINE_OVERLAP */ /************************************************************************** @@ -77,7 +77,7 @@ #define WE_HAVE_A_2X2 0x0080 #define WE_HAVE_INSTR 0x0100 #define USE_MY_METRICS 0x0200 -#define OVERLAP_COMPOUND 0x0400 /* we ignore this value */ +#define OVERLAP_COMPOUND 0x0400 /* retained as FT_OUTLINE_OVERLAP */ #define SCALED_COMPONENT_OFFSET 0x0800 #define UNSCALED_COMPONENT_OFFSET 0x1000 @@ -489,6 +489,10 @@ } } + /* retain the overlap flag */ + if ( n_points && outline->tags[0] & OVERLAP_SIMPLE ) + gloader->base.outline.flags |= FT_OUTLINE_OVERLAP; + /* reading the X coordinates */ vec = outline->points; @@ -2183,6 +2187,11 @@ goto Exit; } } + + /* retain the overlap flag */ + if ( gloader->base.num_subglyphs && + gloader->base.subglyphs[0].flags & OVERLAP_COMPOUND ) + gloader->base.outline.flags |= FT_OUTLINE_OVERLAP; } /***********************************************************************/