summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/microtype/microtype.lua
blob: 8f800c38598d5280d253bf3ceef2cf036d76d04d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
--
-- This is file `microtype.lua',
-- generated with the docstrip utility.
--
-- The original source files were:
--
-- microtype.dtx  (with options: `luafile')
-- 
-- ------------------------------------------------------------------------
-- 
--                       The `microtype' package
--         Subliminal refinements towards typographical perfection
--           Copyright (c) 2004--2013 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
-- your option) any later version. The latest version of this license is in:
-- http://www.latex-project.org/lppl.txt, and version 1.3c or later is part
-- of all distributions of LaTeX version 2005/12/01 or later.
-- 
-- 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.
-- 
-- ------------------------------------------------------------------------
--   This file contains auxiliary lua functions.
--   It was contributed by Elie Roux <elie.roux{at}telecom-bretagne.eu>.
-- ------------------------------------------------------------------------ 
--
if microtype then
  -- we simply don't load
else

microtype = {}

microtype.module = {
  name         = "microtype",
  version      = 2.5,
  date         = "2013/03/13",
  description  = "microtype module.",
  author       = "Elie Roux & R Schlicht",
  copyright    = "Elie Roux & R Schlicht",
  license      = "LPPL",
}

if luatextra and luatextra.provides_module then
  luatextra.provides_module(microtype.module)
end

function microtype.if_int(s)
  if string.find(s,"^-*[0-9]+ *$") then
    tex.write("@firstoftwo")
  else
    tex.write("@secondoftwo")
  end
end

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")
  else
    tex.write("@secondoftwo")
  end
end

function microtype.if_str_eq(s1, s2)
  if s1 == s2 then
    tex.write("@firstoftwo")
  else
    tex.write("@secondoftwo")
  end
end

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])
    end
  end
end

end
-- 
--
-- End of file `microtype.lua'.