[pango/userfont: 2/5] Implement coverage for user faces




commit 660ad677842698f2efaa809d098b3355574bf827
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 28 01:15:29 2022 -0500

    Implement coverage for user faces

 pango/pango-coverage-private.h |  3 +++
 pango/pango-coverage.c         | 29 +++++++++++++++++++++++++++++
 pango/pango-userfont.c         |  5 +++--
 3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-coverage-private.h b/pango/pango-coverage-private.h
index 4f7e79ea..a156913b 100644
--- a/pango/pango-coverage-private.h
+++ b/pango/pango-coverage-private.h
@@ -24,6 +24,7 @@
 
 #include <glib-object.h>
 #include <pango-coverage.h>
+#include <pango-userface.h>
 
 G_BEGIN_DECLS
 
@@ -42,6 +43,7 @@ struct _PangoCoverage
   GObject parent_instance;
 
   hb_set_t *chars;
+  PangoUserFace *face;
 };
 
 struct _PangoCoverageClass
@@ -57,6 +59,7 @@ struct _PangoCoverageClass
 };
 
 PangoCoverage *pango_coverage_new_for_hb_face (hb_face_t *hb_face);
+PangoCoverage *pango_coverage_new_for_user_face (PangoUserFace *face);
 
 G_END_DECLS
 
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index 281407a2..d7b5b2a8 100644
--- a/pango/pango-coverage.c
+++ b/pango/pango-coverage.c
@@ -23,6 +23,8 @@
 #include <string.h>
 
 #include "pango-coverage-private.h"
+#include "pango-userface-private.h"
+
 
 G_DEFINE_TYPE (PangoCoverage, pango_coverage, G_TYPE_OBJECT)
 
@@ -38,6 +40,8 @@ pango_coverage_finalize (GObject *object)
 
   if (coverage->chars)
     hb_set_destroy (coverage->chars);
+  if (coverage->face)
+    g_object_unref (coverage->face);
 
   G_OBJECT_CLASS (pango_coverage_parent_class)->finalize (object);
 }
@@ -46,6 +50,14 @@ static PangoCoverageLevel
 pango_coverage_real_get (PangoCoverage *coverage,
                         int            index)
 {
+  if (coverage->face)
+    {
+      if (pango_user_face_has_char (coverage->face, index))
+        return PANGO_COVERAGE_EXACT;
+      else
+       return PANGO_COVERAGE_NONE;
+    }
+
   if (coverage->chars == NULL)
     return PANGO_COVERAGE_NONE;
 
@@ -60,6 +72,9 @@ pango_coverage_real_set (PangoCoverage     *coverage,
                         int                index,
                         PangoCoverageLevel level)
 {
+  if (coverage->face)
+    return;
+
   if (coverage->chars == NULL)
     coverage->chars = hb_set_create ();
 
@@ -88,6 +103,8 @@ pango_coverage_real_copy (PangoCoverage *coverage)
             hb_set_add (copy->chars, (hb_codepoint_t)i);
         }
     }
+  if (coverage->face)
+    copy->face = g_object_ref (coverage->face);
 
   return copy;
 }
@@ -140,6 +157,18 @@ pango_coverage_new_for_hb_face (hb_face_t *hb_face)
   return coverage;
 }
 
+PangoCoverage *
+pango_coverage_new_for_user_face (PangoUserFace *face)
+{
+  PangoCoverage *coverage;
+
+  coverage = g_object_new (PANGO_TYPE_COVERAGE, NULL);
+
+  coverage->face = g_object_ref (face);
+
+  return coverage;
+}
+
 /**
  * pango_coverage_copy:
  * @coverage: a `PangoCoverage`
diff --git a/pango/pango-userfont.c b/pango/pango-userfont.c
index d0860cca..10ccea13 100644
--- a/pango/pango-userfont.c
+++ b/pango/pango-userfont.c
@@ -92,8 +92,9 @@ static PangoCoverage *
 pango_user_font_get_coverage (PangoFont     *font,
                               PangoLanguage *language G_GNUC_UNUSED)
 {
-  /* FIXME */
-  return pango_coverage_new ();
+  PangoUserFont *self = PANGO_USER_FONT (font);
+
+  return pango_coverage_new_for_user_face (self->face);
 }
 
 static void


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