rpms/paps/FC-5 paps-0.6.6-cpilpi.patch, NONE, 1.1 paps-0.6.6-wordwrap.patch, NONE, 1.1 paps-0.6.6-encoding.patch, 1.2, 1.3 paps-0.6.6-font-option.patch, 1.1, 1.2 paps.spec, 1.9, 1.10

Akira Tagoh (tagoh) fedora-extras-commits at redhat.com
Wed Aug 16 02:04:58 UTC 2006


Author: tagoh

Update of /cvs/extras/rpms/paps/FC-5
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2779

Modified Files:
	paps-0.6.6-encoding.patch paps-0.6.6-font-option.patch 
	paps.spec 
Added Files:
	paps-0.6.6-cpilpi.patch paps-0.6.6-wordwrap.patch 
Log Message:
* Wed Aug 16 2006 Akira TAGOH <tagoh at redhat.com>
- paps-0.6.6-wordwrap.patch: applied to do a wordwrap.
- paps-0.6.6-cpilpi.patch: add --cpi and --lpi option to support the characters
  per inch and the lines per inch.
- paps-0.6.6-font-option.patch: fixed to get this working.
- paps-0.6.6-encoding.patch: null-terminate the output.

paps-0.6.6-cpilpi.patch:

--- NEW FILE paps-0.6.6-cpilpi.patch ---
diff -ruN 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-17 13:33:13.000000000 +0900
@@ -52,16 +52,20 @@
   int last_char_idx;
   double last_pos_y;
   double last_pos_x;
+  double scale_x;
+  double scale_y;
 } paps_private_t;
 
 
 // Forward declarations
-static void add_postscript_prologue(GString *ps_string);
+static void add_postscript_prologue(paps_private_t *paps);
 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()
@@ -76,12 +80,27 @@
     paps->last_pos_x = -1e67;
     paps->last_pos_y = -1e67;
     paps->last_char_idx = 0;
+    paps->scale_x = 1.0;
+    paps->scale_y = 1.0;
 
-    add_postscript_prologue(paps->header);
+    add_postscript_prologue(paps);
 
     return paps;
 }
 
+void
+paps_set_scale(paps_t  *paps_,
+	       gdouble  scale_x,
+	       gdouble  scale_y)
+{
+    paps_private_t *paps = (paps_private_t *)paps_;
+
+    paps->scale_x = scale_x;
+    paps->scale_y = scale_y;
+    g_string_erase(paps->header, 0, -1);
+    add_postscript_prologue(paps);
+}
+
 PangoContext *paps_get_pango_context()
 {
   return pango_ft2_get_context (PAPS_DPI, PAPS_DPI);
@@ -124,14 +143,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 +189,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 +214,8 @@
 			     layout_str,
 			     pos_x,
 			     pos_y,
+			     scale_x,
+			     scale_y,
 			     pango_line);
 
       pos_y -= logical_rect.height * scale;
@@ -203,6 +230,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 +242,8 @@
 			 layout_str,
 			 pos_x,
 			 pos_y,
+			 scale_x,
+			 scale_y,
 			 layout_line);
 
   ret_str = layout_str->str;
@@ -221,9 +252,10 @@
   return ret_str;
 }
 
-void add_postscript_prologue(GString *ps_string)
+static void
+add_postscript_prologue(paps_private_t *paps)
 {
-  g_string_append_printf(ps_string,
+  g_string_append_printf(paps->header,
 			 "%%%%BeginProlog\n"
 			 "/papsdict 1 dict def\n"
 			 "papsdict begin\n"
@@ -231,7 +263,7 @@
 			 );
   
   /* Outline support */
-  g_string_append_printf(ps_string,
+  g_string_append_printf(paps->header,
 			 "/conicto {\n"
 			 "    /to_y exch def\n"
 			 "    /to_x exch def\n"
@@ -249,7 +281,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,14 +293,15 @@
 			 // 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,
+			 paps->scale_x, paps->scale_y
 			 );
 
   // The following is a dispatcher for an encoded string that contains
   // a packed version of the pango layout data. Currently it just executes
   // the symbols corresponding to the encoded characters, but in the future
   // it will also contain some meta data, e.g. the size of the layout.
-  g_string_append_printf(ps_string,
+  g_string_append_printf(paps->header,
 			 "/paps_exec {\n"
 			 "  1 dict begin\n"
 			 "  /ps exch def\n"
@@ -320,7 +353,7 @@
 			 );
 
   /* Open up dictionaries */
-  g_string_append(ps_string,
+  g_string_append(paps->header,
 		  "/fontdict 1 dict def\n"
 		  "papsdict begin fontdict begin\n");
 }
@@ -331,6 +364,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 +384,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 +394,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 +426,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 +436,9 @@
 			      ft_face,
 			      &glyphs->glyphs[glyph_idx],
 			      glyph_pos_x,
-			      glyph_pos_y
+			      glyph_pos_y,
+			      scale_x,
+			      scale_y
 			      );
         }
 
@@ -415,13 +454,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 +521,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 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-17 13:27:59.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 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-17 13:27:27.000000000 +0900
+++ paps-0.6.6/src/paps.c	2006-07-17 13:27:59.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 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-17 13:27:59.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"

paps-0.6.6-wordwrap.patch:

--- NEW FILE paps-0.6.6-wordwrap.patch ---
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;
 
           if (wc == '\f')

paps-0.6.6-encoding.patch:

Index: paps-0.6.6-encoding.patch
===================================================================
RCS file: /cvs/extras/rpms/paps/FC-5/paps-0.6.6-encoding.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- paps-0.6.6-encoding.patch	19 Jun 2006 19:51:44 -0000	1.2
+++ paps-0.6.6-encoding.patch	16 Aug 2006 02:04:57 -0000	1.3
@@ -80,7 +80,7 @@
        if (ferror (file))
          {
            fprintf(stderr, "%s: Error reading file.\n", g_get_prgname ());
-@@ -392,7 +412,19 @@
+@@ -392,7 +412,20 @@
        else if (bp == NULL)
          break;
  
@@ -96,6 +96,7 @@
 +              fprintf (stderr, "%s: Error while converting strings.\n", g_get_prgname ());
 +              return NULL;
 +            }
++          obuffer[BUFSIZE * 6 - 1 - oblen] = 0;
 +        }
 +      g_string_append (inbuf, bp);
      }

paps-0.6.6-font-option.patch:

Index: paps-0.6.6-font-option.patch
===================================================================
RCS file: /cvs/extras/rpms/paps/FC-5/paps-0.6.6-font-option.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- paps-0.6.6-font-option.patch	19 Jun 2006 19:51:44 -0000	1.1
+++ paps-0.6.6-font-option.patch	16 Aug 2006 02:04:57 -0000	1.2
@@ -1,4 +1,3 @@
-diff -ruN paps-0.6.6.orig/src/paps.1 paps-0.6.6/src/paps.1
 --- paps-0.6.6.orig/src/paps.1	2006-06-20 04:09:58.000000000 +0900
 +++ paps-0.6.6/src/paps.1	2006-06-20 04:12:23.000000000 +0900
 @@ -34,11 +34,8 @@
@@ -15,19 +14,18 @@
  .TP
  .B \-\-rtl
  Do rtl layout.
-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-06-20 04:09:58.000000000 +0900
-+++ paps-0.6.6/src/paps.c	2006-06-20 04:01:57.000000000 +0900
+--- paps-0.6.6/src/paps.c	2006-06-20 04:01:57.000000000 +0900
++++ paps-0.6.6/src/paps.c	2006-06-29 15:08:48.000000000 +0100
 @@ -30,7 +30,11 @@
  #include <time.h>
  
  #define BUFSIZE 1024
 -#define HEADER_FONT_SCALE 12
 +#define DEFAULT_FONT_FAMILY	"Monospace"
-+#define DEFAULT_FONT_SIZE	12
++#define DEFAULT_FONT_SIZE	"12"
 +#define HEADER_FONT_FAMILY	"Monospace Bold"
-+#define HEADER_FONT_SCALE	12
-+#define MAKE_FONT_NAME(f,s)	f " " #s
++#define HEADER_FONT_SCALE	"12"
++#define MAKE_FONT_NAME(f,s)	f " " s
  
  typedef enum {
      PAPER_TYPE_A4 = 0,
@@ -67,10 +65,10 @@
    int do_duplex = -1;
    gchar *paps_header = NULL;
 -  gchar *header_font_desc = "Monospace Bold 12";
-+  gchar *header_font_desc = MAKE_FONT_NAME (HEADER_FONT_FAMILY, HEADER_FONT_SIZE);
++  gchar *header_font_desc = MAKE_FONT_NAME (HEADER_FONT_FAMILY, HEADER_FONT_SCALE);
 +  gchar *filename_in, *title, *text;
    int header_sep = 20;
-   GIConv *cvh = NULL;
+   GIConv cvh = NULL;
  
 @@ -271,13 +272,12 @@
    pango_context_set_language (pango_context, pango_language_from_string ("en_US"));
@@ -88,7 +86,7 @@
 +  if ((pango_font_description_get_set_fields (font_description) & PANGO_FONT_MASK_FAMILY) == 0)
 +    pango_font_description_set_family (font_description, DEFAULT_FONT_FAMILY);
 +  if ((pango_font_description_get_set_fields (font_description) & PANGO_FONT_MASK_SIZE) == 0)
-+    pango_font_description_set_size (font_description, DEFAULT_FONT_SIZE * PANGO_SCALE);
++    pango_font_description_set_size (font_description, atoi(DEFAULT_FONT_SIZE) * PANGO_SCALE);
  
    pango_context_set_font_description (pango_context, font_description);
  


Index: paps.spec
===================================================================
RCS file: /cvs/extras/rpms/paps/FC-5/paps.spec,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- paps.spec	19 Jun 2006 19:51:44 -0000	1.9
+++ paps.spec	16 Aug 2006 02:04:57 -0000	1.10
@@ -8,12 +8,22 @@
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:	pango-devel automake autoconf libtool doxygen
 Patch0:		paps-makefile.patch
+## http://sourceforge.net/mailarchive/forum.php?thread_id=9329194&forum_id=47278
 Patch2:		paps-0.6.3-formfeed.patch
+## http://sourceforge.net/tracker/index.php?func=detail&aid=1494769&group_id=153049&atid=786242
 Patch3:		paps-0.6.6-encoding.patch
+## fixed in CVS
 Patch4:		paps-typo-font-scale.patch
+## fixed in CVS
 Patch5:		paps-0.6.6-segfault.patch
+## http://sourceforge.net/tracker/index.php?func=detail&aid=1512382&group_id=153049&atid=786242
 Patch6:		paps-0.6.6-font-option.patch
+## http://sourceforge.net/tracker/index.php?func=detail&aid=1512384&group_id=153049&atid=786239
 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
 
 Summary:	Plain Text to PostScript converter
 Group:		Applications/Publishing
@@ -30,6 +40,8 @@
 %patch5 -p1 -b .segfault
 %patch6 -p1 -b .fontopt
 %patch7 -p1 -b .lcctype
+%patch8 -p1 -b .wordwrap
+%patch9 -p1 -b .cpilpi
 aclocal
 automake
 autoconf
@@ -57,6 +69,13 @@
 
 
 %changelog
+* Wed Aug 16 2006 Akira TAGOH <tagoh at redhat.com>
+- paps-0.6.6-wordwrap.patch: applied to do a wordwrap.
+- paps-0.6.6-cpilpi.patch: add --cpi and --lpi option to support the characters
+  per inch and the lines per inch.
+- paps-0.6.6-font-option.patch: fixed to get this working.
+- paps-0.6.6-encoding.patch: null-terminate the output.
+
 * Tue Jun 20 2006 Akira TAGOH <tagoh at redhat.com> - 0.6.6-5
 - paps-typo-font-scale.patch: backported from CVS.
 - paps-0.6.6-font-option.patch: integrated --font-family and --font-scale




More information about the scm-commits mailing list