0

I wanted to make a Tengwar font, that automatically translates german text to Tengwar using this mapping.

My first approach was to make a command, which translates everything of the argument:

\usepackage{fontspec}
\newfontfamily{\tengwarannatar}{tengwar_annatar.ttf}

\ExplSyntaxOn \DeclareDocumentCommand{\tengwar}{m} { \tl_set:Nn \l_tmpa_tl {#1} % Hier folgt die Übersetzung gemäß Ihren Regeln \tl_replace_all:Nnn \l_tmpa_tl {sch} {{\tengwarannatar\char"0064}} \tl_replace_all:Nnn \l_tmpa_tl {A} {{\tengwarannatar\char"00B5}} \tl_replace_all:Nnn \l_tmpa_tl {a} {{\tengwarannatar\char"00B5}} \tl_replace_all:Nnn \l_tmpa_tl {Ä} {{\tengwarannatar\char"00AA}} \tl_replace_all:Nnn \l_tmpa_tl {ä} {{\tengwarannatar\char"00AA}} \tl_use:N \l_tmpa_tl } \ExplSyntaxOff

Interestingly, without the double braces {{...}}, everything below will be translated. That includes every text inside tikz. On the other hand, the command results in an endless loop, if put into tikz. Thus, I wanted to ask, how a command, similar so the normal font command, could be created. So that I can say use something like \newfontfamily{\tengwar}{...} or \setmainfont{tengwar}. Another problem may be, that numbers can have arbitrary length but need to be convert to base 12. I'm also not yet clear on how to properly implement other "rules" so as not to make everything hardcoded.

So I'm stuck on the problem right now and can't get any further. I also lack ideas how to proceed correctly and possibly design decisions of mine are wrong. Can someone help me? Maybe a blueprint would help me, so that I can proceed further by implementing the rules.

Edit:

\usetikzlibrary{decorations.text}
\begin{tikzpicture}
  \draw[
    decorate,
    decoration={
      text along path,
      text={\tengwar{aaa}},
      text align={center},
      raise=-3pt,
    }
  ] (0,0) arc (0:-360:3.1cm);
\end{tikzpicture}

This creates an endless loop, but I tested around. E.g. in a normal node, everything works fine, which confuses me more than it should.

Titanlord
  • 541
  • Can you please show an example of hpw you're using this? – egreg Oct 08 '23 at 19:28
  • It is hard to give a minimal working example here. I use this font and then I use \tengwar{text} to automatically translate it to tengwar following the rules related to in the post – Titanlord Oct 08 '23 at 19:33
  • Sorry, but I don't get the reference to TikZ, then. And to numbers either. You may add the complete list of substutions, so we don't have to guess the character numbers. – egreg Oct 08 '23 at 19:36
  • There is a whole bunch of rules for text, which is way to much for this post. Additionally, the mapping of the alphabet with char numbers of the font is weird. Thus I asked for a framework ora blueprint for the idea, so that I can implement the rules myself. My problem is, that the command as described above has problems with Tikz. – Titanlord Oct 08 '23 at 19:49
  • Numbers are a different problem: Tengwar uses base 12, therefore a 1:1 mapping of the number symbols does not work. The numbers first have to be extracted in some sense, computed into base 12 and then mapped to the number symbols in the font. I hope you understand my problem better now :D – Titanlord Oct 08 '23 at 19:51
  • No, text along path={\tengwar{...}} is not going to work. That's impossible: you have to pass one character at a time. – egreg Oct 08 '23 at 20:28
  • I hope the edit helps. The error (and a version, that makes a global change instead of just a string parameter) led to the fact that I was not so convinced of the command based version and rather thought of the font command. But for this I have too little deep LaTeX knowledge. – Titanlord Oct 08 '23 at 20:28
  • Have you looked at how tengwarscript works? Note that text along path puts constraints on what's possible, regardless of whether something is treated as a regular font or not. – cfr Oct 08 '23 at 21:12
  • Yes I know that package. My first problem is, that I'm not quite sure how to install it on macos. Additionally, it does not translate, it just gives commands for the symbols, which I could code myself :D – Titanlord Oct 09 '23 at 06:27
  • the transliteration isn't a font selection so while you could give it that top level syntax you can't make it be a font selection and work with along path or \setmainfont If you are using luatex I would look to using the input buffer callback to make the replacements on the fly so tex just sees the tengwar characters and all you need to do is select the font with standard font commands – David Carlisle Oct 09 '23 at 09:47
  • see for example https://tex.stackexchange.com/a/285634/1090 which is cyrillic not tengwar but same issues – David Carlisle Oct 09 '23 at 09:49
  • @DavidCarlisle I build the command and environment, but I have the same Tikz problem with both. Additionally this does not give me an easy global option (putting everything into the environment creates errors). – Titanlord Oct 09 '23 at 11:55
  • I stumbled across this post and the "switch like" structure (similar to commands like \centering (which are implemented differently)) is exactly what I want. I still got no clue, how to implement that... – Titanlord Oct 09 '23 at 18:41

0 Answers0