Problem Using Persian Fonts
- From: "Ali Majdzadeh" <ali majdzadeh gmail com>
- To: gtk-i18n-list gnome org
- Subject: Problem Using Persian Fonts
- Date: Sat, 6 May 2006 13:33:19 +0430
Hi Everybody
I tried to compile and run an example which I found from the list.
I installed Persian fonts and changed the source in order to show
some Farsi texts, the program compiles and runs without any errors, but
it can not load the font which I specify.
Other applications like OpenOffice and KOffice recognize my fonts.
Any ideas?
Regards
Ali
Code:
#include <gtk/gtk.h>
int size=15;
void g_exit_callback(GtkWidget *w) { gtk_main_quit(); }
gboolean play_font(gpointer data)
{
GdkRectangle updateRect;
updateRect.x=0; updateRect.y=0;
updateRect.width=240; updateRect.height=320;
gtk_widget_draw(GTK_WIDGET(data),&updateRect);
}
void drawing_callback(GtkWidget *lWidget)
{
printf("drawing_callback\n");
PangoContext *context=NULL;
PangoLayout *layout=NULL;
PangoFontDescription *fontdesc=NULL;
context = gtk_widget_get_pango_context(lWidget);
layout = pango_layout_new(context);
fontdesc = pango_font_description_new();
// function that i suspect of leaks -
one
pango_font_description_set_family(fontdesc,"Terafik");
// function that i suspect of leaks - two
pango_font_description_set_size(fontdesc,size*PANGO_SCALE);
pango_layout_set_font_description (layout, fontdesc);
pango_layout_set_text(layout, "Farsi Text Here", 6); //I could not paste Farsi!
pango_layout_set_font_description (layout, fontdesc);
pango_layout_set_text(layout, "Farsi Text Here", 6); //I could not paste Farsi!
gdk_draw_layout(lWidget->window, lWidget->style->fg_gc[GTK_STATE_NORMAL] , 5 , 10 , layout);
pango_font_description_free (fontdesc);
g_object_unref (layout);
size++;
}
int main(int argc, char **argv)
{
gtk_init(NULL,NULL);
GtkWidget *pwWindow;
GtkWidget *pWidget;
pwWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (pwWindow), "TEST Widget");
gtk_window_set_position (GTK_WINDOW (pwWindow), GTK_WIN_POS_CENTER_ALWAYS);
g_signal_connect (G_OBJECT (pwWindow), "destroy",G_CALLBACK (g_exit_callback), NULL);
pWidget = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(pwWindow), pWidget);
g_signal_connect (G_OBJECT (pWidget),"expose_event", G_CALLBACK (drawing_callback), NULL);
g_timeout_add(100,(GSourceFunc)play_font,pWidget);
gtk_widget_show (pWidget);
gtk_widget_show (pwWindow);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]