基于规则将 s 替换为 ſ(长 s)

基于规则将 s 替换为 ſ(长 s)

是否有办法在任何 LaTeX(LuaLaTex、LuaHBTeX、pdfTeX 等)中自动排版用标准“s”编写的文档,并在适当的情况下用长 s(ſ)代替?规则似乎主要与语言无关,可以在这里

这基本上与这个问题

我知道OpenType 字符变体方法和在 Latex 中生成长 s但这些都不能回答这个问题。

平均能量损失

\documentclass{article}

\usepackage[german,english]{babel}

\begin{document}
\section{s}
In German, the s stands (please no automatic replacement)
\begin{description}
    \item[At the end of a word]
        \foreignlanguage{german}{Das Haus, des Landes}
    \item[At the end of a syllable]
        \foreignlanguage{german}{dasselbe, Eispalast, Häuschen}
    \item[word gap s if the following word is self standing]
        \foreignlanguage{german}{Donnerstag, lostreten, deswegen}
    \item[a word gap s in case of a following suffix syllable which begins with a consonant]
        \foreignlanguage{german}{Häuslein, Wachstum, nachweisbar, Weisheit}
    \item[in loan word prefix syllables dis- and des-]
        \foreignlanguage{german}{Distribution, Desinfektion}
    \item[before d, k, m, n and w]
        \foreignlanguage{german}{Dresden, brüsk, Osman, Mesner, Oswald}
\end{description}
\section {ſ}
In German, the ſ stands (in the following example words s should be replaced by ſ   )
\begin{description}
    \item[at the beginning of a word]
        \foreignlanguage{german}{so, sieben}
    \item[at the beginning and inside of syllables]
        \foreignlanguage{german}{saufen, Wunsch, erstaunen}
    \item[at the end of a syllable except composita]
        \foreignlanguage{german}{Gasse, Wasser, Bissen, fassen}
    \item[before p, t and ch (sch trigraph)]
        \foreignlanguage{german}{Knospe, fast, löschen}
\end{description}
\section{ſſ}
The double ſſ stands (double replacement desired):
\begin{description}
    \item[if there is as short vowel before the first s and any vowel is following the second s]
        \foreignlanguage{german}{Adresse, müssen, Tasse, vergessen}
    \item[if a following e is omitted by an apostroph]
        \foreignlanguage{german}{ich lass' es sein}
    \item[in flexed forms of words that end with -as, -is, -nis and -us]
        \foreignlanguage{german}{die Ananasse, Wallisser Aprikosen, des Zeugnisses, des Busses}
\end{description}
\section{ß}
The Esszet ligature ſs ß stands:
\begin{description}
    \item[at the end of a word]
        \foreignlanguage{german}{muss, nass, Biss}
    \item[at the end of a syllable]
        \foreignlanguage{german}{hässlich, vergesslich} 
    \item[before a consonant]
        \foreignlanguage{german}{lasst, hasst, wisst, verpasst, verlässlich}
    \item[after a long vowel]
        \foreignlanguage{german}{grüssen, Strasse, fliessen}
    \item[after a diphtong]
        \foreignlanguage{german}{heissen, aussen, scheusslich}
\end{description}
joking: It's that easy!

Rules courtesy of \texttt{www.deutsch-kurrentschrift.de}
\end{document}

答案1

我正在开发一个新功能,babel旨在luatex实现这样的变化,尽管它基于语言,所以它有其局限性(毕竟babel是关于语言的)。它基于lua模式,下面是一个例子:

\documentclass{article}

\usepackage[german]{babel}

\babelfont{rm}{FreeSerif}

\babelprehyphenation{german}{s[a-eg-z]}
  { string = ſ,
    {}
  }
  
\begin{document}

abcs abcsde abcsfe

\end{document}

它打印“abcs abcſde abcsfe”。

编辑。说实话,我发现有些规则有点模糊,另一方面,有些规则显然无法以或多或少简单的方式执行(如何知道一个词是否是外来词?)。所以,解决方案是部分的,但我希望它能对类似的情况有所帮助,也可以作为进行测试和功能请求的起点(毕竟,正如我所说,我正在努力,所以这是个好时机!)。好吧,甚至贡献

相关内容