> > [...] insert a letter from figlet as a drop cap > > at the beginning of a given paragraph? > > > > I assume it could look something like : > > > > 1. cut first letter from paragraph > > 2. *somehow* invoke figlet to draw desired drop cap > > 3. read drop cap's (w)idth & (h)eight > > 4. set the paragraph, indenting h lines by w characters > > 5. insert the drop cap in the indented space
> I doubt it's impossible but it seems like it would be a tricky.
> [...many corner cases...]
If we allow for the implementation to be slightly less general,
it is quite straightforward. Attached is a rough demonstration.
My simplifications are:
1. Have the author do the extraction of the first letter
manually. This also permits punctuation to be included
in the dropcap, if required.
2. Since this is intended for nroff with a monospace font,
we can determine the width and height using "wc".
3. No checking for exceptional conditions is done (short
paragraph, etc. -- this is something that probably
must be solved for each macro package individually).
It's the user's responsibility to ensure there is
sufficient space available, and to not use drop caps
if they don't fit or look bad.
The steps are then as follows:
1. Run figlet and save the output in a file.
Get the width and height and save in a file as well.
2. Mark the current position.
3. Source the figlet output in no-fill mode.
(Temporarily set the escape character to something
else because figlet output may contain backslashes.)
Also read the dimensions into number registers.
4. Return to the marked position and indent by the
required amount. Set a trap to reset the indent
after the correct height.
5. Continue reading text.
This method uses a page trap to reset the indent, so it will
not work inside a diversion. If that is required, it gets a
bit more complicated, because we then have to use a diversion
and its associated diversion trap instead -- see the second
attached file. This also makes use of a dedicated environment
in order not to interfere with the partially collected line
that remains after we have filled our diversion, and which
should continue to collect text and not be output until after
the diversion.
Result (tested using nroff -U -ms):
(For a different font, you may need to fiddle with the
spacing a bit: remove the ".sp -1v" (top edge) and/or
remove 1v from the trap position (bottom edge).)
================================================================
_____
|_ _| his document describes the groff program, the
| | main front-end for the groff document formatting
|_| system. The groff program and macro suite is
the implementation of a roff(7) system within
the free software collection GNU <http://www.gnu.org>.
The groff system has all features of the classical roff,
but adds many extensions.
__ __
\ \ / / hen there is a need to run different roff
\ \/\/ / implementations at the same time, groff pro-
\_/\_/ vides the facility to prepend a prefix to
most of its programs that could provoke name
clashings at run time (default is to have none). His-
torically, this prefix was the character g, but it can
be anything. For example, gtroff stood for groff's
troff, gtbl for the groff version of tbl. By setting
GROFF_COMMAND_PREFIX to different values, the different
roff installations can be addressed. More exactly, if
it is set to prefix xxx then groff as a wrapper program
will internally call xxxtroff instead of troff. This
also applies to the preprocessors eqn, grn, pic, refer,
tbl, soelim, and to the utilities indxbib and lookbib.
This feature does not apply to any programs different
from the ones above (most notably groff itself) since
they are unique to the groff package.
================================================================
Many variants are possible, such as large initials:
================================================================
_____ _ _
|_ _| |_ (_)___
| | | ' \| (_-<
|_| |_||_|_/__/ document describes the groff program,
the main front-end for the groff document formatting
system. The groff program and macro suite is the imple-
mentation of a roff(7) system within the free software
collection GNU <http://www.gnu.org>. The groff system
has all features of the classical roff, but adds many
extensions.
================================================================
which doesn't even require a trap, only a ".sp -2v" and a
".ti +\\n[DCw]n+1n". It doesn't work well with descenders,
though, for which you might instead use an only partially
dropped insert (use ".sp -2v" instead of ".rt"):
================================================================
_ _ _ _
| \| |___ _ _ _ __ __ _| | |_ _
| .` / _ \ '_| ' \/ _` | | | || |_
|_|\_\___/_| |_|_|_\__,_|_|_|\_, ( ) the path separator
|__/|/ in the following
environment variables is the colon; this may vary
depending on the operating system. For example, DOS and
Windows use a semicolon instead.
================================================================
(Make sure your terminal font has symmetrically angled quotes and
backquotes, otherwise many figlet fonts will not look as good.)
.\" ms unsafe .\" ---------------------------------------------------------------- .\" Drop capital using a page trap. .\" ---------------------------------------------------------------- .de DCwh \" load dropcap width and height .nr DCh \\$1 .nr DCw \\$2 .. .de DCr \" reset indent after dropcap 'in .. .de DC \" dropcap macro .open dropcap figlet.in .write dropcap \\$1 .close dropcap .sy figlet -f small <figlet.in >figlet.out; echo -n ".DCwh " >figlet.dim; wc -lL <figlet.out >>figlet.dim .so figlet.dim .mk .rs .sp -1v .ti +0 .nf .ec .so figlet.out .ec .sy rm figlet.in figlet.out figlet.dim .mk DCv .rt .fi .in +\\n[DCw]n+1n .wh \\n[DCv]u-1v DCr .. .\" ---------------------------------------------------------------- .nr PI 4n .RS .PP .DC T his document describes the groff program, the main front-end for the groff document formatting system. The groff program and macro suite is the implementation of a .I roff (7) system within the free software collection GNU \[la]http://www.gnu.org\[ra]. The groff system has all features of the classical roff, but adds many extensions. .PP .DC W hen there is a need to run different roff implementations at the same time, groff provides the facility to prepend a prefix to most of its programs that could provoke name clashings at run time (default is to have none). Historically, this prefix was the character .I g , but it can be anything. For example, gtroff stood for groff's troff, gtbl for the groff version of tbl. By setting GROFF_COMMAND_PREFIX to different values, the different roff installations can be addressed. More exactly, if it is set to prefix .I xxx then groff as a wrapper program will internally call .I xxx troff instead of troff. This also applies to the preprocessors eqn, grn, pic, refer, tbl, soelim, and to the utilities indxbib and lookbib. This feature does not apply to any programs different from the ones above (most notably groff itself) since they are unique to the groff package.
.\" ms unsafe .\" ---------------------------------------------------------------- .\" Drop capital using a diversion. .\" ---------------------------------------------------------------- .de DCwh \" load dropcap width and height .nr DCh \\$1 .nr DCw \\$2 .. .de DCr \" reset indent after dropcap .di .ev DC .in 0 .nf .DCd .ev .rm DCd 'in .. .de DC \" dropcap macro .open dropcap figlet.in .write dropcap \\$1 .close dropcap .sy figlet -f small <figlet.in >figlet.out; echo -n ".DCwh " >figlet.dim; wc -lL <figlet.out >>figlet.dim .so figlet.dim .mk .ds DCe \\n[.ev] .ev DC .evc \\*[DCe] .rs .sp -1v .nf .ec .so figlet.out .ec .ev .sy rm figlet.in figlet.out figlet.dim .rt .di DCd .in +\\n[DCw]n+1n .dt \\n[DCh]v-2v DCr .. .\" ---------------------------------------------------------------- .nr PI 4n .RS .PP .DC T his document describes the groff program, the main front-end for the groff document formatting system. The groff program and macro suite is the implementation of a .I roff (7) system within the free software collection GNU \[la]http://www.gnu.org\[ra]. The groff system has all features of the classical roff, but adds many extensions. .PP .DC W hen there is a need to run different roff implementations at the same time, groff provides the facility to prepend a prefix to most of its programs that could provoke name clashings at run time (default is to have none). Historically, this prefix was the character .I g , but it can be anything. For example, gtroff stood for groff's troff, gtbl for the groff version of tbl. By setting GROFF_COMMAND_PREFIX to different values, the different roff installations can be addressed. More exactly, if it is set to prefix .I xxx then groff as a wrapper program will internally call .I xxx troff instead of troff. This also applies to the preprocessors eqn, grn, pic, refer, tbl, soelim, and to the utilities indxbib and lookbib. This feature does not apply to any programs different from the ones above (most notably groff itself) since they are unique to the groff package.
dropcap.pdf
Description: Adobe PDF document
