通过特征文件替换首字母以及混合规则

通过特征文件替换首字母以及混合规则

我尝试将替换规则添加到功能文件中通过功能文件定义初始变体,但第二个(非上下文)替换只有在第一个被注释掉时才有效。似乎不同类型的替换不能混合使用,除非添加一些东西。所以第一个问题是什么。

其次,我真正想要做的是将单词开头的 theta1 替换为 theta,这与对 beta 所做的相反:第四行应该等于最后一行。据推测这应该可以通过以下方式实现

ignore sub @greekletter theta';
sub theta by theta1;

但事实并非如此,至少在iknownnotwhat的情况下并非如此。

\documentclass{article}
\usepackage{fontspec,filecontents}

\begin{filecontents*}{junicode.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

@greekletter = [
Alphatonos anoteleia Epsilontonos Etatonos Iotatonos Omicrontonos Upsilontonos
Omegatonos iotadieresistonos Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota
Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega
Iotadieresis Upsilondieresis alphatonos epsilontonos etatonos iotatonos
upsilondieresistonos alpha beta gamma delta epsilon zeta eta theta iota kappa
lambda mu nu xi omicron pi rho sigma1 sigma tau upsilon phi chi psi omega
iotadieresis upsilondieresis omicrontonos upsilontonos omegatonos uni03D0
theta1 phi1 omega1 uni03D7 uni03D8 uni03D9 uni03DA uni03DB uni03DC uni03DD
];

feature calt {
        sub @greekletter beta' by uni03D0;
        sub theta by theta1;
} calt;
\end{filecontents*}

\setmainfont[FeatureFile={junicode.fea},Contextuals=Alternate]{junicode}

\begin{document}
\addfontfeature{Contextuals=NoAlternate}
βιβλίον\par
\addfontfeature{Contextuals=Alternate}
βιβλίον\par
\addfontfeature{Contextuals=NoAlternate}
θαυμαστὸς ἅνθρωπος.\par
\addfontfeature{Contextuals=Alternate}
θαυμαστὸς ἅνθρωπος.

\addfontfeature{Script=Greek,Style=Alternate}%
θ%
\addfontfeature{RawFeature={-salt}}%
αυμαστὸς ἅνθρωπος.
\end{document}

在此处输入图片描述

答案1

根据OpenType Cookbook,规则部分,小节“Common Gotcha”,当查找在任何地方包含上下文标记时,第二条规则也需要撇号。

但即使使用撇号,它在 LuaTeX 0.80 中也无法正常工作。这可能是一个错误。第二个错误揭示了 中的范围的使用@greekletters。然后我15在句号之前得到了数字。

下面的双重替换似乎为第一个问题提供了一种解决方法,通过明确指定字形名称而不使用范围可以避免第二个错误。

\documentclass{article}
\usepackage{fontspec,filecontents}

\begin{filecontents*}{junicode.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

@greekletter = [
    Alpha Alphatonos Beta Chi Delta Epsilon Epsilontonos Eta Etatonos
    Gamma Iota Iotadieresis Iotatonos Kappa Lambda Mu Nu Omega
    Omegatonos Omicron Omicrontonos Phi Pi Psi Rho Sigma Tau Theta
    Upsilon Upsilondieresis Upsilontonos Xi Zeta alpha alphatonos beta
    chi delta epsilon epsilontonos eta etatonos gamma iota iotadieresis
    iotadieresistonos iotatonos kappa lambda mu nu omega omega1
    omegatonos omicron omicrontonos phi phi1 pi psi rho sigma sigma1 tau
    theta theta1 uni03D0 uni03D7 uni03D8 uni03D9 uni03DA uni03DB uni03DC
    uni03DD uni03E0 uni03E1 uni03F0 uni03F1 uni1F00 uni1F01 uni1F02
    uni1F03 uni1F04 uni1F05 uni1F06 uni1F07 uni1F08 uni1F09 uni1F0A
    uni1F0B uni1F0C uni1F0D uni1F0E uni1F0F uni1F10 uni1F11 uni1F12
    uni1F13 uni1F14 uni1F15 uni1F18 uni1F19 uni1F1A uni1F1B uni1F1C
    uni1F1D uni1F20 uni1F21 uni1F22 uni1F23 uni1F24 uni1F25 uni1F26
    uni1F27 uni1F28 uni1F29 uni1F2A uni1F2B uni1F2C uni1F2D uni1F2E
    uni1F2F uni1F30 uni1F31 uni1F32 uni1F33 uni1F34 uni1F35 uni1F36
    uni1F37 uni1F38 uni1F39 uni1F3A uni1F3B uni1F3C uni1F3D uni1F3E
    uni1F3F uni1F40 uni1F41 uni1F42 uni1F43 uni1F44 uni1F45 uni1F48
    uni1F49 uni1F4A uni1F4B uni1F4C uni1F4D uni1F50 uni1F51 uni1F52
    uni1F53 uni1F54 uni1F55 uni1F56 uni1F57 uni1F59 uni1F5B uni1F5D
    uni1F5F uni1F60 uni1F61 uni1F62 uni1F63 uni1F64 uni1F65 uni1F66
    uni1F67 uni1F68 uni1F69 uni1F6A uni1F6B uni1F6C uni1F6D uni1F6E
    uni1F6F uni1F70 uni1F71 uni1F72 uni1F73 uni1F74 uni1F75 uni1F76
    uni1F77 uni1F78 uni1F79 uni1F7A uni1F7B uni1F7C uni1F7D uni1F80
    uni1F81 uni1F82 uni1F83 uni1F84 uni1F85 uni1F86 uni1F87 uni1F88
    uni1F89 uni1F8A uni1F8B uni1F8C uni1F8D uni1F8E uni1F8F uni1F90
    uni1F91 uni1F92 uni1F93 uni1F94 uni1F95 uni1F96 uni1F97 uni1F98
    uni1F99 uni1F9A uni1F9B uni1F9C uni1F9D uni1F9E uni1F9F uni1FA0
    uni1FA1 uni1FA2 uni1FA3 uni1FA4 uni1FA5 uni1FA6 uni1FA7 uni1FA8
    uni1FA9 uni1FAA uni1FAB uni1FAC uni1FAD uni1FAE uni1FAF uni1FB0
    uni1FB1 uni1FB2 uni1FB3 uni1FB4 uni1FB6 uni1FB7 uni1FB8 uni1FB9
    uni1FBA uni1FBB uni1FBC uni1FBE uni1FC2 uni1FC3 uni1FC4 uni1FC6
    uni1FC7 uni1FC8 uni1FC9 uni1FCA uni1FCB uni1FCC uni1FD0 uni1FD1
    uni1FD2 uni1FD3 uni1FD6 uni1FD7 uni1FD8 uni1FD9 uni1FDA uni1FDB
    uni1FE0 uni1FE1 uni1FE2 uni1FE3 uni1FE4 uni1FE5 uni1FE6 uni1FE7
    uni1FE8 uni1FE9 uni1FEA uni1FEB uni1FEC uni1FF2 uni1FF3 uni1FF4
    uni1FF6 uni1FF7 uni1FF8 uni1FF9 uni1FFA uni1FFB uni1FFC upsilon
    upsilondieresis upsilondieresistonos upsilontonos xi zeta
];

feature calt {
    # The following two lines don't work in LuaTeX 0.80
    #     ignore sub @greekletter theta';
    #     sub theta' by theta1;
    # Workaround:
    lookup replace_all_theta {
        sub theta by theta1;
    } replace_all_theta;
    lookup switch_inner_theta_back {
        sub @greekletter theta1' by theta;
    } switch_inner_theta_back;

    # Rule for replacing inner beta
    lookup inner_beta {
        sub @greekletter beta' by uni03D0;
    } inner_beta;
} calt;
\end{filecontents*}

\setmainfont[FeatureFile={junicode.fea},Contextuals=Alternate]{junicode}

\begin{document}
\addfontfeature{Contextuals=Alternate}
βιβλίον\par
θαυμαστὸς ἅνθρωπος.\par
\end{document}

结果

相关内容