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.
This commit is contained in:
committed by
Benjamin Otte
parent
9ef17b9b32
commit
5c3a5761b4
@@ -950,3 +950,36 @@ gsk_path_builder_svg_arc_to (GskPathBuilder *self,
|
||||
t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_builder_add_layout:
|
||||
* @self: a #GskPathBuilder
|
||||
* @layout: the pango layout to add
|
||||
*
|
||||
* Adds the outlines for the glyphs in @layout to
|
||||
* the builder.
|
||||
*/
|
||||
void
|
||||
gsk_path_builder_add_layout (GskPathBuilder *self,
|
||||
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 (self, path);
|
||||
|
||||
gsk_path_unref (path);
|
||||
|
||||
cairo_path_destroy (cairo_path);
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gsk_path_builder_add_path (GskPathBuilder *self,
|
||||
GskPath *path);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_path_builder_add_layout (GskPathBuilder *self,
|
||||
PangoLayout *layout);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_path_builder_add_rect (GskPathBuilder *self,
|
||||
const graphene_rect_t *rect);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
Reference in New Issue
Block a user