Re: Macros for writing (German) letters?

2024-01-08 Thread Alexis
Thank you for the quick response, Branden, much appreciated!

> 1.  Meet a need that is shared by others.

  Hopefully Tim, Chris, and I are enough others to meet a need.

> 2.  Implement a solution of reasonable quality.

  Readers of this list shall be the judge of that.

> 3.  Affirm that the work is one's own, or derived from another work that
> is not copyright-encumbered.

  So far that is the case.

> 4.  Offer the contribution to the public under a well understood Free
> Software license.

  That is and was my intention all along.

> 5.  Ask the groff developers to incorporate it, either via a Savannah
> ticket or this mailing list.

  Will do

> If you read through the thread starting at
> https://lists.gnu.org/archive/html/groff/2021-01/msg4.html

That's very helpful!


Thanks,
Alexis



Re: Macros for writing (German) letters?

2024-01-08 Thread G. Branden Robinson
Hi Alexis,

At 2024-01-08T14:00:19+0100, Alexis wrote:
> A question for the groff maintainers:
> What does it take for a new macro package to be considered for
> inclusion in groff (e.g.: contrib), so folks like Tim feel the macro
> package is "integrated into the groff ecosphere?"

I reckon it's something like this.

1.  Meet a need that is shared by others.
2.  Implement a solution of reasonable quality.
3.  Affirm that the work is one's own, or derived from another work that
is not copyright-encumbered.
4.  Offer the contribution to the public under a well understood Free
Software license.
5.  Ask the groff developers to incorporate it, either via a Savannah
ticket or this mailing list.

This is pretty much what we did when Dorai Sitaram contributed
rfc1345.tmac.

If you read through the thread starting at

https://lists.gnu.org/archive/html/groff/2021-01/msg4.html

and click through the "Thread Next" links (ignoring emails where the
Subject line changes), then you'll get a pretty good view of how the
last new "contrib"-ution from someone who didn't already have commit
permission to our Git repository was made and incorporated.

Regards,
Branden


signature.asc
Description: PGP signature


Re: Macros for writing (German) letters?

2024-01-08 Thread Alexis
Here's the din-5008-dimensions.roff I forgot
to attach in my previous mail.


Best Alexis
\# Use the following command to typeset this document:
\# groff -Tpdf -p -dpaper=a4 -P-pa4 din-5008-dimensions.roff > din-5008-dimensions.pdf
.nop \X'ps: exec 2 setlinecap'
.nop \X'ps: exec 0 setlinejoin'
.ft C
.po 1.75c
.sp |\n(.ou
.vs 0
.PS
# Defaults
lineheight   = 4.23 # default line height (12pt) in mm
###
# User configurable variables start here
define form { "A" } # Choose A or B
infoblock_width  = 75 # Set custom width for information block; must be <= 75
infoblock_height = 40 # Set custom height for information block; must be >= 40
footer_height= 2*lineheight # Set custom height of footer
show_dimensions  = 1   # 1: Print measurements; 0: Hide measurements
zoom = 100 # in- or decrease size of picture
   # NOTA BENE: Only a zoom of 100 will be displayed accurately,
   # i.e. other zoom levels may introduce false gaps or overlaps
# User configurable variables end here
###
if form!="A"&&form!="B" then {
  command ".tm Unknown form"
}
# map user variables to internal variables
lh=lineheight
ibw=infoblock_width
ibh=infoblock_height
fth=footer_height
lbls=show_dimensions
ibwd=75 # max width of information block
ibhd=40 # min height of information block
if ibw>ibwd then {
  command sprintf(".tm Using maximum width of %g for information block instead of requested %g", ibwd, ibw)
  ibw=ibwd
}
if ibh left maxpswid outline "orange" \
with .c at Header .b + (0, 5) sprintf("\h'-12'\v'-6p'%g", maxpswid)
}
{ # Draw height measurement
  line <-> up hl outline "orange" \
at Header .sw + (30, 0) aligned sprintf("\v'-6p'%g", hl)
}
{ # Draw top offset measure for information block
  line <-> up hl+5 \
at last box .ne - (10+ibw, hl+5) aligned sprintf("\v'-6p'%g", hl+5)
}
  }
}
define punchmark {
  {
move to Header .nw down maxpsht/2 right 10
{ line left 10 outline "pink2" }
if (lbls==1) then {
  line <-> up 148.5 outline "pink2" \
aligned sprintf("\v'-6p'%g", maxpsht/2)
}
  }
}
define foldmarks {
  hdo=60
  fmd=105
  fmw=5
  {
  if ($1=="top" || $1=="both") then {
move to Header .nw down hdo+hl right fmw
{ line left fmw outline "red" }
if (lbls==1) then {line <-> up hdo+hl outline "red" aligned sprintf("\v'-6p'%g", hdo+hl)}
  }
  if ($1=="bottom" || $1=="both") then {
move to Header .nw down fmd+hdo+hl right fmw
{ line left fmw outline "red" }
if (lbls==1) then {
  move down maxpsht-fmd-(hdo+hl);
  line <-> up maxpsht-fmd-(hdo+hl) outline "red" \
aligned sprintf("\v'-6p'%g", maxpsht-fmd-(hdo+hl))
}
  }
  if ($1=="both" && lbls==1) then {
line <-> up fmd outline "red" aligned sprintf("\v'-6p'%g", fmd)
  }
  }
}
paper
hdr
punchmark
foldmarks("both")
#PF Flyback to position where .PS started
.PF
.vs
.PS
define headerlabel {
  H: box invis wid 210 ht hl "\fRHeader\fP" "\f(TIDIN 5008\fP" "" ""
  if form=="A" then {
box invis at H.c - (0, .5*lh) "\fIForm A\fP"
  } else {
box invis at H.c - (0, .5*lh) "\fIForm B\fP"
  }
}
define addressfield {
  afh=45
  afw=80
  aoo=5
  aow=afw+aoo
  lhadjust=linethick/4
  # Fill
  {box wid afw ht afh color "grey90" with .nw at H .sw + (po, lh-lhadjust);}
  A: box wid aow ht afh with .nw at H .sw + (po-aoo, lh-lhadjust) "\fRAddressfield\fP";
  if (lbls==1) then {
{
  line <-> left aow with .c at A .s + (0, 10) outline "grey70" sprintf("%g", aow) "";
  line <-> up afh with .sw at A .sw + (10, 0) aligned sprintf("%g", afh) ""
}
{ line <-> left afw with .c at A .s + (2.5, 7.5) "" sprintf("%g", afw) }
{
  line <-> left po-aoo sprintf("%g", po-aoo) "" at A .l # distance to left page edge
  line <-> right aoo sprintf("%g", aoo) "" at A .l # inner addressfield padding
}
  }
}
define infoblock {
  ibwm=75
  ibhm=40
  I: box dashed wid ibw ht ibh shaded "grey90" with .ne at H .se + (-10 , lh-5) \
  "\fRInformationblock\fP" sprintf("%g\(mu%g", ibw, ibh) ""
  if (lbls==1) then {
{
  line -> dashed left ibw with .c at I .s + (0, 0) sprintf("\fRvariable <=\fP %g", ibwm) ""
  line <- dashed up ibh with .sw at I .sw + (0, 0) aligned "" sprintf("\fRvariable >=\fP %g", ibhm)
}
{ line <-> right 10 "10" "" at I .r} # distance to right page edge
  }
}
define textblock {
  ibho=0
  if ibh>40 then {
ibho=ibh-40
  }
  tbw=maxpswid-po-po+5
  blanks=4*lh # (2 blank lines between addressfield/information block, 1 blank to page, 1 blank to footer)
  tbh=maxpsht-hl-afh-blanks-fth-lh-10 # 10 = bottom page margin
  if ibh>afh then {
tbh=tbh-ibho
  }
  T: box wid tbw ht tbh dashed shaded "grey90" \
with .nw at A .sw + (5, -(lh*2+ibho)) "\fRContent\fP"
  if (lbls==1) then {
{
  line <-> right tbw sprintf("%g", tbw) "" at T .nw + (0, -10)
  line <-> dashed up tbh \
at T .sw + (0, 0) \
aligned "" "" sprintf("\fRvariable \(ti%.2g lines (%gmm), de

Re: Macros for writing (German) letters?

2024-01-08 Thread Alexis
Hi Tim,

funny you should ask.

I've been working on my own groff macro package to produce documents
that conform to DIN 5008 for quite some time now.
Just a few days ago I started with the implementation of yet another
generation of said macro package that includes the learnings from
previous generations and better understanding of DIN 5008:2020.

The motivation to write a new macro package from scratch rather than
integrate it into an existing one was to focus on and learn the details
of groff(7) while working through implementing the standard¹ and avoid
getting stuck on an issue with an existing macro package due to lack of
my understanding.

Would you and anyone else interested be willing to give feedback
on my macro package or even help with its implementation²?!
Although at this point I feel more comfortable to consider integrating
with an existing package.

A question for the groff maintainers:
What does it take for a new macro package to be considered for inclusion
in groff (e.g.: contrib), so folks like Tim feel the macro package is
"integrated into the groff ecosphere?"

To whet the appetite a bit please find attached a groff/gpic document
(din-5008-dimensions.roff) with which different variants (form a and b,
variable footer height and information block size) can be produced.
Simply change the "user configurable variables" like `form` or 
`informationblock_width`, `footer_height`, etc. and re-create the
document using:

  groff -Tpdf -p -dpaper=a4 -P-pa4 din-5008-dimensions.roff \
> din-5008-dimensions.pdf

I use a PDF version of din-5008-dimensions.roff to superimpose³
documents produced with my macro package onto it and verify that
the layout adheres to the dimensions given in the DIN 5008 standard.

Insight, advice, best-practices from long-term users and macro package
developers and maintainers is especially welcome and much appreciated!


Best
Alexis

¹ using the special print bundle of the DIN 5008
  https://www.beuth.de/de/publikation/paket-din-5008-das-praxispaket/321130650

² Also happy to share my previous generations

³ using pdfcpu (https://pdfcpu.io):
  pdfcpu watermark add -mode pdf -- \
"din-5008-dimensions.pdf" "sc:1 abs, rot:0" \
letter.pdf check.pdf



Macros for writing (German) letters?

2024-01-06 Thread Tim Landscheidt
Hi,

as background: I have been using Apache FOP
(https://xmlgraphics.apache.org/fop/) in the past to print
letters according to the German standard DIN 5008
(https://en.wikipedia.org/wiki/DIN_5008).  Since FOP is a
Java application and the support for Java in Fedora is
dwindling, I want to switch my workflow to groff.

I found Chris Schaller's macros
(https://lists.gnu.org/archive/html/groff/2010-09/msg00038.html)
which work, but feel not very integrated into the groff eco-
sphere.  I'd rather want to set up my new workflow on some
existing "framework" enhanced to accommodate the peculiari-
ties of the German standard.

It appears to me that the (only?) macro packages shipping
with groff which have "proper" support for writing letters
(i. e., macros that have a notion of sender, recipient,
date, etc.) are mom
(http://www.schaffter.ca/mom/momdoc/letters.html) and mm
(https://tkurtbond.github.io/troff/mm-all.pdf, appendix D).

Of the two, mm seems easier to extend as it is not only sig-
nificantly smaller :-), but also already has a structure for
different types of letters (BL, SB, FB, SP).

Am I missing some obvious alternative to produce letters ac-
cording to DIN 5008?

TIA,
Tim