All pastes #50412 Raw Edit

Pango

public c v1 · immutable
#50412 ·published 2006-04-21 14:50 UTC
rendered paste body
// Example to print a label with colors & markup using pango#include <pango/pango.h>#include <gtk/gtk.h>#include <stdio.h>#include <pango/pangocairo.h>/* signal handler(s) */gboolean handle_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data){	return FALSE;}gboolean handle_destroy(GtkWidget *widget, gpointer data){	gtk_main_quit();}int main(int argc, char *argv[]){		GtkWidget *window = NULL;	GtkWidget *entry = NULL;	gchar *text_utf81 = "This was supposed to be a very long string, but is not!\nOkay, its not that big a string....";	gchar *text_utf8 = "\0A10";	GtkWidget *label = NULL;		/* Pango related */	PangoLayout *pg_layout = NULL;	PangoContext *pg_context = NULL;	PangoFontDescription *pg_font_desc = NULL;		/* setup GTK environment */	gtk_init(&argc, &argv);		/* create a window & attach required signals */	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);	gtk_window_set_title(GTK_WINDOW(window), "Pango example");	gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);		/* attach signal handlers to the window */	gtk_signal_connect(GTK_OBJECT(window), "delete-event", GTK_SIGNAL_FUNC(handle_delete_event), NULL);	gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(handle_destroy), NULL);	/* initialize the other widgets */	entry = gtk_entry_new();	label = gtk_label_new(text_utf8);		/* Pango! */	pg_layout = gtk_label_get_layout(GTK_LABEL(label));	pg_font_desc = pango_font_description_from_string("Lohit Punjabi");	pango_layout_set_font_description(pg_layout, pg_font_desc);	pango_layout_set_text(pg_layout, text_utf8, -1);	pango_layout_set_justify(pg_layout, TRUE);	//pango_layout_context_changed (pg_layout);				/* Pack & display the window */	gtk_container_add(GTK_CONTAINER(window), label);	gtk_widget_show_all(window);	/* enter the main loop */	gtk_main();	pango_font_description_free(pg_font_desc);		return 0;}