freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 029c9b2 2/2: [truetype] Round offsets of glyph compon


From: Werner LEMBERG
Subject: [freetype2] master 029c9b2 2/2: [truetype] Round offsets of glyph components only if hinting is on.
Date: Wed, 3 Jan 2018 13:11:53 -0500 (EST)

branch: master
commit 029c9b2391476285cb4b25b52360744c649305b0
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [truetype] Round offsets of glyph components only if hinting is on.
    
    * src/truetype/ttgload.c (TT_Process_Composite_Component): Implement
    it.
---
 ChangeLog              |  7 +++++++
 src/truetype/ttgload.c | 24 ++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b62b173..1c61eae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2018-01-03  Werner Lemberg  <address@hidden>
 
+       [truetype] Round offsets of glyph components only if hinting is on.
+
+       * src/truetype/ttgload.c (TT_Process_Composite_Component): Implement
+       it.
+
+2018-01-03  Werner Lemberg  <address@hidden>
+
        * src/truetype/ttgxvar.c (ft_var_to_design): Remove dead code.
 
        This is a better fix than the previous commit, which is now
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index b62f440..32ed34a 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1206,8 +1206,28 @@
 
         if ( subglyph->flags & ROUND_XY_TO_GRID )
         {
-          x = FT_PIX_ROUND( x );
-          y = FT_PIX_ROUND( y );
+          TT_Face    face   = loader->face;
+          TT_Driver  driver = (TT_Driver)FT_FACE_DRIVER( face );
+
+
+          if ( IS_HINTED( loader->load_flags ) )
+          {
+            /*
+             * We round the horizontal offset only if there is hinting along
+             * the x axis; this corresponds to integer advance width values.
+             *
+             * Theoretically, a glyph's bytecode can toggle ClearType's
+             * `backward compatibility' mode, which would allow modification
+             * of the advance width.  In reality, however, applications
+             * neither allow nor expect modified advance widths if sub-pixel
+             * rendering is active.
+             *
+             */
+            if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 )
+              x = FT_PIX_ROUND( x );
+
+            y = FT_PIX_ROUND( y );
+          }
         }
       }
     }



reply via email to

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