Re: GTk Related Question

From: Date: Tue, 23 Sep 2003 16:45:43 +0000
Subject: Re: GTk Related Question
References: 1 2 3 4 5 6  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3919@lists.php.net to get a copy of this message
No problems at all ..... although I still can not control this properly from PHP, the exec returns 139 (i.e process started) rather than the actual output from the program. I am writing the output to file at the moment to get around this. I'll let you know if I manage to work out this problem, but I'm not sure how the gtk-php architecture works, so this may not affect you. Awesome :-) Z. ----- Original Message ----- > No, thank YOU - this'll probably save us from going through the same > paperchase at some point in the near future :) > > ----- Original Message ----- > > This is from Noah Levitt, general Pango Guru:: (in case you were > remotely > > interested ;-)) > > > > gtk_init tries to open the X display. > > > > You don't need to use gtk+ for this program at all (neither does Attin > > Cotteral). You can create a PangoContext the way pangoft2topgm.c does: > > > > fontmap = pango_ft2_font_map_new (); > > pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), 96, > 96); > > context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP > > (fontmap)); > > > > Noah > > > > Thanks again Steph :-) > > > > > > ----- Original Message ----- > > From: "Steph" <steph@php.net> > > To: "Zitan Broth" <zitan@mediasculpt.net>; > <php-gtk-general@lists.php.net> > > Sent: Thursday, September 18, 2003 8:56 PM > > Subject: Re: [PHP-GTK] GTk Related Question > > > > > > > There *is* an issue with win32 font measurements in GDK 1.3, but I > can't > > > see how it might relate to pango at all (given that pango is a > > > completely other library). > > > > > > Did you try a GTK2-related list? > > > > > > ----- Original Message ----- > > > From: "Zitan Broth" <zitan@mediasculpt.net> > > > To: <php-gtk-general@lists.php.net> > > > Sent: Friday, September 19, 2003 9:44 PM > > > Subject: Re: [PHP-GTK] GTk Related Question > > > > > > > > > > Greetings Again, > > > > > > > > Just thought I'd add this note in case anyway has a brainstorm > about > > > the > > > > problem :-) > > > > > > > > Pango is actually erroring when I call it from the command line - > > > > pango_get_width:5039): Gtk-WARNING **: cannot open display: and > that > > > is the > > > > reason I'm not getting the output back. Did you all have an issue > > > like this > > > > with GTK 1 ? > > > > > > > > Thanks *heaps* again ... Z > > > > > > > > Example:: > > > > > > > > ./pango/pango_get_width "arial 12" "bumpylove" input gives > > > > 1 > output > > > > > > > > Line:0 => > > > > Line:1 => (pango_get_width:5039): Gtk-WARNING **: cannot open > display: > > > > Line:2 => Got fontname 'arial 12' > > > > Line:3 => Got input text 'bumpylove' > > > > Got fontname 'arial 12' Got input text 'bumpylove' > > > > > > > > ----- Original Message ----- > > > > From: "Steph" <steph@php.net> > > > > To: "Zitan Broth" <zitan@mediasculpt.net>; > > > <php-gtk-general@lists.php.net> > > > > Sent: Sunday, September 14, 2003 7:58 PM > > > > Subject: Re: [PHP-GTK] GTk Related Question > > > > > > > > > > > > > We don't have PHP bindings for GTK2 yet, and Pango isn't > assimilated > > > > > into GTK1. > > > > > > > > > > Try the Python guys (and don't tell anyone I said so ;) > > > > > > > > > > ----- Original Message ----- > > > > > From: "Zitan Broth" <zitan@mediasculpt.net> > > > > > To: <php-gtk-general@lists.php.net> > > > > > Sent: Monday, September 15, 2003 8:40 PM > > > > > Subject: [PHP-GTK] GTk Related Question > > > > > > > > > > > > > > > Greetings PHP-GTK Crew, > > > > > > > > > > This question does not related directly to the php-gtk project, > but > > > I am > > > > > hoping that you all wont mind and will perhaps be able to offer > some > > > > > advice, it would be greatly appreciated. > > > > > > > > > > I have some c code which accesses Pango to find out what the > width > > > is of > > > > > a given string with font and font size. Works well when called > from > > > the > > > > > command line. When I call this program from PHP (with exec) it > > > works, > > > > > but the output array contains no data from after the points I > > > initialise > > > > > a GTK object ( e.g. gtk_init(&argc, &argv); ). It seems > wasteful to > > > > > write the output from the program to file, when I should be able > to > > > pipe > > > > > it directly into PHP, and I just thought that as Pango is part > of > > > GTK > > > > > you guys might have an idea about what is causing the problem > .... > > > > > > > > > > I've included the code just for fun, it really is a simple > problem, > > > but > > > > > it is sure causing me a large headache. > > > > > > > > > > Thanks to all, > > > > > Zitan. > > > > > > > > > > > > > > > /* > > > > > pango_get_width > > > > > > > > > > Compile Instructions: > > > > > > > > > > gcc pkg-config --cflags gtk+-2.0 > > > > > pango_get_width.c \ > > > > > pkg-config --libs gtk+-2.0 > > > > > > > > > > */ > > > > > #include <stdio.h> > > > > > #include <stdlib.h> > > > > > #include <string.h> > > > > > #include <gtk/gtk.h> > > > > > > > > > > /* Written by Attin Cotteral */ > > > > > static gint char_width_from_layout (PangoFontDescription *pfd, > const > > > > > gchar *s) > > > > > { > > > > > GtkWidget *w; > > > > > PangoContext *pc; > > > > > PangoLayout *pl; > > > > > gint width; > > > > > > > > > > w = gtk_label_new(NULL); > > > > > pc = gtk_widget_get_pango_context(w); > > > > > pango_context_set_font_description(pc, pfd); > > > > > > > > > > pl = pango_layout_new(pc); > > > > > pango_layout_set_text(pl, s, -1); > > > > > pango_layout_get_pixel_size(pl, &width, NULL); > > > > > > > > > > g_object_unref(G_OBJECT(pl)); > > > > > g_object_unref(G_OBJECT(pc)); > > > > > gtk_widget_destroy(w); > > > > > > > > > > return width; > > > > > } > > > > > > > > > > int main (int argc, char *argv[]) > > > > > { > > > > > gint i, width; > > > > > gchar fontname[128]; > > > > > gchar inputtext[255]; > > > > > gchar width_output[255]; > > > > > > > > > > PangoFontDescription *pfd; > > > > > > > > > > if (argc < 2) { > > > > > fprintf(stderr, "%s: error fontname < 128 > chars\n",argv[0]); > > > > > exit(EXIT_FAILURE); > > > > > } > > > > > > > > > > *fontname = 0; > > > > > > > > > > strcpy(fontname, argv[1]); > > > > > strcpy(inputtext, argv[2]); > > > > > i = 2; > > > > > printf("Got fontname '%s', %d\n", fontname,i); > > > > > > > > > > gtk_init(&argc, &argv); > > > > > // why after calling this command PHP stops getting output? > Have > > > > > tested by putting printf statements before and after init call > > > > > > > > > > pfd = pango_font_description_from_string(fontname); > > > > > > > > > > width = char_width_from_layout(pfd, inputtext); > > > > > > > > > > /* Never get this output */ > > > > > printf("Got char width of %d\n", width); > > > > > return 0; > > > > > } > > > > > > > > > > -- > > > > > PHP-GTK General Mailing List (http://gtk.php.net/) > > > > > To unsubscribe, visit: > > > > > http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > -- > > > > PHP-GTK General Mailing List (http://gtk.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.phpÆÏ@}½ÚPGj¶Ø > > > > ïÑ" > > > > > > > > > > > > > > -- > > > PHP-GTK General Mailing List (http://gtk.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.general (#3919) next »