!2 Package init

Merge pull request !2 from gnaygnil/master
This commit is contained in:
openeuler-ci-bot 2020-02-18 10:01:05 +08:00 committed by Gitee
commit a30565644d
22 changed files with 1476 additions and 75 deletions

View File

@ -1,36 +0,0 @@
# paps
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,39 +0,0 @@
# paps
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -0,0 +1,82 @@
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 2007-03-27 20:25:00.000000000 +0900
+++ paps-0.6.6/src/libpaps.c 2007-03-27 20:31:15.000000000 +0900
@@ -28,6 +28,7 @@
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <errno.h>
+#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -263,7 +264,7 @@
);
/* Outline support */
- g_string_append_printf(paps->header,
+ paps_string_append_printf(paps->header,
"/conicto {\n"
" /to_y exch def\n"
" /to_x exch def\n"
@@ -691,3 +692,28 @@
return points * 1.0 / 72 * PAPS_DPI * PANGO_SCALE;
}
+void
+paps_string_append_printf(GString *string,
+ const gchar *fmt,
+ ...)
+{
+ gchar *buffer, *lc_numeric;
+ gint length;
+ va_list args;
+
+ va_start(args, fmt);
+
+ lc_numeric = g_strdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
+
+ length = g_vasprintf(&buffer, fmt, args);
+ g_string_append_len(string, buffer, length);
+
+ setlocale(LC_NUMERIC, lc_numeric);
+
+ g_free(buffer);
+ g_free(lc_numeric);
+
+ va_end(args);
+}
+
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 2007-03-27 20:25:00.000000000 +0900
+++ paps-0.6.6/src/libpaps.h 2007-03-27 20:31:02.000000000 +0900
@@ -124,4 +124,8 @@
*/
double paps_postscript_points_to_pango(double points);
+void paps_string_append_printf(GString *string,
+ const gchar *fmt,
+ ...) G_GNUC_PRINTF (2, 3);
+
#endif /* LIBPAPS */
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 2007-03-27 20:25:00.000000000 +0900
+++ paps-0.6.6/src/paps.c 2007-03-27 20:31:33.000000000 +0900
@@ -992,7 +992,7 @@
y_top = page_layout->page_height - page_layout->top_margin - page_layout->header_height - page_layout->header_sep / 2;
y_bot = page_layout->bottom_margin - page_layout->footer_height;
- g_string_append_printf(ps_pages_string,
+ paps_string_append_printf(ps_pages_string,
"%f %f moveto %f %f lineto 0 setlinewidth stroke\n",
x_pos, y_top,
x_pos, y_bot);
@@ -1154,7 +1154,7 @@
/* header separator */
line_pos = page_layout->page_height - page_layout->top_margin - page_layout->header_height - page_layout->header_sep / 2;
- g_string_append_printf(ps_pages_string,
+ paps_string_append_printf(ps_pages_string,
"%d %f moveto %d %f lineto 0 setlinewidth stroke\n",
page_layout->left_margin, line_pos,
page_layout->page_width - page_layout->right_margin, line_pos);

35
paps-0.6.8-shared.patch Normal file
View File

@ -0,0 +1,35 @@
diff -ruN paps-0.6.8.orig/src/Makefile.am paps-0.6.8/src/Makefile.am
--- paps-0.6.8.orig/src/Makefile.am 2006-04-17 16:42:08.000000000 +0900
+++ paps-0.6.8/src/Makefile.am 2007-11-16 11:50:07.000000000 +0900
@@ -1,15 +1,15 @@
man_MANS = paps.1
-lib_LIBRARIES = libpaps.a
-libpaps_a_SOURCES = libpaps.c
-libpaps_a_inc_HEADERS = libpaps.h
-libpaps_a_incdir = $(includedir)
+lib_LTLIBRARIES = libpaps.la
+libpaps_la_SOURCES = libpaps.c
+libpapsinc_HEADERS = libpaps.h
+libpapsincdir = $(includedir)
bin_PROGRAMS = paps
paps_CFLAGS = -Wall
paps_SOURCES = paps.c
-paps_LDADD = $(lib_LIBRARIES) $(all_libraries)
+paps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
paps_LDFLAGS = `pkg-config --libs pangoft2`
-paps_DEPENDENCIES = $(lib_LIBRARIES)
+paps_DEPENDENCIES = $(lib_LTLIBRARIES)
EXTRA_DIST = test_libpaps.c paps.1
@@ -21,7 +21,7 @@
test_libpaps_SOURCES = test_libpaps.c
-test_libpaps_LDADD = $(lib_LIBRARIES) $(all_libraries)
+test_libpaps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
test_libpaps_LDFLAGS = `pkg-config --libs pangoft2`
-test_libpaps_DEPENDENCIES = $(lib_LIBRARIES)
+test_libpaps_DEPENDENCIES = $(lib_LTLIBRARIES)

35
paps-0.6.8-wordwrap.patch Normal file
View File

@ -0,0 +1,35 @@
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8.orig/src/paps.c 2007-04-13 14:04:14.000000000 +0900
+++ paps-0.6.8/src/paps.c 2007-11-16 12:28:11.000000000 +0900
@@ -723,9 +723,12 @@ split_text_into_paragraphs (PangoContext
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);
+ if (page_layout->do_wordwrap) {
+ pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
+ pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
+ } else {
+ pango_layout_set_width (para->layout, -1);
+ }
para->height = 0;
result = g_list_prepend (result, para);
@@ -754,9 +757,13 @@ split_text_into_paragraphs (PangoContext
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);
+ if (page_layout->do_wordwrap) {
+ pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
+ pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
+ } else {
+ pango_layout_set_width (para->layout, -1);
+ }
- pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
para->height = 0;
last_para = next;

BIN
paps-0.6.8.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
diff -uprN paps-0.6.8_raw/src/libpaps.c paps-0.6.8/src/libpaps.c
--- paps-0.6.8_raw/src/libpaps.c 2020-01-15 10:17:00.573044177 +0000
+++ paps-0.6.8/src/libpaps.c 2020-01-15 10:20:44.416993428 +0000
@@ -25,8 +25,9 @@
#include <pango/pango.h>
#include <pango/pangoft2.h>
-#include <freetype/ftglyph.h>
-#include <freetype/ftoutln.h>
+#include <ft2build.h>
+#include FT_GLYPH_H
+#include FT_OUTLINE_H
#include <errno.h>
#include <locale.h>
#include <stdlib.h>

View File

@ -0,0 +1,12 @@
diff -uprN paps-0.6.8_raw/src/Makefile.am paps-0.6.8/src/Makefile.am
--- paps-0.6.8_raw/src/Makefile.am 2020-01-15 10:19:03.195207683 +0000
+++ paps-0.6.8/src/Makefile.am 2020-01-15 10:23:03.639449322 +0000
@@ -15,7 +15,7 @@ EXTRA_DIST = test_libpaps.c paps.1
# set the include path found by configure
INCLUDES= $(all_includes) `pkg-config --cflags pangoft2`
-LIBS = `pkg-config --libs pangoft2`
+LIBS = `pkg-config --libs pangoft2 gobject-2.0 glib-2.0`
# Test program
noinst_PROGRAMS = test_libpaps

View File

@ -0,0 +1,41 @@
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 10:16:26.292439298 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:21:23.197677551 +0000
@@ -46,7 +46,8 @@
typedef enum {
PAPER_TYPE_A4 = 0,
PAPER_TYPE_US_LETTER = 1,
- PAPER_TYPE_US_LEGAL = 2
+ PAPER_TYPE_US_LEGAL = 2,
+ PAPER_TYPE_A3 = 3
} paper_type_t ;
typedef struct {
@@ -57,7 +58,8 @@ typedef struct {
const paper_size_t paper_sizes[] = {
{ 595.28, 841.89}, /* A4 */
{ 612, 792}, /* US letter */
- { 612, 1008} /* US legal */
+ { 612, 1008}, /* US legal */
+ { 842, 1190} /* A3 */
};
typedef struct {
@@ -191,6 +193,8 @@ _paps_arg_paper_cb(const char *option_na
paper_type = PAPER_TYPE_US_LETTER;
else if (g_ascii_strcasecmp(value, "a4") == 0)
paper_type = PAPER_TYPE_A4;
+ else if (g_ascii_strcasecmp(value, "a3") == 0)
+ paper_type = PAPER_TYPE_A3;
else {
retval = FALSE;
fprintf(stderr, "Unknown page size name: %s.\n", value);
@@ -301,7 +305,7 @@ int main(int argc, char *argv[])
{"rtl", 0, 0, G_OPTION_ARG_NONE, &do_rtl, "Do rtl layout.", NULL},
{"paper", 0, 0, G_OPTION_ARG_CALLBACK, _paps_arg_paper_cb,
"Choose paper size. Known paper sizes are legal,\n"
- " letter, a4. (Default: a4)", "PAPER"},
+ " letter, a3, a4. (Default: a4)", "PAPER"},
{"bottom-margin", 0, 0, G_OPTION_ARG_INT, &bottom_margin, "Set bottom margin in postscript point units (1/72inch). (Default: 36)", "NUM"},
{"top-margin", 0, 0, G_OPTION_ARG_INT, &top_margin, "Set top margin. (Default: 36)", "NUM"},
{"right-margin", 0, 0, G_OPTION_ARG_INT, &right_margin, "Set right margin. (Default: 36)", "NUM"},

View File

@ -0,0 +1,325 @@
diff -uprN paps-0.6.8_raw/configure.in paps-0.6.8/configure.in
--- paps-0.6.8_raw/configure.in 2007-01-19 11:06:10.000000000 +0000
+++ paps-0.6.8/configure.in 2020-01-15 10:10:47.996480112 +0000
@@ -7,6 +7,19 @@ AC_LANG_C
AC_PROG_CC
AM_PROG_LIBTOOL
+dnl ======================================================
+dnl check for CUPS
+dnl ======================================================
+AC_PATH_PROG(CUPS_CONFIG, cups-config, no)
+if test "$CUPS_CONFIG" = "no"; then
+ AC_MSG_ERROR([Please install cups development packages/files])
+fi
+CUPS_CFLAGS=`$CUPS_CONFIG --cflags | sed -e 's/-O[0-9]*//' -e 's/-m[^\t]*//g'`
+CUPS_LIBS=`$CUPS_CONFIG --libs`
+
+AC_SUBST(CUPS_CFLAGS)
+AC_SUBST(CUPS_LIBS)
+
DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
diff -uprN paps-0.6.8_raw/src/Makefile.am paps-0.6.8/src/Makefile.am
--- paps-0.6.8_raw/src/Makefile.am 2020-01-15 09:58:56.673959902 +0000
+++ paps-0.6.8/src/Makefile.am 2020-01-15 10:10:47.996480112 +0000
@@ -5,10 +5,10 @@ libpapsinc_HEADERS = libpaps.h
libpapsincdir = $(includedir)
bin_PROGRAMS = paps
-paps_CFLAGS = -Wall
+paps_CFLAGS = -Wall $(CUPS_CFLAGS)
paps_SOURCES = paps.c
paps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
-paps_LDFLAGS = `pkg-config --libs pangoft2`
+paps_LDFLAGS = `pkg-config --libs pangoft2` $(CUPS_LIBS)
paps_DEPENDENCIES = $(lib_LTLIBRARIES)
EXTRA_DIST = test_libpaps.c paps.1
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 09:58:56.673959902 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:10:47.996480112 +0000
@@ -31,6 +31,8 @@
#include <string.h>
#include <time.h>
#include <locale.h>
+#include <cups/cups.h>
+#include <cups/ppd.h>
#define BUFSIZE 1024
#define DEFAULT_FONT_FAMILY "Monospace"
@@ -86,9 +88,11 @@ typedef struct {
gboolean do_wordwrap;
gboolean do_use_markup;
gboolean do_stretch_chars;
+ gboolean cups_mode;
PangoDirection pango_dir;
gchar *filename;
gchar *header_font_desc;
+ gchar *owner;
gint lpi;
gint cpi;
} page_layout_t;
@@ -320,8 +324,8 @@ int main(int argc, char *argv[])
int num_pages = 1;
int gutter_width = 40;
int total_gutter_width;
- int page_width = paper_sizes[0].width;
- int page_height = paper_sizes[0].height;
+ int page_width = -1;
+ int page_height = -1;
int do_tumble = -1; /* -1 means not initialized */
int do_duplex = -1;
gchar *paps_header = NULL;
@@ -331,6 +335,8 @@ int main(int argc, char *argv[])
int max_width = 0, w;
GIConv cvh = NULL;
GOptionGroup *options;
+ gboolean cups_mode = FALSE;
+ gchar *page_owner = NULL;
/* Set locale from environment. */
setlocale(LC_ALL, "");
@@ -348,6 +354,130 @@ int main(int argc, char *argv[])
g_option_context_add_main_entries(ctxt, entries, NULL);
#endif
+ /* check if the process is being invoked as CUPS filter */
+ G_STMT_START {
+ gchar *prgname = g_path_get_basename(argv[0]);
+ cups_option_t *options = NULL;
+ ppd_file_t *ppd;
+ ppd_size_t *pagesize;
+ int num_options;
+ const char *val;
+
+ if (strncmp(prgname, "texttopaps", 10) == 0 ||
+ getenv("CUPS_SERVER") != NULL) {
+ g_set_prgname(prgname);
+ /* argument format should be job-id user title copies options [file] */
+ cups_mode = TRUE;
+ /* set default values */
+ page_layout.lpi = 6.0L;
+ page_layout.cpi = 10.0L;
+ left_margin = 18;
+ right_margin = 18;
+ top_margin = 36;
+ bottom_margin = 36;
+ page_width = 612;
+ page_height = 792;
+ font = g_strdup(MAKE_FONT_NAME ("Courier", DEFAULT_FONT_SIZE));
+ header_font_desc = g_strdup(MAKE_FONT_NAME ("Courier", HEADER_FONT_SCALE));
+
+ if (argc < 6 || argc > 7) {
+ fprintf(stderr, "ERROR: %s job-id user title copies options [file]\n", prgname);
+ exit(1);
+ }
+ if (argc == 6) {
+ filename_in = "stdin";
+ IN = stdin;
+ } else {
+ filename_in = argv[6];
+ if ((IN = fopen(filename_in, "rb")) == NULL) {
+ fprintf(stderr, "ERROR: unable to open print file -\n");
+ exit(1);
+ }
+ }
+ title = argv[3];
+ page_owner = argv[2];
+ num_options = cupsParseOptions(argv[5], 0, &options);
+
+ if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
+ g_ascii_strcasecmp(val, "no") &&
+ g_ascii_strcasecmp(val, "off") &&
+ g_ascii_strcasecmp(val, "false")) {
+ /* XXX: need to support the keywords highlighting */
+ }
+ ppd = ppdOpenFile(getenv("PPD"));
+ ppdMarkDefaults(ppd);
+ cupsMarkOptions(ppd, num_options, options);
+
+ if ((pagesize = ppdPageSize(ppd, NULL)) != NULL) {
+ page_width = pagesize->width;
+ page_height = pagesize->length;
+ top_margin = pagesize->length - pagesize->top;
+ bottom_margin = pagesize->bottom;
+ left_margin = pagesize->left;
+ right_margin = pagesize->width - pagesize->right;
+ }
+
+ if ((val = cupsGetOption("landscape", num_options, options)) != NULL) {
+ if (g_ascii_strcasecmp(val, "no") &&
+ g_ascii_strcasecmp(val, "off") &&
+ g_ascii_strcasecmp(val, "false"))
+ do_landscape = TRUE;
+ }
+ /* XXX: need to support orientation-requested? */
+ if ((val = cupsGetOption("page-left", num_options, options)) != NULL) {
+ left_margin = (int)atof(val);
+ }
+ if ((val = cupsGetOption("page-right", num_options, options)) != NULL) {
+ right_margin = (int)atof(val);
+ }
+ if ((val = cupsGetOption("page-bottom", num_options, options)) != NULL) {
+ bottom_margin = (int)atof(val);
+ }
+ if ((val = cupsGetOption("page-top", num_options, options)) != NULL) {
+ top_margin = (int)atof(val);
+ }
+ if (ppdIsMarked(ppd, "Duplex", "DuplexNoTumble") ||
+ ppdIsMarked(ppd, "Duplex", "DuplexTumble") ||
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexNoTumble") ||
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexTumble") ||
+ ppdIsMarked(ppd, "EFDuplex", "DuplexNoTumble") ||
+ ppdIsMarked(ppd, "EFDuplex", "DuplexTumble") ||
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexNoTumble") ||
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexTumble")) {
+ do_duplex = TRUE;
+ }
+ if ((val = cupsGetOption("wrap", num_options, options)) != NULL) {
+ do_wordwrap = !g_ascii_strcasecmp(val, "true") ||
+ !g_ascii_strcasecmp(val, "on") ||
+ !g_ascii_strcasecmp(val, "yes");
+ }
+ if ((val = cupsGetOption("columns", num_options, options)) != NULL) {
+ num_columns = atoi(val);
+ }
+ if ((val = cupsGetOption("cpi", num_options, options)) != NULL) {
+ page_layout.cpi = atof(val);
+ }
+ if ((val = cupsGetOption("lpi", num_options, options)) != NULL) {
+ page_layout.lpi = atof(val);
+ }
+ if (getenv("CHARSET") != NULL) {
+ char *charset = getenv("CHARSET");
+ /* Map CUPS charset names to real ones.
+ * http://cups.org/newsgroups.php?s9797+gcups.general+v9797+T1
+ */
+ if (!g_ascii_strcasecmp(charset, "windows-932")) {
+ charset = "WINDOWS-31J";
+ }
+ if (g_ascii_strcasecmp(charset, "utf-8") &&
+ g_ascii_strcasecmp(charset, "utf8")) {
+ encoding = g_strdup(charset);
+ }
+ }
+ }
+ } G_STMT_END;
+
+ if (!cups_mode) {
+
/* Parse command line */
if (!g_option_context_parse(ctxt, &argc, &argv, &error))
{
@@ -374,6 +504,8 @@ int main(int argc, char *argv[])
IN = stdin;
}
title = filename_in;
+
+ } /* if (!cups_mode) */
paps = paps_new();
pango_context = paps_get_pango_context (paps);
@@ -392,8 +524,10 @@ int main(int argc, char *argv[])
pango_context_set_font_description (pango_context, font_description);
/* Page layout */
- page_width = paper_sizes[(int)paper_type].width;
- page_height = paper_sizes[(int)paper_type].height;
+ if (page_width < 0)
+ page_width = paper_sizes[(int)paper_type].width;
+ if (page_height < 0)
+ page_height = paper_sizes[(int)paper_type].height;
if (num_columns == 1)
total_gutter_width = 0;
@@ -456,6 +590,8 @@ int main(int argc, char *argv[])
page_layout.pango_dir = pango_dir;
page_layout.filename = filename_in;
page_layout.header_font_desc = header_font_desc;
+ page_layout.owner = page_owner;
+ page_layout.cups_mode = cups_mode;
/* calculate x-coordinate scale */
if (page_layout.cpi > 0.0L)
@@ -756,6 +892,12 @@ split_text_into_paragraphs (PangoContext
if (wc == (gunichar)-1)
{
fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ());
+ if (page_layout->cups_mode)
+ {
+ /* try to continue parsing texts */
+ p = next;
+ continue;
+ }
wc = 0;
}
if (!*p || !wc || wc == '\n' || wc == '\f')
@@ -925,21 +1067,32 @@ void print_postscript_header(FILE *OUT,
int orientation = page_layout->page_width > page_layout->page_height;
int bb_page_width = page_layout->page_width;
int bb_page_height = page_layout->page_height;
+ char *owner = NULL;
/* Keep bounding box non-rotated to make ggv happy */
- if (orientation)
+ /* ensure the correct bounding box for CUPS */
+ if (orientation && !page_layout->cups_mode)
{
int tmp = bb_page_width;
bb_page_width = bb_page_height;
bb_page_height = tmp;
}
+ if (page_layout->owner)
+ {
+ owner = g_strdup_printf("%%%%For: %s\n", page_layout->owner);
+ }
+ else
+ {
+ owner = g_strdup("");
+ }
fprintf(OUT,
"%%!PS-Adobe-3.0\n"
+ "%s"
"%%%%Title: %s\n"
"%%%%Creator: paps version 0.6.7 by Dov Grobgeld\n"
"%%%%Pages: (atend)\n"
- "%%%%BoundingBox: 0 0 %d %d\n"
+ "%%%%BoundingBox: 0 0 %d %d\n%s"
"%%%%BeginProlog\n"
"%%%%Orientation: %s\n"
"/papsdict 1 dict def\n"
@@ -961,7 +1114,7 @@ void print_postscript_header(FILE *OUT,
" pagewidth\n"
" /pagewidth pageheight def\n"
" /pageheight exch def\n"
- " /orientation 3 def\n"
+ " /orientation %d def\n"
" } if\n"
" 2 dict\n"
" dup /PageSize [pagewidth pageheight] put\n"
@@ -986,11 +1139,21 @@ void print_postscript_header(FILE *OUT,
" 90 rotate\n"
" 0 pageheight neg translate\n"
"} def\n",
+ /*
+ * Put %%cupsRotation tag to prevent the rotation in pstops.
+ * This breaks paps's behavior to make it in landscape say.
+ * (RH#222137)
+ */
+ (page_layout->cups_mode ? "%cupsRotation: 0\n" : ""),
title,
bb_page_width,
bb_page_height,
- orientation_names[orientation]
+ owner,
+ orientation_names[orientation],
+ /* For landscape, rotate page to portrait orientation for CUPS (RH#222137) */
+ page_layout->cups_mode ? 2 : 3
);
+ g_free(owner);
fprintf(OUT,
"%% User settings\n"

View File

@ -0,0 +1,80 @@
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 10:10:47.996480112 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:11:50.427578844 +0000
@@ -93,8 +93,8 @@ typedef struct {
gchar *filename;
gchar *header_font_desc;
gchar *owner;
- gint lpi;
- gint cpi;
+ gdouble lpi;
+ gdouble cpi;
} page_layout_t;
typedef struct {
@@ -379,6 +379,7 @@ int main(int argc, char *argv[])
page_height = 792;
font = g_strdup(MAKE_FONT_NAME ("Courier", DEFAULT_FONT_SIZE));
header_font_desc = g_strdup(MAKE_FONT_NAME ("Courier", HEADER_FONT_SCALE));
+ do_stretch_chars = TRUE;
if (argc < 6 || argc > 7) {
fprintf(stderr, "ERROR: %s job-id user title copies options [file]\n", prgname);
@@ -596,7 +597,8 @@ int main(int argc, char *argv[])
/* calculate x-coordinate scale */
if (page_layout.cpi > 0.0L)
{
- double scale;
+ gint font_size;
+
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);
@@ -608,13 +610,10 @@ int main(int argc, char *argv[])
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;
-
+ font_size = pango_font_description_get_size (font_description);
// update the font size to that width
- pango_font_description_set_size (font_description, (int)(atoi(DEFAULT_FONT_SIZE) * PANGO_SCALE * scale));
+ pango_font_description_set_size (font_description, font_size * page_layout.scale_x);
pango_context_set_font_description (pango_context, font_description);
-
}
page_layout.scale_x = page_layout.scale_y = 1.0;
@@ -1002,6 +1001,7 @@ output_pages(FILE *OUT,
int column_y_pos = 0;
int page_idx = 1;
int pango_column_height = page_layout->column_height * page_layout->pt_to_pixel * PANGO_SCALE;
+ int height = 0;
LineLink *prev_line_link = NULL;
start_page(OUT, page_idx);
@@ -1039,17 +1039,17 @@ output_pages(FILE *OUT,
);
}
}
+ if (page_layout->lpi > 0.0L)
+ height = (int)(1.0 / page_layout->lpi * 72.0 * page_layout->pt_to_pixel * PANGO_SCALE);
+ else
+ height = line_link->logical_rect.height;
draw_line_to_page(OUT,
column_idx,
- column_y_pos+line_link->logical_rect.height,
+ column_y_pos+height,
page_layout,
line);
- 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 += height;
pango_lines = pango_lines->next;
prev_line_link = line_link;
}

66
paps-exitcode.patch Normal file
View File

@ -0,0 +1,66 @@
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8.orig/src/paps.c 2008-09-01 15:54:11.000000000 +0900
+++ paps-0.6.8/src/paps.c 2008-09-01 15:54:47.000000000 +0900
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
if (!IN)
{
fprintf(stderr, "Failed to open %s!\n", filename_in);
- exit(-1);
+ exit(1);
}
}
else
@@ -499,7 +499,7 @@ int main(int argc, char *argv[])
if (cvh == NULL)
{
fprintf(stderr, "%s: Invalid encoding: %s\n", g_get_prgname (), encoding);
- exit(-1);
+ exit(1);
}
}
@@ -559,7 +559,7 @@ read_file (FILE *file,
{
fprintf(stderr, "%s: Error reading file.\n", g_get_prgname ());
g_string_free (inbuf, TRUE);
- return NULL;
+ exit(1);
}
else if (bp == NULL)
break;
@@ -573,7 +573,7 @@ read_file (FILE *file,
if (g_iconv (handle, &ib, &iblen, &ob, &oblen) == -1)
{
fprintf (stderr, "%s: Error while converting strings.\n", g_get_prgname ());
- return NULL;
+ exit(1);
}
obuffer[BUFSIZE * 6 - 1 - oblen] = 0;
}
@@ -637,7 +637,7 @@ split_text_into_paragraphs (PangoContext
if (wtext == NULL)
{
fprintf (stderr, "Failed to convert UTF-8 to UCS-4.\n");
- return NULL;
+ exit(1);
}
len = g_utf8_strlen (para->text, para->length);
@@ -650,7 +650,7 @@ split_text_into_paragraphs (PangoContext
{
fprintf (stderr, "Failed to allocate a memory.\n");
g_free (wtext);
- return NULL;
+ exit(1);
}
for (i = 0; i < len; i++)
{
@@ -665,7 +665,7 @@ split_text_into_paragraphs (PangoContext
if (newtext == NULL)
{
fprintf (stderr, "Failed to convert UCS-4 to UTF-8.\n");
- return NULL;
+ exit(1);
}
pango_layout_set_text (para->layout, newtext, -1);

View File

@ -0,0 +1,24 @@
diff -uprN paps-0.6.8_raw/acinclude.m4 paps-0.6.8/acinclude.m4
--- paps-0.6.8_raw/acinclude.m4 2006-11-28 20:11:50.000000000 +0000
+++ paps-0.6.8/acinclude.m4 2020-01-15 10:13:29.619324489 +0000
@@ -76,9 +76,9 @@ AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEA
# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
AC_DEFUN([DX_REQUIRE_PROG], [
AC_PATH_TOOL([$1], [$2])
-if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
+if test "$DX_FLAG_DX_CURRENT_FEATURE$$1" = 1; then
AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
- AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+ AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0)
fi
])
@@ -101,7 +101,7 @@ test "$DX_FLAG_$1" = "$2" \
# ----------------------------------------------------------
# Turn off the DX_CURRENT_FEATURE if the required feature is off.
AC_DEFUN([DX_CLEAR_DEPEND], [
-test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0)
])
# DX_FEATURE_ARG(FEATURE, DESCRIPTION,

View File

@ -0,0 +1,339 @@
diff -uprN paps-0.6.8_raw/src/libpaps.c paps-0.6.8/src/libpaps.c
--- paps-0.6.8_raw/src/libpaps.c 2020-01-15 10:12:40.598461793 +0000
+++ paps-0.6.8/src/libpaps.c 2020-01-15 10:15:32.951498063 +0000
@@ -55,6 +55,9 @@ typedef struct {
double last_pos_x;
double scale_x;
double scale_y;
+ double width;
+ double height;
+ double cpi;
} paps_private_t;
@@ -88,6 +91,26 @@ paps_t *paps_new()
}
void
+paps_set_paper_size(paps_t *paps_,
+ gdouble width,
+ gdouble height)
+{
+ paps_private_t *paps = (paps_private_t *)paps_;
+
+ paps->width = width;
+ paps->height = height;
+}
+
+void
+paps_set_cpi(paps_t *paps_,
+ gdouble cpi)
+{
+ paps_private_t *paps = (paps_private_t *)paps_;
+
+ paps->cpi = cpi;
+}
+
+void
paps_set_scale(paps_t *paps_,
gdouble scale_x,
gdouble scale_y)
@@ -401,7 +424,7 @@ static void draw_contour(paps_private_t
FT_Face ft_face = pango_ft2_font_get_face(font);
int num_glyphs = glyphs->num_glyphs;
int glyph_idx;
-
+
for (glyph_idx=0; glyph_idx<num_glyphs; glyph_idx++)
{
PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry;
@@ -410,7 +433,11 @@ static void draw_contour(paps_private_t
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 * paps->scale_x;
+ if (paps->cpi > 0.0L) {
+ x_pos += (1 / paps->cpi * 72.0);
+ } else {
+ x_pos += geometry.width * scale * paps->scale_x;
+ }
if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
continue;
diff -uprN paps-0.6.8_raw/src/libpaps.h paps-0.6.8/src/libpaps.h
--- paps-0.6.8_raw/src/libpaps.h 2020-01-15 09:58:56.673959902 +0000
+++ paps-0.6.8/src/libpaps.h 2020-01-15 10:15:32.951498063 +0000
@@ -53,10 +53,16 @@ void paps_free(paps_t *paps);
* @param scale_y y-coordinate scale
*
*/
-void
-paps_set_scale(paps_t *paps,
- gdouble scale_x,
- gdouble scale_y);
+void paps_set_scale(paps_t *paps,
+ gdouble scale_x,
+ gdouble scale_y);
+
+void paps_set_paper_size(paps_t *paps_,
+ gdouble width,
+ gdouble height);
+
+void paps_set_cpi(paps_t *paps_,
+ gdouble cpi);
/**
* libpaps may currently be used only with a PangoContext that it
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 10:12:40.598461793 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:15:32.951498063 +0000
@@ -33,6 +33,8 @@
#include <locale.h>
#include <cups/cups.h>
#include <cups/ppd.h>
+#include <math.h>
+#include <wchar.h>
#define BUFSIZE 1024
#define DEFAULT_FONT_FAMILY "Monospace"
@@ -594,6 +596,8 @@ int main(int argc, char *argv[])
page_layout.owner = page_owner;
page_layout.cups_mode = cups_mode;
+ paps_set_paper_size(paps, page_width, page_height);
+
/* calculate x-coordinate scale */
if (page_layout.cpi > 0.0L)
{
@@ -606,7 +610,7 @@ 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 / page_layout.cpi * 72.0 * PANGO_SCALE / max_width;
+ page_layout.scale_x = 1 / page_layout.cpi * 72.0 * (gdouble)PANGO_SCALE / (gdouble)max_width;
pango_font_metrics_unref (metrics);
g_object_unref (G_OBJECT (fontmap));
@@ -614,6 +618,8 @@ int main(int argc, char *argv[])
// update the font size to that width
pango_font_description_set_size (font_description, font_size * page_layout.scale_x);
pango_context_set_font_description (pango_context, font_description);
+
+ paps_set_cpi(paps, page_layout.cpi);
}
page_layout.scale_x = page_layout.scale_y = 1.0;
@@ -727,119 +733,6 @@ read_file (FILE *file,
return text;
}
-#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,
- 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;
-
- 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);
-
- 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 = 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");
- exit(1);
- }
-
- 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)
- {
- wnewtext = g_new (wchar_t, wcslen (wtext) + 1);
- if (wnewtext == NULL)
- {
- fprintf (stderr, "Failed to allocate a memory.\n");
- g_free (wtext);
- exit(1);
- }
- 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");
- exit(1);
- }
-
- 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,
- 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')
- para->formfeed = 1;
- else
- para->formfeed = 0;
-
- last_para = next;
-
- result = g_list_prepend (result, para);
- }
- if (!wc) /* incomplete character at end */
- break;
- p = next;
- }
-
- return g_list_reverse (result);
-}
-#endif
-
/* Take a UTF8 string and break it into paragraphs on \n characters
*/
static GList *
@@ -905,18 +798,85 @@ split_text_into_paragraphs (PangoContext
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);
+
+ if (page_layout->cpi > 0.0L && page_layout->do_wordwrap) {
+ /* figuring out the correct width from the pango_font_metrics_get_approximate_width()
+ * is really hard and pango_layout_set_wrap() doesn't work properly then.
+ * Those are not reliable to render the characters exactly according to the given CPI.
+ * So Re-calculate the width to wrap up to be comfortable with CPI.
+ */
+ wchar_t *wtext = NULL, *wnewtext = NULL;
+ gchar *newtext = NULL;
+ gsize len, col, i, wwidth = 0;
+ PangoRectangle ink_rect, logical_rect;
+
+ wtext = (wchar_t *)g_utf8_to_ucs4(para->text, para->length, NULL, NULL, NULL);
+ if (wtext == NULL) {
+ fprintf(stderr, "%s: Unable to convert UTF-8 to UCS-4.\n", g_get_prgname());
+ fail:
+ g_free(wtext);
+ g_free(wnewtext);
+ g_free(newtext);
+ if (page_layout->cups_mode) {
+ /* try to continue parsing text */
+ p = next;
+ continue;
+ } else {
+ exit(1);
+ }
+ }
+ len = g_utf8_strlen(para->text, para->length);
+ /* the amount of characters that can be put on the line against CPI */
+ col = page_layout->column_width / 72.0 * page_layout->cpi;
+ if (len > col) {
+ /* need to wrap up them */
+ wnewtext = g_new(wchar_t, wcslen(wtext) + 1);
+ if (wnewtext == NULL) {
+ fprintf(stderr, "%s: Unable to allocate the memory.\n", g_get_prgname());
+ goto fail;
+ }
+ for (i = 0; i < len; i++) {
+ wwidth += wcwidth(wtext[i]);
+ if (wwidth > col)
+ 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, "%s: Unable to convert UCS-4 to UTF-8.\n", g_get_prgname());
+ goto fail;
+ }
+ pango_layout_set_text(para->layout, newtext, -1);
+ pango_layout_get_extents(para->layout, &ink_rect, &logical_rect);
+ paint_width = logical_rect.width / PANGO_SCALE;
+ g_free(wnewtext);
+ g_free(newtext);
+
+ para->length = i;
+ next = g_utf8_offset_to_pointer(para->text, para->length);
+ wc = g_utf8_prev_char(next);
+ } else {
+ pango_layout_set_text(para->layout, para->text, para->length);
+ }
+ g_free(wtext);
+
+ pango_layout_set_width(para->layout, -1);
+ } else {
+ pango_layout_set_text (para->layout, para->text, para->length);
+ if (page_layout->do_wordwrap) {
+ pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
+ pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
+ } else {
+ pango_layout_set_width (para->layout, -1);
+ }
+ }
+
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);
- if (page_layout->do_wordwrap) {
- pango_layout_set_wrap (para->layout, PANGO_WRAP_WORD_CHAR);
- pango_layout_set_width (para->layout, paint_width * PANGO_SCALE);
- } else {
- pango_layout_set_width (para->layout, -1);
- }
para->height = 0;

View File

@ -0,0 +1,94 @@
diff -uprN paps-0.6.8_raw/src/libpaps.c paps-0.6.8/src/libpaps.c
--- paps-0.6.8_raw/src/libpaps.c 2020-01-15 09:58:56.673959902 +0000
+++ paps-0.6.8/src/libpaps.c 2020-01-15 10:12:40.598461793 +0000
@@ -118,7 +118,6 @@ gchar *paps_get_postscript_header_strdup
gchar *ret_str;
g_string_append_printf(paps->header,
"end end\n"
- "%%%%EndPrologue\n"
);
ret_str = g_strdup(paps->header->str);
g_string_truncate(paps->header, old_len);
@@ -247,7 +246,6 @@ static void
add_postscript_prologue(paps_private_t *paps)
{
g_string_append_printf(paps->header,
- "%%%%BeginProlog\n"
"/papsdict 1 dict def\n"
"papsdict begin\n"
"\n"
@@ -272,10 +270,10 @@ add_postscript_prologue(paps_private_t *
"/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"
- "/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"
+ "/draw_char { fontdict begin gsave %f dup scale last_x cvi last_y cvi translate load exec end grestore} def\n"
+ "/goto_xy { fontdict begin /last_y exch string_y cvs def /last_x exch string_x cvs def end } def\n"
+ "/goto_x { fontdict begin /last_x exch string_x cvs def end } def\n"
+ "/fwd_x { fontdict begin /last_x exch last_x cvi add string_x cvs def end } def\n"
"/c /curveto load def\n"
"/x /conicto load def\n"
"/l /lineto load def\n"
@@ -344,7 +342,7 @@ add_postscript_prologue(paps_private_t *
/* Open up dictionaries */
g_string_append(paps->header,
- "/fontdict 1 dict def\n"
+ "/fontdict 1 dict dup begin 16 string dup /string_x exch def /last_x exch def 16 string dup /string_y exch def /last_y exch def end def\n"
"papsdict begin fontdict begin\n");
}
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 10:11:50.427578844 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:12:40.598461793 +0000
@@ -662,7 +662,7 @@ int main(int argc, char *argv[])
fprintf(OUT, "%s", paps_header);
g_free(paps_header);
- fprintf(OUT, "%%%%EndPrologue\n");
+ fprintf(OUT, "%%%%EndSetup\n");
fprintf(OUT, "%s", ps_pages_string->str);
print_postscript_trailer(OUT, num_pages);
@@ -1093,8 +1093,9 @@ void print_postscript_header(FILE *OUT,
"%%%%Creator: paps version 0.6.7 by Dov Grobgeld\n"
"%%%%Pages: (atend)\n"
"%%%%BoundingBox: 0 0 %d %d\n%s"
- "%%%%BeginProlog\n"
"%%%%Orientation: %s\n"
+ "%%%%EndComments\n"
+ "%%%%BeginProlog\n"
"/papsdict 1 dict def\n"
"papsdict begin\n"
"\n"
@@ -1138,7 +1139,8 @@ void print_postscript_header(FILE *OUT,
"/turnpage {\n"
" 90 rotate\n"
" 0 pageheight neg translate\n"
- "} def\n",
+ "} def\n"
+ "%%%%EndProlog\n",
/*
* Put %%cupsRotation tag to prevent the rotation in pstops.
* This breaks paps's behavior to make it in landscape say.
@@ -1156,6 +1158,7 @@ void print_postscript_header(FILE *OUT,
g_free(owner);
fprintf(OUT,
+ "%%%%BeginSetup\n"
"%% User settings\n"
"/pagewidth %d def\n"
"/pageheight %d def\n"
@@ -1238,8 +1241,8 @@ void print_postscript_trailer(FILE *OUT,
int num_pages)
{
fprintf(OUT,
- "%%%%Pages: %d\n"
"%%%%Trailer\n"
+ "%%%%Pages: %d\n"
"%%%%EOF\n",
num_pages
);

View File

@ -0,0 +1,15 @@
diff -uprN paps-0.6.8_raw/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8_raw/src/paps.c 2020-01-15 10:15:32.951498063 +0000
+++ paps-0.6.8/src/paps.c 2020-01-15 10:16:26.292439298 +0000
@@ -836,7 +836,10 @@ split_text_into_paragraphs (PangoContext
goto fail;
}
for (i = 0; i < len; i++) {
- wwidth += wcwidth(wtext[i]);
+ gssize w = wcwidth(wtext[i]);
+
+ if (w >= 0)
+ wwidth += w;
if (wwidth > col)
break;
wnewtext[i] = wtext[i];

View File

@ -0,0 +1,13 @@
diff -uprN paps-0.6.8_raw/src/paps.1 paps-0.6.8/src/paps.1
--- paps-0.6.8_raw/src/paps.1 2007-01-19 11:05:27.000000000 +0000
+++ paps-0.6.8/src/paps.1 2020-01-15 10:09:44.105355663 +0000
@@ -64,6 +64,9 @@ Draw page header for each page.
.B \-\-markup
Interpret the text as pango markup.
.TP
+.B \-\-encoding=ENCODING
+Assume the documentation encoding is ENCODING.
+.TP
.B \-\-lpi
Set the lines per inch. This determines the line spacing.
.TP

View File

@ -0,0 +1,26 @@
diff -uprN paps-0.6.8_raw/src/Makefile.am paps-0.6.8/src/Makefile.am
--- paps-0.6.8_raw/src/Makefile.am 2020-01-15 10:10:47.996480112 +0000
+++ paps-0.6.8/src/Makefile.am 2020-01-15 10:19:03.195207683 +0000
@@ -8,13 +8,14 @@ bin_PROGRAMS = paps
paps_CFLAGS = -Wall $(CUPS_CFLAGS)
paps_SOURCES = paps.c
paps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
-paps_LDFLAGS = `pkg-config --libs pangoft2` $(CUPS_LIBS)
+paps_LDFLAGS = $(CUPS_LIBS)
paps_DEPENDENCIES = $(lib_LTLIBRARIES)
EXTRA_DIST = test_libpaps.c paps.1
# set the include path found by configure
INCLUDES= $(all_includes) `pkg-config --cflags pangoft2`
+LIBS = `pkg-config --libs pangoft2`
# Test program
noinst_PROGRAMS = test_libpaps
@@ -22,6 +23,5 @@ noinst_PROGRAMS = test_libpaps
test_libpaps_SOURCES = test_libpaps.c
test_libpaps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
-test_libpaps_LDFLAGS = `pkg-config --libs pangoft2`
test_libpaps_DEPENDENCIES = $(lib_LTLIBRARIES)

View File

@ -0,0 +1,73 @@
diff -uprN paps-0.6.8_raw/src/libpaps.c paps-0.6.8/src/libpaps.c
--- paps-0.6.8_raw/src/libpaps.c 2020-01-15 10:15:32.951498063 +0000
+++ paps-0.6.8/src/libpaps.c 2020-01-15 10:17:00.573044177 +0000
@@ -251,7 +251,6 @@ gchar *paps_layout_line_to_postscript_st
{
paps_private_t *paps = (paps_private_t*)paps_;
GString *layout_str = g_string_new("");
- gchar *ret_str;
add_line_to_postscript(paps,
layout_str,
@@ -259,10 +258,7 @@ gchar *paps_layout_line_to_postscript_st
pos_y,
layout_line);
- ret_str = layout_str->str;
- g_string_free(layout_str, FALSE);
-
- return ret_str;
+ return g_string_free(layout_str, FALSE);
}
static void
@@ -408,9 +404,26 @@ static void draw_contour(paps_private_t
{
GSList *runs_list;
double scale = 72.0 / PANGO_SCALE / PAPS_DPI;
+ PangoGlyphUnit avg_width = 1;
g_string_append(layout_str, "(");
-
+
+ if (paps->cpi > 0.0L)
+ {
+ /* calculate approximate width per a character */
+ for (runs_list = pango_line->runs; runs_list != NULL; runs_list = g_slist_next(runs_list))
+ {
+ PangoLayoutRun *run = runs_list->data;
+ PangoGlyphString *glyphs = run->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ {
+ if (glyphs->glyphs[i].glyph != PANGO_GLYPH_EMPTY)
+ avg_width = MAX (avg_width, glyphs->glyphs[i].geometry.width);
+ }
+ }
+ }
/* Loop over the runs and output font info */
runs_list = pango_line->runs;
double x_pos = line_start_pos_x;
@@ -433,11 +446,16 @@ static void draw_contour(paps_private_t
glyph_pos_x = x_pos + 1.0*geometry.x_offset * scale;
glyph_pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale;
- if (paps->cpi > 0.0L) {
- x_pos += (1 / paps->cpi * 72.0);
- } else {
- x_pos += geometry.width * scale * paps->scale_x;
- }
+ if (paps->cpi > 0.0L)
+ {
+ double n = ((double)geometry.width) / avg_width;
+
+ x_pos += n * (1 / paps->cpi * 72.0);
+ }
+ else
+ {
+ x_pos += geometry.width * scale * paps->scale_x;
+ }
if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
continue;

37
paps-langinfo.patch Normal file
View File

@ -0,0 +1,37 @@
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
--- paps-0.6.8.orig/src/paps.c 2008-09-01 15:07:03.000000000 +0900
+++ paps-0.6.8/src/paps.c 2008-09-01 15:49:10.000000000 +0900
@@ -25,6 +25,7 @@
#include <pango/pangoft2.h>
#include "libpaps.h"
#include <errno.h>
+#include <langinfo.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -331,6 +332,9 @@ int main(int argc, char *argv[])
GIConv cvh = NULL;
GOptionGroup *options;
+ /* Set locale from environment. */
+ setlocale(LC_ALL, "");
+
/* Prerequisite when using glib. */
g_type_init();
@@ -480,6 +484,15 @@ int main(int argc, char *argv[])
page_layout.scale_x = page_layout.scale_y = 1.0;
+ if (encoding == NULL)
+ {
+ encoding = g_strdup(nl_langinfo(CODESET));
+ if (!strcmp(encoding, "UTF-8"))
+ {
+ g_free(encoding);
+ encoding = NULL;
+ }
+ }
if (encoding != NULL)
{
cvh = g_iconv_open ("UTF-8", encoding);

View File

@ -0,0 +1,77 @@
diff -uprN paps-0.6.8_raw/COPYING.LIB paps-0.6.8/COPYING.LIB
--- paps-0.6.8_raw/COPYING.LIB 2005-12-20 19:35:27.000000000 +0000
+++ paps-0.6.8/COPYING.LIB 2020-01-15 10:19:46.225966847 +0000
@@ -1,16 +1,15 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -100,7 +99,7 @@ works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
- GNU LIBRARY GENERAL PUBLIC LICENSE
+ GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
@@ -412,7 +411,7 @@ decision will be guided by the two goals
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@@ -435,8 +434,9 @@ FAILURE OF THE LIBRARY TO OPERATE WITH A
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
- END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Libraries
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
@@ -453,18 +453,18 @@ convey the exclusion of warranty; and ea
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
+ modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ Library General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
+ You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.

87
paps.spec Normal file
View File

@ -0,0 +1,87 @@
Name: paps
Version: 0.6.8
Release: 45
License: LGPLv2+
Summary: Plain Text to PostScript converter
URL: http://paps.sourceforge.net/
Source0: http://downloads.sourceforge.net/paps/paps-%{version}.tar.gz
BuildRequires: pango-devel automake autoconf libtool doxygen cups-devel
Requires: cups-filesystem fontpackages-filesystem
Provides: paps-libs = %{version}-%{release}
Obsoletes: paps-libs
Patch0000: paps-0.6.8-shared.patch
Patch0001: paps-0.6.8-wordwrap.patch
Patch0002: paps-langinfo.patch
Patch0003: paps-0.6.6-lcnumeric.patch
Patch0004: paps-exitcode.patch
Patch9001: paps-fix_manpage_inconsistency_issues.patch
Patch9002: paps-applied_to_work_paps_as_cups_filter.patch
Patch9003: paps-cpi_scale_calculation.patch
Patch9004: paps-fix_dsc_compliant_issues.patch
Patch9005: paps-fix_autoconf_error.patch
Patch9006: paps-fix_cpi_setting_not_used_issues.patch
Patch9007: paps-fix_infinite_loop_in_split_text.patch
Patch9008: paps-fix_tab_print_issues.patch
Patch9009: paps-fix_non_weak_symbol_issues.patch
Patch9010: paps-use_correct_fsf_address.patch
Patch9011: paps-add_ft_header_file.patch
Patch9012: paps-add_support_for_a3_paper.patch
Patch9013: paps-add_gobject_glib_lib_for_build.patch
%description
paps is a PostScript converter from plain text file using Pango.
%package devel
Summary: Development files for paps
Requires: paps = %{version}-%{release}
%description devel
paps is a PostScript converter from plain text file using Pango.
This package contains the development files that is necessary to develop
applications using paps API.
%package help
Summary: Documentation for paps
%description help
Documentation for paps
%prep
%autosetup -n paps-%{version} -p1
libtoolize -f -c
autoreconf -f -i
%build
%configure --disable-static
%{make_build}
%install
%{make_install}
%delete_la
install -d $RPM_BUILD_ROOT%{_cups_serverbin}/filter
ln -s %{_bindir}/paps %{buildroot}%{_cups_serverbin}/filter/texttopaps
install -d $RPM_BUILD_ROOT%{_datadir}/cups/mime
install -d $RPM_BUILD_ROOT%{_sysconfdir}/fonts/conf.d
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%doc AUTHORS COPYING.LIB README TODO
%{_bindir}/paps
%{_libdir}/libpaps.so.*
%{_cups_serverbin}/filter/texttopaps
%files devel
%doc COPYING.LIB
%{_includedir}/libpaps.h
%{_libdir}/libpaps.so
%files help
%{_mandir}/man1/paps.1*
%changelog
* Tue Feb 18 2020 Ling Yang <lingyang2@huawei.com> - 0.6.8-45
- Package init