[pango/pango2: 133/301] Implement coverage for user faces
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 133/301] Implement coverage for user faces
- Date: Wed, 22 Jun 2022 15:53:37 +0000 (UTC)
commit d417711137a228580cca65bcc8b8566f35392a3d
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 | 5 ++++-
pango/pango-coverage.c | 31 +++++++++++++++++++++++++++++--
pango/pango-userfont.c | 5 +++--
3 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/pango/pango-coverage-private.h b/pango/pango-coverage-private.h
index 4f7e79ea9..8b95dc8bb 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-font-face.h>
G_BEGIN_DECLS
@@ -42,6 +43,7 @@ struct _PangoCoverage
GObject parent_instance;
hb_set_t *chars;
+ PangoFontFace *face;
};
struct _PangoCoverageClass
@@ -56,7 +58,8 @@ struct _PangoCoverageClass
PangoCoverage * (* copy) (PangoCoverage *coverage);
};
-PangoCoverage *pango_coverage_new_for_hb_face (hb_face_t *hb_face);
+PangoCoverage *pango_coverage_new_for_hb_face (hb_face_t *hb_face);
+PangoCoverage *pango_coverage_new_for_font_face (PangoFontFace *face);
G_END_DECLS
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index fd45e5710..a1ec083b8 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)
@@ -36,8 +38,8 @@ pango_coverage_finalize (GObject *object)
{
PangoCoverage *coverage = PANGO_COVERAGE (object);
- if (coverage->chars)
- hb_set_destroy (coverage->chars);
+ g_clear_pointer (&coverage->chars, hb_set_destroy);
+ g_clear_object (&coverage->face);
G_OBJECT_CLASS (pango_coverage_parent_class)->finalize (object);
}
@@ -46,6 +48,14 @@ static PangoCoverageLevel
pango_coverage_real_get (PangoCoverage *coverage,
int index)
{
+ if (coverage->face)
+ {
+ if (pango_font_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 +70,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 +101,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 +155,18 @@ pango_coverage_new_for_hb_face (hb_face_t *hb_face)
return coverage;
}
+PangoCoverage *
+pango_coverage_new_for_font_face (PangoFontFace *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 e3027f9a1..0ebbb7f68 100644
--- a/pango/pango-userfont.c
+++ b/pango/pango-userfont.c
@@ -93,8 +93,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_font_face (PANGO_FONT_FACE (self->face));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]