- paps-0.6.6-cpilpi.patch: add --cpi and --lpi option to support the
characters per inch and the lines per inch. - paps-cups.patch: add cpi and lpi support.
This commit is contained in:
parent
d5c1021042
commit
cd6d252618
606
paps-0.6.6-cpilpi.patch
Normal file
606
paps-0.6.6-cpilpi.patch
Normal file
@ -0,0 +1,606 @@
|
||||
diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x libtool -x .deps -x .libs -x '*.ps' -x '*a' -x '*~' -x '*o' -x 'stamp*' -x paps -x test_libpaps paps-0.6.6.orig/src/libpaps.c paps-0.6.6/src/libpaps.c
|
||||
--- paps-0.6.6.orig/src/libpaps.c 2006-04-27 04:09:03.000000000 +0900
|
||||
+++ paps-0.6.6/src/libpaps.c 2006-07-03 21:37:01.000000000 +0900
|
||||
@@ -56,12 +56,16 @@
|
||||
|
||||
|
||||
// Forward declarations
|
||||
-static void add_postscript_prologue(GString *ps_string);
|
||||
+static void add_postscript_prologue(GString *ps_string,
|
||||
+ gdouble scale_x,
|
||||
+ gdouble scale_y);
|
||||
static gchar *get_next_char_id_strdup(paps_private_t *paps);
|
||||
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()
|
||||
@@ -77,11 +81,21 @@
|
||||
paps->last_pos_y = -1e67;
|
||||
paps->last_char_idx = 0;
|
||||
|
||||
- add_postscript_prologue(paps->header);
|
||||
+ add_postscript_prologue(paps->header, 1.0, 1.0);
|
||||
|
||||
return paps;
|
||||
}
|
||||
|
||||
+void
|
||||
+paps_set_scale(paps_t *paps_,
|
||||
+ gdouble scale_x,
|
||||
+ gdouble scale_y)
|
||||
+{
|
||||
+ paps_private_t *paps = (paps_private_t *)paps_;
|
||||
+ g_string_erase(paps->header, 0, -1);
|
||||
+ add_postscript_prologue(paps->header, scale_x, scale_y);
|
||||
+}
|
||||
+
|
||||
PangoContext *paps_get_pango_context()
|
||||
{
|
||||
return pango_ft2_get_context (PAPS_DPI, PAPS_DPI);
|
||||
@@ -124,14 +138,18 @@
|
||||
GString *line_str,
|
||||
PangoLayoutLine *pango_line,
|
||||
double line_start_pos_x,
|
||||
- double line_start_pos_y
|
||||
+ double line_start_pos_y,
|
||||
+ double scale_x,
|
||||
+ double scale_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 pos_y,
|
||||
+ double scale_x,
|
||||
+ double scale_y
|
||||
);
|
||||
/* Countour traveling functions */
|
||||
static int paps_ps_move_to( FT_Vector* to,
|
||||
@@ -166,6 +184,8 @@
|
||||
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_;
|
||||
@@ -189,6 +209,8 @@
|
||||
layout_str,
|
||||
pos_x,
|
||||
pos_y,
|
||||
+ scale_x,
|
||||
+ scale_y,
|
||||
pango_line);
|
||||
|
||||
pos_y -= logical_rect.height * scale;
|
||||
@@ -203,6 +225,8 @@
|
||||
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_;
|
||||
@@ -213,6 +237,8 @@
|
||||
layout_str,
|
||||
pos_x,
|
||||
pos_y,
|
||||
+ scale_x,
|
||||
+ scale_y,
|
||||
layout_line);
|
||||
|
||||
ret_str = layout_str->str;
|
||||
@@ -221,7 +247,9 @@
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
-void add_postscript_prologue(GString *ps_string)
|
||||
+void add_postscript_prologue(GString *ps_string,
|
||||
+ gdouble scale_x,
|
||||
+ gdouble scale_y)
|
||||
{
|
||||
g_string_append_printf(ps_string,
|
||||
"%%%%BeginProlog\n"
|
||||
@@ -249,7 +277,7 @@
|
||||
"/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 load exec end grestore} def\n"
|
||||
+ "/draw_char { fontdict begin gsave %f dup scale last_x last_y translate %f %f scale 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"
|
||||
@@ -261,7 +289,8 @@
|
||||
// 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
|
||||
+ 1.0 / PAPS_DPI,
|
||||
+ scale_x, scale_y
|
||||
);
|
||||
|
||||
// The following is a dispatcher for an encoded string that contains
|
||||
@@ -331,6 +360,8 @@
|
||||
GString *line_str,
|
||||
double x_pos,
|
||||
double y_pos,
|
||||
+ double scale_x,
|
||||
+ double scale_y,
|
||||
PangoLayoutLine *line)
|
||||
{
|
||||
PangoRectangle ink_rect, logical_rect;
|
||||
@@ -349,7 +380,7 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
- draw_contour(paps, line_str, line, x_pos, y_pos);
|
||||
+ draw_contour(paps, line_str, line, x_pos, y_pos, scale_x, scale_y);
|
||||
}
|
||||
|
||||
/* draw_contour() draws all of the contours that make up a line.
|
||||
@@ -359,7 +390,9 @@
|
||||
GString *layout_str,
|
||||
PangoLayoutLine *pango_line,
|
||||
double line_start_pos_x,
|
||||
- double line_start_pos_y
|
||||
+ double line_start_pos_y,
|
||||
+ double scale_x,
|
||||
+ double scale_y
|
||||
)
|
||||
{
|
||||
GSList *runs_list;
|
||||
@@ -389,7 +422,7 @@
|
||||
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;
|
||||
+ x_pos += geometry.width * scale * scale_x;
|
||||
|
||||
if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
|
||||
continue;
|
||||
@@ -399,7 +432,9 @@
|
||||
ft_face,
|
||||
&glyphs->glyphs[glyph_idx],
|
||||
glyph_pos_x,
|
||||
- glyph_pos_y
|
||||
+ glyph_pos_y,
|
||||
+ scale_x,
|
||||
+ scale_y
|
||||
);
|
||||
}
|
||||
|
||||
@@ -415,13 +450,15 @@
|
||||
FT_Face face,
|
||||
PangoGlyphInfo *glyph_info,
|
||||
double pos_x,
|
||||
- double pos_y
|
||||
+ double pos_y,
|
||||
+ double scale_x,
|
||||
+ double scale_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;
|
||||
+ double glyph_width = glyph_info->geometry.width * scale * scale_x;
|
||||
gchar *id = NULL;
|
||||
|
||||
/* Output outline */
|
||||
@@ -480,7 +517,7 @@
|
||||
g_string_append_printf(glyph_def_string,
|
||||
"%.0f fwd_x\n"
|
||||
"end_ol\n",
|
||||
- glyph_info->geometry.width * scale * PAPS_DPI
|
||||
+ glyph_info->geometry.width * scale * scale_x * PAPS_DPI
|
||||
);
|
||||
|
||||
// TBD - Check if the glyph_def_string is empty. If so, set the
|
||||
diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x libtool -x .deps -x .libs -x '*.ps' -x '*a' -x '*~' -x '*o' -x 'stamp*' -x paps -x test_libpaps paps-0.6.6.orig/src/libpaps.h paps-0.6.6/src/libpaps.h
|
||||
--- paps-0.6.6.orig/src/libpaps.h 2005-12-21 04:35:39.000000000 +0900
|
||||
+++ paps-0.6.6/src/libpaps.h 2006-07-03 20:17:13.000000000 +0900
|
||||
@@ -40,6 +40,19 @@
|
||||
*/
|
||||
void paps_free(paps_t *paps);
|
||||
|
||||
+/**
|
||||
+ * Set the scales for characters.
|
||||
+ *
|
||||
+ * @param paps Paps object
|
||||
+ * @param scale_x x-coordinate scale
|
||||
+ * @param scale_y y-coordinate scale
|
||||
+ *
|
||||
+ */
|
||||
+void
|
||||
+paps_set_scale(paps_t *paps,
|
||||
+ gdouble scale_x,
|
||||
+ gdouble scale_y);
|
||||
+
|
||||
/**
|
||||
* libpaps may currently be used only with a PangoContext that it
|
||||
* is creating. The context returned may of course be changed though
|
||||
@@ -78,6 +91,8 @@
|
||||
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
|
||||
@@ -95,6 +110,8 @@
|
||||
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);
|
||||
|
||||
/**
|
||||
diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x libtool -x .deps -x .libs -x '*.ps' -x '*a' -x '*~' -x '*o' -x 'stamp*' -x paps -x test_libpaps paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
|
||||
--- paps-0.6.6.orig/src/paps.c 2006-07-04 12:25:33.000000000 +0900
|
||||
+++ paps-0.6.6/src/paps.c 2006-07-04 13:11:32.000000000 +0900
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
|
||||
#include <pango/pango.h>
|
||||
+#include <pango/pangoft2.h>
|
||||
#include "libpaps.h"
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
+#include <wchar.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define DEFAULT_FONT_FAMILY "Monospace"
|
||||
@@ -71,6 +73,8 @@
|
||||
int header_sep;
|
||||
int header_height;
|
||||
int footer_height;
|
||||
+ gdouble scale_x;
|
||||
+ gdouble scale_y;
|
||||
gboolean do_draw_header;
|
||||
gboolean do_draw_footer;
|
||||
gboolean do_duplex;
|
||||
@@ -110,7 +114,8 @@
|
||||
};
|
||||
|
||||
/* Information passed in user data when drawing outlines */
|
||||
-GList *split_paragraphs_into_lines (GList *paragraphs);
|
||||
+GList *split_paragraphs_into_lines (page_layout_t *page_layout,
|
||||
+ GList *paragraphs);
|
||||
static char *read_file (FILE *file,
|
||||
GIConv handle);
|
||||
static GList *split_text_into_paragraphs (PangoContext *pango_context,
|
||||
@@ -136,6 +141,8 @@
|
||||
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,
|
||||
@@ -158,6 +165,7 @@
|
||||
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)
|
||||
|
||||
@@ -190,6 +198,60 @@
|
||||
return retval;
|
||||
}
|
||||
|
||||
+static gboolean
|
||||
+_paps_arg_lpi_cb(const gchar *option_name,
|
||||
+ const gchar *value,
|
||||
+ gpointer data)
|
||||
+{
|
||||
+ gboolean retval = TRUE;
|
||||
+ gchar *p = NULL;
|
||||
+
|
||||
+ if (value && *value)
|
||||
+ {
|
||||
+ errno = 0;
|
||||
+ lpi = g_strtod(value, &p);
|
||||
+ if ((p && *p) || errno == ERANGE)
|
||||
+ {
|
||||
+ fprintf(stderr, "given LPI value was invalid.\n");
|
||||
+ retval = FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ fprintf(stderr, "You must specify the amount of lines per inch.\n");
|
||||
+ retval = FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+_paps_arg_cpi_cb(const gchar *option_name,
|
||||
+ const gchar *value,
|
||||
+ gpointer data)
|
||||
+{
|
||||
+ gboolean retval = TRUE;
|
||||
+ gchar *p = NULL;
|
||||
+
|
||||
+ if (value && *value)
|
||||
+ {
|
||||
+ errno = 0;
|
||||
+ cpi = g_strtod(value, &p);
|
||||
+ if ((p && *p) || errno == ERANGE)
|
||||
+ {
|
||||
+ fprintf(stderr, "given CPI value was invalid.\n");
|
||||
+ retval = FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ fprintf(stderr, "You must specify the amount of characters per inch.\n");
|
||||
+ retval = FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
static PangoLanguage *
|
||||
get_language(void)
|
||||
{
|
||||
@@ -233,6 +295,8 @@
|
||||
{"left-margin", 0, 0, G_OPTION_ARG_INT, &left_margin, "Set left margin. (Default: 36)", "NUM"},
|
||||
{"header", 0, 0, G_OPTION_ARG_NONE, &do_draw_header, "Draw page header for each page.", NULL},
|
||||
{"encoding", 0, 0, G_OPTION_ARG_STRING, &encoding, "Assume the documentation encoding.", "ENCODING"},
|
||||
+ {"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;
|
||||
@@ -243,6 +307,9 @@
|
||||
PangoContext *pango_context;
|
||||
PangoFontDescription *font_description;
|
||||
PangoDirection pango_dir = PANGO_DIRECTION_LTR;
|
||||
+ PangoFontMap *fontmap;
|
||||
+ PangoFontset *fontset;
|
||||
+ PangoFontMetrics *metrics;
|
||||
int num_pages = 1;
|
||||
int gutter_width = 40;
|
||||
int total_gutter_width;
|
||||
@@ -254,6 +321,7 @@
|
||||
gchar *header_font_desc = MAKE_FONT_NAME (HEADER_FONT_FAMILY, HEADER_FONT_SCALE);
|
||||
gchar *filename_in, *title, *text;
|
||||
int header_sep = 20;
|
||||
+ int max_width = 0, w;
|
||||
GIConv cvh = NULL;
|
||||
|
||||
/* Prerequisite when using glib. */
|
||||
@@ -343,6 +411,8 @@
|
||||
page_layout.header_height = 0;
|
||||
page_layout.footer_height = 0;
|
||||
page_layout.do_wordwrap = do_wordwrap;
|
||||
+ page_layout.scale_x = 1.0L;
|
||||
+ page_layout.scale_y = 1.0L;
|
||||
if (do_draw_header)
|
||||
page_layout.header_sep = header_sep;
|
||||
else
|
||||
@@ -365,7 +435,22 @@
|
||||
page_layout.pango_dir = pango_dir;
|
||||
page_layout.filename = filename_in;
|
||||
page_layout.header_font_desc = header_font_desc;
|
||||
-
|
||||
+
|
||||
+ /* calculate x-coordinate scale */
|
||||
+ if (cpi > 0.0L)
|
||||
+ {
|
||||
+ 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);
|
||||
+ max_width = pango_font_metrics_get_approximate_char_width (metrics);
|
||||
+ 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;
|
||||
+ pango_font_metrics_unref (metrics);
|
||||
+ g_object_unref (G_OBJECT (fontmap));
|
||||
+ }
|
||||
+
|
||||
if (encoding != NULL)
|
||||
{
|
||||
cvh = g_iconv_open ("UTF-8", encoding);
|
||||
@@ -385,11 +470,12 @@
|
||||
&page_layout,
|
||||
page_layout.column_width * page_layout.pt_to_pixel,
|
||||
text);
|
||||
- pango_lines = split_paragraphs_into_lines(paragraphs);
|
||||
+ pango_lines = split_paragraphs_into_lines(&page_layout, paragraphs);
|
||||
|
||||
if (OUT == NULL)
|
||||
OUT = stdout;
|
||||
|
||||
+ paps_set_scale(paps, page_layout.scale_x, page_layout.scale_y);
|
||||
print_postscript_header(OUT, title, &page_layout);
|
||||
ps_pages_string = g_string_new("");
|
||||
|
||||
@@ -493,6 +579,58 @@
|
||||
para->text = last_para;
|
||||
para->length = p - last_para;
|
||||
para->layout = pango_layout_new (pango_context);
|
||||
+
|
||||
+ if (cpi > 0.0L && page_layout->do_wordwrap)
|
||||
+ {
|
||||
+ PangoRectangle ink_rect, logical_rect;
|
||||
+ wchar_t *wtext, *wnewtext;
|
||||
+ gchar *newtext;
|
||||
+ size_t i, len, wwidth = 0, n;
|
||||
+
|
||||
+ wtext = (wchar_t *)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);
|
||||
+ /* 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)
|
||||
+ {
|
||||
+ wnewtext = g_new (wchar_t, wcslen (wtext) + 1);
|
||||
+ if (wnewtext == NULL)
|
||||
+ {
|
||||
+ fprintf (stderr, "Failed to allocate a memory.\n");
|
||||
+ g_free (wtext);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ for (i = 0; i < len; i++)
|
||||
+ {
|
||||
+ wwidth += wcwidth (wtext[i]);
|
||||
+ if (wwidth > n)
|
||||
+ break;
|
||||
+ wnewtext[i] = wtext[i];
|
||||
+ }
|
||||
+ wnewtext[i] = 0L;
|
||||
+
|
||||
+ newtext = g_ucs4_to_utf8 ((const gunichar *)wnewtext, i, NULL, NULL, NULL);
|
||||
+ if (newtext == NULL)
|
||||
+ {
|
||||
+ fprintf (stderr, "Failed to convert UCS-4 to UTF-8.\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ pango_layout_set_text (para->layout, newtext, -1);
|
||||
+ pango_layout_get_extents (para->layout, &ink_rect, &logical_rect);
|
||||
+ /* update paint_width to wrap_against CPI */
|
||||
+ paint_width = logical_rect.width / PANGO_SCALE;
|
||||
+ g_free (newtext);
|
||||
+ g_free (wnewtext);
|
||||
+ }
|
||||
+ g_free (wtext);
|
||||
+ }
|
||||
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,
|
||||
@@ -523,9 +661,11 @@
|
||||
/* Split a list of paragraphs into a list of lines.
|
||||
*/
|
||||
GList *
|
||||
-split_paragraphs_into_lines(GList *paragraphs)
|
||||
+split_paragraphs_into_lines(page_layout_t *page_layout,
|
||||
+ GList *paragraphs)
|
||||
{
|
||||
GList *line_list = NULL;
|
||||
+ int max_height = 0;
|
||||
/* Read the file */
|
||||
|
||||
/* Now split all the pagraphs into lines */
|
||||
@@ -554,10 +694,14 @@
|
||||
line_link->formfeed = 1;
|
||||
line_link->ink_rect = ink_rect;
|
||||
line_list = g_list_prepend(line_list, line_link);
|
||||
+ if (logical_rect.height > max_height)
|
||||
+ max_height = logical_rect.height;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return g_list_reverse(line_list);
|
||||
|
||||
@@ -612,9 +756,14 @@
|
||||
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);
|
||||
- column_y_pos += line_link->logical_rect.height;
|
||||
+
|
||||
+ if (lpi > 0.0L)
|
||||
+ column_y_pos += (1 / lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE);
|
||||
+ else
|
||||
+ column_y_pos += line_link->logical_rect.height;
|
||||
|
||||
pango_lines = pango_lines->next;
|
||||
}
|
||||
@@ -840,6 +989,8 @@
|
||||
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)
|
||||
{
|
||||
@@ -874,6 +1025,7 @@
|
||||
|
||||
ps_layout = paps_layout_line_to_postscript_strdup(paps,
|
||||
x_pos, y_pos,
|
||||
+ scale_x, scale_y,
|
||||
line);
|
||||
|
||||
g_string_append(ps_pages_string,
|
||||
@@ -935,6 +1087,7 @@
|
||||
}
|
||||
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);
|
||||
@@ -948,6 +1101,7 @@
|
||||
x_pos = (page_layout->page_width - (logical_rect.width / PANGO_SCALE * page_layout->pixel_to_pt)) / 2;
|
||||
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);
|
||||
@@ -961,6 +1115,7 @@
|
||||
x_pos = page_layout->page_width - page_layout->right_margin - (logical_rect.width / PANGO_SCALE * page_layout->pixel_to_pt);
|
||||
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);
|
||||
@@ -977,4 +1132,3 @@
|
||||
|
||||
return logical_rect.height;
|
||||
}
|
||||
-
|
||||
diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x libtool -x .deps -x .libs -x '*.ps' -x '*a' -x '*~' -x '*o' -x 'stamp*' -x paps -x test_libpaps paps-0.6.6.orig/src/test_libpaps.c paps-0.6.6/src/test_libpaps.c
|
||||
--- paps-0.6.6.orig/src/test_libpaps.c 2005-12-21 04:35:39.000000000 +0900
|
||||
+++ paps-0.6.6/src/test_libpaps.c 2006-07-03 18:48:04.000000000 +0900
|
||||
@@ -83,6 +83,7 @@
|
||||
|
||||
ps_layout = paps_layout_to_postscript_strdup(paps,
|
||||
0, 0,
|
||||
+ 1.0, 1.0,
|
||||
layout);
|
||||
g_string_append_printf(ps_text,
|
||||
"gsave\n"
|
||||
@@ -110,6 +111,7 @@
|
||||
);
|
||||
ps_layout = paps_layout_to_postscript_strdup(paps,
|
||||
0, 0,
|
||||
+ 1.0, 1.0,
|
||||
layout);
|
||||
g_string_append_printf(ps_text,
|
||||
"gsave\n"
|
@ -1,10 +1,35 @@
|
||||
diff -ruN -x 'Makefile*' -x autom4te.cache -x 'config*' -x doc -x 'foo*' -x 'lib*' -x .deps -x .libs -x paps -x '*o' -x '*~' -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-06-20 20:40:11.000000000 +0900
|
||||
+++ paps-0.6.6/src/paps.c 2006-06-21 01:36:54.000000000 +0900
|
||||
@@ -495,6 +495,7 @@
|
||||
diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
|
||||
--- paps-0.6.6.orig/src/paps.c 2006-07-04 12:16:49.000000000 +0900
|
||||
+++ paps-0.6.6/src/paps.c 2006-07-04 12:19:20.000000000 +0900
|
||||
@@ -79,6 +79,7 @@
|
||||
gboolean do_justify;
|
||||
gboolean do_separation_line;
|
||||
gboolean do_draw_contour;
|
||||
+ gboolean do_wordwrap;
|
||||
PangoDirection pango_dir;
|
||||
gchar *filename;
|
||||
gchar *header_font_desc;
|
||||
@@ -212,6 +213,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
gboolean do_landscape = FALSE, do_rtl = FALSE, do_justify = FALSE, do_draw_header = FALSE;
|
||||
+ gboolean do_wordwrap = TRUE;
|
||||
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;
|
||||
@@ -340,6 +342,7 @@
|
||||
page_layout.header_ypos = page_layout.top_margin;
|
||||
page_layout.header_height = 0;
|
||||
page_layout.footer_height = 0;
|
||||
+ page_layout.do_wordwrap = do_wordwrap;
|
||||
if (do_draw_header)
|
||||
page_layout.header_sep = header_sep;
|
||||
else
|
||||
@@ -496,6 +499,8 @@
|
||||
page_layout->pango_dir == PANGO_DIRECTION_LTR
|
||||
? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);
|
||||
pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
|
||||
+ if (page_layout->do_wordwrap)
|
||||
+ pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
|
||||
para->height = 0;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
unchanged:
|
||||
diff -ruN paps-0.6.6.orig/configure.in paps-0.6.6/configure.in
|
||||
--- paps-0.6.6.orig/configure.in 2006-04-28 04:41:36.000000000 +0900
|
||||
+++ paps-0.6.6/configure.in 2006-06-29 17:45:59.000000000 +0900
|
||||
+++ paps-0.6.6/configure.in 2006-07-04 13:22:12.000000000 +0900
|
||||
@@ -7,4 +7,17 @@
|
||||
AC_PROG_CC
|
||||
AM_PROG_LIBTOOL
|
||||
@ -19,9 +19,9 @@ unchanged:
|
||||
+AC_SUBST(CUPS_LIBS)
|
||||
+
|
||||
AC_OUTPUT(Makefile src/Makefile doc/Makefile)
|
||||
unchanged:
|
||||
--- paps-0.6.6.orig/src/Makefile.am 2006-06-20 20:40:11.000000000 +0900
|
||||
+++ paps-0.6.6/src/Makefile.am 2006-06-29 19:09:12.000000000 +0900
|
||||
diff -ruN paps-0.6.6.orig/src/Makefile.am paps-0.6.6/src/Makefile.am
|
||||
--- paps-0.6.6.orig/src/Makefile.am 2006-07-04 13:21:56.000000000 +0900
|
||||
+++ paps-0.6.6/src/Makefile.am 2006-07-04 13:22:12.000000000 +0900
|
||||
@@ -5,10 +5,10 @@
|
||||
libpaps_a_incdir = $(includedir)
|
||||
|
||||
@ -35,26 +35,18 @@ unchanged:
|
||||
paps_DEPENDENCIES = $(noinst_LIBRARIES)
|
||||
|
||||
EXTRA_DIST = test_libpaps.c paps.1
|
||||
diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
--- paps-0.6.6/src/paps.c 2006-06-29 19:06:46.000000000 +0900
|
||||
+++ paps-0.6.6/src/paps.c 2006-06-29 14:29:13.000000000 +0100
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <string.h>
|
||||
diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
|
||||
--- paps-0.6.6.orig/src/paps.c 2006-07-04 13:21:56.000000000 +0900
|
||||
+++ paps-0.6.6/src/paps.c 2006-07-04 13:23:28.000000000 +0900
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <wchar.h>
|
||||
+#include <cups/cups.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define DEFAULT_FONT_FAMILY "Monospace"
|
||||
@@ -79,6 +80,7 @@
|
||||
gboolean do_justify;
|
||||
gboolean do_separation_line;
|
||||
gboolean do_draw_contour;
|
||||
+ gboolean do_wordwrap;
|
||||
PangoDirection pango_dir;
|
||||
gchar *filename;
|
||||
gchar *header_font_desc;
|
||||
@@ -244,8 +246,8 @@
|
||||
@@ -313,8 +314,8 @@
|
||||
int num_pages = 1;
|
||||
int gutter_width = 40;
|
||||
int total_gutter_width;
|
||||
@ -65,11 +57,11 @@ diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
int do_tumble = -1; /* -1 means not initialized */
|
||||
int do_duplex = -1;
|
||||
gchar *paps_header = NULL;
|
||||
@@ -253,12 +255,113 @@
|
||||
gchar *filename_in, *title, *text;
|
||||
@@ -323,12 +324,113 @@
|
||||
int header_sep = 20;
|
||||
int max_width = 0, w;
|
||||
GIConv cvh = NULL;
|
||||
+ gboolean cups_mode = FALSE, do_wordwrap = TRUE;
|
||||
+ gboolean cups_mode = FALSE;
|
||||
|
||||
/* Prerequisite when using glib. */
|
||||
g_type_init();
|
||||
@ -164,10 +156,10 @@ diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
+ num_columns = atoi(val);
|
||||
+ }
|
||||
+ if ((val = cupsGetOption("cpi", num_options, options)) != NULL) {
|
||||
+ /* XXX */
|
||||
+ cpi = atof(val);
|
||||
+ }
|
||||
+ if ((val = cupsGetOption("lpi", num_options, options)) != NULL) {
|
||||
+ /* XXX */
|
||||
+ lpi = atof(val);
|
||||
+ }
|
||||
+ if (getenv("CHARSET") != NULL)
|
||||
+ encoding = getenv("CHARSET");
|
||||
@ -179,7 +171,7 @@ diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
/* Parse command line */
|
||||
if (!g_option_context_parse(ctxt, &argc, &argv, &error))
|
||||
{
|
||||
@@ -285,6 +388,8 @@
|
||||
@@ -355,6 +457,8 @@
|
||||
IN = stdin;
|
||||
}
|
||||
title = filename_in;
|
||||
@ -188,7 +180,7 @@ diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
|
||||
paps = paps_new();
|
||||
pango_context = paps_get_pango_context (paps);
|
||||
@@ -303,8 +408,10 @@
|
||||
@@ -373,8 +477,10 @@
|
||||
pango_context_set_font_description (pango_context, font_description);
|
||||
|
||||
/* Page layout */
|
||||
@ -201,21 +193,3 @@ diff -u paps-0.6.6/src/paps.c paps-0.6.6/src/paps.c
|
||||
|
||||
if (num_columns == 1)
|
||||
total_gutter_width = 0;
|
||||
@@ -340,6 +447,7 @@
|
||||
page_layout.header_ypos = page_layout.top_margin;
|
||||
page_layout.header_height = 0;
|
||||
page_layout.footer_height = 0;
|
||||
+ page_layout.do_wordwrap = do_wordwrap;
|
||||
if (do_draw_header)
|
||||
page_layout.header_sep = header_sep;
|
||||
else
|
||||
@@ -495,7 +603,8 @@
|
||||
page_layout->pango_dir == PANGO_DIRECTION_LTR
|
||||
? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);
|
||||
pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
|
||||
- pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
|
||||
+ if (page_layout->do_wordwrap)
|
||||
+ pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
|
||||
para->height = 0;
|
||||
|
||||
if (wc == '\f')
|
||||
|
10
paps.spec
10
paps.spec
@ -1,6 +1,6 @@
|
||||
Name: paps
|
||||
Version: 0.6.6
|
||||
Release: 9%{?dist}
|
||||
Release: 10%{?dist}
|
||||
|
||||
License: LGPL
|
||||
URL: http://paps.sourceforge.net/
|
||||
@ -22,6 +22,8 @@ Patch6: paps-0.6.6-font-option.patch
|
||||
Patch7: paps-0.6.6-lcctype.patch
|
||||
## http://sourceforge.net/tracker/index.php?func=detail&aid=1512385&group_id=153049&atid=786239
|
||||
Patch8: paps-0.6.6-wordwrap.patch
|
||||
## http://sourceforge.net/tracker/index.php?func=detail&aid=1472021&group_id=153049&atid=786242
|
||||
Patch9: paps-0.6.6-cpilpi.patch
|
||||
Patch50: paps-cups.patch
|
||||
|
||||
Summary: Plain Text to PostScript converter
|
||||
@ -40,6 +42,7 @@ paps is a PostScript converter from plain text file using Pango.
|
||||
%patch6 -p1 -b .fontopt
|
||||
%patch7 -p1 -b .lcctype
|
||||
%patch8 -p1 -b .wordwrap
|
||||
%patch9 -p1 -b .cpilpi
|
||||
%patch50 -p1 -b .cups
|
||||
aclocal
|
||||
automake
|
||||
@ -73,6 +76,11 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 4 2006 Akira TAGOH <tagoh@redhat.com> - 0.6.6-10
|
||||
- paps-0.6.6-cpilpi.patch: add --cpi and --lpi option to support the characters
|
||||
per inch and the lines per inch.
|
||||
- paps-cups.patch: add cpi and lpi support.
|
||||
|
||||
* Thu Jun 29 2006 Tim Waugh <twaugh@redhat.com> - 0.6.6-9
|
||||
- Fixed font-option patch.
|
||||
- Adjusted CUPS patch: CUPS invokes the filter with the destination
|
||||
|
Loading…
Reference in New Issue
Block a user