Commits

Philipp Gesang  committed d3b05da

kill examples requiring the no longer imported typo-krn.lua

  • Participants
  • Parent commits 0e10c13

Comments (0)

Files changed (6)

File pln-letterspace-1.tex

-\input luaotfload.sty
-\def\setcharacterkerning#1{% #1 factor : float
-  \directlua{typesetters.kerns.set(0.618)}%
-}
-%directlua{typesetters.kerns.enablecharacterkerning()}
-
-\font\iwona       = "name:Iwona:mode=node"                at 42pt
-\font\lmregular   = "name:Latin Modern Roman:mode=node"   at 42pt
-
-{\iwona
- foo
- {\setcharacterkerning{0.618}%
-  bar}
- baz}
-
-{\lmregular
- foo {\setcharacterkerning{0.125}ff fi ffi fl Th} baz}
-
-{\lmregular
- \directlua{ %% I’m not exactly sure how those work
-    typesetters.kerns.keepligature = function (start)
-      print("[liga]", start)
-      return true
-    end
-    typesetters.kerns.keeptogether = function (start)
-      print("[keeptogether]", start)
-      return true
-    end}%
- foo {\setcharacterkerning{0.125}ff fi ffi fl Th} baz}
-
-\bye
-

File pln-letterspace-3.tex

-\ifdefined\directlua
-  \input luaotfload.sty
-  \font\iwona     = "name:Iwona:letterspace=.125"                at 14.4pt
-  \font\lmregular = "name:Latin Modern Roman:letterspace=-.125"  at 14.4pt
-\else
-  \font\iwona     = "[Iwona]:letterspace=.125"                at 14.4pt
-  \font\lmregular = "[Latin Modern Roman]:letterspace=-.125"  at 14.4pt
-\fi
-
-before
-
-{\lmregular foo {\iwona ff fi ffi fl Th} baz}
-
-inbetween
-
-{\iwona
- \directlua{ %% I’m not exactly sure how those work
-    typesetters.kernfont.keepligature = function (start)
-      print("[liga]", start)
-      return true
-    end
-    typesetters.kernfont.keeptogether = function (start)
-      print("[keeptogether]", start)
-      return true
-    end}%
- foo {\lmregular ff fi ffi fl Th} baz}
-
-after
-
-\bye
-

File pln-letterspace-5.lua

---- Simple wrapper around typo-krn.lua
-
-packagedata                   = packagedata or { }
-packagedata.characterkerning  = packagedata.characterkerning or { }
-local characterkerning        = packagedata.characterkerning
-
-local lpeg                    = require "lpeg"
-local C, Ct, P                = lpeg.C, lpeg.Ct, lpeg.P
-local lpegmatch               = lpeg.match
-
-local kerns                   = typesetters.kerns
-local nodecodes               = nodes.nodecodes
-local glyph_t                 = nodecodes.glyph
-
-local defaultwidth            = 0.125
-local keepligature            = false --- defaults in Context
-local keeptogether            = false
-
-local splitlist
-do
-  local separator   = P","
-  local noseparator = 1 - separator
-  local escaped     = P"\\" * P(1)
-  local element     = C((escaped + noseparator)^1)
-  splitlist   = Ct((element + separator)^1)
-end
-
---- register a list of character pairs that should not be kerned
-
-local suppresskerns = function (list)
-  if list == "" then
-    keeptogether = false
-    return
-  end
-
-  list = lpegmatch (splitlist, list)
-  if not list then -- garbage
-    keeptogether = false
-    return
-  end
-
-  --- kludge, should be optimized with an 2d array lookup, using
-  --- integers instead of strings as keys
-  local pairs = table.tohash (list)
-
-  keeptogether = function (node1, node2)
-    if node1.id == glyph_t and node2.id == glyph_t then
-      local pair = utf.char (node1.char) .. utf.char (node2.char)
-      return pairs[pair] == true
-    end
-  end
-end
-
-characterkerning.suppresskerns = suppresskerns
-
---- register a list of ligatures
-
-local ignoreligatures = function (list)
-  if list == "" then
-    keepligatures = false
-    return
-  end
-
-  list = lpegmatch (splitlist, list)
-  if not list then -- garbage
-    keepligatures = false
-    return
-  end
-
-  local keep = table.tohash (list)
-
-  keepligature = function (liganode)
-    --- first check if the glyph of the ligature is registered
-    if keep[utf.char (liganode.char)] == true then
-      return true
-    end
-    --- else, test if the components are registered
-    local ligachars = { }
-    for n in node.traverse_id (glyph_t, liganode.components) do
-      ligachars[#ligachars+1] = utf.char (n.char)
-    end
-
-    return keep[table.concat (ligachars)] == true
-  end
-end
-
-characterkerning.ignoreligatures = ignoreligatures
-
---- activate letterspacing
-
-local enable = function (factor)
-  kerns.keepligature = keepligature
-  kerns.keeptogether = keeptogether
-  factor = tonumber (factor) or defaultwidth
-  kerns.set (factor)
-end
-
-characterkerning.enable = enable
-

File pln-letterspace-5.tex

-\input luaotfload.sty
-\directlua{dofile "pln-letterspace-5.lua"}
-
-\def\kerncmd#1{\directlua{packagedata.characterkerning.#1}}
-
-%% #1 -> kernfactor
-\def\setcharacterkerning#1{\kerncmd{enable[[#1]]}}
-
-%% #1 -> comma separated list of pairs
-\def\suppresscharacterkerning#1{\kerncmd{suppresskerns[[#1]]}}
-
-%% #1 -> comma separated list of ligatures,
-%%       either the unicode ligature character or its components
-\def\suppressligaturekerning#1{\kerncmd{ignoreligatures[[#1]]}}
-
-\font\iwona="file:Iwona-Regular.otf" at 42pt
-
-%% example: we’d like “cd” and “ij” to remain unaffected
-\suppresscharacterkerning{cd,ij} %% list of pairs to ignore
-
-%% example: we’d like the “fl” and “ff” ligatures to be
-%% unanalyzed
-\suppressligaturekerning{fl,ff}   %% list of ligatures to ignore
-
-{\iwona
- before\par
- {\setcharacterkerning{0.5}% very noticable
-  abcdefghijk\par
-  ff fi ffi fl}\par
- after}\par
-
-\bye
-

File pln-letterspace-6.tex

 ---
 a{\x test}b
 
-%a{\directlua{typesetters.kerns.set(0.2)}test}b
-
-%a\kern1pt{\x test}b
-
-%a\kern1pt{\directlua{typesetters.kerns.set(0.2)}test}b
 \bye

File pln-letterspace-7-doubly.tex

-%% based on an example by Robert Schlicht
-%% https://github.com/lualatex/luaotfload/issues/106
-
-\ifdefined \directlua
-  \input luaotfload.sty
-\else
-  \endinput
-\fi
-
-\tracingoutput 1
-\showboxdepth  10
-\showboxbreadth100
-
-\font\x = "EB Garamond:mode=node;+liga;+dlig" at 10pt
-
-{\x\directlua{typesetters.kerns.set(0.2)}
-Thefoofi}
-
-\font\x = "EB Garamond:mode=node;-liga;letterspace=0.2" at 10pt
-\x Thefoofi
-
-\font\x = "EB Garamond:mode=node;+liga;+tlig;+dlig;letterspace=0.2" at 10pt
-\x Thefoofi ff fi ffi
-
-\font\x = "EB Garamond:mode=node;+liga;+dlig;letterspace=0.2" at 10pt
-
-\x Thefoofi
-
-\bye