[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Groff] ds in tmac

From: Ted Harding
Subject: RE: [Groff] ds in tmac
Date: Fri, 05 Sep 2003 20:56:38 +0100 (BST)

Hi Erich!

On 05-Sep-03 Erich Hoffmann wrote:
> I'm using groff now some time for most of my writing projects and
> with the normal use of it I'm quite at ease.  But I'm a full blown
> newbie to groff hacking, to be honest to any programming at all.
>    To gather some experience I got the idea of a sort of typesetting
> chess diagrams with groff.  I want to use it.  Especially I want to
> typeset fairy chess diagrams, retro games &c.  Googeling said that
> there is no such thing by now.

I'm not sure of all your motives with this exercise! If you simply want
to produce an end-product which consists of [fairy]chess diagrams, then
I'd suggest you try a different way.

However, you also seem to want to make a certain kind of effort, just
as some people want to climb a mountain with ropes and ice-picks when
they could take the chair-lift (or even walk up the tourist path).

I won't comment on the latter -- though when I get a spare moment I'll
try your macros. However, I would hesitate before using 'pic' for this

The ideal way is to prepare a special font with 22 characters:

White Rook, Knight, Bishop, Queen, King each on a black square and on
  a white square (10 chars)

The same for the Black pieces (10 chars)

An empty black square and an empty white square (2 chars).

You could do this with drawing commands (like your Knight example),
but for best results you could make each one an Encapsulated PostScript
file (.eps). Then you can define a set of characters using the ".char"
command, but for variable sixing you need to incorporate a number
register for the desired size of the square (say "\n[SqSize]" in
PS units).

E.g. (for a white Knight on a black square)

.char \[WNBsq] \Z'\X'ps: import WNBsq.eps \
llx lly urx ury \\n[SqSize]u''\&\h'\\n[.ps]u'

(where "llx lly url ury" stands for the BoundingBox coordinates in
the EPS file) so that you can set up the initial position, for instance,


Each \[...] plants a graphic of width \n[SqSize]u with zero net
movement followed by a horizontal move of that width, until the
row is complete whereupon it moves back to the start (zero movement):
the zero movements are the result of the "\Z'...'" sequences;
then there is a downwards movement of \n[SqSize]u and the next row
is drawn, and so on. The "\" at the end of each line is to conceal
the newlines in the source text so that troff treats the whole thing
as one long line with no spaces creeping in (which would be the
usual consequence of the newline).

An even more efficient solution (at any rate for standard Chess) would
be to obtain a proper PostScript font file of Chess pieces on squares
(And I'm sure there must be some freeely available somewhere on the
web, though I can't some up with a reference just now).

Then you can use the character names from this file as primary, though
for convenience you may want to use the .char mechanism to rename them:

.ft PSChessPieces
.char \[WNBsq] \N'45'
where "45" is the position in the font of the glyph whose PostScript
name in the font is "WhiteKnightOnBlackSquare", for instance.

Finally, you don't want to type all that stuff above every time, so
you could write a macro:

.de position

which would take 64 arguments and be used like

.position r n b q k b n r \
p p p p p p p p \
x x x x x x x x \
... \
x x x x x x x x \
P P P P P P P P \

(inspired by a familiar notation) and itself generate the thing that
was typed out in full above. (You could write a more complicate macro
which accepted a symbol, say X, to stand for a blank row).

Apart from all that, do enjoy hacking you way up the ice-fall!

Best wishes,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 05-Sep-03                                       Time: 20:56:38
------------------------------ XFMail ------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]