freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] gsoc-2019-veeki e82616d 2/3: Minor changes


From: Veeki Yadav
Subject: [freetype2-demos] gsoc-2019-veeki e82616d 2/3: Minor changes
Date: Wed, 26 Jun 2019 18:06:41 -0400 (EDT)

branch: gsoc-2019-veeki
commit e82616d45a8008f072ba67480e48ddf2ca98816b
Author: gevic <address@hidden>
Commit: gevic <address@hidden>

    Minor changes
---
 src/ftinspect/maingui.cpp                |  9 ++-
 src/ftinspect/rendering/glyphsegment.cpp | 99 ++++++++++++++++----------------
 2 files changed, 57 insertions(+), 51 deletions(-)

diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index cc7d6d0..f9b4683 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -11,6 +11,7 @@
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QSettings>
+#include <QtDebug>
 
 #include FT_DRIVER_H
 #include FT_TRUETYPE_TABLES_H
@@ -737,6 +738,7 @@ MainGUI::zoom()
   transform.translate(shift, shift);
 
   glyphView->setTransform(transform);
+  drawGlyph();
 }
 
 
@@ -756,7 +758,7 @@ MainGUI::setGraphicsDefaults()
   axisPen.setColor(Qt::black);
   axisPen.setWidth(0);
   blueZonePen.setColor(QColor(64, 64, 255, 64)); // light blue
-  blueZonePen.setWidth(0);
+  blueZonePen.setWidthF(0.2);
   gridPen.setColor(Qt::lightGray);
   gridPen.setWidth(0);
   offPen.setColor(Qt::darkGreen);
@@ -766,7 +768,7 @@ MainGUI::setGraphicsDefaults()
   outlinePen.setColor(Qt::red);
   outlinePen.setWidth(0);
   segmentPen.setColor(QColor(64, 255, 128, 64)); // light green
-  segmentPen.setWidth(0);
+  segmentPen.setWidthF(0.2);
 }
 
 
@@ -774,6 +776,7 @@ void
 MainGUI::drawGlyph()
 {
   // the call to `engine->loadOutline' updates FreeType's load flags
+  qDebug()<<"called";
 
   if (!engine)
     return;
@@ -1070,7 +1073,7 @@ MainGUI::createLayout()
   glyphView = new QGraphicsViewx;
   glyphView->setRenderHint(QPainter::Antialiasing, true);
   glyphView->setDragMode(QGraphicsView::ScrollHandDrag);
-  glyphView->setOptimizationFlags(QGraphicsView::DontSavePainterState);
+  //glyphView->setOptimizationFlags(QGraphicsView::DontSavePainterState);
   glyphView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
   glyphView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
   glyphView->setScene(glyphScene);
diff --git a/src/ftinspect/rendering/glyphsegment.cpp 
b/src/ftinspect/rendering/glyphsegment.cpp
index dd0869c..1e77420 100644
--- a/src/ftinspect/rendering/glyphsegment.cpp
+++ b/src/ftinspect/rendering/glyphsegment.cpp
@@ -2,7 +2,6 @@
 
 #include <QPainter>
 #include <QStyleOptionGraphicsItem>
-#include <QtDebug>
 
 
 /* these variables, structures, and declarations are for  */
@@ -67,68 +66,72 @@ GlyphSegment::paint(QPainter* painter,
   const qreal lod = option->levelOfDetailFromTransform(
                               painter->worldTransform());
 
-  FT_Fixed  x_scale = ftsize->metrics.x_scale;
-  FT_Fixed  y_scale = ftsize->metrics.y_scale;
+  if (lod >= 5)
+  {
+    FT_Fixed  x_scale = ftsize->metrics.x_scale;
+    FT_Fixed  y_scale = ftsize->metrics.y_scale;
 
-  FT_Int  dimension;
-  int     x_org = 0;
-  int     y_org = 0;
- 
+    FT_Int  dimension;
+    int     x_org = 0;
+    int     y_org = 0;
 
-  painter->setPen(segmentPen);
 
-  for ( dimension = 1; dimension >= 0; dimension-- )
-  {
-    FT_Int  num_seg;
-    FT_Int  count;
+    for ( dimension = 1; dimension >= 0; dimension-- )
+    {
+      FT_Int  num_seg;
+      FT_Int  count;
 
-    af_glyph_hints_get_num_segments( _af_debug_hints, dimension, &num_seg );
+      af_glyph_hints_get_num_segments( _af_debug_hints, dimension, &num_seg );
 
-    for ( count = 0; count < num_seg; count++ )
-    {
-      int      pos;
-      FT_Pos   offset;
-      FT_Bool  is_blue;
-      FT_Pos   blue_offset;
-
-      af_glyph_hints_get_segment_offset( _af_debug_hints, dimension,
-                                           count, &offset,
-                                           &is_blue, &blue_offset);
-      
-      if ( dimension == 0 )
+      for ( count = 0; count < num_seg; count++ )
       {
-        offset = FT_MulFix( offset, x_scale );
-        pos    = x_org + ( ( offset) >> 6 );
-        painter->drawLine(pos, -100, pos, 100);
-      }
-      else
-      {
-        offset = FT_MulFix( offset, y_scale );
-        pos    = y_org - ( ( offset) >> 6 );
-
-        if ( is_blue )
+        int      pos;
+        FT_Pos   offset;
+        FT_Bool  is_blue;
+        FT_Pos   blue_offset;
+
+        painter->setPen(segmentPen);
+
+        af_glyph_hints_get_segment_offset( _af_debug_hints, dimension,
+                                              count, &offset,
+                                              &is_blue, &blue_offset);
+        
+        if ( dimension == 0 )
         {
-          int  blue_pos;
-
+          offset = FT_MulFix( offset, x_scale );
+          pos    = x_org + ( ( offset) >> 6 );
+          painter->drawLine(pos, -100, pos, 100);
+        }
+        else
+        {
+          offset = FT_MulFix( offset, y_scale );
+          pos    = y_org - ( ( offset) >> 6 );
 
-          blue_offset = FT_MulFix( blue_offset, y_scale );
-          blue_pos    = y_org - ( ( blue_offset) >> 6 );
-          if ( blue_pos == pos )
+          if ( is_blue )
           {
-            painter->drawLine(-100, pos, 100, pos);
+            int  blue_pos;
+
+
+            blue_offset = FT_MulFix( blue_offset, y_scale );
+            blue_pos    = y_org - ( ( blue_offset) >> 6 );
+            if ( blue_pos == pos )
+            {
+              painter->setPen(bluezonePen);
+              painter->drawLine(-100, blue_pos, 100, blue_pos);
+            }
+            else
+            {
+              painter->setPen(bluezonePen);
+              painter->drawLine(-100, blue_pos, 100, blue_pos);
+              painter->setPen(segmentPen);
+              painter->drawLine(-100, pos, 100, pos);
+            }
           }
           else
           {
-            painter->setPen(bluezonePen);
-            painter->drawLine(-100, blue_pos, 100, blue_pos);
-            painter->setPen(segmentPen);
             painter->drawLine(-100, pos, 100, pos);
           }
         }
-        else
-        {
-          painter->drawLine(-100, pos, 100, pos);
-        }
       }
     }
   }



reply via email to

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