Changes in unofficial TengTeX releases

Here you'll find a boring list of the little changes which I made to TengTeX. If you're not interested in TeX code or you simply don't know what I'm writing about you'll probably hate this page :-)

Since the first time I dared to put my hands on TengTeX's code I always contributed back any useful change to Ivan, so that the next official release could be improved.

Scaling tengwar

One of the first thing I felt I missed using TengTeX was the automatic scaling mechanism every LaTeX user is used to. Equipped with very little knowledge of TeX and a big help from Gernot Katzer I tried to modify TengTeX, but what I came up with was a bit "rustic": a \scaletengwar macro with which users could specify the exact scaling factor for Bradfield's or Urban's font. Being the lazy person that I am I also added a \blackspeech macro which activated Sindarin mode with switch curls for o and u and velar consonant as in the Ring inscription.

Here is the patch (Unix style) for TengTeX 1.01 which I sent to Ivan:

--- tengtex.sty    Tue Oct 12 19:46:09 1999
+++ tengtex.sty.new Tue Oct 12 19:45:26 1999
@@ -8,26 +8,45 @@
 % Institute for Mathematics and Computer Science
 % Bulgarian Academy of Sciences
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Versione 1.01bis
+% Modificata includendo una macro per scalare i font (suggerimento di
+% Gernot Katzer). Sono state modificate anche le definizioni dei due
+% font.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \def \TengTeX {T\ama@tehta {\char19}{\~g}\TeX }
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%% fount selection %%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\newif \if@nofount
+\newif \if@nofount % Mai usata. Si può togliere?
 
 \def \@jcb{\jcb} \def \@mpu{\mpu}
 
 \def \mere@tengwanda{%
   \loop
     \ifx \@tengwanda \undefined
-      \message{Choose a tengwar fount (\string\jcb\space or \string\mpu): }%
+      \message{Version 1.01bis! Choose a tengwar fount (\string\jcb\space or \string\mpu): }%
       \read-1 to\@answer
       \ifx \@answer \@jcb \jcb \else \ifx \@answer \@mpu \mpu%
       \else \message{That's not a legitimate answer to my question.^^J}\fi\fi
   \repeat}
 
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%% macro varie %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\scaletengwar#1{
+  \def\@tengscalefactor{#1}
+  \ifx \@tengwar \undefined \mere@tengwanda \else \@tengwar \fi}
+
+\def\scaletengwar#1#2{%
+  \def\@tengscalefactor{#1}
+  #2}
+
+\def\@tengscalefactor{1000}
+
+\def\blackspeech{\sindarin\oleft\vaswestron}
+
+
 %%%%%%%%%%%%% character definitions common to both founts %%%%%%%%%%%%%
 
 \def\l@p#1#2{{\setbox0=\hbox{#2}\ooalign{\box0\crcr\hidewidth#1\hidewidth}}}%
@@ -57,7 +76,8 @@
 %%%%%%%%%%%%%%%%%%%%% Julian Bradfield's  tengwar %%%%%%%%%%%%%%%%%%%%%
 
 \def \jcb{\globaldefs=1%
-\font \jcb@tengwar=teng10\let \@tengwanda \jcb@tengwar
+\font \jcb@tengwar=teng10 scaled \@tengscalefactor \let \@tengwanda \jcb@tengwar
+\let \@tengwar \jcb
 \hyphenchar\jcb@tengwar=-1 % hyphenation in tengwar suppressed
 \emergencystretch=2em % but we can do some extra stretching
 %
@@ -122,7 +142,8 @@
 %%%%%%%%%%%%%%%%%%%%%%% Michael Urban's tengwar %%%%%%%%%%%%%%%%%%%%%%%
 
 \def \mpu{\globaldefs=1%
-\font \mpu@tengwar=tengwar\global \let \@tengwanda \mpu@tengwar
+\font \mpu@tengwar=tengwar scaled \@tengscalefactor \global \let \@tengwanda \mpu@tengwar
+\let \@tengwar \mpu
 \hyphenchar\mpu@tengwar=-1 % hyphenation in tengwar suppressed
 \emergencystretch=2em % but we can do some extra stretching
 %

Ivan adapted the above code according to his taste (using the classical TeX's magstep) in the next official release.

A couple of errors

Time passed, my TeX knowledge increased and I found, by luck, two little, subtle errors in Sindarin mode which caused long o and u written in input as double vowels to be typeset wrongly when \oleft was active.

So I sent to Ivan the following corrected definitions for TengTeX 1.01 on 22nd Jun 2000:

\def \O@s #1>{\s@anda@Oman #1>\o@sind}
\def \U@s #1>{\s@anda@Oman #1>\u@sind}

I also proposed to change some code to avoid scaling command had global effect, but as I learned Ivan was going to work on other parts of TengTeX.

Another error for which I didn't have any solutions was that if you used \beleriand (or \blackspeech for what matters) before having selected any font you got a bunch of errors because \vinquesse, \vaswestrong and friends defined particular control sequences (\c@sind and others) using values of control sequences that, at processing time, were not yet defined (remember that TengTeX didn't have any default font in released 1.01). Ivan solved this nasty problem and added the default font Computer Modern Tengwar.

Down into TengTeX parsers

Here I present a letter that Ivan sent to me after I asked about any available documentation about TengTeX parser mechanisms (it's nothing strictly personal, so I hope Ivan is not disturbed by it):

Date: Mon, 03 Jul 2000 17:22:47 +0300
From: Ivan A Derzhanski <iad@...>
To: Vicentini Emanuele <vicentin@...>
Subject: Re: TengTeX

Some notes (from very ancient memory -- it's been years since I did
anything with the package):

The tengwar are written in blocks, each of which consists of a tengwa
and up to two tehtar (in Quenya and Beleriandic) or up to three (in
Classical Sindarin).  The job of TengTeX is to scan the romanised
input, parse it into blocks and output them.

Thus at any time there is a current active block, which the macros
pass on as a triple or quartet of arguments to one another, because
of the awkwardness of handling independent variables in TeX.  This
block is output as soon as it is clear that it will not be modified
any more, which is either when a letter is input that must be written
as part of another block or the end of the word is reached.  There is
no going back, though, so a tengwa is only written when it is known
what tehtar (if any) must accompany it.

The colon is actually used as a null character: it means that the
current glyph contains no tehta in the relevant position.

>     Starting points for Quenya, C. Sindarin and Beleriandic mode are,
> respectively: \def\m@m{\sinta@kolindo ::}, \def\m@m{::\sinta@kolindo :}
> and \def\m@m{:::}.

Correct.  And if the first letter read in is a consonant, it will take
the place of the short carrier, whereas if it is a vowel, it will replace
one of the colons; or in Beleriandic mode it will always replace a colon.
That will be the updated form of the active block.

Saluti,
--Ivan

Shortly after this letter I was one of the beta-tester for TengTeX 1.10, Computer Modern Tengwar and Computer Roman Tengwar and was added to the list of people who bother the author :-) (I'm joking, I'm really proud my name appears in TengTeX's doc).

The first primitive font selection mechanism

After the first "alien" impression I got from Computer Modern Tengwar I started using it more and more, but soon felt the need for a simple way of selecting the other possible "look" of Computer Modern Tengwar.

I tried several ways, but my knowledge of LaTeX and NFSS internals was quite scarce, so the best thing I wrote (and sent to Ivan on the 16th Feb 2001) was a modification of \cmteng to use an optional argument (a simple suffix or a suffix with a size in point) to select an alternative font. The code worked, but users need to know exactly font names and sizes... NFSS was still far, far away.

Here is the code for TengTeX 1.10 (with the original comments):

% I think that copying the following three macros into tengtex.sty (not
% tengtex.tex) instead of using LaTeX internals could be a simple way to
% prevent unplanned changes of LaTeX base and to keep TengTeX usable with
% Plain TeX.
\long\def\teng@ifnextchar#1#2#3{%
  \let\teng@reserved@d=#1%
  \def\teng@reserved@a{#2}%
  \def\teng@reserved@b{#3}%
  \futurelet\teng@let@token\teng@ifnch}

\def\teng@ifnch{%
  \ifx\teng@let@token\@sptoken
    \let\teng@reserved@c\teng@xifnch
  \else
    \ifx\teng@let@token\teng@reserved@d
      \let\teng@reserved@c\teng@reserved@a
    \else
      \let\teng@reserved@c\teng@reserved@b
    \fi
  \fi
  \teng@reserved@c}

\def\teng@xifnch{\futurelet\teng@let@token\teng@ifnch}

% I need this last space to avoid an erroneus expansion below.
\def\@teng@size{10 }
\edef\@teng@type{r\@teng@size}
% Alternatively users could specify a "suffix" (r, ti, ssbx, tt) and a
% "size":
% \def\@teng@type{r10 }

\def\cmteng{\teng@ifnextchar[{\@cmteng}{\@cmteng[r]}}
% Alternatively:
% \def\cmteng{\teng@ifnextchar[{\@cmteng}{\@cmteng[r10]}}
\def\@cmteng[#1]{\global\edef\@teng@type{#1\@teng@size}\@@cmteng}
% Alternatively:
% \def\@cmteng[#1]{\global\def\@teng@type{#1 }\@@cmteng}
\def \@@cmteng {\globaldefs=1%
\font \cm@tengwar=tiad\@teng@type scaled \teng@mag
\global \let \@tengwanda \cm@tengwar
\let \@tengwar \@@cmteng
%
\new@style@tengwar
\chardef \@tinco="A0  \chardef \@SUle="A2   \chardef \@Ore="A4
\chardef \@ando="A1   \chardef \@anto="A3   \chardef \@nUmen="A5
\chardef \x@ando="A7
\chardef \@parma="A8  \chardef \@formen="AA \chardef \@vala="AC
\chardef \@umbar="A9  \chardef \@ampa="AB   \chardef \@malta="AD
\chardef \x@umbar="AF
\chardef \@calma="B0  \chardef \@Harma="B2  \chardef \@Ganna="B4
\chardef \o@tengwa="B4
\chardef \@anga="B1   \chardef \@anca="B3   \chardef \@Noldo="B5
\chardef \@quesse="B8 \chardef \@hwesta="BA \chardef \@wilya="BC
\chardef \@ungwe="B9  \chardef \@unque="BB  \chardef \@Nwalme="BD
%
\globaldefs=0}

\let \@tengwar \@@cmteng

The user could switch to a medium, serifed, italic font issuing \cmteng[ti] (or \cmteng[ti10] if the alternative approach would be used): not an easy way if you're just a casual LaTeX user and not an elegant solution anyway.

And now, let NFSS come in!!!

Never satisfied by my own code I had the opportunity to acquaint myself with NFSS internals and so, in less than an hour of lazy work I produced some day in May 2001 the first NFSS patch for TengTeX 1.10 (making the first unofficial release, 1.10.1, for personal use only). Being quite busy after that I sent the patch to Ivan only on the 20th Jun 2001.

Here is the patch (Unix style) for TengTeX 1.10:

--- tengtex.sty     Thu Feb 15 14:50:43 2001
+++ newtengtex.sty  Sun Jun 17 18:44:22 2001
@@ -91,8 +91,13 @@
 %%%%%%%%%%%%%%%%%%%%%%% Computer Modern tengwar %%%%%%%%%%%%%%%%%%%%%%%
 
 \def \cmteng {\globaldefs=1%
+\def\elvishfamily{\fontfamily{tiad}\selectfont}
 \font \cm@tengwar=tiadr10 scaled \teng@mag
-\global \let \@tengwanda \cm@tengwar
+\ifx\selectfont\empty
+  \let \@tengwanda \cm@tengwar
+\else
+  \let \@tengwanda \elvishfamily
+\fi
 \let \@tengwar \cmteng
 %
 \new@style@tengwar
@@ -116,8 +121,13 @@
 %%%%%%%%%%%%%%%%%%%%%%% Computer Roman tengwar %%%%%%%%%%%%%%%%%%%%%%%%
 
 \def \crteng {\globaldefs=1%
+\def\elvishfamily{\fontfamily{tiad}\selectfont}
 \font \cm@tengwar=tiadr10 scaled \teng@mag
-\global \let \@tengwanda \cm@tengwar
+\ifx\selectfont\empty
+  \let \@tengwanda \cm@tengwar
+\else
+  \let \@tengwanda \elvishfamily
+\fi
 \let \@tengwar \crteng
 %
 \new@style@tengwar
@@ -153,8 +163,13 @@
 %%%%%%%%%%%%%%%%%%%%% Julian Bradfield's  tengwar %%%%%%%%%%%%%%%%%%%%%
 
 \def \jcb {\globaldefs=1%
+\def\elvishfamily{\fontfamily{jcb}\selectfont}
 \font \jcb@tengwar=teng10 scaled \teng@mag
-\let \@tengwanda \jcb@tengwar
+\ifx\selectfont\empty
+  \let \@tengwanda \jcb@tengwar
+\else
+  \let \@tengwanda \elvishfamily
+\fi
 \let \@tengwar \jcb
 \hyphenchar\jcb@tengwar=-1 % hyphenation in tengwar suppressed
 \emergencystretch=2em % but we can do some extra stretching
@@ -223,8 +238,13 @@
 %%%%%%%%%%%%%%%%%%%%%%% Michael Urban's tengwar %%%%%%%%%%%%%%%%%%%%%%%
 
 \def \mpu {\globaldefs=1%
+\def\elvishfamily{\fontfamily{mpu}\selectfont}
 \font \mpu@tengwar=tengwar scaled \teng@mag
-\global \let \@tengwanda \mpu@tengwar
+\ifx\selectfont\empty
+  \let \@tengwanda \mpu@tengwar
+\else
+  \let \@tengwanda \elvishfamily
+\fi
 \let \@tengwar \mpu
 \hyphenchar\mpu@tengwar=-1 % hyphenation in tengwar suppressed
 \emergencystretch=2em % but we can do some extra stretching

Here's a summary of the changes for those not used to patches:

  1. added a \def\elvishfamily{\fontfamily{tiad}\selectfont} at the beginning of \cmteng and \crteng definitions
  2. substituted \@tengwanda creation in \cmteng and \crteng with the following code:
        \ifx\selectfont\empty
           \let \@tengwanda \cm@tengwar
        \else
           \let \@tengwanda \elvishfamily
        \fi
    
  3. these same changes were done to \jcb definition (with "jcb" as the new font-family and \jcb@tengwar instead of \cm@tengwar inside the conditional statement)
  4. these same changes were done to \mpu definition (with "mpu" as the new font-family and \mpu@tengwar instead of \cm@tengwar inside the conditional statement)

Well, after these modifications to tengtex.sty we still needed a couple of definitions to keep using TengTeX with Plain TeX, so I added to tengtex.tex the following code:

    \def\fontfamily#1{}
    \def\selectfont{}

For the font definition files see in the latest unofficial distribution (the only difference being that definitions of jcb and mpu families lacked the turning off of hyphenation). With this first unofficial release I provided more variants of Computer Modern Tengwar for the benefit of users who could lack the technical knowledge to build them up by themselves.

After all these words, I could still use TengTeX with Plain TeX (and \tengwarmag was still needed) but now TengTeX was more integrated with LaTeX to the eyes of final users. The only drawback was I hadn't been able to find a way to use tiadtt* or tiadss*... but this was only the beginning :-)

An error?

On the 27th Jun 2001 I wrote to Ivan reporting what I think is an error in \q@teka. The present definition start as follow:

\def \q@teka #1#2#3#4#5>{%
  \ifx #3:%
    \ifx #1\@halla \@halla
    \else \ifx #4\anda@kolindo \nun@tehta #1#2%
    \else \ifx #4\@yanta \nun@tehta #1#2%
    \else \ifx #4\@Ure \nun@tehta #1#2%
    \else
      \def \q@c@n {\ifx #1\@rOmen \@Ore \else #1\fi}%
      \if@light \expandafter \uOman@tehta {\nun@tehta \q@c@n #2}#1%
    % omit...

Well, I think Ivan wanted the first argument of \uOman@tehta to be expanded before \uOman@tehta itself, but that \expandafter actually expands only the first {. TengTeX seems to work well anyway, but perhaps it could be better to add another \expandafter:

  \if@light \expandafter \uOman@tehta \expandafter {\nun@tehta \q@c@n #2}#1

Following the principle Don't change what's not broken that line has not been changed yet (time will say if it should).

Changes in TengTeX 1.10.2

Some weeks after the birth of TengTeX 1.10.1 I discovered that its behavior was not exactly standard when Bradfield's or Urban's fonts were selected: after a quick search I found that I inadvertly omitted \hyphenchar\font=-1 in the font definition files for the previously cited fonts. A simple cut & paste and problem was fixed. I took that chance to reorganized in a more logic way the NFSS code in tengtex.sty.

Changes in TengTeX 1.10.3

By chance I discovered that my NFSS patch had introduced a little bug: Computer Modern/Roman Tengwar families have a "special" tengwa for "spirant m or... nasal v" (Tolkien's own terms) usually written mh and pronounced [v], but the check was on the value of \@tengwanda, which is markedly different in the new release when you use LaTeX

Here is the patch (Unix style) for TengTeX 1.10.2:

--- /usr/share/texmf/tex/latex/TengTeX/tengtex.sty  Sun Nov  4 17:03:48 2001
+++ tengtex.sty Thu Feb 28 12:45:01 2002
@@ -646,8 +646,17 @@
     \else \s@v@t@c@t #1#2\@formen T%
     \fi\fi
   \else \ifx #3\mh@sind
-    \ifx \@tengwanda \cm@tengwar \s@v@t@c@t #1#2\@mhalta #4%
-    \else \s@v@t@c@t #1\landa@ama@falma \@ampa #4%
+    \ifx\selectfont\empty
+      \ifx \@tengwanda \cm@tengwar \s@v@t@c@t #1#2\@mhalta #4%
+      \else \s@v@t@c@t #1\landa@ama@falma \@ampa #4%
+      \fi
+    \else
+      \begingroup
+        \def\temp@tengtex@family{tiad}%
+        \ifx \f@family\temp@tengtex@family \s@v@t@c@t #1#2\@mhalta #4%
+        \else \s@v@t@c@t #1\landa@ama@falma \@ampa #4%
+        \fi
+      \endgroup
     \fi
   \else \ifx #3\sinta@kolindo
     \ifx #5<\@Oman@tengwa #1\sinta@kolindo
@@ -871,8 +880,17 @@
   \else \ifx #2\@phormen
     \if@thegra \b@t@c@t #1\@formen#3\else \b@t@c@t #1\@formen T\fi
   \else \ifx #2\mh@sind
-    \ifx \@tengwanda \cm@tengwar \b@t@c@t #1\@mhalta #3%
-    \else \b@t@c@t \landa@ama@falma \@ampa #3%
+    \ifx\selectfont\empty
+      \ifx \@tengwanda \cm@tengwar \b@t@c@t #1\@mhalta #3%
+      \else \b@t@c@t \landa@ama@falma \@ampa #3%
+      \fi
+    \else
+      \begingroup
+        \def\temp@tengtex@family{tiad}%
+        \ifx \f@family\temp@tengtex@family \b@t@c@t #1\@mhalta #3%
+        \else \b@t@c@t \landa@ama@falma \@ampa #3%
+        \fi
+      \endgroup
     \fi
   \else \ifx #2\i@iEva
     \b@t@c@t #1\sinta@kolindo#3%   word-initial vocalic _i_

Changes in TengTeX 1.10.4

Ok, I cheated and haven't stop working on NFSS code, so the complete check-up of TengTeX's parsers is still not finished. Anyway, here's the short list of changes (no patch this time - I didn't know if it could be better to make a patch against 1.10.3 or 1.10, so no patch at all):.

  1. LaTeX family declarations (\rmfamily, \sffamily and \ttfamily) are now recognized and affect Computer Modern/Roman Tengwar in the expected way.
  2. Computer Modern/Roman Tengwar families have been expanded to match most of Computer Modern families (there are just a few fonts missing (unslanted italic, the Funny family...), but we have more sizes thanks to Sauter distribution).

Changes in TengTeX 1.10.5

Another fixing release. The code I added to the previous release to extend NFSS support was as buggy as hell: internally changing \rmdefault, \sfdefault and \ttdefault seemed a good idea, but it caused the page headers/footers to be typeset in one of the tengwar fonts if an elvish environment spread across two or more pages - definitely an unpleasing, unwanted effect!

This time I've tested the code before ever thinking about releasing it, and it works well. Here are the changes:

  1. slightly modified the dummy definition of \selectfont in tengtex.tex; the various checks in tengtex.sty have been modified accordingly.
  2. added two macros just after the logo definition to keep code clean:
    1. \@select@font@family: choose and set the right font family for CM/RT according to the active family at the beginning of an elvish environment
    2. \@change@default@font@family: sets \rmdefault, \sfdefault and \ttdefault for internal use in an elvish environment and stores previous values for use in page headers/footers

Changes in TengTeX 1.10.6

I've been lazy on the checking project, but having something to add to TengTeX anyway I've produced another unofficial release. Here are the changes:

  1. added a small appendix to the manual (as a separate document) to explain the main changes
  2. added a semi-new Black Speech mode based upon the existing Sindarin one; it needs some tengwar not available in Urban's font
  3. the two tyeller (with single and double lúvar) with the extended telco has been added to \cmteng, \crteng and \jcb; Urban's font lacks many of those tengwar, so they've been substituted with short telco ones
  4. removed a comment sign in the elvish environment definition where it shouldn't be (it caused the expansion of the following \tUva@kerta before counter \nato@nostale's initialization.

Changes in TengTeX 1.10.7

Again, the checking project has been postponed, but here's another unofficial release of TengTeX. What's been changed? Here are the changes:

  1. every user command has been redefined as a robust one thanks to some code borrowed by ArabTeX of Prof. Klaus Lagally, so now you can use them in moving arguments without \protect
  2. the small appendix to user manual has been slightly expanded with a section about using LaTeX commands inside an elvish environment

What I'm working on

Now that everyone can use TengTeX with LaTeX without worrying about font names and exact sizes I can well take time to delve into TengTeX internals and look for mis-types or (gasp!) errors.

At the moment I've just finished the Quenya mode section and, unfortunately, found some problems with code for diphthongs, voiced consonants (ando, ampa and such) and consonantal tehtar. These problems, however, pop up only in particular situations and only if you don't follow the phonetic constraints of Quenya (i.e., if you write aga instead of anga you get the same tengwar), so there's no hurry to fix them.

Comments and corrections are welcome (please, start the subject with [elvishtc] so that I will be able to filter it and read before other messages).

Last modified: Tue Jul 29 13:28:03 2003

Valid HTML 4.01! Valid CSS!