summaryrefslogtreecommitdiff
path: root/support/findfont/scripts
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-11-30 03:00:43 +0000
committerNorbert Preining <norbert@preining.info>2021-11-30 03:00:43 +0000
commit37729ddea335ca0dfe40ada381d05bde37c5ea61 (patch)
tree960423718ed6c697613f41ab202a79966fef5bf2 /support/findfont/scripts
parent5bfa628a501938d7d9540f3597b39cb4c2d16d8a (diff)
CTAN sync 202111300300
Diffstat (limited to 'support/findfont/scripts')
-rwxr-xr-xsupport/findfont/scripts/luafindfont.lua (renamed from support/findfont/scripts/findfont.lua)108
1 files changed, 76 insertions, 32 deletions
diff --git a/support/findfont/scripts/findfont.lua b/support/findfont/scripts/luafindfont.lua
index 4446e87590..cad6ee4044 100755
--- a/support/findfont/scripts/findfont.lua
+++ b/support/findfont/scripts/luafindfont.lua
@@ -1,23 +1,23 @@
#!/usr/bin/env texlua
--- % $Id: findfont.lua 330 2021-11-28 13:47:56Z herbert $
+-- % $Id: luafindfont.lua 330 2021-11-28 13:47:56Z herbert $
-----------------------------------------------------------------------
--- FILE: findfont.lua
+-- FILE: luafindfont.lua
-- DESCRIPTION: search for fonts in the database
-- REQUIREMENTS: luatex v.0.80 or later; packages lualibs, xindex-lapp
-- AUTHOR: Herbert Voß (C) 2021-11-27
-----------------------------------------------------------------------
- findfont = findfont or { }
- local version = 0.03
-findfont.version = version
+ luafindfont = luafindfont or { }
+ local version = 0.04
+luafindfont.version = version
--[[
Search the font database for fontnames. The database is used
by Lua(La)TeX and created by default with the first run of
-Lua(La)TeX. If there is no such data file then "findfont"
+Lua(La)TeX. If there is no such data file then "luafindfont"
will execute the command to create it.
-findfont(1)
+luafindfont(1)
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
@@ -35,43 +35,87 @@ kpse.set_program_name("luatex")
local f = kpse.find_file("lualibs.lua")
require("lualibs") -- all part of LuaTeX
---require("findfont-utflib")
+--require("luafindfont-utflib")
-local args = require ('xindex-lapp') [[
- Version: 0.02
- Syntax: fintFont [options] <font>
- By default the Lua program 'findfont' creates a list of the
+if #arg == 0 then
+ print("I need at least one argument or option! Will exit ...")
+ os.exit()
+end
+
+local args_verbose = 0
+local args_nosymbolixnames = 0
+local args_otfinfo = 0
+local args_info = 0
+local args_max_string = 90
+
+local i = 1
+while i <= #arg do
+ if arg[i] == "-h" or arg[i] == "--help" then
+ print("Version "..version..", Copyright 2021 by Herbert Voß")
+ print([[Syntax: luafintfont [options] <font>
+ By default the Lua program 'luafindfont' creates a list of the
fonts which have in its names the given string.
- parameter handling
- -q,--quiet
+
+ parameter handling
-h,--help
-n,--nosymbolicnames
-o,--otfinfo (default 0)
-i,--info (default 0)
- -v... Verbosity level; can be -v, -vv, -vvv
+ -v, --verbose
-m,--max_string (default 90)
- <font> (string)
-]]
+ <font> (string) ]])
+ elseif arg[i] == "-v" or arg[i] == "--verbose" then
+ args_verbose = 1
+ elseif arg[i] == "-n" or arg[i] == "--nosymbolicnames" then
+ args_nosymbolicnames = 1
+ elseif arg[i] == "-o" or arg[i] == "--otfinfo" then
+ local fontNr = tonumber(arg[i+1])
+ if fontNr then
+ args_otfinfo = fontNr
+ i = i + 1
+ else
+ print("Option -o needs a following fontnumber!")
+ args_otfinfo = 0
+ end
+ elseif arg[i] == "-i" or arg[i] == "--info" then
+ local fontNr = tonumber(arg[i+1])
+ if fontNr then
+ args_info = fontNr
+ i = i + 1
+ else
+ print("Option -i needs a following fontnumber!")
+ args_info = 0
+ end
+ elseif arg[i] == "-m" or arg[i] == "--max_string" then
+ local string_len = tonumber(arg[i+1])
+ if string_len then
+ args_max_string = string_len
+ i = i + 1
+ else
+ print("Option -m needs a following fontnumber!")
+ args_max_string = 90
+ end
+ else
+ args_font = arg[i]
+ end
+ i = i + 1
+end
---[[
- No -v flag, v is just { false }. not args.v[1] is true, so vlevel becomes 0.
- One -v flags, v is { true }
- Two -v flags, v is { true, true }
- Three -v flags, v is { true, true, true }
-]]
+if not args_font then
+ print("No fontname given, will close ...")
+ os.exit()
+end
-local vlevel = not args.v[1] and 0 or #args.v
-local not_quiet = not args["quiet"]
-local otfinfo = args["otfinfo"]
-local info = args["info"]
-local noSymbolicNames = args["nosymbolicnames"]
+local vlevel = args_verbose
+local otfinfo = args_otfinfo
+local info = args_info
+local noSymbolicNames = args_nosymbolicnames
+local maxStrLength = args_max_string
+local font_str = args_font
-local maxStrLength = args["max_string"]
local luaVersion = _VERSION
print("We are using "..luaVersion)
-
-local font_str = args.font
-if vlevel > 0 then print('Looking for font \"'..font_str..'\"') end
+print('Looking for font \"'..font_str..'\"')
function getFileParts(fullpath,part)
local path, file, ext = string.match(fullpath, "(.-)([^/]-([^%.]+))$")