[pango/simple-fontmap: 15/33] coverage: Add a constructor from hb_face_t




commit fc3f7cf285c73e979e8a4afd86bab0c48abf36ac
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 29 19:01:50 2021 -0400

    coverage: Add a constructor from hb_face_t
    
    Add private API to create a PangoCoverage object
    from a hb_face_t. This will be used in future commits.

 pango/pango-coverage-private.h |  2 ++
 pango/pango-coverage.c         | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/pango/pango-coverage-private.h b/pango/pango-coverage-private.h
index af86ab00..4f7e79ea 100644
--- a/pango/pango-coverage-private.h
+++ b/pango/pango-coverage-private.h
@@ -56,6 +56,8 @@ struct _PangoCoverageClass
   PangoCoverage *    (* copy) (PangoCoverage      *coverage);
 };
 
+PangoCoverage *pango_coverage_new_for_hb_face (hb_face_t *hb_face);
+
 G_END_DECLS
 
 #endif /* __PANGO_COVERAGE_PRIVATE_H__ */
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index 35041521..0b9b62f2 100644
--- a/pango/pango-coverage.c
+++ b/pango/pango-coverage.c
@@ -119,6 +119,27 @@ pango_coverage_new (void)
   return g_object_new (PANGO_TYPE_COVERAGE, NULL);
 }
 
+/*< private>
+ * pango_coverage_new_for_hb_face:
+ * @hb_face: a `hb_face_t`
+ *
+ * Creates a new `PangoCoverage` for the given @hb_face.
+ *
+ * Returns: the newly allocated `PangoCoverage`
+ */
+PangoCoverage *
+pango_coverage_new_for_hb_face (hb_face_t *hb_face)
+{
+  PangoCoverage *coverage;
+
+  coverage = g_object_new (PANGO_TYPE_COVERAGE, NULL);
+
+  coverage->chars = hb_set_create ();
+  hb_face_collect_unicodes (hb_face, coverage->chars);
+
+  return coverage;
+}
+
 /**
  * pango_coverage_copy:
  * @coverage: a `PangoCoverage`


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