static void producer_close( mlt_producer parent );
static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg );
static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font,
- rgba_color fg, rgba_color bg, int pad, int align, int weight );
+ rgba_color fg, rgba_color bg, int pad, int align, int weight, int size );
/** Return nonzero if the two strings are equal, ignoring case, up to
the first n characters.
return ret;
}
+static PangoFT2FontMap *fontmap = NULL;
+
mlt_producer producer_pango_init( const char *filename )
{
producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 );
{
mlt_producer producer = &this->parent;
+ // THIS SHOULD BE MUTEXED...
+ if ( fontmap == NULL )
+ fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new();
+
producer->get_frame = producer_get_frame;
producer->close = ( mlt_destructor )producer_close;
iconv_t cd = iconv_open( "UTF-8", encoding );
if ( cd != ( iconv_t )-1 )
{
- char *inbuf_p = strdup( text );
+ char *inbuf_p = text;
size_t inbuf_n = strlen( text );
size_t outbuf_n = inbuf_n * 6;
char *outbuf = mlt_pool_alloc( outbuf_n );
char *outbuf_p = outbuf;
- if ( iconv( cd, &inbuf_p, &inbuf_n, &outbuf_p, &outbuf_n ) != -1 )
- {
- outbuf[ outbuf_n ] = 0;
+ memset( outbuf, 0, outbuf_n );
+
+ if ( text != NULL && strcmp( text, "" ) && iconv( cd, &inbuf_p, &inbuf_n, &outbuf_p, &outbuf_n ) != -1 )
mlt_properties_set( properties, prop_name, outbuf );
- result = 0;
- }
+ else
+ mlt_properties_set( properties, prop_name, "" );
+
mlt_pool_release( outbuf );
iconv_close( cd );
+ result = 0;
}
return result;
}
char *font = mlt_properties_get( producer_props, "font" );
char *encoding = mlt_properties_get( producer_props, "encoding" );
int weight = mlt_properties_get_int( producer_props, "weight" );
+ int size = mlt_properties_get_int( producer_props, "size" );
// See if any properties changed
int property_changed = ( align != this->align );
}
// Render the title
- pixbuf = pango_get_pixbuf( markup, text, font, fgcolor, bgcolor, pad, align, weight );
+ pixbuf = pango_get_pixbuf( markup, text, font, fgcolor, bgcolor, pad, align, weight, size );
if ( pixbuf != NULL )
{
{
// Clone our image
uint8_t *copy = mlt_pool_alloc( size );
- if ( copy != NULL )
+ if ( copy != NULL && image != NULL )
memcpy( copy, image, size );
// We're going to pass the copy on
// Set producer-specific frame properties
mlt_properties_set_int( properties, "progressive", 1 );
- mlt_properties_set_double( properties, "aspect_ratio", 1 );
+ mlt_properties_set_double( properties, "aspect_ratio", 0 );
// Set alpha call back
( *frame )->get_alpha_mask = producer_get_alpha_mask;
}
}
-static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, rgba_color fg, rgba_color bg, int pad, int align, int weight )
+static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, rgba_color fg, rgba_color bg, int pad, int align, int weight, int size )
{
- PangoFT2FontMap *fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new();
PangoContext *context = pango_ft2_font_map_create_context( fontmap );
PangoLayout *layout = pango_layout_new( context );
int w, h, x;
pango_ft2_font_map_set_resolution( fontmap, 72, 72 );
pango_layout_set_width( layout, -1 ); // set wrapping constraints
pango_font_description_set_weight( desc, ( PangoWeight ) weight );
+ if ( size != 0 )
+ pango_font_description_set_size( desc, PANGO_SCALE * size );
pango_layout_set_font_description( layout, desc );
// pango_layout_set_spacing( layout, space );
pango_layout_set_alignment( layout, ( PangoAlignment ) align );
src += bitmap.pitch;
}
mlt_pool_release( bitmap.buffer );
+ pango_font_description_free( desc );
g_object_unref( layout );
g_object_unref( context );
- g_object_unref( fontmap );
return pixbuf;
}