summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortagoh <tagoh>2006-09-07 06:02:11 +0000
committertagoh <tagoh>2006-09-07 06:02:11 +0000
commita867050847161ba8cb07d520b2b38908541cbb8f (patch)
tree6c13a828d5ffe3168a84c4071082239a001a60c3
parentd191a2fd80a9750a90cb453cfbdb3c4d07e47fd0 (diff)
downloadpaps-a867050847161ba8cb07d520b2b38908541cbb8f.tar.gz
paps-a867050847161ba8cb07d520b2b38908541cbb8f.tar.xz
paps-a867050847161ba8cb07d520b2b38908541cbb8f.zip
2006-09-07 Akira TAGOH <at@gclab.org>
* src/paps.c: added the missing header file. (main): added --font option instead of --font-scale and --family, which works like specifying PangoFontDescription. * src/paps.1: removed --font-scale and --family description and added --font instead.
-rw-r--r--ChangeLog7
-rw-r--r--src/paps.17
-rw-r--r--src/paps.c33
3 files changed, 26 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index cb41462..91c8810 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-09-07 Akira TAGOH <at@gclab.org>
+ * src/paps.c: added the missing header file.
+ (main): added --font option instead of --font-scale and --family, which
+ works like specifying PangoFontDescription.
+
+ * src/paps.1: removed --font-scale and --family description and added
+ --font instead.
+
* src/paps.c (split_text_into_paragraphs)
(split_paragraphs_into_lines, output_pages): formfeed support that is
originally written by Jan Willem Stumpel
diff --git a/src/paps.1 b/src/paps.1
index 15b491b..fb2d0f6 100644
--- a/src/paps.1
+++ b/src/paps.1
@@ -34,11 +34,8 @@ Landscape output. Default is portrait.
.B \-\-columns=cl
Number of columns output. Default is 1.
.TP
-.B \-\-font\-scale=fs
-Font scaling. Default is 12.
-.TP
-.B \-\-family=f
-Pango ft2 font family. Default is Monospace.
+.B \-\-font=desc
+Set the font description. Default is Monospace 12.
.TP
.B \-\-rtl
Do rtl layout.
diff --git a/src/paps.c b/src/paps.c
index cf87b15..582bf96 100644
--- a/src/paps.c
+++ b/src/paps.c
@@ -27,9 +27,14 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#define BUFSIZE 1024
-#define HEADER_FONT_SCALE 12
+#define DEFAULT_FONT_FAMILY "Monospace"
+#define DEFAULT_FONT_SIZE "12"
+#define HEADER_FONT_FAMILY "Monospace Bold"
+#define HEADER_FONT_SCALE "12"
+#define MAKE_FONT_NAME(f,s) f " " s
typedef enum {
PAPER_TYPE_A4 = 0,
@@ -186,15 +191,14 @@ _paps_arg_paper_cb(const char *option_name,
int main(int argc, char *argv[])
{
gboolean do_landscape = FALSE, do_rtl = FALSE, do_justify = FALSE, do_draw_header = FALSE;
- int num_columns = 1, font_scale = 12;
+ int num_columns = 1;
int top_margin = 36, bottom_margin = 36, right_margin = 36, left_margin = 36;
- char *font_family = "Monospace", *encoding = NULL;
+ gchar *font = MAKE_FONT_NAME (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE), *encoding = NULL;
GOptionContext *ctxt = g_option_context_new("[text file]");
GOptionEntry entries[] = {
{"landscape", 0, 0, G_OPTION_ARG_NONE, &do_landscape, "Landscape output. (Default: portrait)", NULL},
{"columns", 0, 0, G_OPTION_ARG_INT, &num_columns, "Number of columns output. (Default: 1)", "NUM"},
- {"font-scale", 0, 0, G_OPTION_ARG_INT, &font_scale, "Font scaling. (Default: 12)", "NUM"},
- {"family", 0, 0, G_OPTION_ARG_STRING, &font_family, "Pango FT2 font family. (Default: Monospace)", "FAMILY"},
+ {"font", 0, 0, G_OPTION_ARG_STRING, &font, "Set the font description. (Default: Monospace 12)", "DESC"},
{"rtl", 0, 0, G_OPTION_ARG_NONE, &do_rtl, "Do rtl layout.", NULL},
{"justify", 0, 0, G_OPTION_ARG_NONE, &do_justify, "Do justify the lines.", NULL},
{"paper", 0, 0, G_OPTION_ARG_CALLBACK, _paps_arg_paper_cb,
@@ -209,11 +213,8 @@ int main(int argc, char *argv[])
{NULL}
};
GError *error = NULL;
- char *filename_in;
- char *title;
FILE *IN, *OUT = NULL;
page_layout_t page_layout;
- char *text;
GList *paragraphs;
GList *pango_lines;
PangoContext *pango_context;
@@ -227,7 +228,8 @@ int main(int argc, char *argv[])
int do_tumble = -1; /* -1 means not initialized */
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_SCALE);
+ gchar *filename_in, *title, *text;
int header_sep = 20;
GIConv cvh = NULL;
@@ -270,13 +272,12 @@ int main(int argc, char *argv[])
pango_context_set_language (pango_context, pango_language_from_string ("en_US"));
pango_context_set_base_dir (pango_context, pango_dir);
- font_description = pango_font_description_new ();
- pango_font_description_set_family (font_description, g_strdup(font_family));
- pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL);
- pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL);
- pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL);
- pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL);
- pango_font_description_set_size (font_description, font_scale * PANGO_SCALE);
+ /* create the font description */
+ font_description = pango_font_description_from_string (font);
+ 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, atoi(DEFAULT_FONT_SIZE) * PANGO_SCALE);
pango_context_set_font_description (pango_context, font_description);