diff options
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/libpaps.c | 82 | ||||
-rw-r--r-- | src/libpaps.h | 4 | ||||
-rw-r--r-- | src/paps.1 | 12 | ||||
-rw-r--r-- | src/paps.c | 186 | ||||
-rw-r--r-- | src/test_libpaps.c | 2 |
7 files changed, 238 insertions, 88 deletions
@@ -1,3 +1,41 @@ +2006-11-03 Dov Grobgeld <dov.grobgeld@gmail.com> + + * configure.in: Bumped version to 0.6.7 + + * src/paps.1: Described the new options. + + * src/paps.c: + + (split_text_into_paragraphs) Reverted to old + split_text_into_paragraphs as I couldn't understand Akira's code + and I don't think it is relevant anymore with the new cpi/lpi + interpretation. + + (split_text_into_paragraphs) Added functionality for using markup. + + - Added option --markup for printing pango markup'd text. + + - Changed the interpretation of LPI so that it only controls the + line spacing and not the size of the characters. + + - Added option --stretch-chars to stretch characters to fill + the --lpi value. + + - Removed global variables lpi and cpi and moved them into + page_layout_t . + + - Changed creation of options to allow passing the + page_layout_t as a parameter. + + - Removed all references to wchar as it is not used anymore. (It + shouldn't have been used in the first place as there are plenty of + utf8 and ucs4 manipulating function in glib.) + + * src/libpaps.c: + Moved the stretching of characters to c-level only. Erased the + scale_x and scale_y parameters from most functions. + + 2006-09-07 Akira TAGOH <at@gclab.org> * src/paps.c (_paps_arg_lpi_cb): new function. diff --git a/configure.in b/configure.in index 44539f4..9ec422b 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ AC_INIT(configure.in) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(paps, 0.6.5) +AM_INIT_AUTOMAKE(paps, 0.6.7) AC_LANG_C AC_PROG_CC diff --git a/src/libpaps.c b/src/libpaps.c index aba81e1..11abaaf 100644 --- a/src/libpaps.c +++ b/src/libpaps.c @@ -64,8 +64,6 @@ static void add_line_to_postscript(paps_private_t *paps, GString *line_str, double x_pos, double y_pos, - double scale_x, - double scale_y, PangoLayoutLine *line); paps_t *paps_new() @@ -97,8 +95,11 @@ paps_set_scale(paps_t *paps_, paps->scale_x = scale_x; paps->scale_y = scale_y; +#if 0 + // Why would you want to do such a thing??? g_string_erase(paps->header, 0, -1); add_postscript_prologue(paps); +#endif } PangoContext *paps_get_pango_context() @@ -133,6 +134,7 @@ typedef struct { /* Information passed in user data when drawing outlines */ typedef struct _OutlineInfo OutlineInfo; struct _OutlineInfo { + paps_private_t *paps; GString *out_string; FT_Vector glyph_origin; int dpi; @@ -143,18 +145,14 @@ static void draw_contour(paps_private_t *paps, GString *line_str, PangoLayoutLine *pango_line, double line_start_pos_x, - double line_start_pos_y, - double scale_x, - double scale_y + double line_start_pos_y ); void draw_bezier_outline(paps_private_t *paps, GString *layout_str, FT_Face face, PangoGlyphInfo *glyph_info, double pos_x, - double pos_y, - double scale_x, - double scale_y + double pos_y ); /* Countour traveling functions */ static int paps_ps_move_to( FT_Vector* to, @@ -189,8 +187,6 @@ static void get_glyph_hash_string(FT_Face face, gchar *paps_layout_to_postscript_strdup(paps_t *paps_, double pos_x, double pos_y, - double scale_x, - double scale_y, PangoLayout *layout) { paps_private_t *paps = (paps_private_t*)paps_; @@ -214,8 +210,6 @@ gchar *paps_layout_to_postscript_strdup(paps_t *paps_, layout_str, pos_x, pos_y, - scale_x, - scale_y, pango_line); pos_y -= logical_rect.height * scale; @@ -230,8 +224,6 @@ gchar *paps_layout_to_postscript_strdup(paps_t *paps_, gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_, double pos_x, double pos_y, - double scale_x, - double scale_y, PangoLayoutLine *layout_line) { paps_private_t *paps = (paps_private_t*)paps_; @@ -242,8 +234,6 @@ gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_, layout_str, pos_x, pos_y, - scale_x, - scale_y, layout_line); ret_str = layout_str->str; @@ -281,7 +271,7 @@ add_postscript_prologue(paps_private_t *paps) "/start_ol { gsave } bind def\n" "/end_ol { closepath fill grestore } bind def\n" /* Specify both x and y. */ - "/draw_char { fontdict begin gsave %f dup scale last_x last_y translate %f %f scale load exec end grestore} def\n" + "/draw_char { fontdict begin gsave %f dup scale last_x last_y translate load exec end grestore} def\n" "/goto_xy { fontdict begin /last_y exch def /last_x exch def end } def\n" "/goto_x { fontdict begin /last_x exch def end } def\n" "/fwd_x { fontdict begin /last_x exch last_x add def end } def\n" @@ -293,8 +283,7 @@ add_postscript_prologue(paps_private_t *paps) // The scaling is a combination of the scaling due // to the dpi and the difference in the coordinate // systems of postscript and freetype2. - 1.0 / PAPS_DPI, - paps->scale_x, paps->scale_y + 1.0 / PAPS_DPI ); // The following is a dispatcher for an encoded string that contains @@ -364,8 +353,6 @@ add_line_to_postscript(paps_private_t *paps, GString *line_str, double x_pos, double y_pos, - double scale_x, - double scale_y, PangoLayoutLine *line) { PangoRectangle ink_rect, logical_rect; @@ -384,7 +371,7 @@ add_line_to_postscript(paps_private_t *paps, } #endif - draw_contour(paps, line_str, line, x_pos, y_pos, scale_x, scale_y); + draw_contour(paps, line_str, line, x_pos, y_pos); } /* draw_contour() draws all of the contours that make up a line. @@ -394,9 +381,7 @@ static void draw_contour(paps_private_t *paps, GString *layout_str, PangoLayoutLine *pango_line, double line_start_pos_x, - double line_start_pos_y, - double scale_x, - double scale_y + double line_start_pos_y ) { GSList *runs_list; @@ -426,7 +411,7 @@ static void draw_contour(paps_private_t *paps, glyph_pos_x = x_pos + 1.0*geometry.x_offset * scale; glyph_pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale; - x_pos += geometry.width * scale * scale_x; + x_pos += geometry.width * scale * paps->scale_x; if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY) continue; @@ -436,10 +421,7 @@ static void draw_contour(paps_private_t *paps, ft_face, &glyphs->glyphs[glyph_idx], glyph_pos_x, - glyph_pos_y, - scale_x, - scale_y - ); + glyph_pos_y); } runs_list = runs_list->next; @@ -454,15 +436,12 @@ void draw_bezier_outline(paps_private_t *paps, FT_Face face, PangoGlyphInfo *glyph_info, double pos_x, - double pos_y, - double scale_x, - double scale_y - ) + double pos_y) { static gchar glyph_hash_string[100]; double scale = 72.0 / PANGO_SCALE / PAPS_DPI; double epsilon = 1e-2; - double glyph_width = glyph_info->geometry.width * scale * scale_x; + double glyph_width = glyph_info->geometry.width * scale * paps->scale_x; gchar *id = NULL; /* Output outline */ @@ -505,6 +484,7 @@ void draw_bezier_outline(paps_private_t *paps, // Create the outline outlinefunc = &ps_outlinefunc; + outline_info.paps = paps; outline_info.glyph_origin.x = pos_x; outline_info.is_empty = 1; outline_info.glyph_origin.y = pos_y; @@ -521,7 +501,7 @@ void draw_bezier_outline(paps_private_t *paps, g_string_append_printf(glyph_def_string, "%.0f fwd_x\n" "end_ol\n", - glyph_info->geometry.width * scale * scale_x * PAPS_DPI + glyph_info->geometry.width * scale * paps->scale_x * PAPS_DPI ); // TBD - Check if the glyph_def_string is empty. If so, set the @@ -529,7 +509,7 @@ void draw_bezier_outline(paps_private_t *paps, if (outline_info.is_empty || glyph_info->glyph == 0) id[0] = '*'; - else + else // Put the font in the font def dictionary g_string_append_printf(paps->header, "/%s { %s } def\n", @@ -600,8 +580,8 @@ static int paps_ps_move_to( FT_Vector* to, OutlineInfo *outline_info = (OutlineInfo*)user_data; g_string_append_printf(outline_info->out_string, "%d %d m\n", - (int)(to->x * FT2PS) , - (int)(to->y * FT2PS )); + (int)(to->x * FT2PS*outline_info->paps->scale_x) , + (int)(to->y * FT2PS*outline_info->paps->scale_y )); return 0; } @@ -611,8 +591,8 @@ static int paps_ps_line_to( FT_Vector* to, OutlineInfo *outline_info = (OutlineInfo*)user_data; g_string_append_printf(outline_info->out_string, "%d %d l\n", - (int)(to->x * FT2PS) , - (int)(to->y * FT2PS) ); + (int)(to->x * FT2PS * outline_info->paps->scale_x) , + (int)(to->y * FT2PS * outline_info->paps->scale_y) ); outline_info->is_empty = 0; return 0; } @@ -624,10 +604,10 @@ static int paps_ps_conic_to( FT_Vector* control, OutlineInfo *outline_info = (OutlineInfo*)user_data; g_string_append_printf(outline_info->out_string, "%d %d %d %d x\n", - (int)(control->x * FT2PS) , - (int)(control->y * FT2PS) , - (int)(to->x * FT2PS), - (int)(to->y * FT2PS)); + (int)(control->x * FT2PS*outline_info->paps->scale_x) , + (int)(control->y * FT2PS*outline_info->paps->scale_y) , + (int)(to->x * FT2PS*outline_info->paps->scale_x), + (int)(to->y * FT2PS*outline_info->paps->scale_y)); outline_info->is_empty = 0; return 0; } @@ -640,12 +620,12 @@ static int paps_ps_cubic_to( FT_Vector* control1, OutlineInfo *outline_info = (OutlineInfo*)user_data; g_string_append_printf(outline_info->out_string, "%d %d %d %d %d %d c\n", - (int)(control1->x * FT2PS) , - (int)(control1->y * FT2PS) , - (int)(control2->x * FT2PS) , - (int)(control2->y * FT2PS) , - (int)(to->x * FT2PS) , - (int)(to->y * FT2PS) ); + (int)(control1->x * FT2PS*outline_info->paps->scale_x) , + (int)(control1->y * FT2PS*outline_info->paps->scale_y) , + (int)(control2->x * FT2PS*outline_info->paps->scale_x) , + (int)(control2->y * FT2PS*outline_info->paps->scale_y) , + (int)(to->x * FT2PS*outline_info->paps->scale_x) , + (int)(to->y * FT2PS*outline_info->paps->scale_y) ); outline_info->is_empty = 0; return 0; } diff --git a/src/libpaps.h b/src/libpaps.h index 3fd7118..ac619dd 100644 --- a/src/libpaps.h +++ b/src/libpaps.h @@ -91,8 +91,6 @@ gchar *paps_get_postscript_header_strdup(paps_t *paps); gchar *paps_layout_to_postscript_strdup(paps_t *paps, double pos_x, double pos_y, - double scale_x, - double scale_y, PangoLayout *layout); /** * Create postscript related to a single PangoLayout line at position @@ -110,8 +108,6 @@ gchar *paps_layout_to_postscript_strdup(paps_t *paps, gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_, double pos_x, double pos_y, - double scale_x, - double scale_y, PangoLayoutLine *layout_line); /** @@ -60,6 +60,18 @@ Show summary of options. .TP .B \-\-header Draw page header for each page. +.TP +.B \-\-mark +Interpret the text as pango markup. +.TP +.B \-\-lpi +Set the lines per inch. This determines the line spacing. +.TP +.B \-\-cpi +Set the characters per inch. This is an alternative method of specifying the font size. +.TP +.B \-\-stretch-chars +Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. .br .SH AUTHOR paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. @@ -18,6 +18,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * + * + * This is so broken, I feel like crying... :-( */ @@ -30,7 +32,6 @@ #include <string.h> #include <time.h> #include <locale.h> -#include <wchar.h> #define BUFSIZE 1024 #define DEFAULT_FONT_FAMILY "Monospace" @@ -84,9 +85,13 @@ typedef struct { gboolean do_separation_line; gboolean do_draw_contour; gboolean do_wordwrap; + gboolean do_use_markup; + gboolean do_stretch_chars; PangoDirection pango_dir; gchar *filename; gchar *header_font_desc; + gint lpi; + gint cpi; } page_layout_t; typedef struct { @@ -141,8 +146,6 @@ static void start_page (FILE *OUT, static void draw_line_to_page (FILE *OUT, int column_idx, int column_pos, - gdouble scale_x, - gdouble scale_y, page_layout_t *page_layout, PangoLayoutLine *line); static int draw_page_header_line_to_page(FILE *OUT, @@ -165,7 +168,6 @@ double last_pos_y = -1; double last_pos_x = -1; paps_t *paps; paper_type_t paper_type = PAPER_TYPE_A4; -gdouble lpi = 0.0L, cpi = 0.0L; #define CASE(s) if (strcmp(S_, s) == 0) @@ -205,11 +207,12 @@ _paps_arg_lpi_cb(const gchar *option_name, { gboolean retval = TRUE; gchar *p = NULL; + page_layout_t *page_layout = (page_layout_t*)data; if (value && *value) { errno = 0; - lpi = g_strtod(value, &p); + page_layout->lpi = g_strtod(value, &p); if ((p && *p) || errno == ERANGE) { fprintf(stderr, "given LPI value was invalid.\n"); @@ -232,11 +235,12 @@ _paps_arg_cpi_cb(const gchar *option_name, { gboolean retval = TRUE; gchar *p = NULL; - + page_layout_t *page_layout = (page_layout_t*)data; + if (value && *value) { errno = 0; - cpi = g_strtod(value, &p); + page_layout->cpi = g_strtod(value, &p); if ((p && *p) || errno == ERANGE) { fprintf(stderr, "given CPI value was invalid.\n"); @@ -275,13 +279,18 @@ get_language(void) int main(int argc, char *argv[]) { gboolean do_landscape = FALSE, do_rtl = FALSE, do_justify = FALSE, do_draw_header = FALSE; - gboolean do_wordwrap = TRUE; + gboolean do_stretch_chars = FALSE; + gboolean do_use_markup = FALSE; + gboolean do_wordwrap = TRUE; // What should be default? int num_columns = 1; int top_margin = 36, bottom_margin = 36, right_margin = 36, left_margin = 36; gchar *font = MAKE_FONT_NAME (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE), *encoding = NULL; + page_layout_t page_layout; GOptionContext *ctxt = g_option_context_new("[text file]"); GOptionEntry entries[] = { {"landscape", 0, 0, G_OPTION_ARG_NONE, &do_landscape, "Landscape output. (Default: portrait)", NULL}, + {"stretch-chars", 0, 0, G_OPTION_ARG_NONE, &do_stretch_chars, "Whether to stretch characters in y-direction to fill lines. (Default: no)", NULL}, + {"markup", 0, 0, G_OPTION_ARG_NONE, &do_use_markup, "Should the text be considered pango markup? (Default: no)", NULL}, {"columns", 0, 0, G_OPTION_ARG_INT, &num_columns, "Number of columns output. (Default: 1)", "NUM"}, {"font", 0, 0, G_OPTION_ARG_STRING, &font, "Set the font description. (Default: Monospace 12)", "DESC"}, {"rtl", 0, 0, G_OPTION_ARG_NONE, &do_rtl, "Do rtl layout.", NULL}, @@ -298,10 +307,10 @@ int main(int argc, char *argv[]) {"lpi", 0, 0, G_OPTION_ARG_CALLBACK, _paps_arg_lpi_cb, "Set the amount of lines per inch.", "REAL"}, {"cpi", 0, 0, G_OPTION_ARG_CALLBACK, _paps_arg_cpi_cb, "Set the amount of characters per inch.", "REAL"}, {NULL} + }; GError *error = NULL; FILE *IN, *OUT = NULL; - page_layout_t page_layout; GList *paragraphs; GList *pango_lines; PangoContext *pango_context; @@ -323,11 +332,20 @@ int main(int argc, char *argv[]) int header_sep = 20; int max_width = 0, w; GIConv cvh = NULL; + GOptionGroup *options; /* Prerequisite when using glib. */ g_type_init(); - + + /* Init page_layout_t parameters set by the option parsing */ + page_layout.cpi = page_layout.lpi = 0; + + options = g_option_group_new("main","","",&page_layout, NULL); + g_option_group_add_entries(options, entries); + g_option_context_set_main_group(ctxt, options); +#if 0 g_option_context_add_main_entries(ctxt, entries, NULL); +#endif /* Parse command line */ if (!g_option_context_parse(ctxt, &argc, &argv, &error)) @@ -430,6 +448,8 @@ int main(int argc, char *argv[]) page_layout.do_separation_line = TRUE; page_layout.do_landscape = do_landscape; page_layout.do_justify = do_justify; + page_layout.do_stretch_chars = do_stretch_chars; + page_layout.do_use_markup = do_use_markup; page_layout.do_tumble = do_tumble; page_layout.do_duplex = do_duplex; page_layout.pango_dir = pango_dir; @@ -437,8 +457,9 @@ int main(int argc, char *argv[]) page_layout.header_font_desc = header_font_desc; /* calculate x-coordinate scale */ - if (cpi > 0.0L) + if (page_layout.cpi > 0.0L) { + double scale; fontmap = pango_ft2_font_map_new (); fontset = pango_font_map_load_fontset (fontmap, pango_context, font_description, get_language ()); metrics = pango_fontset_get_metrics (fontset); @@ -446,11 +467,24 @@ int main(int argc, char *argv[]) w = pango_font_metrics_get_approximate_digit_width (metrics); if (w > max_width) max_width = w; - page_layout.scale_x = 1 / cpi * 72.0 * PANGO_SCALE / max_width; + page_layout.scale_x = 1 / page_layout.cpi * 72.0 * PANGO_SCALE / max_width; pango_font_metrics_unref (metrics); g_object_unref (G_OBJECT (fontmap)); + + // Now figure out how to scale the font to get that size + scale = 1 / page_layout.cpi * 72.0 * PANGO_SCALE / max_width; + + fprintf(stderr, "scale = %f\n", scale); + + // update the font size to that width + pango_font_description_set_size (font_description, (int)(atoi(DEFAULT_FONT_SIZE) * PANGO_SCALE * scale)); + pango_context_set_font_description (pango_context, font_description); + } + page_layout.scale_x = page_layout.scale_y = 1.0; + + if (encoding != NULL) { cvh = g_iconv_open ("UTF-8", encoding); @@ -471,7 +505,7 @@ int main(int argc, char *argv[]) page_layout.column_width * page_layout.pt_to_pixel, text); pango_lines = split_paragraphs_into_lines(&page_layout, paragraphs); - + if (OUT == NULL) OUT = stdout; @@ -550,7 +584,11 @@ read_file (FILE *file, return text; } -/* Take a UTF8 string and break it into paragraphs on \n characters +#if 0 +/* Take a UTF8 string and break it into paragraphs on \n characters. + * + * Sorry. I couldn't figure out what this version was supposed to do + * */ static GList * split_text_into_paragraphs (PangoContext *pango_context, @@ -587,14 +625,14 @@ split_text_into_paragraphs (PangoContext *pango_context, gchar *newtext; size_t i, len, wwidth = 0, n; - wtext = (wchar_t *)g_utf8_to_ucs4 (para->text, para->length, NULL, NULL, NULL); + wtext = g_utf8_to_ucs4 (para->text, para->length, NULL, NULL, NULL); if (wtext == NULL) { fprintf (stderr, "Failed to convert UTF-8 to UCS-4.\n"); return NULL; } - len = wcswidth (wtext); + len = g_utf8_strlen (para->text, para->length); /* the amount of characters to be able to put on the line against CPI */ n = page_layout->column_width / 72.0 * cpi; if (len > n) @@ -657,6 +695,94 @@ split_text_into_paragraphs (PangoContext *pango_context, return g_list_reverse (result); } +#endif + +/* Take a UTF8 string and break it into paragraphs on \n characters + */ +static GList * +split_text_into_paragraphs (PangoContext *pango_context, + page_layout_t *page_layout, + int paint_width, /* In pixels */ + char *text) +{ + char *p = text; + char *next; + gunichar wc; + GList *result = NULL; + char *last_para = text; + + /* If we are using markup we treat the entire text as a single paragraph. + * I tested it and found that this is much slower than the split and + * assign method used below. Otherwise we might as well use this single + * chunk method always. + */ + if (page_layout->do_use_markup) + { + Paragraph *para = g_new (Paragraph, 1); + para->text = text; + para->length = strlen(text); + para->layout = pango_layout_new (pango_context); + // pango_layout_set_font_description (para->layout, font_description); + pango_layout_set_markup (para->layout, para->text, para->length); + pango_layout_set_justify (para->layout, page_layout->do_justify); + pango_layout_set_alignment (para->layout, + page_layout->pango_dir == PANGO_DIRECTION_LTR + ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT); + pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR); + + pango_layout_set_width (para->layout, paint_width * PANGO_SCALE); + para->height = 0; + + result = g_list_prepend (result, para); + } + else + { + + while (p != NULL && *p) + { + wc = g_utf8_get_char (p); + next = g_utf8_next_char (p); + if (wc == (gunichar)-1) + { + fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ()); + wc = 0; + } + if (!*p || !wc || wc == '\n' || wc == '\f') + { + Paragraph *para = g_new (Paragraph, 1); + para->text = last_para; + para->length = p - last_para; + para->layout = pango_layout_new (pango_context); + // pango_layout_set_font_description (para->layout, font_description); + pango_layout_set_text (para->layout, para->text, para->length); + pango_layout_set_justify (para->layout, page_layout->do_justify); + pango_layout_set_alignment (para->layout, + page_layout->pango_dir == PANGO_DIRECTION_LTR + ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT); + pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR); + + pango_layout_set_width (para->layout, paint_width * PANGO_SCALE); + para->height = 0; + + last_para = next; + + if (wc == '\f') + para->formfeed = 1; + else + para->formfeed = 0; + + result = g_list_prepend (result, para); + } + if (!wc) /* incomplete character at end */ + break; + p = next; + } + } + + return g_list_reverse (result); +} + + /* Split a list of paragraphs into a list of lines. */ @@ -700,8 +826,9 @@ split_paragraphs_into_lines(page_layout_t *page_layout, par_list = par_list->next; } - if (lpi > 0.0L) - page_layout->scale_y = 1 / lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE / max_height; + + if (page_layout->do_stretch_chars && page_layout->lpi > 0.0L) + page_layout->scale_y = 1.0 / page_layout->lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE / max_height; return g_list_reverse(line_list); @@ -758,14 +885,13 @@ output_pages(FILE *OUT, draw_line_to_page(OUT, column_idx, column_y_pos+line_link->logical_rect.height, - page_layout->scale_x, page_layout->scale_y, page_layout, line); - if (lpi > 0.0L) - column_y_pos += (1 / lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE); + if (page_layout->lpi > 0.0L) + column_y_pos += (int)(1.0 / page_layout->lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE); else - column_y_pos += line_link->logical_rect.height; + column_y_pos += line_link->logical_rect.height; pango_lines = pango_lines->next; prev_line_link = line_link; @@ -796,7 +922,7 @@ void print_postscript_header(FILE *OUT, fprintf(OUT, "%%!PS-Adobe-3.0\n" "%%%%Title: %s\n" - "%%%%Creator: paps version 0.6.3 by Dov Grobgeld\n" + "%%%%Creator: paps version 0.6.7 by Dov Grobgeld\n" "%%%%Pages: (atend)\n" "%%%%BoundingBox: 0 0 %d %d\n" "%%%%BeginProlog\n" @@ -918,6 +1044,8 @@ void print_postscript_header(FILE *OUT, " papsdict begin\n" " gsave\n" " do_landscape {turnpage} if \n" + " %% ps2pdf gets wrong orientation without this!\n" + " /Helvetica findfont setfont 100 100 moveto ( ) show\n" " firstcolumn\n" " end\n" "} def\n" @@ -957,7 +1085,7 @@ void eject_column(FILE *OUT, if (column_idx == 1) total_gutter = 1.0 * page_layout->gutter_width /2; else - total_gutter = (column_idx + 1.5) * page_layout->gutter_width; + total_gutter = (column_idx - 0.5) * page_layout->gutter_width; x_pos = page_layout->left_margin + page_layout->column_width * column_idx @@ -992,8 +1120,6 @@ void draw_line_to_page(FILE *OUT, int column_idx, int column_pos, - gdouble scale_x, - gdouble scale_y, page_layout_t *page_layout, PangoLayoutLine *line) { @@ -1026,9 +1152,9 @@ draw_line_to_page(FILE *OUT, x_pos += page_layout->column_width - logical_rect.width / (page_layout->pt_to_pixel * PANGO_SCALE); } + paps_set_scale(paps, page_layout->scale_x, page_layout->scale_y); ps_layout = paps_layout_line_to_postscript_strdup(paps, x_pos, y_pos, - scale_x, scale_y, line); g_string_append(ps_pages_string, @@ -1088,9 +1214,9 @@ draw_page_header_line_to_page(FILE *OUT, y_pos = page_layout->page_height - page_layout->top_margin - height; page_layout->header_height = height; } + paps_set_scale(paps, page_layout->scale_x, page_layout->scale_y); ps_layout = paps_layout_line_to_postscript_strdup(paps, x_pos, y_pos, - page_layout->scale_x, page_layout->scale_y, line); g_string_append(ps_pages_string, ps_layout); @@ -1102,9 +1228,9 @@ draw_page_header_line_to_page(FILE *OUT, &ink_rect, &logical_rect); x_pos = (page_layout->page_width - (logical_rect.width / PANGO_SCALE * page_layout->pixel_to_pt)) / 2; + paps_set_scale(paps, page_layout->scale_x, page_layout->scale_y); ps_layout = paps_layout_line_to_postscript_strdup(paps, x_pos, y_pos, - page_layout->scale_x, page_layout->scale_y, line); g_string_append(ps_pages_string, ps_layout); @@ -1116,9 +1242,9 @@ draw_page_header_line_to_page(FILE *OUT, &ink_rect, &logical_rect); x_pos = page_layout->page_width - page_layout->right_margin - (logical_rect.width / PANGO_SCALE * page_layout->pixel_to_pt); + paps_set_scale(paps, page_layout->scale_x, page_layout->scale_y); ps_layout = paps_layout_line_to_postscript_strdup(paps, x_pos, y_pos, - page_layout->scale_x, page_layout->scale_y, line); g_string_append(ps_pages_string, ps_layout); diff --git a/src/test_libpaps.c b/src/test_libpaps.c index 89c8ae6..c293d4b 100644 --- a/src/test_libpaps.c +++ b/src/test_libpaps.c @@ -83,7 +83,6 @@ int main(int argc, char*argv[]) ps_layout = paps_layout_to_postscript_strdup(paps, 0, 0, - 1.0, 1.0, layout); g_string_append_printf(ps_text, "gsave\n" @@ -111,7 +110,6 @@ int main(int argc, char*argv[]) ); ps_layout = paps_layout_to_postscript_strdup(paps, 0, 0, - 1.0, 1.0, layout); g_string_append_printf(ps_text, "gsave\n" |