summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/microtype/microtype.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/microtype/microtype.lua')
-rw-r--r--Master/texmf-dist/tex/latex/microtype/microtype.lua103
1 files changed, 84 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/latex/microtype/microtype.lua b/Master/texmf-dist/tex/latex/microtype/microtype.lua
index 2da38c7d643..b6ac668d4f8 100644
--- a/Master/texmf-dist/tex/latex/microtype/microtype.lua
+++ b/Master/texmf-dist/tex/latex/microtype/microtype.lua
@@ -10,7 +10,7 @@
--
-- The `microtype' package
-- Subliminal refinements towards typographical perfection
--- Copyright (c) 2004--2013 R Schlicht <w.m.l@gmx.net>
+-- Copyright (c) 2004--2016 R Schlicht <w.m.l@gmx.net>
--
-- This work may be distributed and/or modified under the conditions of the
-- LaTeX Project Public License, either version 1.3c of this license or (at
@@ -21,33 +21,38 @@
-- This work has the LPPL maintenance status `author-maintained'.
--
-- This work consists of the files microtype.dtx and microtype.ins and the
--- derived files microtype.sty, microtype-pdftex.def, microtype-xetex.def,
--- microtype-luatex.def, microtype.lua and letterspace.sty.
+-- derived files microtype.sty, microtype-pdftex.def, microtype-luatex.def,
+-- microtype-xetex.def, microtype.lua and letterspace.sty.
--
-- ------------------------------------------------------------------------
-- This file contains auxiliary lua functions.
--- It was contributed by Elie Roux <elie.roux{at}telecom-bretagne.eu>.
+-- It was originally contributed by Elie Roux <elie.roux{at}telecom-bretagne.eu>.
+-- (Bugs are mine.)
-- ------------------------------------------------------------------------
--
-microtype = microtype or {}
-local microtype = microtype
-local microtype_module = {
- name = "microtype",
- version = 2.5,
- date = "2013/05/15",
- description = "microtype module.",
- author = "E. Roux, R. Schlicht and P. Gesang",
- copyright = "E. Roux, R. Schlicht and P. Gesang",
- license = "LPPL",
+microtype = microtype or {}
+local microtype = microtype
+microtype.module = {
+ name = "microtype",
+ version = 2.6,
+ date = "2016/05/01",
+ description = "microtype module.",
+ author = "E. Roux, R. Schlicht and P. Gesang",
+ copyright = "E. Roux, R. Schlicht and P. Gesang",
+ license = "LPPL",
}
-if luatexbase and luatexbase.provides_module then
- luatexbase.provides_module(microtype_module)
-end
+local err, warn, info, log = luatexbase.provides_module(microtype.module)
+microtype.warning = warn
+
+local find = string.find
+local match = string.match
+local tex_write = tex.write
-local find = string.find
-local tex_write = tex.write
+function microtype.sprint (...)
+ tex.sprint(luatexbase.catcodetables['latex-package'], ...)
+end
local function if_int(s)
if find(s,"^-*[0-9]+ *$") then
@@ -77,6 +82,66 @@ local function if_str_eq(s1, s2)
end
microtype.if_str_eq = if_str_eq
+local function do_font()
+ if fonts then
+ local thefont
+ if fonts.ids then --- legacy luaotfload
+ thefont = fonts.ids[font.current()]
+ else --- new location
+ thefont = fonts.hashes.identifiers[font.current()]
+ end
+ if thefont then
+ for i,v in next,thefont.characters do
+ if v.index > 0 then
+ microtype.sprint([[\@tempcnta=]]..i..[[\relax\MT@dofont@function]])
+ end
+ end
+ end
+ end
+end
+microtype.do_font = do_font
+
+microtype.ligs = microtype.ligs or { }
+
+local function noligatures(fontcs,liga)
+ local fontcs = match(fontcs,"([^ ]+)")
+ microtype.ligs[fontcs] = microtype.ligs[fontcs] or { }
+ table.insert(microtype.ligs[fontcs],liga)
+end
+microtype.noligatures = noligatures
+
+local function keepligature(c)
+ local nodedirect = node.direct
+ local getfield = nodedirect.getfield
+ local getfont = nodedirect.getfont
+ local f,ch
+ if type(c) == "userdata" then -- in older luaotfload versions, c was a node
+ f = c.font
+ ch = c.components.char
+ else -- since 2.6, c is a (direct node) number
+ f = getfont(c)
+ ch = getfield(getfield(c,"components"),"char")
+ end
+-- if ch then -- should always be true
+ local ligs = microtype.ligs[match(tex.fontidentifier(f),"\\([^ ]+)")]
+ if ligs then
+ for _,lig in pairs(ligs) do
+ if lig == "_all_" or tonumber(lig) == ch then
+ return false
+ end
+ end
+ end
+ return true
+-- end
+end
+
+if luaotfload and luaotfload.letterspace then
+ if luaotfload.letterspace.keepligature then
+ microtype.warning("overwriting function `keepligature'")
+ end
+ luaotfload.letterspace.keepligature = keepligature
+end
+
if luaotfload and luaotfload.aux and luaotfload.aux.slot_of_name then
local slot_of_name = luaotfload.aux.slot_of_name
microtype.name_to_slot = function(name, unsafe)