luametalatex/luametalatex-font-enc.lua

14 lines
547 B
Lua
Raw Normal View History

2020-07-15 04:51:59 +02:00
local readfile = require'luametalatex-readfile'
2019-07-17 21:14:34 +02:00
local white = (lpeg.S'\0\9\10\12\13\32' + '%' * (1 - lpeg.S'\r\n')^0)^1
local regular = 1-lpeg.S'()<>[]{}/%\0\9\10\12\13\32'
local name = lpeg.C(regular^1)
local lname = '/' * name / 1
local namearray = lpeg.Ct('['*white^0*lpeg.Cg(lname*white^0, 0)^-1*(lname*white^0)^0*']')
local encfile = white^0*lname*white^0*namearray*white^0*'def'*white^0*-1
return function(filename)
2020-07-15 16:36:11 +02:00
local file <close> = readfile('enc', filename)
2020-07-15 04:51:59 +02:00
local name, encoding = encfile:match(file())
2019-07-17 21:14:34 +02:00
return encoding, name
end