[Top][All Lists]

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

RE: [Groff] Trying to do a very special thing with the hyphenati

From: Ted Harding
Subject: RE: [Groff] Trying to do a very special thing with the hyphenati
Date: Sat, 05 May 2001 19:59:05 +0100 (BST)

Tu nous pousses, Thomas!

On 05-May-01 Thomas Baruchel wrote:
> I begun to write my very own set of macros (among other things,
> my principal goal is the intelligent formatting of a paragraph:
> put in a line a wider space between the words in order to have
> a shorter one somewhere under).
> I actually have another idea: someone told me about putting the
> hyphenation character (what we call the \(hy char) in the right
> margin:
> Example:
>     This is a very
>   little paragraph
>   with  a very spe-
>   cial  way of put-
>   ting the hyphena-
>   tion character.
> As you can see, the '-' is in the margin and not in the text.
> But the .shc request doesn't allow something like:
> .shc \Z'\(hy'
> Do you see a way of doing this ?
> In fact, I also have the idea of putting the half of the \(hy after the
> right margin, in order to have half of \(hy before the margin and the
> other half after the margin. Say \(hy is -- and have a look at:
> Example:
>     This is a very
>   little paragraph
>   with a very spe--
>   cial way of...

The documentation (man troff) for .shc both explains why it does
not work, and provides a clue for doing it:

  "If the soft hyphen character does not exist in the font
   of the character immediately preceding a potential break
   point, then the line will not be broken at that point.
   Neither definitions (specified with the char request) nor
   translations (specified with the tr request) are considered
   when finding the soft hyphen character."

So, since the sort of character you want ("\Z'\(hy'" or else
"\(hy\h'-\w'\(hy'u/2u'") does not exist in the font, you must
put it in the font.

For example, edit the file TR in groff/font/devps so that,
as well as the usual lines

  -       333,257 0       0055    hyphen
  hy      "

for the hyphen character (i.e. groff recognises both "-"
and "\(hy" as the names of the character with code 0055
(octal, = 45 decimal), you extend it with two further lines:

  -       333,257 0       0055    hyphen
  hy      "
  HY      0,257   0       0055    hyphen
  Hy      166,257 0       0055    hyphen

In this, the first number after the name is the width
(the other two are the height and the type -- see "man
groff_font"). Therefore "\(HY" has width zero, and "\(Hy"
has half the normal width of "-" (as near as possible),
but both cause the character with code 0055 to be printed.
To revert to normal, simply do


of course (which resets it to "\(hy").

Now try this out with

  .nr LL 8m
  .ll 8m
  .shc \(HY
  This is antidisestablishmentarianism in all its 
  .shc \(Hy
  antidisestablishmentarian glory

(ms macros), and you should find that it does exactly what
you want.

Admittedly, interfering with the font description files is not
a nice thing to do (one would prefer to find a way of doing it
in the input file), but in this case I think it has no harmful
side-effects (except that you have to do it for all the fonts
where you want to achieve this effect).

The fact that you have to do it this way is, I think, strongly
implied by the above quotation from "man troff": you can only
set the hyphenation character to something which is in the font
to start with.

Good luck,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 284 7749
Date: 05-May-01                                       Time: 19:59:05
------------------------------ XFMail ------------------------------

reply via email to

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