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.
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:28tengwarscriptworks? Note thattext along pathputs constraints on what's possible, regardless of whether something is treated as a regular font or not. – cfr Oct 08 '23 at 21:12along pathor\setmainfontIf 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