freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 924bf9a: [ftview] Stuff right margin.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 924bf9a: [ftview] Stuff right margin.
Date: Mon, 27 Mar 2017 23:28:29 -0400 (EDT)

branch: master
commit 924bf9ad035896e38c591257b775aec36ee773a3
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftview] Stuff right margin.
    
    * src/ftview.c (X_TOO_LONG): Rely on `horiAdvance' when available.
    (Render_All): Use `FTDemo_Draw_Slot' so that updated X_TOO_LONG works.
    (Render_Stroke, Render_Fancy): Updated.
---
 ChangeLog    |  8 ++++++
 src/ftview.c | 82 +++++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 826820a..11d5376 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-27  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftview] Stuff right margin.
+
+       * src/ftview.c (X_TOO_LONG): Rely on `horiAdvance' when available.
+       (Render_All): Use `FTDemo_Draw_Slot' so that updated X_TOO_LONG works.
+       (Render_Stroke, Render_Fancy): Updated.
+
 2017-03-26  Alexei Podtelezhnikov  <address@hidden>
 
        [ftview] Hide LCD filter from grayscale modes.
diff --git a/src/ftview.c b/src/ftview.c
index 2d6e921..f64d2c6 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -43,7 +43,7 @@
 #endif
 #define CEIL( x )  ( ( (x) + 63 ) >> 6 )
 
-#define START_X  19 * 8
+#define START_X  18 * 8
 #define START_Y  4 * HEADER_HEIGHT
 
 #define INIT_SIZE( size, start_x, start_y, step_y, x, y )     \
@@ -56,9 +56,9 @@
             y = start_y;                                      \
           } while ( 0 )
 
-#define X_TOO_LONG( x, size, display )                   \
-          ( (x) + ( (size)->metrics.max_advance >> 6 ) > \
-            (display)->bitmap->width )
+#define X_TOO_LONG( x, slot, display )                   \
+          ( (x) + ( (slot)->metrics.horiAdvance >> 6 ) > \
+            (display)->bitmap->width - 3 )
 #define Y_TOO_LONG( y, size, display )       \
           ( (y) >= (display)->bitmap->rows )
 
@@ -225,6 +225,15 @@
           goto Next;
         }
 
+        if ( X_TOO_LONG( x, slot, display ) )
+        {
+          x  = start_x;
+          y += step_y;
+
+          if ( Y_TOO_LONG( y, size, display ) )
+            break;
+        }
+
         error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
 
         FT_Done_Glyph( glyph );
@@ -237,15 +246,6 @@
           have_topleft   = 1;
           status.topleft = i;
         }
-
-        if ( X_TOO_LONG( x, size, display ) )
-        {
-          x  = start_x;
-          y += step_y;
-
-          if ( Y_TOO_LONG( y, size, display ) )
-            break;
-        }
       }
       else
     Next:
@@ -363,6 +363,15 @@
       if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
         slot->bitmap_top += ystr >> 6;
 
+      if ( X_TOO_LONG( x, slot, display ) )
+      {
+        x  = start_x;
+        y += step_y;
+
+        if ( Y_TOO_LONG( y, size, display ) )
+          break;
+      }
+
       error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
 
       if ( error )
@@ -374,15 +383,6 @@
         status.topleft = i;
       }
 
-      if ( X_TOO_LONG( x, size, display ) )
-      {
-        x  = start_x;
-        y += step_y;
-
-        if ( Y_TOO_LONG( y, size, display ) )
-          break;
-      }
-
       continue;
 
     Next:
@@ -397,9 +397,11 @@
   Render_All( int  num_indices,
               int  offset )
   {
-    int      start_x, start_y, step_y, x, y;
-    int      i, have_topleft;
-    FT_Size  size;
+    int           start_x, start_y, step_y, x, y;
+    int           i, have_topleft;
+    FT_Size       size;
+    FT_Face       face;
+    FT_GlyphSlot  slot;
 
 
     error = FTDemo_Get_Size( handle, &size );
@@ -411,6 +413,8 @@
     }
 
     INIT_SIZE( size, start_x, start_y, step_y, x, y );
+    face = size->face;
+    slot = face->glyph;
 
     have_topleft = 0;
 
@@ -424,18 +428,11 @@
       else
         glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
 
-      error = FTDemo_Draw_Index( handle, display, glyph_idx, &x, &y );
-
+      error = FT_Load_Glyph( face, glyph_idx, handle->load_flags );
       if ( error )
         goto Next;
 
-      if ( !have_topleft )
-      {
-        have_topleft   = 1;
-        status.topleft = i;
-      }
-
-      if ( X_TOO_LONG( x, size, display ) )
+      if ( X_TOO_LONG( x, slot, display ) )
       {
         x = start_x;
         y += step_y;
@@ -444,6 +441,17 @@
           break;
       }
 
+      error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
+
+      if ( error )
+        goto Next;
+
+      if ( !have_topleft )
+      {
+        have_topleft   = 1;
+        status.topleft = i;
+      }
+
       continue;
 
     Next:
@@ -454,6 +462,12 @@
   }
 
 
+#undef  X_TOO_LONG
+#define X_TOO_LONG( x, size, display )                   \
+          ( (x) + ( (size)->metrics.max_advance >> 6 ) > \
+            (display)->bitmap->width )
+
+
   static FT_Error
   Render_Text( int  num_indices,
                int  offset )



reply via email to

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