freetype-devel
[Top][All Lists]
Advanced

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

[PATCH] [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND.


From: Alexei Podtelezhnikov
Subject: [PATCH] [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND.
Date: Sat, 1 Aug 2020 10:28:24 -0400

For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set
FT_OUTLINE_OVERLAP to render them with direct oversampling.
This might improve rendering of these glyphs.

* src/truetype/ttgload.c (TT_Load_Glyph): Trace glyph content.
(TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE.
(load_truetype_glyph): Retain OVERLAP_COMPOUND.
* src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags.
* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme
with OVERLAP_SIMPLE.
---
 ChangeLog                  | 15 +++++++++++++++
 include/freetype/ftimage.h |  2 +-
 src/base/ftgloadr.c        |  1 +
 src/truetype/ttgload.c     | 23 +++++++++++++++++++----
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e96ec6101..e64fc23da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2020-08-01  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [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.
+       This might improve rendering of these glyphs.
+
+       * src/truetype/ttgload.c (TT_Load_Glyph): Trace glyph content.
+       (TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE.
+       (load_truetype_glyph): Retain OVERLAP_COMPOUND.
+       * src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags.
+       * include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme
+       with OVERLAP_SIMPLE.
+
 2020-07-28  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        Hide internal functions with SunPro.
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 671061356..307f88f0d 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;
     }
 
     /***********************************************************************/
@@ -2981,8 +2990,6 @@
       error = compute_glyph_metrics( &loader, glyph_index );
     }
 
-    tt_loader_done( &loader );
-
     /* Set the `high precision' bit flag.                           */
     /* This is _critical_ to get correct output for monochrome      */
     /* TrueType glyphs at all sizes using the bytecode interpreter. */
@@ -2991,6 +2998,14 @@
          size->metrics->y_ppem < 24         )
       glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
 
+    FT_TRACE1(( "  subglyphs = %u, contours = %hd, points = %hd, flags = 
0x%.3x\n",
+                loader.gloader->base.num_subglyphs,
+                glyph->outline.n_contours,
+                glyph->outline.n_points,
+                glyph->outline.flags ));
+
+    tt_loader_done( &loader );
+
   Exit:
 #ifdef FT_DEBUG_LEVEL_TRACE
     if ( error )
-- 
2.26.2




reply via email to

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