freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 69ff8ca 1/7: [ftinspect] Handle engine properti


From: Werner LEMBERG
Subject: [freetype2-demos] master 69ff8ca 1/7: [ftinspect] Handle engine properties.
Date: Fri, 06 May 2016 14:20:49 +0000

branch: master
commit 69ff8ca5448b237fa9b185ad63cd3204e3e38f5a
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [ftinspect] Handle engine properties.
    
    * src/ftinspect.cpp (Engine::Engine): Handle CFF's `hinting-engine',
    TrueType's `interpreter-version', and the auto-hinter's `warping'
    properties.
    
    * src/ftinspect.h (Engine): Updated.
---
 ChangeLog         |   10 +++++
 src/ftinspect.cpp |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ftinspect.h   |   12 ++++++
 3 files changed, 137 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index add3ea7..dcff0e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2016-05-05  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Handle engine properties.
+
+       * src/ftinspect.cpp (Engine::Engine): Handle CFF's `hinting-engine',
+       TrueType's `interpreter-version', and the auto-hinter's `warping'
+       properties.
+
+       * src/ftinspect.h (Engine): Updated.
+
+2016-05-05  Werner Lemberg  <address@hidden>
+
        [ftinspect] Start implementation of `showFont'.
 
        * src/ftinspect.cpp (MainGUI::loadFonts): Call `showFont'.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 2170b21..7ea8b14 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -67,6 +67,121 @@ Engine::Engine(MainGUI* g)
     // XXX error handling
   }
 
+  // query engines and check for alternatives
+
+  // CFF
+  error = FT_Property_Get(library,
+                          "cff",
+                          "hinting-engine",
+                          &cffHintingEngineDefault);
+  if (error)
+  {
+    // no CFF engine
+    cffHintingEngineDefault = -1;
+    cffHintingEngineOther = -1;
+  }
+  else
+  {
+    int engines[2] =
+    {
+      FT_CFF_HINTING_FREETYPE,
+      FT_CFF_HINTING_ADOBE
+    };
+
+    int i;
+    for (i = 0; i < 2; i++)
+      if (cffHintingEngineDefault == engines[i])
+        break;
+
+    cffHintingEngineOther = engines[(i + 1) % 2];
+
+    error = FT_Property_Set(library,
+                            "cff",
+                            "hinting-engine",
+                            &cffHintingEngineOther);
+    if (error)
+      cffHintingEngineOther = -1;
+
+    // reset
+    FT_Property_Set(library,
+                    "cff",
+                    "hinting-engine",
+                    &cffHintingEngineDefault);
+  }
+
+  // TrueType
+  error = FT_Property_Get(library,
+                          "truetype",
+                          "interpreter-version",
+                          &ttInterpreterVersionDefault);
+  if (error)
+  {
+    // no TrueType engine
+    ttInterpreterVersionDefault = -1;
+    ttInterpreterVersionOther = -1;
+    ttInterpreterVersionOther1 = -1;
+  }
+  else
+  {
+    int interpreters[3] =
+    {
+      TT_INTERPRETER_VERSION_35,
+      TT_INTERPRETER_VERSION_38,
+      40, // TT_INTERPRETER_VERSION_40, not yet implemented
+    };
+
+    int i;
+    for (i = 0; i < 3; i++)
+      if (ttInterpreterVersionDefault == interpreters[i])
+        break;
+
+    ttInterpreterVersionOther = interpreters[(i + 1) % 3];
+
+    error = FT_Property_Set(library,
+                            "truetype",
+                            "interpreter-version",
+                            &ttInterpreterVersionOther);
+    if (error)
+      ttInterpreterVersionOther = -1;
+
+    ttInterpreterVersionOther1 = interpreters[(i + 2) % 3];
+
+    error = FT_Property_Set(library,
+                            "truetype",
+                            "interpreter-version",
+                            &ttInterpreterVersionOther1);
+    if (error)
+      ttInterpreterVersionOther1 = -1;
+
+    // reset
+    FT_Property_Set(library,
+                    "truetype",
+                    "interpreter-version",
+                    &ttInterpreterVersionDefault);
+  }
+
+  // auto-hinter
+  error = FT_Property_Get(library,
+                          "autofitter",
+                          "warping",
+                          &doWarping);
+  if (error)
+  {
+    // no warping
+    haveWarping = 0;
+    doWarping = 0;
+  }
+  else
+  {
+    haveWarping = 1;
+    doWarping = 0; // we don't do warping by default
+
+    FT_Property_Set(library,
+                    "autofitter",
+                    "warping",
+                    &doWarping);
+  }
+
   update();
 }
 
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 61dde19..7878cbc 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -6,6 +6,9 @@
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_CACHE_H
+#include FT_CFF_DRIVER_H
+#include FT_MODULE_H
+#include FT_TRUETYPE_DRIVER_H
 
 #include <QAction>
 #include <QApplication>
@@ -79,6 +82,15 @@ private:
   FTC_ImageCache imageCache;
   FTC_SBitCache sbitsCache;
 
+  int cffHintingEngineDefault;
+  int cffHintingEngineOther;
+
+  int ttInterpreterVersionDefault;
+  int ttInterpreterVersionOther;
+  int ttInterpreterVersionOther1;
+
+  int haveWarping;
+
   double pointSize;
   double pixelSize;
   int dpi;



reply via email to

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