diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/microtype/microtype.lua')
-rw-r--r-- | Master/texmf-dist/tex/latex/microtype/microtype.lua | 81 |
1 files changed, 50 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/latex/microtype/microtype.lua b/Master/texmf-dist/tex/latex/microtype/microtype.lua index 8f800c38598..2da38c7d643 100644 --- a/Master/texmf-dist/tex/latex/microtype/microtype.lua +++ b/Master/texmf-dist/tex/latex/microtype/microtype.lua @@ -29,63 +29,82 @@ -- It was contributed by Elie Roux <elie.roux{at}telecom-bretagne.eu>. -- ------------------------------------------------------------------------ -- -if microtype then - -- we simply don't load -else - -microtype = {} +microtype = microtype or {} +local microtype = microtype -microtype.module = { +local microtype_module = { name = "microtype", version = 2.5, - date = "2013/03/13", + date = "2013/05/15", description = "microtype module.", - author = "Elie Roux & R Schlicht", - copyright = "Elie Roux & R Schlicht", + author = "E. Roux, R. Schlicht and P. Gesang", + copyright = "E. Roux, R. Schlicht and P. Gesang", license = "LPPL", } -if luatextra and luatextra.provides_module then - luatextra.provides_module(microtype.module) +if luatexbase and luatexbase.provides_module then + luatexbase.provides_module(microtype_module) end -function microtype.if_int(s) - if string.find(s,"^-*[0-9]+ *$") then - tex.write("@firstoftwo") +local find = string.find +local tex_write = tex.write + +local function if_int(s) + if find(s,"^-*[0-9]+ *$") then + tex_write("@firstoftwo") else - tex.write("@secondoftwo") + tex_write("@secondoftwo") end end +microtype.if_int = if_int -function microtype.if_dimen(s) - if (string.find(s, "^-*[0-9]+(%a*) *$") or - string.find(s, "^-*[0-9]*[.,][0-9]+(%a*) *$")) then - tex.write("@firstoftwo") +local function if_dimen(s) + if (find(s, "^-*[0-9]+(%a*) *$") or + find(s, "^-*[0-9]*[.,][0-9]+(%a*) *$")) then + tex_write("@firstoftwo") else - tex.write("@secondoftwo") + tex_write("@secondoftwo") end end +microtype.if_dimen = if_dimen -function microtype.if_str_eq(s1, s2) +local function if_str_eq(s1, s2) if s1 == s2 then - tex.write("@firstoftwo") + tex_write("@firstoftwo") else - tex.write("@secondoftwo") + tex_write("@secondoftwo") end end +microtype.if_str_eq = if_str_eq -function microtype.name_to_slot(name) - if fonts then - local tfmdata = fonts.ids[font.current()] - if tfmdata and tfmdata.shared then - local otfdata = tfmdata.shared.otfdata - local unicode = otfdata.luatex.unicodes[name] - return unicode and (type(unicode) == "number" and unicode or unicode[1]) +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) + return slot_of_name(font.current(), name, unsafe) + end +else + -- we dig into internal structure (should be avoided) + local function name_to_slot(name, unsafe) + if fonts then + local unicodes + if fonts.ids then --- legacy luaotfload + local tfmdata = fonts.ids[font.current()] + if not tfmdata then return end + unicodes = tfmdata.shared.otfdata.luatex.unicodes + else --- new location + local tfmdata = fonts.hashes.identifiers[font.current()] + if not tfmdata then return end + unicodes = tfmdata.resources.unicodes + end + local unicode = unicodes[name] + if unicode then --- does the 'or' branch actually exist? + return type(unicode) == "number" and unicode or unicode[1] + end end end + microtype.name_to_slot = name_to_slot end -end -- -- -- End of file `microtype.lua'. |