freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master ddd8dfe: [ftgrid] Fix display of segment lines.


From: Werner LEMBERG
Subject: [freetype2-demos] master ddd8dfe: [ftgrid] Fix display of segment lines.
Date: Sat, 9 Sep 2017 02:15:17 -0400 (EDT)

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

    [ftgrid] Fix display of segment lines.
    
    `af_glyph_hints_get_segment_offset' now returns values in font
    units.  Previously, values were scaled to the device resolution but
    with x height correction applied, which caused a mismatch to the
    displayed unhinted outlines.
    
    * src/ftgrid.c (grid_hint_draw_segment): Add new argument for
    `FT_Size' object.
    Scale return values of `af_glyph_hints_get_segment_offset' manually.
    (grid_status_draw_outline): Updated.
---
 ChangeLog    | 14 ++++++++++++++
 src/ftgrid.c | 17 +++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ac5af6e..2c1ed9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2017-09-09  Werner Lemberg  <address@hidden>
+
+       [ftgrid] Fix display of segment lines.
+
+       `af_glyph_hints_get_segment_offset' now returns values in font
+       units.  Previously, values were scaled to the device resolution but
+       with x height correction applied, which caused a mismatch to the
+       displayed unhinted outlines.
+
+       * src/ftgrid.c (grid_hint_draw_segment): Add new argument for
+       `FT_Size' object.
+       Scale return values of `af_glyph_hints_get_segment_offset' manually.
+       (grid_status_draw_outline): Updated.
+
 2017-09-06  Alexei Podtelezhnikov  <address@hidden>
 
        * src/{ftdump.c,ftcommon.c} (PanicZ): Handle error messages.
diff --git a/src/ftgrid.c b/src/ftgrid.c
index ef9cde3..e202637 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -302,8 +302,12 @@
 
   static void
   grid_hint_draw_segment( GridStatus     st,
+                          FT_Size        size,
                           AF_GlyphHints  hints )
   {
+    FT_Fixed  x_scale = size->metrics.x_scale;
+    FT_Fixed  y_scale = size->metrics.y_scale;
+
     FT_Int  dimension;
     int     x_org = st->x_origin;
     int     y_org = st->y_origin;
@@ -331,18 +335,23 @@
 
         if ( dimension == 0 ) /* AF_DIMENSION_HORZ is 0 */
         {
-          pos = x_org + ( ( offset * st->scale ) >> 6 );
+          offset = FT_MulFix( offset, x_scale );
+          pos    = x_org + ( ( offset * st->scale ) >> 6 );
           grFillVLine( st->disp_bitmap, pos, 0,
                        st->disp_height, st->segment_color );
         }
         else
         {
-          pos = y_org - ( ( offset * st->scale ) >> 6 );
+          offset = FT_MulFix( offset, y_scale );
+          pos    = y_org - ( ( offset * st->scale ) >> 6 );
 
           if ( is_blue )
           {
-            int  blue_pos = y_org - ( ( blue_offset * st->scale ) >> 6 );
+            int  blue_pos;
+
 
+            blue_offset = FT_MulFix( blue_offset, y_scale );
+            blue_pos    = y_org - ( ( blue_offset * st->scale ) >> 6 );
 
             if ( blue_pos == pos )
               grFillHLine( st->disp_bitmap, 0, blue_pos,
@@ -661,7 +670,7 @@
                            FT_LOAD_NO_BITMAP      |
                            FT_LOAD_FORCE_AUTOHINT |
                            FT_LOAD_TARGET_NORMAL ) )
-        grid_hint_draw_segment( &status, _af_debug_hints );
+        grid_hint_draw_segment( &status, size, _af_debug_hints );
     }
 
     _af_debug_disable_horz_hints = !st->do_horz_hints;



reply via email to

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