freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] veeki-gsoc-experimental 6c57eb9: UI Changes


From: Veeki Yadav
Subject: [freetype2-demos] veeki-gsoc-experimental 6c57eb9: UI Changes
Date: Sat, 20 Jul 2019 03:59:53 -0400 (EDT)

branch: veeki-gsoc-experimental
commit 6c57eb9612a40764a734e51ae03aa5ec59871f2e
Author: gevic <address@hidden>
Commit: gevic <address@hidden>

    UI Changes
---
 src/ftinspect/maingui.cpp        |  42 ++++-
 src/ftinspect/rendering/view.cpp | 337 ++++++++++++++++++++++++---------------
 2 files changed, 246 insertions(+), 133 deletions(-)

diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index c22e99c..531834f 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -470,9 +470,8 @@ MainGUI::checkKerningMode()
     kerning_mode = 2;
   }
   
-  render_mode = 6;
   renderAll();
-  renderingModeComboBoxx->setItemEnabled(5, true);
+  //renderingModeComboBoxx->setItemEnabled(5, true);
 }
 
 
@@ -496,9 +495,8 @@ MainGUI::checkKerningDegree()
     kerning_degree = 3;
   }
 
-  render_mode = 6;
   renderAll();
-  renderingModeComboBoxx->setItemEnabled(5, true);
+  //renderingModeComboBoxx->setItemEnabled(5, true);
 }
 
 
@@ -590,6 +588,40 @@ MainGUI::gridViewRender()
 void
 MainGUI::renderAll()
 {
+  kerningDegreeComboBoxx->setEnabled(false);
+  kerningModeComboBoxx->setEnabled(false);
+  stroke_Slider->setEnabled(false);
+
+  if (render_mode == 3)
+  {
+    stroke_Slider->setEnabled(true);
+  }
+
+  if (render_mode == 4 || render_mode == 5)
+  {
+    kerningDegreeComboBoxx->setEnabled(true);
+    kerningModeComboBoxx->setEnabled(true);
+  }
+
+  if (render_mode == 2)
+  {
+    embolden_x_Slider->setEnabled(true);
+    embolden_y_Slider->setEnabled(true);
+    slant_Slider->setEnabled(true);
+  } else
+  {
+    // Diable unused parameters for render modes
+    embolden_x_Slider->setEnabled(false);
+    embolden_y_Slider->setEnabled(false);
+    slant_Slider->setEnabled(false);
+  }
+
+  // Diable unused parameters
+  showPointNumbersCheckBox->setEnabled(false);
+  showBitmapCheckBox->setEnabled(false);
+  showPointsCheckBox->setEnabled(false);
+  showOutlinesCheckBox->setEnabled(false);
+
   // Embolden factors
   double x_factor = embolden_x_Slider->value()/1000.0;
   double y_factor = embolden_y_Slider->value()/1000.0;
@@ -1180,9 +1212,7 @@ MainGUI::createLayout()
   embolden_y_Slider = new QSlider(Qt::Horizontal);
   embolden_x_Slider->setRange(0, 100); // 5 = 0.005
   embolden_y_Slider->setRange(0, 100);
-  embolden_x_Slider->setTickPosition(QSlider::TicksBelow);
   embolden_x_Slider->setTickInterval(5);
-  embolden_y_Slider->setTickPosition(QSlider::TicksBelow);
   embolden_y_Slider->setTickInterval(5);
   xLabel->setBuddy(embolden_x_Slider);
   yLabel->setBuddy(embolden_y_Slider);
diff --git a/src/ftinspect/rendering/view.cpp b/src/ftinspect/rendering/view.cpp
index 2c74ae8..56a0df0 100644
--- a/src/ftinspect/rendering/view.cpp
+++ b/src/ftinspect/rendering/view.cpp
@@ -11,12 +11,8 @@
 
 #define ft_render_mode_normal  FT_RENDER_MODE_NORMAL
   /* special encoding to display glyphs in order */
-#define FT_ENCODING_ORDER  0xFFFF
-#define ft_encoding_unicode         FT_ENCODING_UNICODE
-#define START_X  18 * 8
-#define START_Y  3 * 12
-
-#define TRUNC(x) ((x) >> 6)
+#define FT_ENCODING_ORDER 0xFFFF
+#define ft_encoding_unicode FT_ENCODING_UNICODE
 
 extern "C" {
 
@@ -98,6 +94,12 @@ static FT_Outline_Funcs outlineFuncs =
 
 static const char*  Sample[] =
   {
+    "None   The quick brown fox jumps over the lazy dog",
+
+    "Track  The quick brown fox jumps over the lazy dog",
+
+    "Both   The quick brown fox jumps over the lazy dog",
+
     "The quick brown fox jumps over the lazy dog",
 
     /* Luís argüia à Júlia que «brações, fé, chá, óxido, pôr, zângão» */
@@ -142,7 +144,7 @@ static const char*  Sample[] =
 
 
 
-/* static const char*  Sample[0] =
+/* static const char*  Sample[3] =
       "The quick brown fox jumps over the lazy dog"
       " 0123456789"
       " \303\242\303\252\303\256\303\273\303\264"
@@ -214,8 +216,8 @@ RenderAll::paint(QPainter* painter,
   // Basic def or just pass size 
   slot = face->glyph;
   FT_UInt  glyph_idx;
-  int x = -350;
-  int y = -180;
+  int x = -280;
+  int y = -20;
 
 
  // Normal rendering mode
@@ -269,10 +271,10 @@ RenderAll::paint(QPainter* painter,
       x += face->glyph->advance.x/64;
       // extra space between the glyphs
       x++;
-      if (x >= 350)
+      if (x >= 280)
       { 
         y += (size->metrics.height + 4)/64;
-        x = -350;
+        x = -280;
       }
     }
   }
@@ -382,10 +384,10 @@ RenderAll::paint(QPainter* painter,
       x += face->glyph->advance.x/64;
       // extra space between the glyphs
       x++;
-      if (x >= 350)
+      if (x >= 280)
       { 
         y += (size->metrics.height + 4)/64;
-        x = -350;
+        x = -280;
       }
     }
   }
@@ -507,52 +509,69 @@ RenderAll::paint(QPainter* painter,
   // Render String mode
   if (mode == 4)
   {
-    /*
-     In UTF-8 encoding:
-
-       The quick brown fox jumps over the lazy dog
-       0123456789
-       âêîûôäëïöüÿàùéèç
-       &#~"'(-`_^@)=+°
-       ABCDEFGHIJKLMNOPQRSTUVWXYZ
-       $£^¨*µù%!§:/;.,?<>
-
-     The trailing space is for `looping' in case `Sample[0]' gets displayed 
more
-     than once.
-   */
-    
+    FT_Pos lsb_delta = 0; /* delta caused by hinting */
+    FT_Pos rsb_delta = 0; /* delta caused by hinting */
     const char*  p;
     const char*  pEnd;
     int          ch;
+    FT_Pos track_kern = 0;
+    FT_Bool use_kerning;
+    FT_UInt previous;
 
-    p    = Sample[0];
-    pEnd = p + strlen( Sample[0] ); 
+    use_kerning = FT_HAS_KERNING( face );
+    previous = 0;
 
-    int length = strlen(Sample[0]);
+    p    = Sample[3];
+    pEnd = p + strlen( Sample[3] ); 
+
+    int length = strlen(Sample[3]);
+
+    // if kerning degree > 0
+    if ( kerning_degree )
+    {
+      /* this function needs and returns points, not pixels */
+      if ( !FT_Get_Track_Kerning( face,
+                                  (FT_Fixed)scaler.width << 10,
+                                  -kerning_degree,
+                                  &track_kern ) )
+      track_kern = (FT_Pos)(
+                    ( track_kern / 1024.0 * scaler.x_res ) /
+                    72.0 );
+    }
 
     for ( int i = 0; i < length; i++ )
     {
-      QChar ch = Sample[0][i];
+      QChar ch = Sample[3][i];
 
       // get char index 
       glyph_idx = FT_Get_Char_Index( face , ch.unicode());
-      /* if ( face->charmap->encoding != FT_ENCODING_ORDER )
+
+      x += track_kern;
+
+      if (previous && glyph_idx )
       {
-        glyph_idx = FTC_CMapCache_Lookup(cmap_cache, face_id,
-                                          FT_Get_Charmap_Index(face->charmap), 
(FT_UInt32)ch);
+        FT_Vector delta;
+
+        FT_Get_Kerning( face, previous, glyph_idx,
+                        FT_KERNING_UNFITTED, &delta );
+
+        x += delta.x;
+        
+        if ( kerning_mode > 1 )
+        {   
+            if ( rsb_delta && rsb_delta - face->glyph->lsb_delta > 32 )
+              x -= 1;
+            else if ( rsb_delta && rsb_delta - face->glyph->lsb_delta < -31 )
+              x += 1;
+        }
       }
-      else
-      {
-        glyph_idx = (FT_UInt32)ch;
-      }*/
 
-      //glyph_idx = (FT_UInt)i;
       /* load glyph image into the slot (erase previous one) */
       error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
       if ( error )
       {
         break;  /* ignore errors */
-      } 
+      }
 
       error = FT_Render_Glyph(face->glyph,
                                 FT_RENDER_MODE_NORMAL);
@@ -571,39 +590,81 @@ RenderAll::paint(QPainter* painter,
       }
         
       glyphImage.setColorTable(colorTable);
-      
-
       painter->drawImage(x, y,
                         glyphImage, 0, 0, -1, -1);
 
-      x += face->glyph->advance.x/64;
-      if (x >= 350)
-      { 
-        y += (size->metrics.height + 4)/64;
-        x = -350;
+      if (previous)
+      {
+        lsb_delta = face->glyph->lsb_delta;
+        rsb_delta = face->glyph->rsb_delta;
       }
+      // space between the glyphs
+      x += face->glyph->advance.x/64;
+
+      previous = glyph_idx;
     }
   }
 
   // Waterfall rendering mode
   if (mode == 5)
   {
+    FT_Pos track_kern = 0;
+    FT_Bool use_kerning;
+    y = -180;
     
-    int length = strlen(Sample[0]);
+    int length = strlen(Sample[3]);
+
+       // if kerning degree > 0
+    if ( kerning_degree )
+    {
+      /* this function needs and returns points, not pixels */
+      if ( !FT_Get_Track_Kerning( face,
+                                  (FT_Fixed)scaler.width << 10,
+                                  -kerning_degree,
+                                  &track_kern ) )
+      track_kern = (FT_Pos)(
+                    ( track_kern / 1024.0 * scaler.x_res ) /
+                    72.0 );
+    }
+
     while (y <= 200)
     { 
       int m = 0;
+      FT_Pos lsb_delta = 0; /* delta caused by hinting */
+      FT_Pos rsb_delta = 0; /* delta caused by hinting */
+      FT_UInt previous;
+
       while ( m < length )
       {
 
         FT_Glyph  glyph;
-        QChar ch = Sample[0][m];
+        QChar ch = Sample[3][m];
         m += 1;
 
           
         // get char index 
         glyph_idx = FT_Get_Char_Index( face , ch.unicode());
 
+        x += track_kern;
+
+        if (previous && glyph_idx )
+        {
+          FT_Vector delta;
+
+          FT_Get_Kerning( face, previous, glyph_idx,
+                          FT_KERNING_UNFITTED, &delta );
+
+          x += delta.x;
+          
+          if ( kerning_mode > 1 )
+          {   
+              if ( rsb_delta && rsb_delta - face->glyph->lsb_delta > 32 )
+                x -= 1;
+              else if ( rsb_delta && rsb_delta - face->glyph->lsb_delta < -31 )
+                x += 1;
+          }
+        }
+
         error = FTC_ImageCache_LookupScaler(imageCache,
                                   &scaler,
                                   FT_LOAD_NO_BITMAP,
@@ -644,118 +705,140 @@ RenderAll::paint(QPainter* painter,
 
         painter->drawImage(x, y,
                           glyphImage, 0, 0, -1, -1);
+        
+        if (previous)
+        {
+          lsb_delta = face->glyph->lsb_delta;
+          rsb_delta = face->glyph->rsb_delta;
+        }
 
         x += face->glyph->advance.x/64;
         if (x >= 350)
         { 
           break;
         }
+        previous = glyph_idx;
       }
       y = y + 50;
-      x = -350;
+      x = -280;
     }
   }
 
   // Kerning comparison
   if (mode == 6)
   {
-    /* 1. Print text without kerning
-    2. Print text with kerning mode 1
-    3. Print text with kerning mode 2 */
-    FT_Pos     lsb_delta = 0; /* delta caused by hinting */
-    FT_Pos     rsb_delta = 0; /* delta caused by hinting */
-    const char*  p;
-    const char*  pEnd;
-    int          ch;
-    FT_Pos   track_kern   = 0;
-    FT_Bool use_kerning;
-    FT_UInt previous;
 
-    use_kerning = FT_HAS_KERNING( face );
-    previous = 0;
+    for (int line = 0; line < 3; line++)
+    {
 
-    p    = Sample[0];
-    pEnd = p + strlen( Sample[0] ); 
+      FT_Pos     lsb_delta = 0; /* delta caused by hinting */
+      FT_Pos     rsb_delta = 0; /* delta caused by hinting */
+      const char*  p;
+      const char*  pEnd;
+      int          ch;
+      FT_Pos   track_kern   = 0;
+      FT_Bool use_kerning;
+      FT_UInt previous;
 
-    int length = strlen(Sample[0]);
+      use_kerning = FT_HAS_KERNING( face );
 
-    // if kerning degree > 0
-    if ( kerning_degree )
-    {
-      /* this function needs and returns points, not pixels */
-      if ( !FT_Get_Track_Kerning( face,
-                                  (FT_Fixed)scaler.width << 10,
-                                  -kerning_degree,
-                                  &track_kern ) )
-      track_kern = (FT_Pos)(
-                    ( track_kern / 1024.0 * scaler.x_res ) /
-                    72.0 );
-    }
+      // Line 1 (None)
+      if (line == 0)
+      {
+        use_kerning = 1;
+      } else
+      {
+        kerning_degree = 1;
+      }
 
-    for ( int i = 0; i < length; i++ )
-    {
-      QChar ch = Sample[0][i];
+      previous = 0;
 
-      // get char index 
-      glyph_idx = FT_Get_Char_Index( face , ch.unicode());
+      p    = Sample[line];
+      pEnd = p + strlen( Sample[line] ); 
 
-      x += track_kern;
+      int length = strlen(Sample[line]);
 
-      if (previous && glyph_idx )
+      // if kerning degree > 0
+      if ( kerning_degree )
       {
-        FT_Vector delta;
+        /* this function needs and returns points, not pixels */
+        if ( !FT_Get_Track_Kerning( face,
+                                    (FT_Fixed)scaler.width << 10,
+                                    -kerning_degree,
+                                    &track_kern ) )
+        track_kern = (FT_Pos)(
+                      ( track_kern / 1024.0 * scaler.x_res ) /
+                      72.0 );
+      }
 
-        FT_Get_Kerning( face, previous, glyph_idx,
-                        FT_KERNING_UNFITTED, &delta );
+      for ( int i = 0; i < length; i++ )
+      {
+        QChar ch = Sample[line][i];
 
-        x += delta.x;
-        
-        if ( kerning_mode > 1 )
-        {   
-            if ( rsb_delta && rsb_delta - face->glyph->lsb_delta > 32 )
-              x -= 1;
-            else if ( rsb_delta && rsb_delta - face->glyph->lsb_delta < -31 )
-              x += 1;
+        // get char index 
+        glyph_idx = FT_Get_Char_Index( face , ch.unicode());
+
+        x += track_kern;
+
+        if (!use_kerning && previous && glyph_idx )
+        {
+          FT_Vector delta;
+
+          FT_Get_Kerning( face, previous, glyph_idx,
+                          FT_KERNING_UNFITTED, &delta );
+
+          x += delta.x;
+          
+          if ( kerning_mode > 1 )
+          {   
+              if ( rsb_delta && rsb_delta - face->glyph->lsb_delta > 32 )
+                x -= 1;
+              else if ( rsb_delta && rsb_delta - face->glyph->lsb_delta < -31 )
+                x += 1;
+          }
         }
-      }
 
-      /* load glyph image into the slot (erase previous one) */
-      error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
-      if ( error )
-      {
-        break;  /* ignore errors */
-      }
+        /* load glyph image into the slot (erase previous one) */
+        error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+        if ( error )
+        {
+          break;  /* ignore errors */
+        }
 
-      error = FT_Render_Glyph(face->glyph,
-                                FT_RENDER_MODE_NORMAL);
+        error = FT_Render_Glyph(face->glyph,
+                                  FT_RENDER_MODE_NORMAL);
 
-      QImage glyphImage(face->glyph->bitmap.buffer,
-                          face->glyph->bitmap.width,
-                          face->glyph->bitmap.rows,
-                          face->glyph->bitmap.pitch,
-                          QImage::Format_Indexed8);
+        QImage glyphImage(face->glyph->bitmap.buffer,
+                            face->glyph->bitmap.width,
+                            face->glyph->bitmap.rows,
+                            face->glyph->bitmap.pitch,
+                            QImage::Format_Indexed8);
 
 
-      QVector<QRgb> colorTable;
-      for (int i = 0; i < 256; ++i)
-      {
-        colorTable << qRgba(0, 0, 0, i);
-      }
-        
-      glyphImage.setColorTable(colorTable);
-      painter->drawImage(x, y,
-                        glyphImage, 0, 0, -1, -1);
+        QVector<QRgb> colorTable;
+        for (int i = 0; i < 256; ++i)
+        {
+          colorTable << qRgba(0, 0, 0, i);
+        }
+          
+        glyphImage.setColorTable(colorTable);
+        painter->drawImage(x, y,
+                          glyphImage, 0, 0, -1, -1);
 
-      if (previous)
-      {
-        lsb_delta = face->glyph->lsb_delta;
-        rsb_delta = face->glyph->rsb_delta;
+        if (previous)
+        {
+          lsb_delta = face->glyph->lsb_delta;
+          rsb_delta = face->glyph->rsb_delta;
+        }
+        // space between the glyphs
+        x += face->glyph->advance.x/64;
+
+        previous = glyph_idx;
       }
-      // space between the glyphs
-      x += face->glyph->advance.x/64;
 
-      previous = glyph_idx;
-    }
+      y += (size->metrics.height + 4)/64;
+      x = -280;
+    }    
   }
 }
 



reply via email to

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