freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] veeki-gsoc-experimental 16e8ad5: UI and general bug fi


From: Veeki Yadav
Subject: [freetype2-demos] veeki-gsoc-experimental 16e8ad5: UI and general bug fixes.
Date: Fri, 16 Aug 2019 03:15:38 -0400 (EDT)

branch: veeki-gsoc-experimental
commit 16e8ad55878c52a347978a47f03d9626fb5f4384
Author: gevic <address@hidden>
Commit: gevic <address@hidden>

    UI and general bug fixes.
    
    'All Glyphs' mode now displays glyphs starting top.
    'General' tab settings supported in other modes.
    'Gamma Correction' supports all the modes.
---
 src/ftinspect/engine/engine.cpp         |   6 +
 src/ftinspect/engine/engine.hpp         |   1 +
 src/ftinspect/maingui.cpp               |  98 ++++++++++-----
 src/ftinspect/maingui.hpp               |   1 +
 src/ftinspect/rendering/comparator.cpp  |  37 +++++-
 src/ftinspect/rendering/comparator.hpp  |   6 +-
 src/ftinspect/rendering/glyphbitmap.cpp |   1 +
 src/ftinspect/rendering/view.cpp        | 217 ++++++++++++++++++++++++++------
 src/ftinspect/rendering/view.hpp        |   6 +-
 9 files changed, 300 insertions(+), 73 deletions(-)

diff --git a/src/ftinspect/engine/engine.cpp b/src/ftinspect/engine/engine.cpp
index 2e5c552..1d1dccf 100644
--- a/src/ftinspect/engine/engine.cpp
+++ b/src/ftinspect/engine/engine.cpp
@@ -711,6 +711,12 @@ Engine::setTTInterpreterVersion(int mode)
   }
 }
 
+unsigned long
+Engine::getFlags()
+{
+  return loadFlags;
+}
+
 
 void
 Engine::update()
diff --git a/src/ftinspect/engine/engine.hpp b/src/ftinspect/engine/engine.hpp
index c69bb93..8e98d7d 100644
--- a/src/ftinspect/engine/engine.hpp
+++ b/src/ftinspect/engine/engine.hpp
@@ -66,6 +66,7 @@ public:
   double getPtSize();
   double getPixelSize();
   int getResolution();
+  unsigned long getFlags();
   void setTTInterpreterVersion(int version);
   void update();
 
diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index ffea3d1..26587ed 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -470,6 +470,22 @@ MainGUI::closeFont()
   // disable font info menu
   menuInfo->setEnabled(false);
 
+  if (currentRenderAllItem)
+  {
+    glyphScene->removeItem(currentRenderAllItem);
+    delete currentRenderAllItem;
+
+    currentRenderAllItem = NULL;
+  }
+
+  if (currentComparatorItem)
+  {
+    glyphScene->removeItem(currentComparatorItem);
+    delete currentComparatorItem;
+
+    currentComparatorItem = NULL;
+  }
+
   showFont();
 }
 
@@ -612,6 +628,12 @@ MainGUI::checkHinting()
   }
 
   drawGlyph();
+
+  // hinting in 'all glyphs mode'
+  if (allGlyphs->isChecked())
+  {
+    renderAll();
+  }
 }
 
 
@@ -861,9 +883,11 @@ MainGUI::comparatorViewRender()
       {
         pixelMode[column_index] = FT_PIXEL_MODE_GRAY;
       }
-
     }
 
+    int column = columnComboBoxx->currentIndex();
+    load_flags[column] |= engine->getFlags();
+
         // Diable unused parameters
     showPointNumbersCheckBox->setEnabled(false);
     showBitmapCheckBox->setEnabled(false);
@@ -908,7 +932,9 @@ MainGUI::comparatorViewRender()
                                 grayColorTable,
                                 monoColorTable,
                                 warping,
-                                kerningCol);
+                                kerningCol,
+                                (gammaSlider->value()/10.0),
+                                engine->getFlags());
     glyphScene->addItem(currentComparatorItem);
     sizeDoubleSpinBox->setValue(11);
     zoomSpinBox->setValue(1);
@@ -974,6 +1000,19 @@ MainGUI::gridViewRender()
 
 
 void
+MainGUI::gammaChange()
+{
+  if (allGlyphs->isChecked())
+  {
+    renderAll();
+  } else
+  {
+    drawGlyph();
+  }
+}
+
+
+void
 MainGUI::renderAll()
 {
   kerningDegreeComboBoxx->setEnabled(false);
@@ -1043,14 +1082,6 @@ MainGUI::renderAll()
     currentGridItem = NULL;
   }
 
-  if (currentRenderAllItem)
-  {
-    glyphScene->removeItem(currentRenderAllItem);
-    delete currentRenderAllItem;
-
-    currentRenderAllItem = NULL;
-  }
-
   if (currentComparatorItem)
   {
     glyphScene->removeItem(currentComparatorItem);
@@ -1059,6 +1090,14 @@ MainGUI::renderAll()
     currentComparatorItem = NULL;
   }
 
+  if (currentRenderAllItem)
+  {
+    glyphScene->removeItem(currentRenderAllItem);
+    delete currentRenderAllItem;
+
+    currentRenderAllItem = NULL;
+  }
+
   showPointNumbersCheckBox->setChecked(false);
   showBitmapCheckBox->setChecked(false);
   showPointsCheckBox->setChecked(false);
@@ -1103,7 +1142,9 @@ MainGUI::renderAll()
                                   slant_factor,
                                   stroke_factor,
                                   kerning_mode,
-                                  kerning_degree);
+                                  kerning_degree,
+                                  engine->getFlags(),
+                                  (gammaSlider->value()/10.0));
   glyphScene->addItem(currentRenderAllItem);
   sizeDoubleSpinBox->setValue(20);
   zoomSpinBox->setValue(1);
@@ -1443,15 +1484,6 @@ MainGUI::drawGlyph()
     currentGlyphPointNumbersItem = NULL;
   }
 
-  /* if (currentRenderAllItem)
-  {
-    glyphScene->removeItem(currentRenderAllItem);
-    delete currentRenderAllItem;
-
-    currentRenderAllItem = NULL;
-
-  }*/
-
   FT_Outline* outline = engine->loadOutline(currentGlyphIndex);
   if (outline)
   {
@@ -1463,19 +1495,19 @@ MainGUI::drawGlyph()
         pixelMode = FT_PIXEL_MODE_MONO;
 
       currentGlyphBitmapItem = new GlyphBitmap(outline,
-                                               engine->library,
-                                               pixelMode,
-                                               (gammaSlider->value()/10.0),
-                                               monoColorTable,
-                                               grayColorTable);
+                                              engine->library,
+                                              pixelMode,
+                                              (gammaSlider->value()/10.0),
+                                              monoColorTable,
+                                              grayColorTable);
       glyphScene->addItem(currentGlyphBitmapItem);
     }
 
     if (segmentDrawingCheckBox->isChecked())
     {
       currentGlyphSegmentItem = new GlyphSegment(segmentPen,
-                                                 blueZonePen,
-                                                 engine->getFtSize());
+                                                blueZonePen,
+                                                engine->getFtSize());
       glyphScene->addItem(currentGlyphSegmentItem);
     }
 
@@ -1493,14 +1525,18 @@ MainGUI::drawGlyph()
       if (showPointNumbersCheckBox->isChecked())
       {
         currentGlyphPointNumbersItem = new GlyphPointNumbers(onPen,
-                                                             offPen,
-                                                             outline);
+                                                            offPen,
+                                                            outline);
         glyphScene->addItem(currentGlyphPointNumbersItem);
       }
     }
   }
-
   glyphScene->update();
+
+  if (comparatorView->isChecked())
+  {
+    comparatorViewRender();
+  }
 }
 
 
@@ -2075,7 +2111,7 @@ MainGUI::createConnections()
   connect(warpingColumnCheckBox, SIGNAL(clicked()),
           SLOT(comparatorViewRender()));
   connect(gammaSlider, SIGNAL(valueChanged(int)),
-          SLOT(drawGlyph()));
+          SLOT(gammaChange()));
   connect(embolden_x_Slider, SIGNAL(valueChanged(int)),
           SLOT(renderAll()));
   connect(embolden_y_Slider, SIGNAL(valueChanged(int)),
diff --git a/src/ftinspect/maingui.hpp b/src/ftinspect/maingui.hpp
index 524e07f..2a9aafe 100644
--- a/src/ftinspect/maingui.hpp
+++ b/src/ftinspect/maingui.hpp
@@ -115,6 +115,7 @@ private slots:
   void watchCurrentFont();
   void zoom();
   void renderAll();
+  void gammaChange();
   void gridViewRender();
   void comparatorViewRender();
 
diff --git a/src/ftinspect/rendering/comparator.cpp 
b/src/ftinspect/rendering/comparator.cpp
index 97656c0..89c67d1 100644
--- a/src/ftinspect/rendering/comparator.cpp
+++ b/src/ftinspect/rendering/comparator.cpp
@@ -30,13 +30,17 @@ Comparator::Comparator(FT_Library lib,
                         QVector<QRgb> grayColorTable,
                         QVector<QRgb> monoColorTable,
                         bool warping[],
-                        bool kerningCol[])
+                        bool kerningCol[],
+                        double gammaVal,
+                        unsigned long loadFlags)
 : library(lib),
 face(face),
 size(size),
 fontList(fontList),
 grayColorTable(grayColorTable),
-monoColorTable(monoColorTable)
+monoColorTable(monoColorTable),
+gamma(gammaVal),
+loadFlags(loadFlags)
 {
   load[0] = load_flags[0];
   load[1] = load_flags[1];
@@ -116,6 +120,9 @@ Comparator::paint(QPainter* painter,
   column_x_temp[1] = width + 3 * border_width + column_width;
   column_x_temp[2] = width + 5 * border_width + 2 * column_width;
 
+  const qreal lod = option->levelOfDetailFromTransform(
+                            painter->worldTransform());
+
   int height = -220;
 
   /* error = FT_New_Face(library,
@@ -198,9 +205,31 @@ Comparator::paint(QPainter* painter,
         FT_Pos bottom = face->glyph->metrics.height/64;
       }
 
+      for (int n = 0; n < glyphImage.width(); n++)
+      {
+        for (int m = 0; m < glyphImage.height(); m++)
+        {
+          // be careful not to lose the alpha channel
+          const QRgb p = glyphImage.pixel(n, m);
+          const double r = qRed(p) / 255.0;
+          const double g = qGreen(p) / 255.0;
+          const double b = qBlue(p) / 255.0;
+          const double a = qAlpha(p) / 255.0;
+          painter->fillRect(QRectF(n + column_x_start[col]- 1 / lod / 2,
+                                    m + height + bottom - 
face->glyph->metrics.horiBearingY/64- 1 / lod / 2,
+                                    1/lod,
+                                    1/lod),
+                            QColor(
+                                  255 * std::pow(r, 1/gamma),
+                                  255 * std::pow(g, 1/gamma),
+                                  255 * std::pow(b, 1/gamma),
+                                  255 * std::pow(a, 1/gamma)));
+        }
+      }
+
 
-      painter->drawImage(column_x_start[col], height + bottom - 
face->glyph->metrics.horiBearingY/64,
-                        glyphImage, 0, 0, -1, -1);
+      //painter->drawImage(column_x_start[col], height + bottom - 
face->glyph->metrics.horiBearingY/64,
+      //                 glyphImage, 0, 0, -1, -1);
 
 
       column_x_start[col] += face->glyph->advance.x/64;
diff --git a/src/ftinspect/rendering/comparator.hpp 
b/src/ftinspect/rendering/comparator.hpp
index 58c7272..f79b08d 100644
--- a/src/ftinspect/rendering/comparator.hpp
+++ b/src/ftinspect/rendering/comparator.hpp
@@ -36,7 +36,9 @@ public:
              QVector<QRgb> grayColorTable,
              QVector<QRgb> monoColorTable,
              bool warping[],
-             bool kerningCol[]);
+             bool kerningCol[],
+             double gamma,
+             unsigned long loadFlags);
   ~Comparator();
   QRectF boundingRect() const;
   void paint(QPainter* painter,
@@ -58,6 +60,8 @@ private:
   QVector<QRgb> monoColorTable;
   FT_UInt kerning_mode = FT_KERNING_DEFAULT;
   bool kerning[3];
+  double gamma;
+  unsigned long loadFlags;
 };
 
 
diff --git a/src/ftinspect/rendering/glyphbitmap.cpp 
b/src/ftinspect/rendering/glyphbitmap.cpp
index eae5fba..f82289c 100644
--- a/src/ftinspect/rendering/glyphbitmap.cpp
+++ b/src/ftinspect/rendering/glyphbitmap.cpp
@@ -8,6 +8,7 @@
 #include <cmath>
 #include <QPainter>
 #include <QStyleOptionGraphicsItem>
+#include <QtDebug>
 
 
 GlyphBitmap::GlyphBitmap(FT_Outline* outline,
diff --git a/src/ftinspect/rendering/view.cpp b/src/ftinspect/rendering/view.cpp
index c5d5304..2579e2d 100644
--- a/src/ftinspect/rendering/view.cpp
+++ b/src/ftinspect/rendering/view.cpp
@@ -171,7 +171,9 @@ RenderAll::RenderAll(FT_Face face,
           double slant_factor,
           double stroke_factor,
           int kern_mode,
-          int kern_degree)
+          int kern_degree,
+          unsigned long loadFlags,
+          double gammaVal)
 :face(face),
 size(size),
 cacheManager(cacheManager),
@@ -187,14 +189,15 @@ y_factor(y),
 slant_factor(slant_factor),
 stroke_factor(stroke_factor),
 kerning_mode(kern_mode),
-kerning_degree(kern_degree)
+kerning_degree(kern_degree),
+loadFlags(loadFlags),
+gamma(gammaVal)
 {
 }
 
 
 RenderAll::~RenderAll()
 {
-  //FT_Stroker_Done(stroker);
   //FTC_Manager_Done(cacheManager);
 }
 
@@ -220,7 +223,15 @@ RenderAll::paint(QPainter* painter,
   slot = face->glyph;
   FT_UInt  glyph_idx;
   int x = -280;
-  int y = -20;
+  int y = -180;
+
+  if ( gamma <= 0 ) // special case for sRGB
+  {
+    gamma = 2.4;
+  }
+
+  const qreal lod = option->levelOfDetailFromTransform(
+                              painter->worldTransform());
 
 
  // Normal rendering mode
@@ -245,7 +256,7 @@ RenderAll::paint(QPainter* painter,
       }
       //glyph_idx = (FT_UInt)i;
       /* load glyph image into the slot (erase previous one) */
-      error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+      error = FT_Load_Glyph( face, glyph_idx, loadFlags);
       if ( error )
       {
         break;  /* ignore errors */
@@ -276,8 +287,31 @@ RenderAll::paint(QPainter* painter,
         FT_Pos bottom = face->glyph->metrics.height/64;
       }
 
-      painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
-                        glyphImage, 0, 0, -1, -1);
+    
+      for (int n = 0; n < glyphImage.width(); n++)
+      {
+          for (int m = 0; m < glyphImage.height(); m++)
+          {
+            // be careful not to lose the alpha channel
+            const QRgb p = glyphImage.pixel(n, m);
+            const double r = qRed(p) / 255.0;
+            const double g = qGreen(p) / 255.0;
+            const double b = qBlue(p) / 255.0;
+            const double a = qAlpha(p) / 255.0;
+            painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                     m + y + bottom - 
face->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                     1,
+                                     1),
+                              QColor(
+                                    255 * std::pow(r, 1/gamma),
+                                    255 * std::pow(g, 1/gamma),
+                                    255 * std::pow(b, 1/gamma),
+                                    255 * std::pow(a, 1/gamma)));
+          }
+      }
+      //painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
+      //                  glyphImage, 0, 0, -1, -1);
+
 
       x += face->glyph->advance.x/64;
       // extra space between the glyphs
@@ -322,7 +356,7 @@ RenderAll::paint(QPainter* painter,
       }
 
       /* load glyph image into the slot (erase previous one) */
-      error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+      error = FT_Load_Glyph( face, glyph_idx, loadFlags );
       if ( error )
       {
         break;  /* ignore errors */
@@ -380,7 +414,7 @@ RenderAll::paint(QPainter* painter,
                           face->glyph->bitmap.pitch,
                           QImage::Format_Indexed8);
 
-      
+
 
       QVector<QRgb> colorTable;
       for (int i = 0; i < 256; ++i)
@@ -389,14 +423,37 @@ RenderAll::paint(QPainter* painter,
       }
         
       glyphImage.setColorTable(colorTable);
+
       FT_Pos bottom = 0;
       if (count == 1)
       {
         FT_Pos bottom = face->glyph->metrics.height/64;
       }
 
-      painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
-                        glyphImage, 0, 0, -1, -1);
+      for (int n = 0; n < glyphImage.width(); n++)
+      {
+          for (int m = 0; m < glyphImage.height(); m++)
+          {
+            // be careful not to lose the alpha channel
+            const QRgb p = glyphImage.pixel(n, m);
+            const double r = qRed(p) / 255.0;
+            const double g = qGreen(p) / 255.0;
+            const double b = qBlue(p) / 255.0;
+            const double a = qAlpha(p) / 255.0;
+            painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                     m + y + bottom - 
face->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                     1,
+                                     1),
+                              QColor(
+                                    255 * std::pow(r, 1/gamma),
+                                    255 * std::pow(g, 1/gamma),
+                                    255 * std::pow(b, 1/gamma),
+                                    255 * std::pow(a, 1/gamma)));
+          }
+        }
+
+      //painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
+      //                  glyphImage, 0, 0, -1, -1);
 
       x += face->glyph->advance.x/64;
       // extra space between the glyphs
@@ -437,7 +494,7 @@ RenderAll::paint(QPainter* painter,
         glyph_idx = (FT_UInt32)i;
       }
 
-      error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+      error = FT_Load_Glyph( face, glyph_idx, loadFlags );
 
       // XXX handle bitmap fonts
 
@@ -499,8 +556,30 @@ RenderAll::paint(QPainter* painter,
           FT_Pos bottom = face->glyph->metrics.height/64;
         }
 
-        painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
-                    glyphImage, 0, 0, -1, -1);
+        for (int n = 0; n < glyphImage.width(); n++)
+        {
+            for (int m = 0; m < glyphImage.height(); m++)
+            {
+              // be careful not to lose the alpha channel
+              const QRgb p = glyphImage.pixel(n, m);
+              const double r = qRed(p) / 255.0;
+              const double g = qGreen(p) / 255.0;
+              const double b = qBlue(p) / 255.0;
+              const double a = qAlpha(p) / 255.0;
+              painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                       m + y + bottom - 
face->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                       1,
+                                       1),
+                                QColor(
+                                      255 * std::pow(r, 1/gamma),
+                                      255 * std::pow(g, 1/gamma),
+                                      255 * std::pow(b, 1/gamma),
+                                      255 * std::pow(a, 1/gamma)));
+            }
+        }
+
+        //painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
+        //            glyphImage, 0, 0, -1, -1);
 
         x += face->glyph->advance.x/64;
         // extra space between the glyphs
@@ -579,7 +658,7 @@ RenderAll::paint(QPainter* painter,
       }
 
       /* load glyph image into the slot (erase previous one) */
-      error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+      error = FT_Load_Glyph( face, glyph_idx, loadFlags );
       if ( !error )
       {
         
@@ -611,21 +690,45 @@ RenderAll::paint(QPainter* painter,
 
       painter->translate(m_glyphRect.x(),m_glyphRect.y());
 
+      QVector<QRgb> colorTable;
+      for (int i = 0; i < 256; ++i)
+      {
+        colorTable << qRgba(0, 0, 0, i);
+      }
+
+      glyphImage.setColorTable(colorTable);
+
       FT_Pos bottom = 0;
       if (count == 1)
       {
         FT_Pos bottom = face->glyph->metrics.height/64;
       }
 
-      QVector<QRgb> colorTable;
-      for (int i = 0; i < 256; ++i)
+    
+      for (int n = 0; n < glyphImage.width(); n++)
       {
-        colorTable << qRgba(0, 0, 0, i);
+          for (int m = 0; m < glyphImage.height(); m++)
+          {
+            // be careful not to lose the alpha channel
+            const QRgb p = glyphImage.pixel(n, m);
+            const double r = qRed(p) / 255.0;
+            const double g = qGreen(p) / 255.0;
+            const double b = qBlue(p) / 255.0;
+            const double a = qAlpha(p) / 255.0;
+            painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                     m + y + bottom - 
face->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                     1,
+                                     1),
+                              QColor(
+                                    255 * std::pow(r, 1/gamma),
+                                    255 * std::pow(g, 1/gamma),
+                                    255 * std::pow(b, 1/gamma),
+                                    255 * std::pow(a, 1/gamma)));
+          }
       }
-        
-      glyphImage.setColorTable(colorTable);
-      painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
-                        glyphImage, 0, 0, -1, -1);
+
+      //painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
+      //                  glyphImage, 0, 0, -1, -1);
 
       if (previous)
       {
@@ -644,7 +747,6 @@ RenderAll::paint(QPainter* painter,
   {
     FT_Pos track_kern = 0;
     FT_Bool use_kerning;
-    y = -180;
     FT_Face f;
 
     error = FT_New_Face(library,
@@ -713,9 +815,9 @@ RenderAll::paint(QPainter* painter,
           
           if ( kerning_mode > 1 )
           {   
-              if ( rsb_delta && rsb_delta - face->glyph->lsb_delta > 32 )
+              if ( rsb_delta && rsb_delta - f->glyph->lsb_delta > 32 )
                 x -= 1;
-              else if ( rsb_delta && rsb_delta - face->glyph->lsb_delta < -31 )
+              else if ( rsb_delta && rsb_delta - f->glyph->lsb_delta < -31 )
                 x += 1;
           }
         }
@@ -728,7 +830,7 @@ RenderAll::paint(QPainter* painter,
                                   NULL);
 
         /* load glyph image into the slot (erase previous one) */
-        error = FT_Load_Glyph( f, glyph_idx, FT_LOAD_DEFAULT );
+        error = FT_Load_Glyph( f, glyph_idx, loadFlags );
         if ( error )
         {
           break;  /* ignore errors */
@@ -754,7 +856,7 @@ RenderAll::paint(QPainter* painter,
         {
           colorTable << qRgba(0, 0, 0, i);
         }
-          
+
         glyphImage.setColorTable(colorTable);
 
         FT_Pos bottom = 0;
@@ -763,14 +865,34 @@ RenderAll::paint(QPainter* painter,
           FT_Pos bottom = f->glyph->metrics.height/64;
         }
 
-
-        painter->drawImage(x, y + bottom - f->glyph->metrics.horiBearingY/64,
-                          glyphImage, 0, 0, -1, -1);
+        for (int n = 0; n < glyphImage.width(); n++)
+        {
+            for (int m = 0; m < glyphImage.height(); m++)
+            {
+              // be careful not to lose the alpha channel
+              const QRgb p = glyphImage.pixel(n, m);
+              const double r = qRed(p) / 255.0;
+              const double g = qGreen(p) / 255.0;
+              const double b = qBlue(p) / 255.0;
+              const double a = qAlpha(p) / 255.0;
+              painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                       m + y + bottom - 
f->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                       1,
+                                       1),
+                                QColor(
+                                      255 * std::pow(r, 1/gamma),
+                                      255 * std::pow(g, 1/gamma),
+                                      255 * std::pow(b, 1/gamma),
+                                      255 * std::pow(a, 1/gamma)));
+            }
+        }
+        //painter->drawImage(x, y + bottom - f->glyph->metrics.horiBearingY/64,
+        //                  glyphImage, 0, 0, -1, -1);
         
         if (previous)
         {
-          lsb_delta = face->glyph->lsb_delta;
-          rsb_delta = face->glyph->rsb_delta;
+          lsb_delta = f->glyph->lsb_delta;
+          rsb_delta = f->glyph->rsb_delta;
         }
 
         x += f->glyph->advance.x/64;
@@ -871,7 +993,7 @@ RenderAll::paint(QPainter* painter,
         }
 
         /* load glyph image into the slot (erase previous one) */
-        error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+        error = FT_Load_Glyph( face, glyph_idx, loadFlags );
         if ( error )
         {
           break;  /* ignore errors */
@@ -899,10 +1021,33 @@ RenderAll::paint(QPainter* painter,
         {
           FT_Pos bottom = face->glyph->metrics.height/64;
         }
-          
+
         glyphImage.setColorTable(colorTable);
-        painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
-                          glyphImage, 0, 0, -1, -1);
+
+
+        for (int n = 0; n < glyphImage.width(); n++)
+        {
+            for (int m = 0; m < glyphImage.height(); m++)
+            {
+              // be careful not to lose the alpha channel
+              const QRgb p = glyphImage.pixel(n, m);
+              const double r = qRed(p) / 255.0;
+              const double g = qGreen(p) / 255.0;
+              const double b = qBlue(p) / 255.0;
+              const double a = qAlpha(p) / 255.0;
+              painter->fillRect(QRectF(n + x - 1 / lod / 2,
+                                       m + y + bottom - 
face->glyph->metrics.horiBearingY/64 - 1 / lod / 2,
+                                       1,
+                                       1),
+                                QColor(
+                                      255 * std::pow(r, 1/gamma),
+                                      255 * std::pow(g, 1/gamma),
+                                      255 * std::pow(b, 1/gamma),
+                                      255 * std::pow(a, 1/gamma)));
+            }
+        }
+        //painter->drawImage(x, y + bottom - 
face->glyph->metrics.horiBearingY/64,
+        //                  glyphImage, 0, 0, -1, -1);
 
         if (previous)
         {
diff --git a/src/ftinspect/rendering/view.hpp b/src/ftinspect/rendering/view.hpp
index 82326dd..9bcda9d 100644
--- a/src/ftinspect/rendering/view.hpp
+++ b/src/ftinspect/rendering/view.hpp
@@ -46,7 +46,9 @@ public:
        double slant_factor,
        double stroke_factor,
        int kerning_mode,
-       int kerning_degree);
+       int kerning_degree,
+       unsigned long loadFlags,
+       double gamma);
   ~RenderAll();
   QRectF boundingRect() const;
   void paint(QPainter* painter,
@@ -74,6 +76,8 @@ private:
   double stroke_factor;
   int kerning_mode;
   int kerning_degree;
+  unsigned long loadFlags;
+  double gamma;
 };
 
 



reply via email to

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