[Top][All Lists]

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

RE: [Groff] Accents in output

From: Ted Harding
Subject: RE: [Groff] Accents in output
Date: Thu, 29 Jan 2004 08:19:28 -0000 (GMT)

[As seems to be a regular problem when I send mail to groff via
 btinternet, the message below seems not to have reached the list.
 Apologies if you receive it twice.]

> This is an old chestnut, but I can't figure the answer out from the
> list archives.
> How do I get accented characters in my output?
> I'm particularly interested in c, g, h, j and s with circumflex
> (ĉĝĥĵŝ), and u with breve (ŭ). I understand that I can't enter
> UTF-8 at present, but neither \(c^ or \[^c] works for me. For that
> matter, nor does \[^a].
> Just in case it matters, I'm variously using ms, mandoc and mom macros,
> but this looks like a basic groff matter.

Indeed it is ... the key to it (assuming you're using PostScript
output) is in constructing the composite glyph (character+accent),
since (pre-UTF8 and anyway in PS) you only get a few accented
characters as pre-cooked glyphs, and you have to compose anything
else yourself.

Fortunately it is straightforward. In the ms macros, you will find
a module "module acc". Have a look at the code here and in macro .AM
to see what is going on and how it is done.

You have, in particular, macros

.de acc*over-def
.de acc*under-def

which you can use to make any mark an accent above any character or
an accent below any character. These macros are defined when s.tmac
is read in, regardless of whether you invoke .AM or not.

If, for example, you have a character \[char1], then something like

.acc*over-def C1 \[char1]

defines a string \*C1 such that


will produce a composite in which \[char1] is an accent above \[anychar].
Similarly for accents-under.

Thus you can define the accent-over "breve" as

.acc*over-def breve \(ab

and then your u-breve as (e.g.)

.char \[ub] u\*[breve]

Now, if you look in .AM, you will find that \*^ is already defined therein
as a circumflex above, so to get what you want (with the excpetion
of j) you first invoke .AM and then you can define your own .chars as

.char \[c^] c\*^
.char \[g^] g\*^
.char \[h^] h\*^
.char \[s^] s\*^

Then, when you need them in text, you simply insert them by name,
as in \[c^]ummy, etc.

However, to get \[j^] you would need to use the "dotless j" character
which unfortunately is not in the standard PostScript character sets.
(Dotless i, however, is there, and is known to groff as "\[.i]").

You could fudge it as above with

.char \[j^] j\*^

but this is likely to produce a composite in which the "^" and the dot
on the j are both somewhat untidily visible.

However, you may be able to tune this yourself by adapting the
code for .acc*over-def so that the position of the "^" is slightly
adjusted so as to hide the dot on the "j". Basically, you need
to write something like

.char \[j^] j\Z'\v'(u;\w'x'*0+\En[rst]-\En[.cht])'\

(quoting the .acc*over-def unchanged, but substituting "^" for "\\$2"),
in which the horizontal motions (\h'...' and \v'...') need to be tweaked
until you get the result you want. Unfortunately, again, this may be font
dependent! So, if you are really fussy, you may perhaps need to make a
separate definition for each font you use ...

Indeed, if you use this definition in Times Roman, you will find that the
"^" stands well clear of the dot on the j.

The best I can do with this seems to be

.char \[j^] j\Z'\v'(u;\w'x'*0+\En[rst]-\En[.cht]+0.48n)'\

since unfortunately the dot on the j has a large enough diameter to
protrude beyond the outline of the "^", so it's going to look a little
bit bad whatever you do. However, it should not show up except under
close inspection in moderate (10-12) point sizes.

I hope this helps to get you started.

Best wishes, and Floreat ALUG! (OK groffers, now start searching ... ).


E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 28-Jan-04                                       Time: 18:38:41
------------------------------ XFMail ------------------------------

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 29-Jan-04                                       Time: 08:19:28
------------------------------ XFMail ------------------------------

reply via email to

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