% language=us \startcomponent languages-options \environment languages-environment \startchapter[title=Options][color=darkblue] \startsection[title=Introduction] Hyphenation of words is controlled by so called patterns. They take a word and try to match parts with a pattern that describes where a hyphen can be injected. Preferred and discouraged injection points accumulate to a score that in the end determine where so called discretionary nodes gets injected in the list of glyphs that make a word. The patterns are language specific. This mechanism is agnostic when it comes to the characters involved: they are just numbers. However, when in a next step font features like ligature building and kerning are applied we also have to deal with language specific properties (and meanings). Often a ligature at the boundary of a composed word can make reading confusing and has to be avoided. Some of that can be controlled by the font when it implements language specific features but because that approach is not based on a dictionary it is more about playing safe and prevention than about quality. In the next sections a mechanism is discussed that also uses patterns. This time it is about controlling fonts as well as how hyphenation patterns are applied. This process kicks in before hyphenation is applied but it definitely has to be seen as part of that same process. It is integrated in hyphenation machinery and acts as preprocessor with the possibility to feedback and move forward. The implementation is such that when it's not used there is no performance penalty. \footnote {There are by now plenty of alternative approaches to these problems but after some discussion about the pro's and cons of each this new mechanism was made. I admit that the fun factor played a role. It is also one of the things we can do in \LUAMETATEX\ without worrying about a possible negative impact on \LUATEX\ users other than \CONTEXT .} There are several predefined operations that are characterized by keywords and shortcuts and collected in an option list that is part of a language goodie file. Examples can be found in the distribution in files with the suffix \type {llg} (\LUA\ language goodie). The framework of such a file is: \starttyping return { name = "whatever", version = "1.00", comment = "Goodies for experiments and demo.", author = "Hans Hagen", copyright = "ConTeXt development team", options = { { ... }, ........ { ... }, } } \stoptyping These options will eventually result in patterns that are bound to words, think of: \starttabulate[|T||||] \NC effe \NC \type {foo|bar} \NC \type {..|..} \NC inhibit ligature \NC \NR \NC foobar \NC \type {foo=bar} \NC \type {...=...} \NC inhibit kerning \NC \NR \NC somemore \NC \type {some+more} \NC \type {....+....} \NC compound word \NC \NR \stoptabulate The whole repertoire is: \starttabulate[||T|] \NC \type {a|b} \NC a:norightligature, b:noleftligature \NC \NR \NC \type {a=b} \NC a:norightkern, b:noleftkern \NC \NR \NC \type {ab} \NC a:norightkern \NC \NR \NC \type {a+b} \NC a:compound:b \NC \NR \stoptabulate Later we will see how some can be combined. An option can be defined using entries in a subtable: \starttabulate[|T|||] \NC patterns \NC hash \NC \type {[snippet] = "replacement pattern"} \NC \NR \NC words \NC string \NC string of words, separated by whitespace \NC \NR \NC prefixes \NC string \NC snippets that combine with words (at the start) \NC \NR \NC suffixes \NC string \NC snippets that combine with words (at the end) \NC \NR \NC matches \NC array or number \NC a number or table indicating which match matters \NC \NR \NC actions \NC hash \NC \type {[character] = "action(s)"} \NC \NR \NC characters \NC string \NC permitted characters (additional hjcodes) \NC \NR \NC return \NC integer \NC what to do next \NC \NR \stoptabulate The default return value is~2 but there are some more: \starttabulate[|T||] \NC 0 \NC go to the next (valid) word \NC \NR \NC 1 \NC restart \NC \NR \NC 2 \NC exceptions and after that patterns \NC \NR \NC 3 \NC patterns \NC \NR \stoptabulate There are some safeguards built in that force a restart. For instance when a word is replaced a restart is enforces unless we skip the word. A restart will not permit a second replacement (after all we need to avoid endless loops). In a multi|-|line word list, lines that start with a comment trigger: \LUA's double dash or the usual \TEX\ percent sign. \stopsection \startsection[title=Inhibiting] The next definition replaces \type {ff} by \type {f|f} in the words given and eventually block a ligature. \starttyping { patterns = { ff = "f|f", }, words = [[ effe ]], } \stoptyping Some fonts provide the \type {ij} ligature or do some special kerning between these characters (something Dutch). Because it depends on the font logic if a dedicated replacement or kerning is used this is an example where we do this: \starttyping { patterns = { ij = "i|j", }, actions = { ["|"] = "nokern noligature", }, words = [[ ijverig -- fijn -- to ligature fi or ij, that's the question ]], } \stoptyping A more extensive definition is the following. Here we explicitly define that only the first match in a word get treated. Here we not only block ligatures but also kerns. \starttyping { patterns = { ff = "f|f", }, matches = { 1 }, actions = { ["|"] = "noligature nokern" }, words = [[ effe effeffe ]], } \stoptyping You can also omit the pattern when you inject specifiers yourself: \starttyping { actions = { ["|"] = "noligature nokern" }, words = [[ ef|fe ef|fef|fe ]], } \stoptyping You can also use different shortcuts: \starttyping { actions = { ["1"] = "noligature" ["2"] = "nokern" }, words = [[ ef1fe ef1fef2fe ]], } \stoptyping Although I cannot come up with a nice example, there can be reasons for inhibiting kerns. Here we inhibit kerns left of the upcoming character: \starttyping { patterns = { fo = "f