From: Giacomo C. <jw...@bu...> - 2005-08-05 10:44:04
|
Dear xmlroff list, I'm posting here a brief summary of what I found out recently regarding justification of paragraphs (sorry Tony, I didn't notice your request at first, due to scrolling-hurry): 1) Since Pango didn't support justification natively, Damon Chaplin has written a patch which adds justification, however the initial patch had some problems, so he sent me a new one which should be almost final (in attachment). The full justification story can be found here: http://bugzilla.gnome.org/show_bug.cgi?id=64538 2) After applying the above patch, xmlroff could be modified to support justification, so I wrote a small patch (in attachment). Please notice that text-alignment and direction is still in early stage and most combinations aren't supported. I suppose xmlroff needs some kind of masterplan to face all the possible orientations/alignments. I'm willing to contribute, however I need some time and training on pango etc. ;-) 3) The result isn't completely satisfactory due to the following problem: (pseudo-quoting from a private mail to Tony Graham) ---> snip <--- When a 3-line paragraph is compressed into a 2-line paragraph, the following assertion shows up: process:26210): libfo-CRITICAL **: fo_doc_gp_do_callbacks: assertion `line_last >= line_first && line_last <= g_slist_length (pango_layout_get_lines (layout)) - 1' failed (process:26210): libfo-CRITICAL **: fo_doc_gp_do_callbacks: assertion `line_last >= line_first && line_last <= g_slist_length (pango_layout_get_lines (layout)) - 1' failed and an empty line is showed after the paragraph. I suppose for some reason the real number of lines isn't updated correctly. Damon tells me that he doesn't experience the above problem using pango with GtkTextView widget, so could you please verify how/when lines count are fetched from pango and what actually happens if pango returns a shorter line count? ---> snip <--- Tony answers that: ---> snip <--- The assertion happens in the xmlroff code in libfo/fo-doc-gp.c: ------------------------------------------------------------ static void fo_doc_gp_do_callbacks (GnomePrintContext *context, PangoLayout *layout, gint line_first, gint line_last, gint x, gint y) { PangoLayoutIter *iter; g_return_if_fail (context != NULL); g_return_if_fail (PANGO_IS_LAYOUT (layout)); g_return_if_fail (line_first >= 0); g_return_if_fail (line_last >= line_first && line_last <= g_slist_length (pango_layout_get_lines (layout)) - 1); iter = pango_layout_get_iter (layout); gint line_number = -1; do { PangoRectangle logical_rect; PangoLayoutLine *line; int baseline; line_number++; if (line_number < line_first) { continue; } line = pango_layout_iter_get_line (iter); pango_layout_iter_get_line_extents (iter, NULL, &logical_rect); baseline = pango_layout_iter_get_baseline (iter); fo_doc_gp_do_line_callbacks (context, line, x + logical_rect.x, y - baseline); if (line_number >= line_last) { break; } } while (pango_layout_iter_next_line (iter)); pango_layout_iter_free (iter); } ------------------------------------------------------------ The assertion is to stop you trying to lay out more lines than are in the PangoLayout. xmlroff handles printing subsets of the lines in a PangoLayout since a PangoLayout may be broken across a page. I suspect that xmlroff is getting a count of the lines before the justification code removes the last line. I would expect that the do-while in the function only iterates for as many lines as there are in the PangoLayout and that what you're seeing as an extra line is because xmlroff is leaving enough room for the original 3-line block and not the current 2-line block. ---> snip <--- I suppose that's about all. Sincerely, - Giacomo Cariello |