Re: Ornamented Page Borders

2024-02-02 Thread Deri
On Thursday, 1 February 2024 16:59:36 GMT Emilia Stoyanova wrote:
> Greetings everyone,
> 
> Do any of you have experience with creating ornamented page borders?
> I have looked through the mailing list[^1] and through both mom's and
> utmac's
> documentation but I couldn't find exactly what I have in mind.
> 
> I have attached a pdf document, together with its pic(1) source code,
> to illustrate exactly what I am going for.
> 
> I also tried looking through cstr54 and UTP to maybe figure out how I might
> do
> that myself with pure troff requests, but I gave up after a while, since I'm
> still a bit of a neophyte here . . .
> 
> Also, does anyone perhaps have/host a collection of pic decorations one
> might
> browse and/or add to? I don't even know if using pic for that is standard
> o.o
> 
> Kind Regards,
> Emilia
> ---
> [^1]: https://lists.gnu.org/r/groff/2022-09/msg00088.html

Hi Emilia,

Everyone has probably got a different way of doing this. Tadziu gave you a 
pure pic way of doing the edge ornamentation, but the resulting pdf was over 
100kb, which is why he would program the pattern in postscript. Peter offered 
a method using a suitable repeated glyph from a font, which resulted in a 
9.5kb file. The big reduction is because the actual stroking of the pattern is 
stored in the font so the actual pattern is only stored once but used many 
times.

There is a way of pinching that idea of storing the pattern once and using it 
again and again, but using a single pic instance of your pattern rather than a 
font glyph. There are 3 stages:-

A) First run ornsingle.tr which produces ornsingle.pdf with this command:-

groff -Tpdf -p ornsingle.tr -P-p.35i,.35i >orn.pdf

Notice the custom paper size (.35 inch square) which is big enough to 
encompass one instance of your pattern, which, on its own is 2.9kb.

B) Now run ornpage.tr which generates an A4 page containing many copies of the 
pattern in ornpage.pdf, using groff commands. Use:-

groff -Tpdf -P-pa4 ornpage.tr > ornpage.pdf

Note the 4 lines at the top of the groff script which can affect the pattern 
generated. Now the whole page of patterns is 4.1kb.

C) Is to use ornpage.pdf as a type of watermark to ornament your document. 
There are several pdf utility programs which could do this job after groff has 
produced the document you want to ornament. But there is a way to get groff to 
do this while it is producing your document. The trick is to hook some code 
into whichever macro deals with starting a new page, for whichever macro 
language you use, that includes ornpage.pdf on every page. If you include the 
same pdf multiple times gropdf only stores it once and links to it if you use 
it again. The file ornmom.tr is a very crude example of this. Since it hooks 
into the START macro it is really only useful for single page simple 
documents, something much more sophisticated would be required for multi-page 
documents, possibly hooking in to NEWPAGE as well. You can run the example 
like this:-

groff -Tpdf -mom -k -P-pa4 ornmom.tr /usr/share/doc/groff-1.23.0/examples/mom/
letter.mom > letter.pdf

The document, including the letter, is now 6.3kb.

Cheers 

Deri
.ig
	groff -Tpdf -p ornsingle.tr -P-p.35i,.35i >orn.pdf
..
.po 1p
.vs 1p
.PS 		\" Scale width for close fit

define orn { [
	# Variables
	sideLength = $1/2;
	cupRad = $1/10;
	petalRad = $1/16.6;
	cornerRad = $1/20;
	splineLength = sideLength/5;
	splineTravel = splineLength * 2;
	rodLength = splineTravel;
	danglyFstRad = sideLength / 10;
	danglySndRad = danglyFstRad/2;
	danglyTrdRad = danglySndRad/2;

	Diamond: [
		NE: line down sideLength right sideLength;
		SE: line down sideLength left sideLength;
		SW: line up sideLength left sideLength;
		NW: line up sideLength right sideLength;
	];

	# Flower in the middle (Cup & Petals)
	Cup: circle rad cupRad at Diamond;
	circle rad petalRad with .s at Cup.n;
	circle rad petalRad with .sw at Cup.ne;
	circle rad petalRad with .w at Cup.e;
	circle rad petalRad with .nw at Cup.se;
	circle rad petalRad with .n at Cup.s;
	circle rad petalRad with .ne at Cup.sw;
	circle rad petalRad with .e at Cup.w;
	circle rad petalRad with .se at Cup.nw;

	# Corner Circles
	N: circle rad cornerRad at Diamond.NE.start;
	E: circle rad cornerRad at Diamond.SE.start;
	W: circle rad cornerRad at Diamond.SW.start;
	S: circle rad cornerRad at Diamond.NW.start;

	# Side splines
	move to N down splineTravel left splineTravel;
	spline left splineLength then down splineLength;
	move to N down splineTravel right splineTravel;
	spline right splineLength then down splineLength;
	move to W up splineTravel right splineTravel;
	spline right splineLength then up splineLength;
	move to W up splineTravel left splineTravel;
	spline left splineLength then up splineLength;

	# Side dangly bits
	Lnw: line up rodLength left rodLength at Diamond.NW.center;
	arc rad danglyFstRad from Lnw.end; 

Re: Ornamented Page Borders

2024-02-01 Thread Peter Schaffter
On Thu, Feb 01, 2024, Emilia Stoyanova wrote:
> Do any of you have experience with creating ornamented page
> borders?
> 
> I have attached a pdf document, together with its pic(1) source
> code, to illustrate exactly what I am going for.

This got me thinking: How would I tackle ornamental page borders in
mom using a speciality font instead of pic(1) or groff's drawing
escapes?  This is what I came up with, using a glyph from the
WmDesigns font.  It's proof of concept only.  The basic idea is that
once you create a border with the desired size/leading/margins, it
can be wrapped in a macro, inserted manually on the first page,
and added to the top of the HEADER macro for subsequent pages
in multi-page documents.

This probably isn't what Emilia is looking for, but it may prove
useful to mom users.  pdf output attached.

---Begin---
.PAPER LETTER
.
.\" Choose glyph from border font
.ds glyph \f[WmDesigns]l\f[]
.ds width "\h'\w'\f[WmDesigns]l\f[]'u'
.
.\" Adjust size and leading of border glyph
.PT_SIZE 17.5
.LS 27.75
.LEFT
.
.\" Adjust margins to compenseate for glyph width and height
.\" Produces a border whose inner sides are 1 inch from page edges
.L_MARGIN .75i
.R_MARGIN .75i
.T_MARGIN   1i
.B_MARGIN  .5i
.
.\" Use PAD to mark off string tabs that space glyphs evenly over line length
.nr tab 0 1
.PAD \
"\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]#\
\*[ST\n+[tab]]\*[width]\*[ST\n[tab]X]" \
NOBREAK
.
.\" Create string tabs
.nr loop 18
.nr loop_count 0 1
.while \n+[loop_count]<=\n[loop] \{\
. ST \n[loop_count] L
.\}
.
.\" Top
.mk
.TB 1 \" Call first tab explictly
.nop \*[glyph]
.nr loop_count 1 1
.
.while \n+[loop_count]<=\n[loop] \{\
. TN \" Call remaining tabs with "tab next" to keep on same baseline
. nop \*[glyph]
.\}
.TQ
.
.\" Left
.while (\n[.t]-\n[.v])>\n[.v] \{\
. nop \*[glyph]
.\}
.
.\" Right
.rt
.sp
.RIGHT
.while (\n[.t]-\n[.v])>\n[.v] \{\
. nop \*[glyph]
.\}
.
.\" Bottom (same as top)
.LEFT
.TB 1
.nop \*[glyph]
.nr loop_count 0 1
.while \n+[loop_count]<=\n[loop] \{\
. TN
.nop \*[glyph]
.\}
---End---

-- 
Peter Schaffter
https://www.schaffter.ca


border-test.pdf
Description: Adobe PDF document


Ornamented Page Borders

2024-02-01 Thread Emilia Stoyanova
Greetings everyone,

Do any of you have experience with creating ornamented page borders?
I have looked through the mailing list[^1] and through both mom's and
utmac's
documentation but I couldn't find exactly what I have in mind.

I have attached a pdf document, together with its pic(1) source code,
to illustrate exactly what I am going for.

I also tried looking through cstr54 and UTP to maybe figure out how I might
do
that myself with pure troff requests, but I gave up after a while, since I'm
still a bit of a neophyte here . . .

Also, does anyone perhaps have/host a collection of pic decorations one
might
browse and/or add to? I don't even know if using pic for that is standard
o.o

Kind Regards,
Emilia
---
[^1]: https://lists.gnu.org/r/groff/2022-09/msg00088.html


orn.pdf
Description: Adobe PDF document
.PS

define orn { [
	# Variables
	sideLength = $1/2;
	cupRad = $1/10;
	petalRad = $1/16.6;
	cornerRad = $1/20;
	splineLength = sideLength/5;
	splineTravel = splineLength * 2;
	rodLength = splineTravel;
	danglyFstRad = sideLength / 10;
	danglySndRad = danglyFstRad/2;
	danglyTrdRad = danglySndRad/2;

	Diamond: [
		NE: line down sideLength right sideLength;
		SE: line down sideLength left sideLength;
		SW: line up sideLength left sideLength;
		NW: line up sideLength right sideLength;
	];

	# Flower in the middle (Cup & Petals)
	Cup: circle rad cupRad at Diamond;
	circle rad petalRad with .s at Cup.n;
	circle rad petalRad with .sw at Cup.ne;
	circle rad petalRad with .w at Cup.e;
	circle rad petalRad with .nw at Cup.se;
	circle rad petalRad with .n at Cup.s;
	circle rad petalRad with .ne at Cup.sw;
	circle rad petalRad with .e at Cup.w;
	circle rad petalRad with .se at Cup.nw;

	# Corner Circles
	N: circle rad cornerRad at Diamond.NE.start;
	E: circle rad cornerRad at Diamond.SE.start;
	W: circle rad cornerRad at Diamond.SW.start;
	S: circle rad cornerRad at Diamond.NW.start;

	# Side splines
	move to N down splineTravel left splineTravel;
	spline left splineLength then down splineLength;
	move to N down splineTravel right splineTravel;
	spline right splineLength then down splineLength;
	move to W up splineTravel right splineTravel;
	spline right splineLength then up splineLength;
	move to W up splineTravel left splineTravel;
	spline left splineLength then up splineLength;

	# Side dangly bits
	Lnw: line up rodLength left rodLength at Diamond.NW.center;
	arc rad danglyFstRad from Lnw.end; arc rad danglySndRad; arc rad danglyTrdRad;
	arc cw rad danglyFstRad from Lnw.end; arc cw rad danglySndRad; arc cw rad danglyTrdRad;
	Lsw: line down rodLength left rodLength at Diamond.SW.center;
	arc cw rad danglyFstRad; arc cw rad danglySndRad; arc cw rad danglyTrdRad;
	arc rad danglyFstRad from Lsw.end; arc rad danglySndRad; arc rad danglyTrdRad;
	Lne: line up rodLength right rodLength at Diamond.NE.center;
	arc cw rad danglyFstRad; arc cw rad danglySndRad; arc cw rad danglyTrdRad;
	arc rad danglyFstRad from Lne.end; arc rad danglySndRad; arc rad danglyTrdRad;
	Lse: line down rodLength right rodLength at Diamond.SE.center;
	arc rad danglyFstRad; arc rad danglySndRad; arc rad danglyTrdRad;
	arc cw rad danglyFstRad from Lse.end; arc cw rad danglySndRad; arc cw rad danglyTrdRad;
] }

size = 0.3
for i = 0 to 21 by 1 do { orn(size); move to last [] down size; }
for i = 0 to 12 by 1 do { orn(size); move to last [] right size; }
for i = 0 to 21 by 1 do { orn(size); move to last [] up size; }
for i = 0 to 12 by 1 do { orn(size); move to last [] left size; }

.PE