[Top][All Lists]

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

Re: [Groff] chess font?

From: Tadziu Hoffmann
Subject: Re: [Groff] chess font?
Date: Sun, 4 Feb 2007 17:54:12 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

> > be implemented as macros which map onto a similar escape
> > technique as the suppression escapes \O etc.  In any event
> > the obvious advantage to this approach is that one can
> > harness the ability of a scripting language to manipulate
> > raw text rather than fight .tr et al and diversions.
> > It would also mean one could distribute filters hidden
> > inside macro sets.  Potentially with mechanisms such as
> > swig it might be possible for, say Python to import more
> > runtime information from the troff parent.  Which would
> > be fun - and _might_ enable easier experimentation with
> > micro typography to take place, possibly.  Or you could
> > include the knights tour program inside the troff source.
> >
> > Of course this could all be regarded as several steps too
> > far :-)

We also just _might_ write a *roff interpreter in Python and
skip groff altogether.  This would have the added advantage
of having full access to the internals of the formatter at
runtime.  We could do the same for the preprocessors and do
without "pre"-processing at all, allowing those specialized
processors to be fully aware of the environment.

> I like it.  But it's overkill for chess typetting; with a
> font consisting of 25 constant-width piece-on-square images
> you could do .CS/.CE with two trivial macros, .CS being a
> wrapper around a .tr statement.

Ah, but it's not quite as trivial as it initially appears.
You can't just translate "Q" to "white queen" with a simple
"tr" request -- you have consider the position of the "Q" on
the field and distinguish between "white queen" and "white
queen on black".  So you either define two input characters
for each piece (and unnecessarily complicate the nicely
designed mnemonic layout), or you need something a little bit
more complicated.  The best I've been able to come up with so
far is the following, based on a simple "active character"

(Additional niceties such as labeling the sides "A B C ..."
and "1 2 3 ..." is left as an exercise for the reader.)

.\" ----------------------------------------------------------------
.\" font definition file must specify matching codes
.char \[ES] \N'\\n[WB]+256'\R'WB 1-\\n[WB]'\" empty square
.char \[WP] \N'\\n[WB]+258'\R'WB 1-\\n[WB]'\" white pawn
.char \[BP] \N'\\n[WB]+260'\R'WB 1-\\n[WB]'\" black pawn
.char \[WR] \N'\\n[WB]+262'\R'WB 1-\\n[WB]'\" white rook
.char \[BR] \N'\\n[WB]+264'\R'WB 1-\\n[WB]'\" black rook
.char \[WN] \N'\\n[WB]+266'\R'WB 1-\\n[WB]'\" white knight
.char \[BN] \N'\\n[WB]+268'\R'WB 1-\\n[WB]'\" black knight
.char \[WB] \N'\\n[WB]+270'\R'WB 1-\\n[WB]'\" white bishop
.char \[BB] \N'\\n[WB]+272'\R'WB 1-\\n[WB]'\" black bishop
.char \[WQ] \N'\\n[WB]+274'\R'WB 1-\\n[WB]'\" white queen
.char \[BQ] \N'\\n[WB]+276'\R'WB 1-\\n[WB]'\" black queen
.char \[WK] \N'\\n[WB]+278'\R'WB 1-\\n[WB]'\" white king
.char \[BK] \N'\\n[WB]+280'\R'WB 1-\\n[WB]'\" black king
.char \[TE] \N'282'\" top edge
.char \[LE] \N'283'\" left edge
.char \[RE] \N'284'\" right edge
.char \[BE] \N'285'\" bottom edge
.\" ----------------------------------------------------------------
.de Cb
.sp \\n[.v]u-\\n[.s]p
.vs \\n[.s]
.ft Cheq
.tr P\[WP]p\[BP]R\[WR]r\[BR]N\[WN]n\[BN]
.tr B\[WB]b\[BB]Q\[WQ]q\[BQ]K\[WK]k\[BK]
.tr .\[ES]
.nr WB 0 \" white/black alternator
.nr Cn 8 \" line count
.it 1 Cc
.cc :
.\" ----------------------------------------------------------------
.de Cc
.nr WB 1-\\n[WB]
.nr Cn -1
.if \\n[Cn]>0 \{\
.it 1 Cc
.cc : \}
.\" ----------------------------------------------------------------
.de Ce
.tr PPppRRrrNNnnBBbbQQqqKKkk..
.\" ----------------------------------------------------------------
.sp 3c
.ps 36
.vs 38
.po 2.5c
.ll 21c-5c
.in 0

reply via email to

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