From 13fad7a264640796f512d6139bd5bdfdff444312 Mon Sep 17 00:00:00 2001 From: Lei Yang Date: Tue, 14 Jul 2015 02:22:54 +0800 Subject: [PATCH] create/text: adding linespacing support --- libvips/create/text.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libvips/create/text.c b/libvips/create/text.c index 1736ed93..5d703d49 100644 --- a/libvips/create/text.c +++ b/libvips/create/text.c @@ -64,6 +64,7 @@ typedef struct _VipsText { char *text; char *font; int width; + int linespacing; VipsAlign align; int dpi; @@ -103,7 +104,7 @@ vips_text_dispose( GObject *gobject ) static PangoLayout * text_layout_new( PangoContext *context, - const char *text, const char *font, int width, + const char *text, const char *font, int width, int linespacing, VipsAlign align, int dpi ) { PangoLayout *layout; @@ -120,6 +121,9 @@ text_layout_new( PangoContext *context, if( width > 0 ) pango_layout_set_width( layout, width * PANGO_SCALE ); + if (linespacing > 0) + pango_layout_set_spacing( layout, linespacing * PANGO_SCALE); + switch( align ) { case VIPS_ALIGN_LOW: palign = PANGO_ALIGN_LEFT; @@ -180,7 +184,7 @@ vips_text_build( VipsObject *object ) if( !(text->layout = text_layout_new( text->context, text->text, text->font, - text->width, text->align, text->dpi )) ) { + text->width, text->linespacing, text->align, text->dpi )) ) { g_mutex_unlock( vips_text_lock ); return( -1 ); } @@ -308,6 +312,13 @@ vips_text_class_init( VipsTextClass *class ) G_STRUCT_OFFSET( VipsText, dpi ), 1, 1000000, 72 ); + VIPS_ARG_INT( class, "linespacing", 4, + _( "Line Spacing" ), + _( "Line Spacing to render at" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsText, linespacing ), + 0, 1000000, 0 ); + } static void