paps/paps-formfeed.patch

94 lines
3.1 KiB
Diff
Raw Normal View History

diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x libtool -x .deps -x .libs -x '*a' -x '*o' -x paps -x '*orig' -x 'stamp*' -x 'test*' paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
--- paps-0.6.6.orig/src/paps.c 2006-05-03 18:09:58.000000000 +0900
+++ paps-0.6.6/src/paps.c 2006-08-31 17:57:47.000000000 +0900
@@ -88,6 +88,7 @@
PangoLayoutLine *pango_line;
PangoRectangle logical_rect;
PangoRectangle ink_rect;
+ int formfeed;
} LineLink;
typedef struct _Paragraph Paragraph;
@@ -98,6 +99,7 @@
char *text;
int length;
int height; /* Height, in pixels */
+ int formfeed;
PangoLayout *layout;
};
@@ -428,7 +430,7 @@
fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ());
wc = 0;
}
- if (!*p || !wc || wc == '\n')
+ if (!*p || !wc || wc == '\n' || wc == '\f')
{
Paragraph *para = g_new (Paragraph, 1);
para->text = last_para;
@@ -442,6 +444,11 @@
pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
para->height = 0;
+ if (wc == '\f')
+ para->formfeed = 1;
+ else
+ para->formfeed = 0;
+
last_para = next;
result = g_list_prepend (result, para);
@@ -469,6 +476,7 @@
while(par_list)
{
int para_num_lines, i;
+ LineLink *line_link;
Paragraph *para = par_list->data;
para_num_lines = pango_layout_get_line_count(para->layout);
@@ -476,12 +484,15 @@
for (i=0; i<para_num_lines; i++)
{
PangoRectangle logical_rect, ink_rect;
- LineLink *line_link = g_new(LineLink, 1);
+ line_link = g_new(LineLink, 1);
+ line_link->formfeed = 0;
line_link->pango_line = pango_layout_get_line(para->layout, i);
pango_layout_line_get_extents(line_link->pango_line,
&ink_rect, &logical_rect);
line_link->logical_rect = logical_rect;
+ if (para->formfeed && i == (para_num_lines - 1))
+ line_link->formfeed = 1;
line_link->ink_rect = ink_rect;
line_list = g_list_prepend(line_list, line_link);
}
@@ -504,6 +515,7 @@
int column_y_pos = 0;
int page_idx = 1;
int pango_column_height = page_layout->column_height * page_layout->pt_to_pixel * PANGO_SCALE;
+ LineLink *prev_line_link = NULL;
start_page(OUT, page_idx);
@@ -516,8 +528,9 @@
PangoLayoutLine *line = line_link->pango_line;
/* Check if we need to move to next column */
- if (column_y_pos + line_link->logical_rect.height
- >= pango_column_height)
+ if ((column_y_pos + line_link->logical_rect.height
+ >= pango_column_height) ||
+ (prev_line_link && prev_line_link->formfeed))
{
column_idx++;
column_y_pos = 0;
@@ -547,6 +560,7 @@
column_y_pos += line_link->logical_rect.height;
pango_lines = pango_lines->next;
+ prev_line_link = line_link;
}
eject_page(OUT);
return page_idx;