create/text: adding linespacing support

This commit is contained in:
Lei Yang 2015-07-14 02:22:54 +08:00
parent 96796d3202
commit 13fad7a264
1 changed files with 13 additions and 2 deletions

View File

@ -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