freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 428b8aa: [ftview] Draw warning box for zero-wid


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 428b8aa: [ftview] Draw warning box for zero-width glyphs.
Date: Sun, 9 Sep 2018 13:39:03 -0400 (EDT)

branch: master
commit 428b8aa6a3ec17343f75b97d1d9424056b539b1c
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftview] Draw warning box for zero-width glyphs.
    
    * src/ftview.c ({X,Y}_TOO_LONG): Reworked the macros.
    (Render_{Stroke,Fancy,All}): Fill the added space with a warning box
    for zero-width glyphs.
    (Render_{Waterfall,Text}): Updated accordingly.
---
 ChangeLog    |  9 +++++++
 src/ftview.c | 84 +++++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 58 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d930700..427937c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2018-09-09  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftview] Draw warning box for zero-width glyphs.
+
+       * src/ftview.c ({X,Y}_TOO_LONG): Reworked the macros.
+       (Render_{Stroke,Fancy,All}): Fill the added space with a warning box
+       for zero-width glyphs.
+       (Render_{Waterfall,Text}): Updated accordingly.
+
 2018-09-07  Alexei Podtelezhnikov  <address@hidden>
 
        [ftview] Extra space for zero-width glyphs.
diff --git a/src/ftview.c b/src/ftview.c
index 3e5650e..5d01e24 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -59,11 +59,10 @@
             y = start_y;                                         \
           } while ( 0 )
 
-#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 )
+#define X_TOO_LONG( x, display )                 \
+          ( (x) >= (display)->bitmap->width - 3 )
+#define Y_TOO_LONG( y, display )                \
+          ( (y) >= (display)->bitmap->rows - 3 )
 
 #ifdef _WIN32
 #define snprintf  _snprintf
@@ -177,7 +176,7 @@
   Render_Stroke( int  num_indices,
                  int  offset )
   {
-    int           start_x, start_y, step_y, x, y;
+    int           start_x, start_y, step_y, x, y, width;
     int           i, have_topleft;
     FT_Size       size;
     FT_Face       face;
@@ -233,23 +232,30 @@
           goto Next;
         }
 
-        /* extra space between glyphs */
-        x++;
-        if ( slot->advance.x == 0 )
-          x += size->metrics.y_ppem / 2;
+        width = slot->advance.x ? slot->advance.x >> 6
+                                : size->metrics.y_ppem / 2;
 
-        if ( X_TOO_LONG( x, slot, display ) )
+        if ( X_TOO_LONG( x + width, display ) )
         {
           x  = start_x;
           y += step_y;
 
-          if ( Y_TOO_LONG( y, size, display ) )
+          if ( Y_TOO_LONG( y, display ) )
           {
             FT_Done_Glyph( glyph );
             break;
           }
         }
 
+        /* extra space between glyphs */
+        x++;
+        if ( slot->advance.x == 0 )
+        {
+          grFillRect( display->bitmap, x, y - width, width, width,
+                      display->warn_color );
+          x += width;
+        }
+
         error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
 
         if ( error )
@@ -276,7 +282,7 @@
   Render_Fancy( int  num_indices,
                 int  offset )
   {
-    int           start_x, start_y, step_y, x, y;
+    int           start_x, start_y, step_y, x, y, width;
     int           i, have_topleft;
     FT_Size       size;
     FT_Face       face;
@@ -375,20 +381,27 @@
       if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
         slot->bitmap_top += ystr >> 6;
 
-      /* extra space between glyphs */
-      x++;
-      if ( slot->advance.x == 0 )
-        x += size->metrics.y_ppem / 2;
+      width = slot->advance.x ? slot->advance.x >> 6
+                              : size->metrics.y_ppem / 2;
 
-      if ( X_TOO_LONG( x, slot, display ) )
+      if ( X_TOO_LONG( x + width, display ) )
       {
         x  = start_x;
         y += step_y;
 
-        if ( Y_TOO_LONG( y, size, display ) )
+        if ( Y_TOO_LONG( y, display ) )
           break;
       }
 
+      /* extra space between glyphs */
+      x++;
+      if ( slot->advance.x == 0 )
+      {
+        grFillRect( display->bitmap, x, y - width, width, width,
+                    display->warn_color );
+        x += width;
+      }
+
       error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
 
       if ( error )
@@ -414,7 +427,7 @@
   Render_All( int  num_indices,
               int  offset )
   {
-    int           start_x, start_y, step_y, x, y;
+    int           start_x, start_y, step_y, x, y, width;
     int           i, have_topleft;
     FT_Size       size;
     FT_Face       face;
@@ -521,20 +534,27 @@
           goto Next;
       }
 
-      /* extra space between glyphs */
-      x++;
-      if ( slot->advance.x == 0 )
-        x += size->metrics.y_ppem / 2;
+      width = slot->advance.x ? slot->advance.x >> 6
+                              : size->metrics.y_ppem / 2;
 
-      if ( X_TOO_LONG( x, slot, display ) )
+      if ( X_TOO_LONG( x + width, display ) )
       {
         x = start_x;
         y += step_y;
 
-        if ( Y_TOO_LONG( y, size, display ) )
+        if ( Y_TOO_LONG( y, display ) )
           break;
       }
 
+      /* extra space between glyphs */
+      x++;
+      if ( slot->advance.x == 0 )
+      {
+        grFillRect( display->bitmap, x, y - width, width, width,
+                    display->warn_color );
+        x += width;
+      }
+
       error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
       if ( error )
         goto Next;
@@ -555,12 +575,6 @@
   }
 
 
-#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 )
@@ -627,12 +641,12 @@
         status.topleft = ch;
       }
 
-      if ( X_TOO_LONG( x, size, display ) )
+      if ( X_TOO_LONG( x + ( size->metrics.max_advance >> 6 ), display ) )
       {
         x  = start_x;
         y += step_y;
 
-        if ( Y_TOO_LONG( y, size, display ) )
+        if ( Y_TOO_LONG( y, display ) )
           break;
       }
 
@@ -743,7 +757,7 @@
           status.topleft = ch;
         }
 
-        if ( X_TOO_LONG( x, size, display ) )
+        if ( X_TOO_LONG( x + ( size->metrics.max_advance >> 6 ), display ) )
           break;
 
         continue;



reply via email to

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