summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/fontscripts/fntbuild.lua
blob: 5dc5c1f5eddfe6636356d2705a99bf2870b49a22 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
-- $Id: fntbuild.lua 10802 2025-02-12 20:11:33Z cfrees $
-------------------------------------------------
-------------------------------------------------
-- I don't know how to bootstrap this ... 
-- these are needed when fontscripts is part of the same repo
-------------------------------------------------
sourcefiledir = sourcefiledir or "."
maindir = maindir or sourcefiledir
-------------------------------------------------
-- namespace
---@usage ??
fnt = fnt or {}
-- error-tracking
---@usage private
fnt.nifergwall = 0
-- target names
-- fnttarg
---@usage private
local ntarg = "fnttarg"
-- uniquifyencs
---@usage private
local utarg = "uniquifyencs"
-------------------------------------------------
-- fnt.gwall {{{
---@param msg string 
---@param file string
---@param rtn number 
---@see 
---@usage private
function fnt.gwall (msg,file,rtn)
  file = file or "current file"
  msg = msg or "Error:"
  rtn = rtn or 0
  if rtn ~= 0 then 
    fnt.nifergwall = fnt.nifergwall + rtn
    print (msg, file, "failed (" .. rtn .. ")\n")
  end
end
-- }}}
-------------------------------------------------
-------------------------------------------------
local possplaces = { sourcefiledir, maindir, maindir .. "/fontscripts" }
for _,i in ipairs (possplaces) do
  if fileexists( i .. "/fntbuild.lua" ) then
    fnt.fntbuild_home = i
    break
  end
end
print("fnt.fntbuild_home:", fnt.fntbuild_home)
if fnt.fntbuild_home == nil then
  -- dwyn o Joseph Wright: l3build.lua
  -- ar gael am fod Joseph yn wneud kpse.set_program_name("kpsewhich")
  -- gweler texdoc luatex
  local p = kpse.find_file("fntbuild.lua", "lua")
  if p ~= nil and p ~= "" then
    fnt.fntbuild_home = dirname(p)
  else
    fnt.gwall("Search for ","self",1)
  end
end
-------------------------------------------------
print("Found myself in", fnt.fntbuild_home)
-------------------------------------------------
-- dwyn o Joseph Wright: l3build.lua
local function fntbuild_require (frag)
  require(kpse.lookup("fntbuild-" .. frag .. ".lua", { path = fnt.fntbuild_home }))
end
-------------------------------------------------
fntbuild_require("vars")
fntbuild_require("utils")
fntbuild_require("build")
fntbuild_require("check")
fntbuild_require("doc")
fntbuild_require("ctan")
-------------------------------------------------
-- load user config
-- local (if fnt.buildsearch) - maindir -- sourcefiledir
-------------------------------------------------
-- execute before testing afmtotfm so fnttarg is correct in case the 
-- config sets it true
fnt.build_config()
-------------------------------------------------
-------------------------------------------------
-- fontinst must be specified first
-- it just ain't TeX
-- ntarg {{{
target_list[ntarg] = {
	func = fnt.fontinst,
  desc = "Creates TeX font file",
  pre = function(names)
    if names then
      print("fontinst does not need names\n")
      help()
      exit(1)
    end
    return 0
  end
}
-- }}}
-- utarg {{{
target_list[utarg] = {
  func = fnt.uniquify,
  desc = "Uniquifies encodings ONLY",
  pre = function(names)
    fnt.standalone = true
    if names and #names > 1 then
      print("Too many encoding tags specified; no more than one allowed")
      help()
      exit(1)
    else
      names = names or fnt.encodingtag or ""
    end
    return 0
  end
}
-- }}}
-- diwedd targets
-------------------------------------------------
-------------------------------------------------
-- fnt.afmtotfm -> fnttarg {{{
if fnt.afmtotfm then
  target_list[ntarg] = {
    func = fnt.afm2tfm,
    desc = "Creates TeX font files",
    pre = function(names)
      if names then
        print("fntmake does not need names\n")
        help()
        exit(1)
      end
      return 0
    end
  }
end
-- }}}
-------------------------------------------------
-------------------------------------------------
if options["target"] == "install" then
  table.insert(sourcefiles,fnt.keepdir .. "/*.*")
end
-------------------------------------------------
-------------------------------------------------
-- override l3build functions {{{
checkinit_hook = fnt.checkinit_hook
copyctan = fnt.copyctan
docinit_hook = fnt.docinit_hook
-- }}}
-- other exports {{{
fnt.ntarg = ntarg
-- }}}
-------------------------------------------------
-------------------------------------------------
-- vim: ts=2:sw=2:et:foldmethod=marker: