X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fgtk2%2Fproducer_pango.c;h=7b14d3a47cc2ab6f0cd57a1d2a7493f9fbb629dd;hb=f4d4669b66a9f23be85527f65dec19a566db561c;hp=2368d3ecc13cfae3c0b19e061b7e1a657ea16ec7;hpb=d33f444d4ef4c7bc4074d07a49eca0ab7d108394;p=melted diff --git a/src/modules/gtk2/producer_pango.c b/src/modules/gtk2/producer_pango.c index 2368d3e..7b14d3a 100644 --- a/src/modules/gtk2/producer_pango.c +++ b/src/modules/gtk2/producer_pango.c @@ -146,7 +146,7 @@ mlt_producer producer_pango_init( const char *filename ) ( *strrchr( markup, '.' ) ) = '\0'; while ( strchr( markup, '~' ) ) ( *strchr( markup, '~' ) ) = '\n'; - mlt_properties_set( properties, "resource", ( char * )filename ); + mlt_properties_set( properties, "resource", filename ); mlt_properties_set( properties, "markup", markup ); free( copy ); } @@ -156,7 +156,7 @@ mlt_producer producer_pango_init( const char *filename ) mlt_properties contents = mlt_properties_load( filename ); mlt_geometry key_frames = mlt_geometry_init( ); struct mlt_geometry_item_s item; - mlt_properties_set( properties, "resource", ( char * )filename ); + mlt_properties_set( properties, "resource", filename ); mlt_properties_set_data( properties, "contents", contents, 0, ( mlt_destructor )mlt_properties_close, NULL ); mlt_properties_set_data( properties, "key_frames", key_frames, 0, ( mlt_destructor )mlt_geometry_close, NULL ); @@ -202,8 +202,8 @@ mlt_producer producer_pango_init( const char *filename ) if ( markup[ strlen( markup ) - 1 ] == '\n' ) markup[ strlen( markup ) - 1 ] = '\0'; - mlt_properties_set( properties, "resource", ( char * ) filename ); - mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) ); + mlt_properties_set( properties, "resource", filename ); + mlt_properties_set( properties, "markup", ( markup == NULL ? "" : markup ) ); free( markup ); } else @@ -442,8 +442,8 @@ static void refresh_image( mlt_frame frame, int width, int height ) else if ( strcmp( interps, "hyper" ) == 0 ) interp = GDK_INTERP_HYPER; -// fprintf( stderr, "SCALING PANGO from %dx%d to %dx%d was %dx%d\n", gdk_pixbuf_get_width( pixbuf ), gdk_pixbuf_get_height( pixbuf ), width, height, this->width, this->height ); - +// fprintf(stderr,"%s: scaling from %dx%d to %dx%d\n", __FILE__, this->width, this->height, width, height); + // Note - the original pixbuf is already safe and ready for destruction pixbuf = gdk_pixbuf_scale_simple( pixbuf, width, height, interp ); @@ -638,7 +638,7 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const 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_font_description_set_absolute_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 ); @@ -662,6 +662,19 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const } pango_layout_get_pixel_size( layout, &w, &h ); + // Interpret size property as an absolute pixel height and compensate for + // freetype's "interpretation" of our absolute size request. This gives + // precise control over compositing and better quality by reducing scaling + // artifacts with composite geometries that constrain the dimensions. + // If you do not want this, then put the size in the font property or in + // the pango markup. + if ( size != 0 ) + { + pango_font_description_set_absolute_size( desc, PANGO_SCALE * size * size/h ); + pango_layout_set_font_description( layout, desc ); + pango_layout_get_pixel_size( layout, &w, &h ); + } + pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE /* has alpha */, 8, w + 2 * pad, h + 2 * pad ); pango_draw_background( pixbuf, bg );