source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Add in -Opaper=xxx support for -Tps postscript.
@ 2010-06-29 14:53 kristaps
  2010-06-29 16:34 ` Joerg Sonnenberger
  0 siblings, 1 reply; 3+ messages in thread
From: kristaps @ 2010-06-29 14:53 UTC (permalink / raw)
  To: source

Log Message:
-----------
Add in -Opaper=xxx support for -Tps postscript.  This doesn't have any
functional changes beyond the getsubopt() parse in term_ps.c.  If you
want to test this (it only does -Opaper=a4 and -Opaper=letter; adding
more is trivial), make sure you specify (e.g.) -sPAPERSIZE=a4 to gs(1).

Modified Files:
--------------
    mdocml:
        main.c
        main.h
        term_ps.c

Revision Data
-------------
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.16 -r1.17
--- term_ps.c
+++ term_ps.c
@@ -22,6 +22,7 @@
 
 #include <assert.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -373,14 +374,17 @@ static	void		  ps_setfont(struct termp *
 
 
 void *
-ps_alloc(void)
+ps_alloc(char *outopts)
 {
 	struct termp	*p;
 	size_t		 pagex, pagey, margin;
+	const char	*toks[2];
+	char		*v;
 
 	if (NULL == (p = term_alloc(TERMENC_ASCII)))
 		return(NULL);
 
+	/* Default is USA letter. */
 	pagex = 612;
 	pagey = 792;
 	margin = 72;
@@ -392,6 +396,24 @@ ps_alloc(void)
 	p->advance = ps_advance;
 	p->endline = ps_endline;
 	p->width = ps_width;
+
+	toks[0] = "paper";
+	toks[1] = NULL;
+
+	while (outopts && *outopts)
+		switch (getsubopt(&outopts, UNCONST(toks), &v)) {
+		case (0):
+			if (0 == strcasecmp(v, "a4")) {
+				pagex = 595;
+				pagey = 842;
+			} else if (0 == strcasecmp(v, "letter")) {
+				pagex = 612;
+				pagey = 792;
+			}
+			break;
+		default:
+			break;
+		}
 
 	assert(margin * 2 < pagex);
 	assert(margin * 2 < pagey);
Index: main.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lmain.h -Lmain.h -u -p -r1.7 -r1.8
--- main.h
+++ main.h
@@ -44,7 +44,7 @@ void		  tree_man(void *, const struct ma
 void		 *ascii_alloc(char *);
 void		  ascii_free(void *);
 
-void		 *ps_alloc(void);
+void		 *ps_alloc(char *);
 void		  ps_free(void *);
 
 void		  terminal_mdoc(void *, const struct mdoc *);
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -Lmain.c -Lmain.c -u -p -r1.92 -r1.93
--- main.c
+++ main.c
@@ -599,7 +599,7 @@ fdesc(struct curparse *curp)
 			curp->outfree = ascii_free;
 			break;
 		case (OUTT_PS):
-			curp->outdata = ps_alloc();
+			curp->outdata = ps_alloc(curp->outopts);
 			curp->outfree = ps_free;
 			break;
 		default:
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mdocml: Add in -Opaper=xxx support for -Tps postscript.
  2010-06-29 14:53 mdocml: Add in -Opaper=xxx support for -Tps postscript kristaps
@ 2010-06-29 16:34 ` Joerg Sonnenberger
  2010-06-29 19:12   ` Kristaps Dzonsons
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Sonnenberger @ 2010-06-29 16:34 UTC (permalink / raw)
  To: source

I would suggest reordering the option parsing slightly:
Just set the keep a variable with the default paper size as string.
After parsing all options, set the paper size accordingly (single point
of reference value). Maybe additionally accept input of the format
100x100 to get a paper size of 100mm times 100mm. Default margins might
be useful to derive from the paper size as well.

Joerg

On Tue, Jun 29, 2010 at 10:53:14AM -0400, kristaps@mdocml.bsd.lv wrote:
> Log Message:
> -----------
> Add in -Opaper=xxx support for -Tps postscript.  This doesn't have any
> functional changes beyond the getsubopt() parse in term_ps.c.  If you
> want to test this (it only does -Opaper=a4 and -Opaper=letter; adding
> more is trivial), make sure you specify (e.g.) -sPAPERSIZE=a4 to gs(1).
> 
> Modified Files:
> --------------
>     mdocml:
>         main.c
>         main.h
>         term_ps.c
> 
> Revision Data
> -------------
> Index: term_ps.c
> ===================================================================
> RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
> retrieving revision 1.16
> retrieving revision 1.17
> diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.16 -r1.17
> --- term_ps.c
> +++ term_ps.c
> @@ -22,6 +22,7 @@
>  
>  #include <assert.h>
>  #include <stdarg.h>
> +#include <stdint.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> @@ -373,14 +374,17 @@ static	void		  ps_setfont(struct termp *
>  
>  
>  void *
> -ps_alloc(void)
> +ps_alloc(char *outopts)
>  {
>  	struct termp	*p;
>  	size_t		 pagex, pagey, margin;
> +	const char	*toks[2];
> +	char		*v;
>  
>  	if (NULL == (p = term_alloc(TERMENC_ASCII)))
>  		return(NULL);
>  
> +	/* Default is USA letter. */
>  	pagex = 612;
>  	pagey = 792;
>  	margin = 72;
> @@ -392,6 +396,24 @@ ps_alloc(void)
>  	p->advance = ps_advance;
>  	p->endline = ps_endline;
>  	p->width = ps_width;
> +
> +	toks[0] = "paper";
> +	toks[1] = NULL;
> +
> +	while (outopts && *outopts)
> +		switch (getsubopt(&outopts, UNCONST(toks), &v)) {
> +		case (0):
> +			if (0 == strcasecmp(v, "a4")) {
> +				pagex = 595;
> +				pagey = 842;
> +			} else if (0 == strcasecmp(v, "letter")) {
> +				pagex = 612;
> +				pagey = 792;
> +			}
> +			break;
> +		default:
> +			break;
> +		}
>  
>  	assert(margin * 2 < pagex);
>  	assert(margin * 2 < pagey);
> Index: main.h
> ===================================================================
> RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.h,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -Lmain.h -Lmain.h -u -p -r1.7 -r1.8
> --- main.h
> +++ main.h
> @@ -44,7 +44,7 @@ void		  tree_man(void *, const struct ma
>  void		 *ascii_alloc(char *);
>  void		  ascii_free(void *);
>  
> -void		 *ps_alloc(void);
> +void		 *ps_alloc(char *);
>  void		  ps_free(void *);
>  
>  void		  terminal_mdoc(void *, const struct mdoc *);
> Index: main.c
> ===================================================================
> RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
> retrieving revision 1.92
> retrieving revision 1.93
> diff -Lmain.c -Lmain.c -u -p -r1.92 -r1.93
> --- main.c
> +++ main.c
> @@ -599,7 +599,7 @@ fdesc(struct curparse *curp)
>  			curp->outfree = ascii_free;
>  			break;
>  		case (OUTT_PS):
> -			curp->outdata = ps_alloc();
> +			curp->outdata = ps_alloc(curp->outopts);
>  			curp->outfree = ps_free;
>  			break;
>  		default:
> --
>  To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mdocml: Add in -Opaper=xxx support for -Tps postscript.
  2010-06-29 16:34 ` Joerg Sonnenberger
@ 2010-06-29 19:12   ` Kristaps Dzonsons
  0 siblings, 0 replies; 3+ messages in thread
From: Kristaps Dzonsons @ 2010-06-29 19:12 UTC (permalink / raw)
  To: source, tech, dillo@danbala.tuwien.ac.at

> I would suggest reordering the option parsing slightly:
> Just set the keep a variable with the default paper size as string.
> After parsing all options, set the paper size accordingly (single point
> of reference value). Maybe additionally accept input of the format
> 100x100 to get a paper size of 100mm times 100mm. Default margins might
> be useful to derive from the paper size as well.

Joerg, good point on dumping it into a string and the NNxNN option. 
Will do.  I'll also look into the margin parts -- I don't know enough 
typography to say whether this is "good" or not.

Dieter, do you know of any typography experts I can consult for these 
sorts of questions?  I'd like to have somebody on call for "expert" 
level questions.

(Dieter, because I'm not sure whether you see the commits, -Tps now 
supports an -Opaper=xxxx option, accepting "a4" and "letter" as 
arguments, and I'm forward-looking into more advance typography.)

Thanks,

Kristaps
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-29 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-29 14:53 mdocml: Add in -Opaper=xxx support for -Tps postscript kristaps
2010-06-29 16:34 ` Joerg Sonnenberger
2010-06-29 19:12   ` Kristaps Dzonsons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).