[gtk/wip/otte/lottie: 2493/2503] gsk: Add gsk_path_builder_add_layout
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/lottie: 2493/2503] gsk: Add gsk_path_builder_add_layout
- Date: Tue, 13 Jul 2021 04:28:09 +0000 (UTC)
commit 1d5361dae9f39ba1dd805a42271e0aebc90e4be1
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 27 00:59:02 2020 -0500
gsk: Add gsk_path_builder_add_layout
This api makes it easy to turn text into a path that
can be further manipulated. The implementation currently
goes via cairo.
gsk/gskpathbuilder.c | 33 +++++++++++++++++++++++++++++++++
gsk/gskpathbuilder.h | 5 +++++
2 files changed, 38 insertions(+)
---
diff --git a/gsk/gskpathbuilder.c b/gsk/gskpathbuilder.c
index 3b578627a0..58700e77ef 100644
--- a/gsk/gskpathbuilder.c
+++ b/gsk/gskpathbuilder.c
@@ -941,3 +941,36 @@ gsk_path_builder_svg_arc_to (GskPathBuilder *builder,
t);
}
}
+
+/**
+ * gsk_path_builder_add_layout:
+ * @builder: a #GskPathBuilder
+ * @layout: the pango layout to add
+ *
+ * Adds the outlines for the glyphs in @layout to
+ * @builder.
+ */
+void
+gsk_path_builder_add_layout (GskPathBuilder *builder,
+ PangoLayout *layout)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ cairo_path_t *cairo_path;
+ GskPath *path;
+
+ surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
+ cr = cairo_create (surface);
+
+ pango_cairo_layout_path (cr, layout);
+ cairo_path = cairo_copy_path (cr);
+ path = gsk_path_new_from_cairo (cairo_path);
+
+ gsk_path_builder_add_path (builder, path);
+
+ gsk_path_unref (path);
+
+ cairo_path_destroy (cairo_path);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+}
diff --git a/gsk/gskpathbuilder.h b/gsk/gskpathbuilder.h
index 0a4024b60e..44f9129ce3 100644
--- a/gsk/gskpathbuilder.h
+++ b/gsk/gskpathbuilder.h
@@ -53,6 +53,10 @@ GDK_AVAILABLE_IN_ALL
void gsk_path_builder_add_path (GskPathBuilder *builder,
GskPath *path);
GDK_AVAILABLE_IN_ALL
+void gsk_path_builder_add_layout (GskPathBuilder *builder,
+ PangoLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
void gsk_path_builder_add_rect (GskPathBuilder *builder,
const graphene_rect_t *rect);
GDK_AVAILABLE_IN_ALL
@@ -123,6 +127,7 @@ void gsk_path_builder_rel_conic_to (GskPathBuilder
GDK_AVAILABLE_IN_ALL
void gsk_path_builder_close (GskPathBuilder *builder);
+
G_END_DECLS
#endif /* __GSK_PATH_BUILDER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]