diff options
Diffstat (limited to 'Master/texmf-dist/doc/luatex/fontloader-luaotfload/test-fontloader-2017-07-28.tex')
-rw-r--r-- | Master/texmf-dist/doc/luatex/fontloader-luaotfload/test-fontloader-2017-07-28.tex | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/luatex/fontloader-luaotfload/test-fontloader-2017-07-28.tex b/Master/texmf-dist/doc/luatex/fontloader-luaotfload/test-fontloader-2017-07-28.tex new file mode 100644 index 00000000000..5750fa345c7 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/fontloader-luaotfload/test-fontloader-2017-07-28.tex @@ -0,0 +1,127 @@ +% !Mode:: "TeX:UTF-8:Main" +%needs a fontloader 2017-07-28 or later +%substitutions at word boundaries + +\documentclass{article} + +\usepackage{luacode,fontspec} +\begin{luacode*} + fonts.handlers.otf.addfeature { + name = "test-a", + type = "chainsubstitution", + lookups = { + { + type = "substitution", + data = { + ["a"] = "A", + ["b"] = "B", + ["c"] = "C", + ["d"] = "D", + }, + }, + { + type = "ligature", + data = { + ['1'] = { "a", "b" }, + ['2'] = { "c", "d" }, + }, + }, + }, + data = { + rules = { + { + before = { { " ", 0xFFFC } }, + current = { { "a" }, { "b" } }, + lookups = { 2 }, + }, + { + current = { { "c" }, { "d" } }, + after = { { 0xFFFC, " " } }, + lookups = { 2 }, + }, + { + current = { { "a" } }, + after = { { "b" } }, + lookups = { 1 }, + }, + { + current = { { "c" } }, + after = { { "d" } }, + lookups = { 1 }, + }, + }, + }, + } + + fonts.handlers.otf.addfeature { + name = "test-b", + type = "chainsubstitution", + lookups = { + { + type = "ligature", + data = { + ['1'] = { "a", "b" }, + ['2'] = { "c", "d" }, + }, + }, + }, + data = { + rules = { + { + -- the space is redundant as 0xFFFC contains it + before = { { " ", 0xFFFC } }, + current = { { "a" }, { "b" } }, + lookups = { 1 }, + }, + { + current = { { "c" }, { "d" } }, + -- the space is redundant as 0xFFFC contains it + after = { { 0xFFFC, " " } }, + lookups = { 1 }, + }, + }, + }, + } + + fonts.handlers.otf.addfeature { + name = "test-c", + type = "chainsubstitution", + lookups = { + { + type = "ligature", + data = { + ['1'] = { "a", "b" }, + ['2'] = { "c", "d" }, + }, + }, + }, + data = { + rules = { + { + before = { { " " } }, + current = { { "a" }, { "b" } }, + lookups = { 1 }, + }, + { + current = { { "c" }, { "d" } }, + after = { { " " } }, + lookups = { 1 }, + }, + }, + }, + } +\end{luacode*} + + +\setmainfont{Arial}[RawFeature=+test-a;] + +\begin{document} +Substitutions at word boundaries (spaces): + +ab ab abxcd abxcdcdcd + +expected output: + +1 1 1x2 1xCdCd2 + +\end{document}
\ No newline at end of file |