Upside down and mirrored text

Last-Updated: 2021-08-30

Sources

Macros

Upside down text can be useful to approximate letter in language like Azeri. Azeri uses an upside down "e" that can be typeset with the following macro (2000-08/msg00068) by Ted Harding:

.\" Azeri upside-down e and E
.ds eupsidedown "\h'\w'e'u'\v'-0.45m'\X'ps: exec gsave currentpoint \
2 copy translate -180 rotate neg exch neg exch \
translate'e\X'ps: exec grestore'\h'-\w'e'u'\v'0.45m'
Upside down "e": \*[eupsidedown]
.char \(EU \s+'\\n[.ps]/2'\(eu\s0
\(EU

This macro sets up a new temporary graphics state in which the coordinate system has been rotated through 180 degrees. Then the "e" is printed. Then the original graphics state is restored.

If you want to reflect in a vertical axis it is sufficient to scale x by -1 and y by +1:

.ds Kmirrored "\h'\w'e'u'\X'ps: exec gsave currentpoint \
2 copy translate  -1 1 scale  neg exch neg exch \
translate'K\X'ps: exec grestore'\h'-\w'e'u'
\*[Kmirrored]

You may have to shift it right a bit by a \h'…' to get it where you want it.

The mirroring effect of the previous macro can be generalised as showed by Thomas Baruchel (2000-08/msg00070).

.de mirror
.  ds \\$1tmp "\h'\w'\\$2'u'\X'ps: exec gsave currentpoint \
   2 copy translate -180.0000 rotate neg exch neg exch \
   translate'\\$2\X'ps: exec grestore'\h'-\w'\\$2'u'
.  nr symetric \w'\\$2'
.  char \\[\\$1]
\v'-\\n[rsb]u'\v'-\\n[rst]u'\\*[\\$1tmp]\v'\\n[rst]u'\v'\\n[rsb]u'
.  rr symetric
..

Then, you can use :

.mirror eee E
\[eee]ssai

or even:

.mirror eee \s16E\s0
\[eee]ssay

Of course it works correctly with letters like "j" with a part under the baseline.

.mirror jjj j
\[jjj]oy