tiny cleanups
see https://github.com/jcupitt/libvips/pull/327 - small layout changes - rename @linespacing as @spacing - add ChangeLog notes and gtk-doc notes - fix text arg priority
This commit is contained in:
parent
1cdeefe955
commit
956e2f5cdf
|
@ -18,6 +18,7 @@
|
||||||
- add vips_hist_entropy()
|
- add vips_hist_entropy()
|
||||||
- vips_log(), vips_log10() are zero-avoiding
|
- vips_log(), vips_log10() are zero-avoiding
|
||||||
- better overlap handling for dzsave, thanks robclouth
|
- better overlap handling for dzsave, thanks robclouth
|
||||||
|
- add @spacing option to vips_text()
|
||||||
|
|
||||||
7/5/15 started 8.0.3
|
7/5/15 started 8.0.3
|
||||||
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas
|
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
* - gtkdoc
|
* - gtkdoc
|
||||||
* 3/6/13
|
* 3/6/13
|
||||||
* - rewrite as a class
|
* - rewrite as a class
|
||||||
|
* 20/9/15 leiyangyou
|
||||||
|
* - add @spacing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -64,7 +66,7 @@ typedef struct _VipsText {
|
||||||
char *text;
|
char *text;
|
||||||
char *font;
|
char *font;
|
||||||
int width;
|
int width;
|
||||||
int linespacing;
|
int spacing;
|
||||||
VipsAlign align;
|
VipsAlign align;
|
||||||
int dpi;
|
int dpi;
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ vips_text_dispose( GObject *gobject )
|
||||||
|
|
||||||
static PangoLayout *
|
static PangoLayout *
|
||||||
text_layout_new( PangoContext *context,
|
text_layout_new( PangoContext *context,
|
||||||
const char *text, const char *font, int width, int linespacing,
|
const char *text, const char *font, int width, int spacing,
|
||||||
VipsAlign align, int dpi )
|
VipsAlign align, int dpi )
|
||||||
{
|
{
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
|
@ -121,8 +123,8 @@ text_layout_new( PangoContext *context,
|
||||||
if( width > 0 )
|
if( width > 0 )
|
||||||
pango_layout_set_width( layout, width * PANGO_SCALE );
|
pango_layout_set_width( layout, width * PANGO_SCALE );
|
||||||
|
|
||||||
if (linespacing > 0)
|
if( spacing > 0 )
|
||||||
pango_layout_set_spacing( layout, linespacing * PANGO_SCALE);
|
pango_layout_set_spacing( layout, spacing * PANGO_SCALE );
|
||||||
|
|
||||||
switch( align ) {
|
switch( align ) {
|
||||||
case VIPS_ALIGN_LOW:
|
case VIPS_ALIGN_LOW:
|
||||||
|
@ -184,7 +186,7 @@ vips_text_build( VipsObject *object )
|
||||||
|
|
||||||
if( !(text->layout = text_layout_new( text->context,
|
if( !(text->layout = text_layout_new( text->context,
|
||||||
text->text, text->font,
|
text->text, text->font,
|
||||||
text->width, text->linespacing, text->align, text->dpi )) ) {
|
text->width, text->spacing, text->align, text->dpi )) ) {
|
||||||
g_mutex_unlock( vips_text_lock );
|
g_mutex_unlock( vips_text_lock );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
@ -284,39 +286,39 @@ vips_text_class_init( VipsTextClass *class )
|
||||||
G_STRUCT_OFFSET( VipsText, text ),
|
G_STRUCT_OFFSET( VipsText, text ),
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
VIPS_ARG_STRING( class, "font", 4,
|
VIPS_ARG_STRING( class, "font", 5,
|
||||||
_( "Font" ),
|
_( "Font" ),
|
||||||
_( "Font to render width" ),
|
_( "Font to render width" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsText, font ),
|
G_STRUCT_OFFSET( VipsText, font ),
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "width", 4,
|
VIPS_ARG_INT( class, "width", 6,
|
||||||
_( "Width" ),
|
_( "Width" ),
|
||||||
_( "Maximum image width in pixels" ),
|
_( "Maximum image width in pixels" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsText, width ),
|
G_STRUCT_OFFSET( VipsText, width ),
|
||||||
0, 1000000, 0 );
|
0, 1000000, 0 );
|
||||||
|
|
||||||
VIPS_ARG_ENUM( class, "align", 5,
|
VIPS_ARG_ENUM( class, "align", 7,
|
||||||
_( "Align" ),
|
_( "Align" ),
|
||||||
_( "Align on the low, centre or high coordinate edge" ),
|
_( "Align on the low, centre or high edge" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsText, align ),
|
G_STRUCT_OFFSET( VipsText, align ),
|
||||||
VIPS_TYPE_ALIGN, VIPS_ALIGN_LOW );
|
VIPS_TYPE_ALIGN, VIPS_ALIGN_LOW );
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "dpi", 4,
|
VIPS_ARG_INT( class, "dpi", 8,
|
||||||
_( "DPI" ),
|
_( "DPI" ),
|
||||||
_( "DPI to render at" ),
|
_( "DPI to render at" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsText, dpi ),
|
G_STRUCT_OFFSET( VipsText, dpi ),
|
||||||
1, 1000000, 72 );
|
1, 1000000, 72 );
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "linespacing", 4,
|
VIPS_ARG_INT( class, "spacing", 9,
|
||||||
_( "Line Spacing" ),
|
_( "Spacing" ),
|
||||||
_( "Line Spacing to render at" ),
|
_( "Line spacing" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsText, linespacing ),
|
G_STRUCT_OFFSET( VipsText, spacing ),
|
||||||
0, 1000000, 0 );
|
0, 1000000, 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -343,6 +345,7 @@ vips_text_init( VipsText *text )
|
||||||
* @width: render within this many pixels across
|
* @width: render within this many pixels across
|
||||||
* @alignment: left/centre/right alignment
|
* @alignment: left/centre/right alignment
|
||||||
* @dpi: render at this resolution
|
* @dpi: render at this resolution
|
||||||
|
* @spacing: space lines by this in points
|
||||||
*
|
*
|
||||||
* Draw the string @text to an image. @out is a one-band 8-bit
|
* Draw the string @text to an image. @out is a one-band 8-bit
|
||||||
* unsigned char image, with 0 for no text and 255 for text. Values inbetween
|
* unsigned char image, with 0 for no text and 255 for text. Values inbetween
|
||||||
|
@ -357,11 +360,14 @@ vips_text_init( VipsText *text )
|
||||||
* @width is the maximum number of pixels across to draw within. If the
|
* @width is the maximum number of pixels across to draw within. If the
|
||||||
* generated text is wider than this, it will wrap to a new line. In this
|
* generated text is wider than this, it will wrap to a new line. In this
|
||||||
* case, @alignment can be used to set the alignment style for multi-line
|
* case, @alignment can be used to set the alignment style for multi-line
|
||||||
* text. 0 means left-align, 1 centre, 2 right-align.
|
* text.
|
||||||
*
|
*
|
||||||
* @dpi sets the resolution to render at. "sans 12" at 72 dpi draws characters
|
* @dpi sets the resolution to render at. "sans 12" at 72 dpi draws characters
|
||||||
* approximately 12 pixels high.
|
* approximately 12 pixels high.
|
||||||
*
|
*
|
||||||
|
* @spacing sets the line spacing, in points. It would typicallly be something
|
||||||
|
* like font size times 1.2.
|
||||||
|
*
|
||||||
* See also: vips_xyz(), vips_text(), vips_gaussnoise().
|
* See also: vips_xyz(), vips_text(), vips_gaussnoise().
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, -1 on error
|
* Returns: 0 on success, -1 on error
|
||||||
|
|
Loading…
Reference in New Issue