[librsvg] Add rsvg_drawing_ctx_render_pango_layout(); bind it to Rust



commit e9cf303cc826aa1c3f4471574b1440842a2ff3d8
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Dec 19 17:34:01 2017 -0600

    Add rsvg_drawing_ctx_render_pango_layout(); bind it to Rust

 rsvg-base.c             |  9 +++++++++
 rsvg-private.h          |  6 ++++++
 rsvg-text.c             |  2 +-
 rust/src/drawing_ctx.rs | 14 ++++++++++++++
 4 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 72c10b1..c79ce22 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1799,6 +1799,15 @@ rsvg_drawing_ctx_get_pango_context (RsvgDrawingCtx *draw_ctx)
 }
 
 void
+rsvg_drawing_ctx_render_pango_layout (RsvgDrawingCtx *draw_ctx,
+                                      PangoLayout *layout,
+                                      double x,
+                                      double y)
+{
+    draw_ctx->render->render_pango_layout (draw_ctx, layout, x, y);
+}
+
+void
 rsvg_render_path_builder (RsvgDrawingCtx * ctx, RsvgPathBuilder *builder)
 {
     ctx->render->render_path_builder (ctx, builder);
diff --git a/rsvg-private.h b/rsvg-private.h
index a923c0e..cc2c700 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -537,6 +537,12 @@ G_GNUC_INTERNAL
 PangoContext *rsvg_drawing_ctx_get_pango_context (RsvgDrawingCtx *draw_ctx);
 
 G_GNUC_INTERNAL
+void rsvg_drawing_ctx_render_pango_layout (RsvgDrawingCtx *draw_ctx,
+                                           PangoLayout *layout,
+                                           double x,
+                                           double y);
+
+G_GNUC_INTERNAL
 double _rsvg_css_accumulate_baseline_shift (RsvgState * state, RsvgDrawingCtx * ctx);
 
 /* Implemented in rust/src/length.rs */
diff --git a/rsvg-text.c b/rsvg-text.c
index 1107864..3c69cd9 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -584,7 +584,7 @@ rsvg_text_render_text (RsvgDrawingCtx * ctx, const char *text, gdouble * x, gdou
         offset_y = offset;
     }
     pango_layout_iter_free (iter);
-    ctx->render->render_pango_layout (ctx, layout, *x - offset_x, *y - offset_y);
+    rsvg_drawing_ctx_render_pango_layout (ctx, layout, *x - offset_x, *y - offset_y);
     if (PANGO_GRAVITY_IS_VERTICAL (gravity))
         *y += w / (double)PANGO_SCALE;
     else
diff --git a/rust/src/drawing_ctx.rs b/rust/src/drawing_ctx.rs
index 77e0257..27de22f 100644
--- a/rust/src/drawing_ctx.rs
+++ b/rust/src/drawing_ctx.rs
@@ -50,6 +50,11 @@ extern "C" {
 
     fn rsvg_drawing_ctx_get_pango_context(draw_ctx: *const RsvgDrawingCtx) -> *mut pango_sys::PangoContext;
 
+    fn rsvg_drawing_ctx_render_pango_layout(draw_ctx: *const RsvgDrawingCtx,
+                                            layout: *const pango_sys::PangoLayout,
+                                            x: f64,
+                                            y: f64);
+
     fn rsvg_drawing_ctx_add_clipping_rect (draw_ctx: *const RsvgDrawingCtx,
                                            x: f64,
                                            y: f64,
@@ -210,6 +215,15 @@ pub fn get_pango_context(draw_ctx: *const RsvgDrawingCtx) -> pango::Context {
     }
 }
 
+pub fn render_pango_layout(draw_ctx: *const RsvgDrawingCtx,
+                           layout: pango::Layout,
+                           x: f64,
+                           y: f64) {
+    unsafe {
+        rsvg_drawing_ctx_render_pango_layout(draw_ctx, layout.to_glib_none().0, x, y);
+    }
+}
+
 pub fn add_clipping_rect (draw_ctx: *const RsvgDrawingCtx,
                           x: f64,
                           y: f64,


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