* Copyright (C) 2003-2004 Ushodaya Enterprises Limited
* Author: Dan Dennedy <dan@dennedy.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "producer_pango.h"
#include <freetype/freetype.h>
#include <iconv.h>
#include <pthread.h>
+#include <ctype.h>
static pthread_mutex_t pango_mutex = PTHREAD_MUTEX_INITIALIZER;
// pango_layout_set_spacing( layout, space );
pango_layout_set_alignment( layout, ( PangoAlignment ) align );
if ( markup != NULL && strcmp( markup, "" ) != 0 )
+ {
pango_layout_set_markup( layout, markup, strlen( markup ) );
+ }
else if ( text != NULL && strcmp( text, "" ) != 0 )
- pango_layout_set_text( layout, text, strlen( text ) );
+ {
+ // Replace all ~'s with a line feed (silly convention, but handy)
+ char *copy = strdup( text );
+ while ( strchr( copy, '~' ) )
+ ( *strchr( copy, '~' ) ) = '\n';
+ pango_layout_set_text( layout, copy, strlen( copy ) );
+ free( copy );
+ }
else
+ {
+ // Pango doesn't like empty strings
pango_layout_set_text( layout, " ", 2 );
+ }
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 );