Error while getting cursor position in Pango
- From: "Arjan J. Molenaar" <arjanmolenaar hetnet nl>
- To: gnome2-list <gnome-2-0-list gnome org>
- Subject: Error while getting cursor position in Pango
- Date: 04 Jan 2002 18:43:58 +0100
Hi,
I have some problems with Pango's pango_layout_get_cursor_pos()
function. I try to find the cursor position in a line ended with a
newline ('\n') character. For some reason the call to
pango_layout_get_cursor_pos(). If the line is ended with a '\n' this
function is not able to find the correct cursor position and aborts
execution with the message:
(process:18459): ** ERROR **: file pango-layout.c: line 1667
(pango_layout_line_get_char_direction): should not be reached
aborting...
Trace/breakpoint trap (core dumped)
I have attached a demo program that triggers the error.
Regards,
Arjan
#include <pango/pango-layout.h>
#include <pango/pangoft2.h>
void
do_test (gchar *text)
{
PangoContext *context;
PangoLayout *layout;
PangoRectangle sp, wp;
gint i;
g_print ("Checking string '%s' (len=%d)\n", text, strlen (text));
context = pango_ft2_get_context (100, 100);
layout = pango_layout_new (context);
pango_layout_set_text (layout, text, -1);
for (i = 0; i <= strlen (text); i++) {
g_print ("Finding cursor pos %d\n", i);
pango_layout_get_cursor_pos (layout, i, &sp, &wp);
}
g_object_unref (layout);
g_object_unref (context);
}
int
main ()
{
g_type_init ();
do_test ("Text\ntext");
do_test ("Newline\n");
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]