用不同的颜色书写辅音、元音和重音符号的圣经希伯来语文本

用不同的颜色书写辅音、元音和重音符号的圣经希伯来语文本

我遇到了以下问题:我正在使用用 XeTeX 编写的圣经希伯来语文本,但我想为辅音以及元音和重音符号添加不同的颜色。我读过在不改变基本角色颜色的情况下对组合角色进行着色,但所建议的方法似乎太费力了。

那么,有没有一种更直接的方法来为每个unicode符号(或者可能是整个连续的unicode符号范围)分配一个单独的颜色 - 或多或少是永久的?例如,如链接示例中所示,我希望所有辅音都显示为黑色,所有元音符号都显示为红色,所有重音符号都显示为蓝色。

答案1

您可以在 LuaLaTeX 中执行此操作,它允许您(在大多数情况下)简单地将希伯来语复制并粘贴到文档正文中。\begin{otherlanguage}{hebrew}在从左到右和从右到左的段落、部分和表格之间切换时,您需要一个语言标签(例如)。除了下面提到的几个错误外,它基本上可以正常工作。

最新答案

此版本与其他版本相比有一些改进。它重新定义了原始字体的大多数(但不是全部)字形替换。如果渲染问题并不像使所有元音和只有元音具有相同的颜色那么重要,您可能更喜欢下面我的第一个答案。

\documentclass{article}
\tracinglostchars=3 % Panic if a font does not contain the character we need.
\usepackage[svgnames]{xcolor}
\usepackage{ luacode, luatexbase, luacolor }
\usepackage{inputnormalization}
% The input should be normalized to NFD form in order to correctly display
% ligatures.
\Uinputnormalization=2
\usepackage[bidi=basic, layout=sectioning.tabular, english]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{newunicodechar}

\babelprovide[import=he, onchar=fonts ids]{hebrew}

\begin{luacode*}
fonts.handlers.otf.addfeature {
  -- Currently unused.
  name = "xdsh", -- Disable unwanted shuruk and holam male ligatures. Happens too late to add color.
  type ="multiple",
  data = {
    [0xfb35] = { 0x05d5, 0x05bc },
    [0xfb4b] = { 0x05d5, 0x05b9 },
  },
}

fonts.handlers.otf.addfeature {
  name = "xalt",
  type = "chainsubstitution",
  lookups = {
    {
      type = "substitution", -- 1
      data = {
        ["sheva"] = "sheva_for_finalkaf",
        ["qamats"] = "qamats_for_finalkaf",
      },
    },
    {
      type = "substitution", -- 2
      data = {
        ["holamhaser"] = "holam",
      },
    },
    {
      type = "substitution", -- 3
      data = {
       [ "hiriq"] = "hiriqmem",
      },
    },
    {
      type = "substitution", -- 4
      data = {
        ["ayin"] = "ayin.alt",
      },
    },
  },
  data = {
    rules = {
      {
        before = { {"finalkaf"} }, -- This needs to work for final kaf with tafa, too.
        current = { {"sheva", "qamats"} },
        lookups = { 1 },
      },
      {
        current = { {"holamhaser"} },
        lookups = { 2 },
      },
      {
        before = { { "finalmem", "finalmem.wide" } }, -- Should allow intervening vowels and taamim.
        current = { {"hiriq"} },
        after = { { "patah", "qamats" } },
        lookups = { 3 },
      },
      {
        current = { {"ayin"} },
        -- Should support many other combinations, including accents between the ayin and an accent below.
        after = { { "atnah", "tipeha", "yetiv", "tevir", "atnahhafukh",
                    "munah", "mahapakh", "merkha", "merkhakefula", "darga",
                    "yerahbenyomo", "dehi", "sheva", "hatafsegol",
                    "hatafpatah", "hatafqamats", "hiriq", "tsere", "segol",
                    "patah", "qamats", "qubuts", "meteg", "qamatsqatan",
                    "hatafsegol_meteg", "hatafpatah_meteg",
                    "hatafqamats_meteg" } },
        lookups = { 4 },
      },
    },
  },
}

fonts.handlers.otf.addfeature {
  name = "xlig", -- User-defined replacement ligatures
  type = "ligature",
  data = {
    ["vavvav"] = { "vav", "vav" },
    ["vavyod"] = { "vav", "yod" },
    ["yodyod"] = { "yod", "yod" },
    -- Of the dagesh ligatures, only vav, zayin, yod and nun are defined in
    -- Taamey Ashkenaz of which vavdagesh, AKA shuruk, is intentionally
    -- omitted.
    ["zayindagesh"] = { "zayin", "dagesh" },
    ["yoddagesh"] = { "yod", "dagesh" },
    ["nundagesh"] = { "nun", "dagesh" },
    -- vavholam is intentionally omitted.
    -- None of the rafe ligatures are defined in Taamey Ashkenaz
    ["shinshindot.thin"] = { "shin.thin", "shindot" },
    ["shinsindot.thin"] = { "shin.thin", "sindot" },
    ["zayindagesh.thin"] = { "zayin.thin", "dagesh" },
    ["yoddagesh.thin"] = { "yod.thin", "dagesh" },
    ["nundagesh.thin"] = { "nun.thin", "dagesh" },
    ["hatafsegol_meteg"] = { "hatafsegol", "zerojoin", "meteg" },
    ["hatafpatah_meteg"] = { "hatafmatah", "zerojoin", "meteg" },
    ["hatafqamats_meteg"] = { "hatafqamats", "zerojoin", "meteg" },
    ["aleflamed"] = { "alef", "zerojoin", "lamed" },
  },
}

fonts.handlers.otf.addfeature {
  name = "xkrn", -- custom kern
  type = "pair",
  data = {
    ["vav"] = {
      ["holam"] = { -- AKA holam male
        false, { 300, 0, 0, 0 } -- Tuned for Taamey Ashkenaz
      },
    },
  },
}
\end{luacode*}

\defaultfontfeatures{ Scale=MatchUppercase }

% Taamey Ashkenaz and other Culmus fonts with Taamim are available, libre, at:
% https://culmus.sourceforge.io/taamim/index.html
% If you want Hebrew letters that slant from left to right rather than right
% to left, replace the ItalicFont= and BoldItalicFont= features with
% AutoFakeSlant = 0.15
\defaultfontfeatures[TaameyAshkenaz]{
  RawFeature = {-ccmp,+xlig,+xalt,+xkrn},
  UprightFont = *-Medium,
  BoldFont = *-Bold,
  ItalicFont = *-MediumOblique,
  BoldItalicFont = *-BoldOblique,
  Extension = .ttf }

\babelfont{rm}
          [Scale=1.0, Language=Default]{TaameyAshkenaz}
\babelfont[english]{rm}
          [Language=Default]{TeX Gyre Schola}

\newcommand\niqqudcolor{DarkOrange}
\newcommand\taameycolor{DarkCyan}

% In order to make shuruk behave differently from dagesh, we need some state:
\makeatletter
\newif\ifafter@vav@
\after@vav@false
\newcommand\DeclareHeBase[1]{\newunicodechar{#1}{\after@vav@false #1}}
\DeclareHeBase{^^^^05d0} % alef
\DeclareHeBase{^^^^05d1} % bet
\DeclareHeBase{^^^^05d2} % gimel
\DeclareHeBase{^^^^05d3} % dalet
\DeclareHeBase{^^^^05d4} % he
\newunicodechar{^^^^05d5}{\after@vav@true ^^^^05d5} % vav
\DeclareHeBase{^^^^05d6} % zayin
\DeclareHeBase{^^^^05d7} % het
\DeclareHeBase{^^^^05d8} % tet
\DeclareHeBase{^^^^05d9} % yod
\DeclareHeBase{^^^^05da} % final qof
\DeclareHeBase{^^^^05db} % qof
\DeclareHeBase{^^^^05dc} % lamed
\DeclareHeBase{^^^^05dd} % final mem
\DeclareHeBase{^^^^05de} % mem
\DeclareHeBase{^^^^05df} % final nun
\DeclareHeBase{^^^^05e0} % nun
\DeclareHeBase{^^^^05e1} % samekh
\DeclareHeBase{^^^^05e2} % ayin
\DeclareHeBase{^^^^05e3} % final pe
\DeclareHeBase{^^^^05e4} % pe
\DeclareHeBase{^^^^05e5} % final tsadi
\DeclareHeBase{^^^^05e6} % tsadi
\DeclareHeBase{^^^^05e7} % qof
\DeclareHeBase{^^^^05e8} % resh
\DeclareHeBase{^^^^05e9} % shin
\DeclareHeBase{^^^^05ea} % tav
\DeclareHeBase{^^^^00a0} % non-breaking space
\DeclareHeBase{^^^^25cc} % dotted circle

%Omitted: base letters that do not appear in NFD-normalized Biblical Hebrew.

% U+05BC needs to be check whether it is a dagesh, mapiq or shuruq:
\newunicodechar{^^^^05bc}{%
  \ifafter@vav@%
    {\textcolor{\niqqudcolor}{^^^^05bc}}%
    \else\textcolor{Red}{^^^^05bc}%
  \fi%
}

\newcommand\DeclareTaamey[1]{\newunicodechar{#1}{\textcolor{\taameycolor}{#1}}}
\DeclareTaamey{^^^^0591} % etnahta
\DeclareTaamey{^^^^0592} % segol
\DeclareTaamey{^^^^0593} % shalshelet
\DeclareTaamey{^^^^0594} % zakef qatan
\DeclareTaamey{^^^^0595} % zakef gadol
\DeclareTaamey{^^^^0596} % tipcha
\DeclareTaamey{^^^^0597} % revia
\DeclareTaamey{^^^^0598} % zarqa
\DeclareTaamey{^^^^0599} % pashta
\DeclareTaamey{^^^^059a} % yehiv
\DeclareTaamey{^^^^059b} % tevir
\DeclareTaamey{^^^^059c} % qeresh
\DeclareTaamey{^^^^059d} % weresh muqdam
\DeclareTaamey{^^^^059e} % gershayim
\DeclareTaamey{^^^^059f} % qarney para
\DeclareTaamey{^^^^05a0} % telishah gedola
\DeclareTaamey{^^^^05a1} % pazer
\DeclareTaamey{^^^^05a2} % atnah hafukh
\DeclareTaamey{^^^^05a3} % munah
\DeclareTaamey{^^^^05a4} % mahapakh
\DeclareTaamey{^^^^05a5} % merkha
\DeclareTaamey{^^^^05a6} % merkha kefula
\DeclareTaamey{^^^^05a7} % darga
\DeclareTaamey{^^^^05a8} % qadma
\DeclareTaamey{^^^^05a9} % telisha qetana
\DeclareTaamey{^^^^05aa} % yerah ben yomo
\DeclareTaamey{^^^^05ab} % ole
\DeclareTaamey{^^^^05ac} % iluy
\DeclareTaamey{^^^^05ad} % dehi
\DeclareTaamey{^^^^05ae} % zinor
\DeclareTaamey{^^^^05c0} % paseq
\DeclareTaamey{^^^^05c3} % sof pasuq
\DeclareTaamey{^^^^05c4} % upper dot
\DeclareTaamey{^^^^05c5} % lower dot
\DeclareTaamey{^^^^05f3} % geresh
\DeclareTaamey{^^^^05f4} % gershayim

\newcommand\DeclareNiqqud[1]{\newunicodechar{#1}{\textcolor{\niqqudcolor}{#1}}}
\DeclareNiqqud{^^^^05b0} % sheva
\DeclareNiqqud{^^^^05b1} % hataf segol
\DeclareNiqqud{^^^^05b2} % hataf paqah
\DeclareNiqqud{^^^^05b3} % hataf qamats
\DeclareNiqqud{^^^^05b4} % hiriq
\DeclareNiqqud{^^^^05b5} % tsere
\DeclareNiqqud{^^^^05b6} % segol
\DeclareNiqqud{^^^^05b7} % patah
\DeclareNiqqud{^^^^05b8} % qamatz
\DeclareNiqqud{^^^^05b9} % holam
\DeclareNiqqud{^^^^05ba} % holam haser
\DeclareNiqqud{^^^^05bb} % qubuts
\DeclareNiqqud{^^^^05bd} % meteg
\DeclareNiqqud{^^^^05c7} % qamats qatan

% Alphabetic presentation forms that need special handling
%\DeclareNiqqud{^^^^fb4b}
%\DeclareNiqqud{^^^^fb35}

% Intentionally not colored: shin dot, sin dot, rafe, maqaf, nun hafukha
\makeatother

% Improves layout of paragraphs with long, un-hyphenatable words:
\emergencystretch=3em

\begin{document}
\begin{otherlanguage}{hebrew}
\section*{קדושים}

\noindent
וּֽבְקֻצְרְכֶם֙ אֶת־קְצִ֣יר אַרְצְכֶ֔ם לֹ֧א תְכַלֶּ֛ה פְּאַ֥ת שָׂדְךָ֖ לִקְצֹ֑ר וְלֶ֥קֶט קְצִֽירְךָ֖ לֹ֥א תְלַקֵּֽט׃
וְכַרְמְךָ֙ לֹ֣א תְעוֹלֵ֔ל וּפֶ֥רֶט כַּרְמְךָ֖ לֹ֣א תְלַקֵּ֑ט לֶֽעָנִ֤י וְלַגֵּר֙ תַּעֲזֹ֣ב אֹתָ֔ם אֲנִ֖י יְהֹוָ֥ה אֱלֹהֵיכֶֽם׃
וְלֹֽא־תִשָּׁבְע֥וּ בִשְׁמִ֖י לַשָּׁ֑קֶר וְחִלַּלְתָּ֛ אֶת־שֵׁ֥ם אֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹֽא־תַעֲשֹׁ֥ק אֶת־רֵֽעֲךָ֖ וְלֹ֣א תִגְזֹ֑ל לֹֽא־תָלִ֞ין פְּעֻלַּ֥ת שָׂכִ֛יר אִתְּךָ֖ עַד־בֹּֽקֶר׃
לֹא־תְקַלֵּ֣ל חֵרֵ֔שׁ וְלִפְנֵ֣י עִוֵּ֔ר לֹ֥א תִתֵּ֖ן מִכְשֹׁ֑ל וְיָרֵ֥אתָ מֵּאֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹא־תַעֲשׂ֥וּ עָ֙וֶל֙ בַּמִּשְׁפָּ֔ט לֹא־תִשָּׂ֣א פְנֵי־דָ֔ל וְלֹ֥א תֶהְדַּ֖ר פְּנֵ֣י גָד֑וֹל בְּצֶ֖דֶק תִּשְׁפֹּ֥ט עֲמִיתֶֽךָ׃
לֹא־תֵלֵ֤ךְ רָכִיל֙ בְּעַמֶּ֔יךָ לֹ֥א תַעֲמֹ֖ד עַל־דַּ֣ם רֵעֶ֑ךָ אֲנִ֖י יְהֹוָֽה׃
לֹֽא־תִשְׂנָ֥א אֶת־אָחִ֖יךָ בִּלְבָבֶ֑ךָ הוֹכֵ֤חַ תּוֹכִ֙יחַ֙ אֶת־עֲמִיתֶ֔ךָ וְלֹא־תִשָּׂ֥א עָלָ֖יו חֵֽטְא׃
לֹֽא־תִקֹּ֤ם וְלֹֽא־תִטֹּר֙ אֶת־בְּנֵ֣י עַמֶּ֔ךָ וְאָֽהַבְתָּ֥ לְרֵעֲךָ֖ כָּמ֑וֹךָ אֲנִ֖י יְהֹוָֽה׃
\end{otherlanguage}


This is followed by, {הַגָּ֣ר אִתְּכֶ֗ם וְאָהַבְתָּ֥ לוֹ֙ כָּמ֔וֹךָ}.

\end{document}

塔米·阿什肯纳兹的凯多希姆

因此,您会注意到,ayin 现在通常会在应该显示时显示浅下行音,但并非总是如此。如果 ayin 带有 dagesh、holam 或 rafa,则不会起作用。最后一个 kaf 现在将在正确的位置显示元音,除非它还带有 rafe。而且 dalet 和 holam 雄性之间的 pashta 显示得太靠右了。

所有这些都是因为我还没有实现任何需要多个标记前瞻或后瞻的模式。

第一个答案

\documentclass{article}
\tracinglostchars=3 % Panic if a font does not contain the character we need.
\usepackage[svgnames]{xcolor}
\usepackage{luacolor}
\usepackage{inputnormalization}
% The code to set combining characters active assumes input in decomposed form.
% Setting input normalization should suffice for all real-world cases.  If,
% for some reason, you need to generate Hebrew text programmatically, please
% avoid generating any codepoints such as YOD WITH HIRIQ.  (Which is also
% not valid NFC since Unicode 3.0.)
\Uinputnormalization=2
\usepackage[bidi=basic, layout=sectioning.tabular, english]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{newunicodechar}

\babelprovide[import=he, onchar=fonts ids]{hebrew}
\defaultfontfeatures{ Ligatures=TeX, Scale=MatchUppercase }

% Taamey Ashkenaz and other Culmus fonts with Taamim are available, libre, at:
% https://culmus.sourceforge.io/taamim/index.html
% If you want Hebrew letters that slant from left to right rather than right
% to left, replace the ItalicFont= and BoldItalicFont= features with
% AutoFakeSlant = 0.15
\defaultfontfeatures[TaameyAshkenaz]{
  UprightFont = *-Medium,
  BoldFont = *-Bold,
  ItalicFont = *-MediumOblique,
  BoldItalicFont = *-BoldOblique,
  Extension = .ttf }

\babelfont{rm}
          [Scale=1.0, Language=Default]{TeX Gyre Schola}
\babelfont[hebrew]{rm}
          [Language=Default]{TaameyAshkenaz}

\newcommand\niqqudcolor{DarkOrange}
\newcommand\taameycolor{DarkCyan}
\newcommand\DeclareTaamey[1]{\newunicodechar{#1}{\textcolor{\taameycolor}{#1}}}
\DeclareTaamey{^^^^0591} % etnahta
\DeclareTaamey{^^^^0592} % segol
\DeclareTaamey{^^^^0593} % shalshelet
\DeclareTaamey{^^^^0594} % zakef qatan
\DeclareTaamey{^^^^0595} % zakef gadol
\DeclareTaamey{^^^^0596} % tipcha
\DeclareTaamey{^^^^0597} % revia
\DeclareTaamey{^^^^0598} % zarqa
\DeclareTaamey{^^^^0599} % pashta
\DeclareTaamey{^^^^059a} % yehiv
\DeclareTaamey{^^^^059b} % tevir
\DeclareTaamey{^^^^059c} % qeresh
\DeclareTaamey{^^^^059d} % weresh muqdam
\DeclareTaamey{^^^^059e} % gershayim
\DeclareTaamey{^^^^059f} % qarney para
\DeclareTaamey{^^^^05a0} % telishah gedola
\DeclareTaamey{^^^^05a1} % pazer
\DeclareTaamey{^^^^05a2} % atnah hafukh
\DeclareTaamey{^^^^05a3} % munah
\DeclareTaamey{^^^^05a4} % mahapakh
\DeclareTaamey{^^^^05a5} % merkha
\DeclareTaamey{^^^^05a6} % merkha kefula
\DeclareTaamey{^^^^05a7} % darga
\DeclareTaamey{^^^^05a8} % qadma
\DeclareTaamey{^^^^05a9} % telisha qetana
\DeclareTaamey{^^^^05aa} % yerah ben yomo
\DeclareTaamey{^^^^05ab} % ole
\DeclareTaamey{^^^^05ac} % iluy
\DeclareTaamey{^^^^05ad} % dehi
\DeclareTaamey{^^^^05ae} % zinor
\DeclareTaamey{^^^^05c0} % paseq
\DeclareTaamey{^^^^05c3} % sof pasuq
\DeclareTaamey{^^^^05c4} % upper dot
\DeclareTaamey{^^^^05c5} % lower dot
\DeclareTaamey{^^^^05f3} % geresh
\DeclareTaamey{^^^^05f4} % gershayim

\newcommand\DeclareNiqqud[1]{\newunicodechar{#1}{\textcolor{\niqqudcolor}{#1}}}
\DeclareNiqqud{^^^^05b0} % sheva
\DeclareNiqqud{^^^^05b1} % hataf segol
\DeclareNiqqud{^^^^05b2} % hataf paqah
\DeclareNiqqud{^^^^05b3} % hataf qamats
\DeclareNiqqud{^^^^05b4} % hiriq
\DeclareNiqqud{^^^^05b5} % tsere
\DeclareNiqqud{^^^^05b6} % segol
\DeclareNiqqud{^^^^05b7} % patah
\DeclareNiqqud{^^^^05b8} % qamatz
\DeclareNiqqud{^^^^05b9} % holam
\DeclareNiqqud{^^^^05ba} % holam haser
\DeclareNiqqud{^^^^05bb} % qubuts
\DeclareNiqqud{^^^^05bd} % meteg
\DeclareNiqqud{^^^^05c7} % qamats qatan

% Intentionally not colored: shin dot, sin dot, dagesh/mapiq, rafe, maqaf, nun hafukha

% Improves layout of paragraphs with long, un-hyphenatable words:
\emergencystretch=3em

\begin{document}
\begin{otherlanguage}{hebrew}
\section*{קדושים}

\noindent
וּֽבְקֻצְרְכֶם֙ אֶת־קְצִ֣יר אַרְצְכֶ֔ם לֹ֧א תְכַלֶּ֛ה פְּאַ֥ת שָׂדְךָ֖ לִקְצֹ֑ר וְלֶ֥קֶט קְצִֽירְךָ֖ לֹ֥א תְלַקֵּֽט׃
וְכַרְמְךָ֙ לֹ֣א תְעוֹלֵ֔ל וּפֶ֥רֶט כַּרְמְךָ֖ לֹ֣א תְלַקֵּ֑ט לֶֽעָנִ֤י וְלַגֵּר֙ תַּעֲזֹ֣ב אֹתָ֔ם אֲנִ֖י יְהֹוָ֥ה אֱלֹהֵיכֶֽם׃
וְלֹֽא־תִשָּׁבְע֥וּ בִשְׁמִ֖י לַשָּׁ֑קֶר וְחִלַּלְתָּ֛ אֶת־שֵׁ֥ם אֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹֽא־תַעֲשֹׁ֥ק אֶת־רֵֽעֲךָ֖ וְלֹ֣א תִגְזֹ֑ל לֹֽא־תָלִ֞ין פְּעֻלַּ֥ת שָׂכִ֛יר אִתְּךָ֖ עַד־בֹּֽקֶר׃
לֹא־תְקַלֵּ֣ל חֵרֵ֔שׁ וְלִפְנֵ֣י עִוֵּ֔ר לֹ֥א תִתֵּ֖ן מִכְשֹׁ֑ל וְיָרֵ֥אתָ מֵּאֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹא־תַעֲשׂ֥וּ עָ֙וֶל֙ בַּמִּשְׁפָּ֔ט לֹא־תִשָּׂ֣א פְנֵי־דָ֔ל וְלֹ֥א תֶהְדַּ֖ר פְּנֵ֣י גָד֑וֹל בְּצֶ֖דֶק תִּשְׁפֹּ֥ט עֲמִיתֶֽךָ׃
לֹא־תֵלֵ֤ךְ רָכִיל֙ בְּעַמֶּ֔יךָ לֹ֥א תַעֲמֹ֖ד עַל־דַּ֣ם רֵעֶ֑ךָ אֲנִ֖י יְהֹוָֽה׃
לֹֽא־תִשְׂנָ֥א אֶת־אָחִ֖יךָ בִּלְבָבֶ֑ךָ הוֹכֵ֤חַ תּוֹכִ֙יחַ֙ אֶת־עֲמִיתֶ֔ךָ וְלֹא־תִשָּׂ֥א עָלָ֖יו חֵֽטְא׃
לֹֽא־תִקֹּ֤ם וְלֹֽא־תִטֹּר֙ אֶת־בְּנֵ֣י עַמֶּ֔ךָ וְאָֽהַבְתָּ֥ לְרֵעֲךָ֖ כָּמ֑וֹךָ אֲנִ֖י יְהֹוָֽה׃
\end{otherlanguage}


This is followed by,
הַגָּ֣ר אִתְּכֶ֗ם וְאָהַבְתָּ֥ לוֹ֙ כָּמ֔וֹךָ.

\end{document}

凯多辛

至少对于这个特定的字体,这不能正确处理 shuruk 和 holam male。在这个字体中,它们被映射到上下文组合 וּ (U+FB35) 和 וֹ (U+FB4B)。分解会导致颜色被忽略。禁用上下文组合会破坏其他渲染。规范化规范化不会转换为预组合形式。

为了解决这个问题,您可以通过 Lua 回调以更复杂的方式拦截字形节点列表。

第二个答案

这是另一个修复了 shuruk 和 holam male 的版本。我认为对 לוֹ֙ (lamed vav holam pashta) 的处理有些不足。(编辑:因为我没有复制的许多默认字体替换之一将 lamed 左侧的 pashta 替换为 qadma。)

\documentclass{article}
\tracinglostchars=3 % Panic if a font does not contain the character we need.
\usepackage[svgnames]{xcolor}
\usepackage{ luacode, luatexbase, luacolor }
\usepackage{inputnormalization}
% The input should be normalized to NFD form in order to correctly display
% ligatures.
\Uinputnormalization=2
\usepackage[bidi=basic, layout=sectioning.tabular, english]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{newunicodechar}

\babelprovide[import=he, onchar=fonts ids]{hebrew}

\begin{luacode*}
fonts.handlers.otf.addfeature {
  name = "xalt",
  type = "chainsubstitution",
  lookups = {
    {
      type = "substitution",
      data = {
        ["sheva"] = "sheva_for_finalkaf",
        ["qamats"] = "qamats_for_finalkaf",
      },
    },
  },
  data = {
    rules = {
      {
        before = { {"finalkaf"} },
        current = { {"sheva", "qamats"} },
        lookups = { 1 },
      },
    },
  },
}

fonts.handlers.otf.addfeature {
  name = "xlig", -- User-defined replacement ligatures
  type = "ligature",
  data = {
    ["vavvav"] = { "vav", "vav" },
    ["vavyod"] = { "vav", "yod" },
    ["yodyod"] = { "yod", "yod" },
    -- Of the dagesh ligatures, only vav, zayin, yod and nun are defined in
    -- Taamey Ashkenaz of which vavdagesh, AKA shuruk, is intentionally
    -- omitted.
    ["zayindagesh"] = { "zayin", "dagesh" },
    ["yoddagesh"] = { "yod", "dagesh" },
    ["nundagesh"] = { "nun", "dagesh" },
    -- vavholam is intentionally omitted.
    -- None of the rafe ligatures are defined in Taamey Ashkenaz
    ["shinshindot.thin"] = { "shin.thin", "shindot" },
    ["shinsindot.thin"] = { "shin.thin", "sindot" },
    ["zayindagesh.thin"] = { "zayin.thin", "dagesh" },
    ["yoddagesh.thin"] = { "yod.thin", "dagesh" },
    ["nundagesh.thin"] = { "nun.thin", "dagesh" },
    ["hatafsegol_meteg"] = { "hatafsegol", "zerojoin", "meteg" },
    ["hatafpatah_meteg"] = { "hatafmatah", "zerojoin", "meteg" },
    ["hatafqamats_meteg"] = { "hatafqamats", "zerojoin", "meteg" },
    ["aleflamed"] = { "alef", "zerojoin", "lamed" },
  },
}

fonts.handlers.otf.addfeature {
  name = "xkrn", -- custom kern
  type = "pair",
  data = {
    ["vav"] = {
      ["holam"] = { -- AKA holam male
        false, { 300, 0, 0, 0 } -- Tuned for Taamey Ashkenaz
      },
    },
  },
}
\end{luacode*}

\defaultfontfeatures{ Scale=MatchUppercase }

% Taamey Ashkenaz and other Culmus fonts with Taamim are available, libre, at:
% https://culmus.sourceforge.io/taamim/index.html
% If you want Hebrew letters that slant from left to right rather than right
% to left, replace the ItalicFont= and BoldItalicFont= features with
% AutoFakeSlant = 0.15
\defaultfontfeatures[TaameyAshkenaz]{
  UprightFont = *-Medium,
  BoldFont = *-Bold,
  ItalicFont = *-MediumOblique,
  BoldItalicFont = *-BoldOblique,
  RawFeature={-ccmp, -calt, +xalt, +xlig, +xkrn},
  Extension = .ttf }

\babelfont{rm}
          [Scale=1.0, Language=Default]{TaameyAshkenaz}
\babelfont[english]{rm}
          [Language=Default]{TeX Gyre Schola}

\newcommand\niqqudcolor{DarkOrange}
\newcommand\taameycolor{DarkCyan}

% In order to make shuruk behave differently from dagesh, we need some state:
\makeatletter
\newif\ifafter@vav@
\after@vav@false
\newcommand\DeclareHeBase[1]{\newunicodechar{#1}{\after@vav@false #1}}
\DeclareHeBase{^^^^05d0} % alef
\DeclareHeBase{^^^^05d1} % bet
\DeclareHeBase{^^^^05d2} % gimel
\DeclareHeBase{^^^^05d3} % dalet
\DeclareHeBase{^^^^05d4} % he
\newunicodechar{^^^^05d5}{\after@vav@true ^^^^05d5} % vav
\DeclareHeBase{^^^^05d6} % zayin
\DeclareHeBase{^^^^05d7} % het
\DeclareHeBase{^^^^05d8} % tet
\DeclareHeBase{^^^^05d9} % yod
\DeclareHeBase{^^^^05da} % final qof
\DeclareHeBase{^^^^05db} % qof
\DeclareHeBase{^^^^05dc} % lamed
\DeclareHeBase{^^^^05dd} % final mem
\DeclareHeBase{^^^^05de} % mem
\DeclareHeBase{^^^^05df} % final nun
\DeclareHeBase{^^^^05e0} % nun
\DeclareHeBase{^^^^05e1} % samekh
\DeclareHeBase{^^^^05e2} % ayin
\DeclareHeBase{^^^^05e3} % final pe
\DeclareHeBase{^^^^05e4} % pe
\DeclareHeBase{^^^^05e5} % final tsadi
\DeclareHeBase{^^^^05e6} % tsadi
\DeclareHeBase{^^^^05e7} % qof
\DeclareHeBase{^^^^05e8} % resh
\DeclareHeBase{^^^^05e9} % shin
\DeclareHeBase{^^^^05ea} % tav
\DeclareHeBase{^^^^00a0} % non-breaking space
\DeclareHeBase{^^^^25cc} % dotted circle

%Omitted: base letters that do not appear in NFD-normalized Biblical Hebrew.

% U+05BC needs to be check whether it is a dagesh, mapiq or shuruq:
\newunicodechar{^^^^05bc}{%
  \ifafter@vav@%
    {\textcolor{\niqqudcolor}{^^^^05bc}}%
    \else{^^^^05bc}%
  \fi%
}

\newcommand\DeclareTaamey[1]{\newunicodechar{#1}{\textcolor{\taameycolor}{#1}}}
\DeclareTaamey{^^^^0591} % etnahta
\DeclareTaamey{^^^^0592} % segol
\DeclareTaamey{^^^^0593} % shalshelet
\DeclareTaamey{^^^^0594} % zakef qatan
\DeclareTaamey{^^^^0595} % zakef gadol
\DeclareTaamey{^^^^0596} % tipcha
\DeclareTaamey{^^^^0597} % revia
\DeclareTaamey{^^^^0598} % zarqa
\DeclareTaamey{^^^^0599} % pashta
\DeclareTaamey{^^^^059a} % yehiv
\DeclareTaamey{^^^^059b} % tevir
\DeclareTaamey{^^^^059c} % qeresh
\DeclareTaamey{^^^^059d} % weresh muqdam
\DeclareTaamey{^^^^059e} % gershayim
\DeclareTaamey{^^^^059f} % qarney para
\DeclareTaamey{^^^^05a0} % telishah gedola
\DeclareTaamey{^^^^05a1} % pazer
\DeclareTaamey{^^^^05a2} % atnah hafukh
\DeclareTaamey{^^^^05a3} % munah
\DeclareTaamey{^^^^05a4} % mahapakh
\DeclareTaamey{^^^^05a5} % merkha
\DeclareTaamey{^^^^05a6} % merkha kefula
\DeclareTaamey{^^^^05a7} % darga
\DeclareTaamey{^^^^05a8} % qadma
\DeclareTaamey{^^^^05a9} % telisha qetana
\DeclareTaamey{^^^^05aa} % yerah ben yomo
\DeclareTaamey{^^^^05ab} % ole
\DeclareTaamey{^^^^05ac} % iluy
\DeclareTaamey{^^^^05ad} % dehi
\DeclareTaamey{^^^^05ae} % zinor
\DeclareTaamey{^^^^05c0} % paseq
\DeclareTaamey{^^^^05c3} % sof pasuq
\DeclareTaamey{^^^^05c4} % upper dot
\DeclareTaamey{^^^^05c5} % lower dot
\DeclareTaamey{^^^^05f3} % geresh
\DeclareTaamey{^^^^05f4} % gershayim

\newcommand\DeclareNiqqud[1]{\newunicodechar{#1}{\textcolor{\niqqudcolor}{#1}}}
\DeclareNiqqud{^^^^05b0} % sheva
\DeclareNiqqud{^^^^05b1} % hataf segol
\DeclareNiqqud{^^^^05b2} % hataf paqah
\DeclareNiqqud{^^^^05b3} % hataf qamats
\DeclareNiqqud{^^^^05b4} % hiriq
\DeclareNiqqud{^^^^05b5} % tsere
\DeclareNiqqud{^^^^05b6} % segol
\DeclareNiqqud{^^^^05b7} % patah
\DeclareNiqqud{^^^^05b8} % qamatz
\DeclareNiqqud{^^^^05b9} % holam
\DeclareNiqqud{^^^^05ba} % holam haser
\DeclareNiqqud{^^^^05bb} % qubuts
\DeclareNiqqud{^^^^05bd} % meteg
\DeclareNiqqud{^^^^05c7} % qamats qatan

% Alphabetic presentation forms that need special handling
%\DeclareNiqqud{^^^^fb4b}
%\DeclareNiqqud{^^^^fb35}

% Intentionally not colored: shin dot, sin dot, rafe, maqaf, nun hafukha
\makeatother

% Improves layout of paragraphs with long, un-hyphenatable words:
\emergencystretch=3em

\begin{document}
\begin{otherlanguage}{hebrew}
\section*{קדושים}

\noindent
וּֽבְקֻצְרְכֶם֙ אֶת־קְצִ֣יר אַרְצְכֶ֔ם לֹ֧א תְכַלֶּ֛ה פְּאַ֥ת שָׂדְךָ֖ לִקְצֹ֑ר וְלֶ֥קֶט קְצִֽירְךָ֖ לֹ֥א תְלַקֵּֽט׃
וְכַרְמְךָ֙ לֹ֣א תְעוֹלֵ֔ל וּפֶ֥רֶט כַּרְמְךָ֖ לֹ֣א תְלַקֵּ֑ט לֶֽעָנִ֤י וְלַגֵּר֙ תַּעֲזֹ֣ב אֹתָ֔ם אֲנִ֖י יְהֹוָ֥ה אֱלֹהֵיכֶֽם׃
וְלֹֽא־תִשָּׁבְע֥וּ בִשְׁמִ֖י לַשָּׁ֑קֶר וְחִלַּלְתָּ֛ אֶת־שֵׁ֥ם אֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹֽא־תַעֲשֹׁ֥ק אֶת־רֵֽעֲךָ֖ וְלֹ֣א תִגְזֹ֑ל לֹֽא־תָלִ֞ין פְּעֻלַּ֥ת שָׂכִ֛יר אִתְּךָ֖ עַד־בֹּֽקֶר׃
לֹא־תְקַלֵּ֣ל חֵרֵ֔שׁ וְלִפְנֵ֣י עִוֵּ֔ר לֹ֥א תִתֵּ֖ן מִכְשֹׁ֑ל וְיָרֵ֥אתָ מֵּאֱלֹהֶ֖יךָ אֲנִ֥י יְהֹוָֽה׃
לֹא־תַעֲשׂ֥וּ עָ֙וֶל֙ בַּמִּשְׁפָּ֔ט לֹא־תִשָּׂ֣א פְנֵי־דָ֔ל וְלֹ֥א תֶהְדַּ֖ר פְּנֵ֣י גָד֑וֹל בְּצֶ֖דֶק תִּשְׁפֹּ֥ט עֲמִיתֶֽךָ׃
לֹא־תֵלֵ֤ךְ רָכִיל֙ בְּעַמֶּ֔יךָ לֹ֥א תַעֲמֹ֖ד עַל־דַּ֣ם רֵעֶ֑ךָ אֲנִ֖י יְהֹוָֽה׃
לֹֽא־תִשְׂנָ֥א אֶת־אָחִ֖יךָ בִּלְבָבֶ֑ךָ הוֹכֵ֤חַ תּוֹכִ֙יחַ֙ אֶת־עֲמִיתֶ֔ךָ וְלֹא־תִשָּׂ֥א עָלָ֖יו חֵֽטְא׃
לֹֽא־תִקֹּ֤ם וְלֹֽא־תִטֹּר֙ אֶת־בְּנֵ֣י עַמֶּ֔ךָ וְאָֽהַבְתָּ֥ לְרֵעֲךָ֖ כָּמ֑וֹךָ אֲנִ֖י יְהֹוָֽה׃
\end{otherlanguage}


This is followed by, {הַגָּ֣ר אִתְּכֶ֗ם וְאָהַבְתָּ֥ לוֹ֙ כָּמ֔וֹךָ}.

\end{document}

凯多辛

答案2

我曾经尝试为校对时使用连字颜色。我希望它们更突出。LaTeX 自动使用连字来表示 ffl ffi 和此类字母组合。然而,德语的排版规则不允许使用连字。因此,为了真正看到 LaTeX 插入连字的位置,de.comp.text.tex 上发起的讨论促成了使用 Tex 的虚拟字体来实现这一目的的想法。

我在 2006 年就成功地使用 MiKTeX 发行版实现了这一点,所以如果我没有把所有细节都说清楚,请多多包涵。基本上,我改变了每个虚拟字体的字形颜色。

我使用命令行工具vftovp将现有文件转换.vf.vpl文件。(虚拟属性列表)通过testfont /table我检查字体中可用的连字符,然后更改文件中的条目.vpl

(CHARACTER O 33
    (CHARWD R 0.777781)
    (CHARHT R 0.683332)
    (MAP
        (SPECIAL pdf:direct: 1.0 0 0 rg)
        (SETCHAR O 2)
        (SPECIAL pdf:direct: 0 0 0 rg)
    )
)

然后通过将它们编译vptovf.vf文件,然后使用彩色连字符pdflatex生成.pdfs。这两个特殊命令将颜色切换为红色,然后切换回黑色。这是一个非常粗暴的黑客行为!但当时它有效。由于整个 LaTeX 字体业务并不适合胆小的人,因此可能需要对当前的 TeX 发行版进行一些实验。

如果您必须创建新的虚拟字体,请选择您想要的字体作为基础字体。在您的例子中是希伯来语字体。由于我对 XeTeX 了解不多,我使用 helvetica 克隆 ( phvr8r) 继续此示例。

tftopl phvr8r.tfm > myfont.vpl

应该会为您提供人类可读的虚拟属性列表。现在可以编辑了。例如以下行

(MAPFONT D 0 (FONTNAME phvr8r))
(MAPFONT D 1 (FONTNAME pcrr8r))

加载phvr8r(我们的基础字体)和pcrr8r(Courier)。现在您必须知道要更改哪些字符。

(CHARACTER O 65
   (CHARWD R 0.8)
   (MAP
      (SELECTFONT D 1)
      (SETCHAR O 045)
      (MOVELEFT R 0.200)
      (SELECTFONT D 0)
      (SETCHAR O 051)
      )
   )

这将从045字体中选择字符(八进制),1向左移动一点,然后051从其他字体中选择字符(八进制)。我对希伯来字体一无所知,但如果字形像这样组合,则可以像第一个示例中那样散布颜色变化命令。

然后通过以下方式创建虚拟字体(a.vf和 a.tfm文件)

vptovf myfont

现在就可以使用了。但棘手的部分往往是,在 TDS(TeX 目录结构)中,字体文件必须位于正确的子目录中,才能被 TeX 找到。而且,在发生此类更改后,TeX 发行版的文件名数据库 (FNDB) 通常必须刷新。

我不知道 XeTeX 是否知道类似 plain-TeX 的东西,有一个简单的测试文件如下所示:

\font\myfont=myfont
\hsize 2in
\myfont
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis hendrerit dictum nisi
a suscipit. Proin velit arcu, tincidunt et gravida ac, pretium vel nunc. Suspendisse
scelerisque malesuada orci, quis volutpat diam ornare nec. Duis ligula est, posuere
non auctor ut, sodales elementum lacus. Nam egestas, diam et varius ornare, nisi
mauris posuere turpis, eu adipiscing diam mauris consequat nulla. Cras id lacus non
ante malesuada sodales. 
\bye

使用 LaTeX 和 pdfLaTeX 通常需要调整或创建pdftex.map字体定义文件。最好的方法是使用基础字体的现有文件并对其进行小修改,以了解所有缺陷。该命令可能在 latex 文档中添加修改后的字体时有用。.fd\pdfmapline

TeX FAQ 有一个关于虚拟字体

相关内容