freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] gsoc-2022-chariri-3 6a26451 34/36: [ftinspect] Support


From: Werner Lemberg
Subject: [freetype2-demos] gsoc-2022-chariri-3 6a26451 34/36: [ftinspect] Support color layer rendering in Singular View.
Date: Wed, 27 Jul 2022 06:32:47 -0400 (EDT)

branch: gsoc-2022-chariri-3
commit 6a264517f29f490762f42869c7621988c7f106ec
Author: Charlie Jiang <w@chariri.moe>
Commit: Charlie Jiang <w@chariri.moe>

    [ftinspect] Support color layer rendering in Singular View.
    
    * src/ftinspect/rendering/glyphbitmap.cpp,
      src/ftinspect/rendering/glyphbitmap.hpp:
      Add an extra argument `glyphIndex` in the constructor and attempt to
      render the glyph as color layered in the first.
    
    * src/ftinspect/panels/singular.cpp: Pass glyph index to `GlyphBitmap`.
---
 src/ftinspect/panels/singular.cpp       |  3 ++-
 src/ftinspect/rendering/glyphbitmap.cpp | 13 +++++++++++--
 src/ftinspect/rendering/glyphbitmap.hpp |  3 ++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/ftinspect/panels/singular.cpp 
b/src/ftinspect/panels/singular.cpp
index 69da230..4f58590 100644
--- a/src/ftinspect/panels/singular.cpp
+++ b/src/ftinspect/panels/singular.cpp
@@ -94,7 +94,8 @@ SingularTab::drawGlyph()
     if (showBitmapCheckBox_->isChecked())
     {
       currentGlyphBitmapItem_
-        = new GlyphBitmap(glyph,
+        = new GlyphBitmap(currentGlyphIndex_, 
+                          glyph,
                           engine_);
       glyphScene_->addItem(currentGlyphBitmapItem_);
     }
diff --git a/src/ftinspect/rendering/glyphbitmap.cpp 
b/src/ftinspect/rendering/glyphbitmap.cpp
index a3a35db..6cdc49a 100644
--- a/src/ftinspect/rendering/glyphbitmap.cpp
+++ b/src/ftinspect/rendering/glyphbitmap.cpp
@@ -14,12 +14,21 @@
 #include <freetype/ftbitmap.h>
 
 
-GlyphBitmap::GlyphBitmap(FT_Glyph glyph,
+GlyphBitmap::GlyphBitmap(int glyphIndex, 
+                         FT_Glyph glyph,
                          Engine* engine)
 {
   QRect bRect;
+  image_ = engine->tryDirectRenderColorLayers(glyphIndex, &bRect);
+  if (image_)
+  {
+    bRect.setTop(-bRect.top());
+    boundingRect_ = bRect; // QRect to QRectF
+    return;
+  }
+
   image_ = engine->convertGlyphToQImage(glyph, &bRect, true);
-  boundingRect_ = bRect; // QRectF to QRect
+  boundingRect_ = bRect; // QRect to QRectF
 }
 
 
diff --git a/src/ftinspect/rendering/glyphbitmap.hpp 
b/src/ftinspect/rendering/glyphbitmap.hpp
index 4e771ca..73c4f71 100644
--- a/src/ftinspect/rendering/glyphbitmap.hpp
+++ b/src/ftinspect/rendering/glyphbitmap.hpp
@@ -20,7 +20,8 @@ class GlyphBitmap
 : public QGraphicsItem
 {
 public:
-  GlyphBitmap(FT_Glyph glyph,
+  GlyphBitmap(int glyphIndex,
+              FT_Glyph glyph,
               Engine* engine);
   ~GlyphBitmap() override;
   QRectF boundingRect() const override;



reply via email to

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