Re: Pango Integration?
- From: Zitan Broth <zitan mediasculpt net>
- To: Noah Levitt <nlevitt columbia edu>
- Cc: gtk-i18n-list gnome org
- Subject: Re: Pango Integration?
- Date: Fri, 19 Sep 2003 15:57:08 -0700
Hi Noah,
Thanks **heaps** for your response - you rock!
I had a try at changing the code to work in the way you suggested, as well
as looking at pangoft2.h and the example mentioned, but my system doesn't
want to recognise any of the fontmap API calls .... I think while I have
downloaded 1.23 I might still be running 1.0, however I saw these API calls
in the version 1 pangoft2.h, so I figured it should be okay. I've included
the error message and updated code ....
Sorry for all the questions, all I can say is thank you :-)
Z.
Full Error Message:
[zitan linuxdev zitan]$ gcc `pkg-config --cflags gtk+-2.0` pango_get_width.c
`pkg-config --libs gtk+-2.0` -o pango_get_width
/tmp/ccxkytsb.o(.text+0x7): In function `char_width_from_layout':
: undefined reference to `pango_ft2_font_map_new'
/tmp/ccxkytsb.o(.text+0x26): In function `char_width_from_layout':
: undefined reference to `pango_ft2_font_map_get_type'
/tmp/ccxkytsb.o(.text+0x3b): In function `char_width_from_layout':
: undefined reference to `pango_ft2_font_map_set_resolution'
/tmp/ccxkytsb.o(.text+0x4c): In function `char_width_from_layout':
: undefined reference to `pango_ft2_font_map_get_type'
/tmp/ccxkytsb.o(.text+0x61): In function `char_width_from_layout':
: undefined reference to `pango_ft2_font_map_create_context'
collect2: ld returned 1 exit status
Code::
#include <pango/pangoft2.h>
#include <pango/pango.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
static gint char_width_from_layout (PangoFontDescription *pfd, const gchar
*s)
{
PangoLayout *pl;
gint width;
PangoContext *context;
PangoFontMap *fontmap;
/* Set Context using fontmap */
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));
pango_context_set_font_description(context, pfd);
pl = pango_layout_new(context);
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(context));
return width;
}
int main (int argc, char *argv[])
{
gint i, width;
gchar fontname[128];
gchar inputtext[255];
gchar width_output[255];
*fontname = 0;
PangoFontDescription *pfd;
if (argc < 2) {
fprintf(stderr, "%s: error fontname < 128 chars\n",argv[0]);
exit(EXIT_FAILURE);
}
strcpy(fontname, argv[1]);
strcpy(inputtext, argv[2]);
i = 2;
printf("Got fontname '%s'\n", fontname);
printf("Got input text '%s'\n", inputtext);
pfd = pango_font_description_from_string(fontname);
if (pfd == NULL)
fprintf(stderr, "%s: error couldn't get a font
description\n",fontname);
exit(EXIT_FAILURE);
}
width = char_width_from_layout(pfd, inputtext);
printf("Got char width of %d\n", width);
return 0;
}
----- Original Message -----
> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]