groff
[Top][All Lists]
Advanced

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

[Groff] YaDCM (Yet another Drop Capital Macro)


From: Gaius Mulley
Subject: [Groff] YaDCM (Yet another Drop Capital Macro)
Date: 17 Mar 2005 11:27:03 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2


Werner LEMBERG <address@hidden> writes:

> Maybe some of you can use such a macro...
> 
> 
>     Werner

Yes thanks Werner and in return I offer `Yet another Drop Capital
Macro'.

[ I've never been one to indulge in crosswords - groff macro
  fiddling more than satisfies afternoon problem solving..]

A simple example follows the YaDCM


----------- cut here ----------- cut here ----------- cut here
.\"
.\"  DROPCAP - macro set provides a reasonably comprehensive macro
.\"            to achieve a drop capital.
.\"
.\"            What is different from other drop capital implementations
.\"            is that this allows a user to add in adjustments on
.\"            a per line basis all the way down the drop capital.
.\"            So for example a user may pull/push text in and out of a
.\"            capital `I' if required.
.\"            The first argument is the first whole word. This is
.\"            automatically chopped into a letter and the subsequent
.\"            letters are capitalized.
.\"
.\"            This macro was written
.\"            by Gaius Mulley - _but_ it was based on a number of
.\"            postings from the address@hidden mailing list.
.\"            Note it also uses the .uppercase macro written by
.\"            Werner Lemberg.
.\"            From memory other postings which gave ideas to this
.\"            macro were from: Werner Lemberg, Ted Harding,
.\"            Ralph Corderoy (and others). Also some of its features
.\"            were inspired by the great mom macros.
.\"
.\"            Please feel free to improve and modify the macro or
.\"            simply take ideas and incorporate them elsewhere.
.\"
.\"  Usage:
.
.\"  dropcap - WORD LINES COLOUR FONT FAMILY ADJUSTMENT { ADJUSTMENT }
.
.\"  Example:
.
.\"  .dropcap When 4 darkblue R T -1n
.\"  produces a rather nice effect as we can see the
.\"  subsequent lines indented by -1n each line down
.\"  the drop capital. It is possible to append more
.\"  parameters to this macro, each parameter indicates
.\"  the relative indentation for the next line.
.\"  Therefore it is possible to make text pull in
.\"  and out of a drop capital I.
.
.\"
.\" .uppercase in out
.\"
.\"   Convert the contents of string with name `in' to uppercase
.\"   and return the result in a string with name `out'.
.\"
.\"   Note that this macro by default only translates the characters a-z;
.\"   if you need other characters, define them in the strings
.\"   `uppercase-set' and `uppercase-reset'.  Both are used with the `.tr'
.\"   request; the former to set the mapping, the latter to reset it.
.\"
.de uppercase
.  rm \\$2
.  tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
.  tr \\*[uppercase-set]
.  di uppercase-div
.    nop \\*[\\$1]
.    br
.  di
.  asciify uppercase-div
.  chop uppercase-div
.  tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
.  tr \\*[uppercase-reset]
.  ds \\$2 \\*[uppercase-div]\"
..
.
.ds uppercase-set ä\[:A]
.ds uppercase-reset ä\[:a]
.
.de dc::next-line
.  ie \\n[dc::linesm1]>0 \{\
'     in +\\n[dc::adjustarray\\n[dc::linesm1]]u
.     mk dc::droppos2
.     wh \\n[dc::droppos2]u+1v dc::next-line
.     nr dc::linesm1 \\n[dc::linesm1]-1
.  \}
.  el \{\
'    in \\n[dc::orig-indent]u
.  \}
..
.\"
.\"  dropcap - WORD LINES COLOUR FONT FAMILY ADJUSTMENT { ADJUSTMENT }
.\"
.de dropcap
.  rm dc::lines dc::linesm1
.  ds dc::word \\$1
.  ds dc::letter \\$1
.  substring dc::letter 0 0
.  ds dc::originalremainder \\*[dc::word]
.  length dc::word-len \\*[dc::word]
.  ie \\n[dc::word-len]>1 \{\
.     substring dc::originalremainder -1 1
.     uppercase dc::originalremainder dc::remainderofword
.  \}
.  el \{\
.     ds dc::originalremainder "
.     ds dc::remainderofword   "
.     ds dc::letter \\$1
.  \}
.  nr dc::lines \\$2
.  ds dc::dropcolor \\$3
.  ne \\n[dc::lines]
.  nr dc::dummy \\w'\\*[dc::letter]'u
.  nr dc::charheight \\n[rst]
.  nr dc::linesm1 \\n[dc::lines]-1
.  nr dc::linesindex \\n[dc::linesm1]
.  ds dc::font \\$4
.  ds dc::family \\$5
.  nr dc::adjustment (\\$6;u)
.  nr dc::lastadjust (\\$6;u)
.  shift 5
.  while \\n[dc::linesindex]>0 \{\
.     nr dc::adjustarray\\n[dc::linesindex] 0
.     ie \\n[.$]>0 \{\
.        nr dc::lastadjust (\\$1;u)
.        nr dc::adjustarray\\n[dc::linesindex] \\n[dc::lastadjust]
.        shift
.     \}
.     el .nr dc::adjustarray\\n[dc::linesindex] 0+\\n[dc::lastadjust]
.     nr dc::linesindex \\n[dc::linesindex]-1
.  \}
.  nr dc::inside-drop 1
.  nr dc::dcht 
((\\n[.v]*\\n[dc::linesm1])+\\n[dc::charheight])*(\\n[.ps])/\\n[rst]
.  char \[dc::dcap] \\s'\\n[dc::dcht]u'\\F[\\*[dc::family]]\
\\f[\\*[dc::font]]\\*[dc::letter]\\fP\\F[]\\s0
.  nr dc::dummy \\w'\[dc::dcap]'u
.  nr dc::dropheight \\n[rst]
.  nr dc::orig-indent \\n[.i]
.  nop \\v'(\\n[dc::dropheight]u-\\n[dc::charheight]u)'\c
.  nop \\m[\\*[dc::dropcolor]]\\[dc::dcap]\\m[]\c
.  nop \\v'-\\n[dc::dropheight]u+\\n[dc::charheight]u'\c
.  nop \\v'\\n[dc::linesm1]'\c
.  mk dc::droppos
.  wh \\n[dc::droppos]u+1v dc::next-line
.  nop \\v'-\\n[dc::linesm1]'\c
'  in +\w'\\[dc::dcap]'u+\\n[dc::adjustment]u
.  nr dc::linesm1 \\n[dc::linesm1]-1
.  if \\n[dc::word-len]>1 .nop \\*[dc::remainderofword]
..
.
.\" this should be the last line
----------- cut here ----------- cut here ----------- cut here
.sp
.ps 16
.vs 20
.so dropcap.tmac
.defcolor darkblue rgb 0.1f 0.1f 0.3f
.dropcap When 4 darkblue R T -1n
produces a rather nice effect as we can see the
subsequent lines indented by -1n each line down
the drop capital. It is possible to append more
parameters to this macro, each parameter indicates
the relative indentation for the next line.
Therefore it is possible to make text pull in
and out of a drop capital I.
.sp
.dropcap In 7 darkblue R T -1n 0 0 0 0 1n
an attempt to provide an example of the drop capital
macro I needed to write some text. This is always
problematic and I wish I could just hash include
some dummy text instead.
In an attempt to provide an example of the drop capital
macro I needed to write some text. This is always
problematic and I wish I could just hash include
some dummy text instead.
In an attempt to provide an example of the drop capital
macro I needed to write some text. This is always
problematic and I wish I could just hash include
some dummy text instead.




reply via email to

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