All pastes #42996 Raw Edit

Pango-text-change :)

public text v1 · immutable
#42996 ·published 2006-02-24 11:32 UTC
rendered paste body
// testing & playing with pango :-)

#include <gtk/gtk.h>
#include <pango/pango.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 *label = 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), 200, 100);
	
	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);
	
	label = gtk_label_new(NULL);

	//PangoFontDescription *font_desc = pango_font_description_new();
	PangoFontDescription *font_desc = pango_font_description_from_string("Verdana");
	pango_font_description_set_size(font_desc, 20 * PANGO_SCALE);
	gtk_widget_modify_font(label, font_desc);
	g_print("Font family used : %s\n", pango_font_description_get_family(font_desc));

	// Gtk uses pango to layout all the text - text picked up from gtk-demo
	gtk_label_set_text(GTK_LABEL(label), "Japanese (\346\227\245\346\234\254\350\252\236)\n");
	
	// add the pango'ised label & show it
	gtk_container_add(GTK_CONTAINER(window), label);
	
	gtk_widget_show_all(window);
	
	gtk_main();
}