summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/generic/context/luatex')
-rw-r--r--tex/generic/context/luatex/luatex-core.lua217
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua234
2 files changed, 297 insertions, 154 deletions
diff --git a/tex/generic/context/luatex/luatex-core.lua b/tex/generic/context/luatex/luatex-core.lua
index 6e1b31e96..a0f46dd2e 100644
--- a/tex/generic/context/luatex/luatex-core.lua
+++ b/tex/generic/context/luatex/luatex-core.lua
@@ -1,13 +1,13 @@
--- luatex-core security and io overloads ...........
+-- luatex-core security and io overloads ..
-- if not modules then modules = { } end modules ['luatex-core'] = {
--- version = 1.080,
+-- version = 1.112,
-- comment = 'companion to luatex',
-- author = 'Hans Hagen & Luigi Scarso',
-- copyright = 'LuaTeX Development Team',
-- }
-LUATEXCOREVERSION = 1.080 -- we reflect the luatex version where changes happened
+LUATEXCOREVERSION = 1.112 -- we reflect the luatex version where changes happened
-- This file overloads some Lua functions. The readline variants provide the same
-- functionality as LuaTeX <= 1.04 and doing it this way permits us to keep the
@@ -16,125 +16,135 @@ LUATEXCOREVERSION = 1.080 -- we reflect the luatex version where changes happene
-- We test for functions already being defined so that we don't overload ones that
-- are provided in the startup script.
-local type, next, getmetatable, require = type, next, getmetatable, require
-local find, gsub, format = string.find, string.gsub, string.format
+local saferoption = status.safer_option
+local shellescape = status.shell_escape -- 0 (disabled) 1 (anything) 2 (restricted)
+local kpseused = status.kpse_used -- 0 1
-local io_open = io.open
-local io_popen = io.popen
-local io_lines = io.lines
+if kpseused == 1 then
-local fio_readline = fio.readline
-local fio_checkpermission = fio.checkpermission
-local fio_recordfilename = fio.recordfilename
+ local type = type
+ local gsub = string.gsub
+ local find = string.find
-local mt = getmetatable(io.stderr)
-local mt_lines = mt.lines
-local saferoption = status.safer_option
-local shellescape = status.shell_escape -- 0 (disabled) 1 (anything) 2 (restricted)
-local kpseused = status.kpse_used -- 0 1
+ local mt = getmetatable(io.stderr)
+ local mt_lines = mt.lines
-local write_nl = texio.write_nl
+ local kpse_checkpermission = kpse.check_permission
+ local kpse_recordinputfile = kpse.record_input_file
+ local kpse_recordoutputfile = kpse.record_output_file
-io.saved_lines = io_lines -- always readonly
-mt.saved_lines = mt_lines -- always readonly
+ local io_open = io.open
+ local io_popen = io.popen
+ local io_lines = io.lines
-local function luatex_io_open(name,how)
- if not how then
- how = 'r'
- end
- local f = io_open(name,how)
- if f then
- if type(how) == 'string' and find(how,'w') then
- fio_recordfilename(name,'w')
- else
- fio_recordfilename(name,'r')
+ local fio_readline = fio.readline
+
+ local write_nl = texio.write_nl
+
+ io.saved_lines = io_lines -- always readonly
+ mt.saved_lines = mt_lines -- always readonly
+
+ local function luatex_io_open(name,how)
+ if not how then
+ how = 'r'
+ end
+ local f = io_open(name,how)
+ if f then
+ if type(how) == 'string' and find(how,'w') then
+ kpse_recordoutputfile(name,'w')
+ else
+ kpse_recordinputfile(name,'r')
+ end
end
+ return f
end
- return f
-end
-local function luatex_io_open_readonly(name,how)
- if not how then
- how = 'r'
- else
- how = gsub(how,'[^rb]','')
- if how == '' then
+ local function luatex_io_open_readonly(name,how)
+ if not how then
how = 'r'
+ else
+ how = gsub(how,'[^rb]','')
+ if how == '' then
+ how = 'r'
+ end
end
+ local f = io_open(name,how)
+ if f then
+ fio_recordfilename(name,'r')
+ end
+ return f
end
- local f = io_open(name,how)
- if f then
- fio_recordfilename(name,'r')
- end
- return f
-end
-local function luatex_io_popen(name,...)
- local okay, found = fio_checkpermission(name)
- if okay and found then
- return io_popen(found,...)
+ local function luatex_io_popen(name,...)
+ local okay, found = kpse_checkpermission(name)
+ if okay and found then
+ return io_popen(found,...)
+ end
end
-end
--- local function luatex_io_lines(name,how)
--- if name then
--- local f = io_open(name,how or 'r')
--- if f then
--- return function()
--- return fio_readline(f)
--- end
--- end
--- else
--- return io_lines()
--- end
--- end
-
--- For some reason the gc doesn't kick in so we need to close explitly
--- so that the handle is flushed.
-
-local error, type = error, type
-
-local function luatex_io_lines(name,how)
- if type(name) == "string" then
- local f = io_open(name,how or 'r')
- if f then
- return function()
- local l = fio_readline(f)
- if not l then
- f:close()
+ -- local function luatex_io_lines(name,how)
+ -- if name then
+ -- local f = io_open(name,how or 'r')
+ -- if f then
+ -- return function()
+ -- return fio_readline(f)
+ -- end
+ -- end
+ -- else
+ -- return io_lines()
+ -- end
+ -- end
+
+ -- For some reason the gc doesn't kick in so we need to close explicitly
+ -- so that the handle is flushed.
+
+ local error, type = error, type
+
+ local function luatex_io_lines(name,how)
+ if type(name) == "string" then
+ local f = io_open(name,how or 'r')
+ if f then
+ return function()
+ local l = fio_readline(f)
+ if not l then
+ f:close()
+ end
+ return l
end
- return l
+ else
+ -- for those who like it this way:
+ error("patched 'io.lines' can't open '" .. name .. "'")
end
else
- -- for those who like it this way:
- error("patched 'io.lines' can't open '" .. name .. "'")
+ return io_lines()
end
- else
- return io_lines()
end
-end
-local function luatex_io_readline(f)
- return function()
- return fio_readline(f)
+ local function luatex_io_readline(f)
+ return function()
+ return fio_readline(f)
+ end
end
-end
-
-io.lines = luatex_io_lines
-mt.lines = luatex_io_readline
--- We assume management to be provided by the replacement of kpse. This is the
--- case in ConTeXt.
-
-if kpseused == 1 then
+ io.lines = luatex_io_lines
+ mt.lines = luatex_io_readline
io.open = luatex_io_open
io.popen = luatex_io_popen
+else
+
+ -- we assume management elsewhere
+
end
+-- maybe also only when in kpse mode
+
if saferoption == 1 then
+ local write_nl = texio.write_nl
+ local format = string.format
+
local function installdummy(str,f)
local reported = false
return function(...)
@@ -176,8 +186,12 @@ if saferoption == 1 then
debug = nil
+ -- os.[execute|os.spawn|os.exec] already are shellescape aware)
+
end
+-- maybe also only when in kpse mode
+
if saferoption == 1 or shellescape ~= 1 then
ffi = require('ffi')
@@ -190,9 +204,6 @@ if saferoption == 1 or shellescape ~= 1 then
end
--- os.[execute|os.spawn|os.exec] already are shellescape aware)
-
-
if md5 then
local sum = md5.sum
@@ -419,25 +430,25 @@ do
end
--- so far
+-- start omit
if utilities and utilities.merger and utilities.merger.compact then
- local byte, format, gmatch = string.byte, string.format, string.gmatch
+ local byte, format, gmatch, gsub = string.byte, string.format, string.gmatch, string.gsub
local concat = table.concat
- local data = gsub(io.loaddata('luatex-core.lua'),'if%s+utilities.*','')
+ local data = io.loaddata('luatex-core.lua')
+
+ data = gsub(data,'%-%-%s*start%s*omit.-%-%-%s*stop%s*omit%s*','')
+ data = gsub(data,'\r\n','\n')
local t = { }
local r = { }
local n = 0
- local d = gsub(data,'\r\n','\n') -- be nice for unix
- local s = utilities.merger.compact(d) -- no comments and less spaces
+ local s = utilities.merger.compact(data) -- no comments and less spaces
t[#t+1] = '/* generated from and by luatex-core.lua */'
t[#t+1] = ''
- -- t[#t+1] = format('/*\n\n%s\n\n*/',d)
- -- t[#t+1] = ''
t[#t+1] = '#include "lua.h"'
t[#t+1] = '#include "lauxlib.h"'
t[#t+1] = ''
@@ -446,7 +457,7 @@ if utilities and utilities.merger and utilities.merger.compact then
t[#t+1] = 'int load_luatex_core_lua (lua_State * L)'
t[#t+1] = '{'
t[#t+1] = ' static unsigned char luatex_core_lua[] = {'
- for c in gmatch(d,'.') do
+ for c in gmatch(data,'.') do
if n == 16 then
n = 1
t[#t+1] = ' ' .. concat(r,', ') .. ','
@@ -467,3 +478,5 @@ if utilities and utilities.merger and utilities.merger.compact then
io.savedata('luatex-core-stripped.lua',s)
end
+
+-- stop omit
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index b8a21fc93..a0a45c63d 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 10/29/19 15:00:00
+-- merge date : 11/12/19 18:49:12
do -- begin closure to overcome local limits and interference
@@ -20,9 +20,6 @@ if LUAVERSION<5.2 and jit then
MINORVERSION=2
LUAVERSION=5.2
end
-if lua and lua.openfile then
- io.open=lua.openfile
-end
if not lpeg then
lpeg=require("lpeg")
end
@@ -9032,6 +9029,7 @@ function constructors.scale(tfmdata,specification)
properties.direction=direction
target.size=scaledpoints
target.encodingbytes=properties.encodingbytes or 1
+ target.subfont=properties.subfont
target.embedding=properties.embedding or "subset"
target.tounicode=1
target.cidinfo=properties.cidinfo
@@ -9524,6 +9522,7 @@ function constructors.finalize(tfmdata)
properties.name=properties.name or tfmdata.name
properties.psname=properties.psname or tfmdata.psname
properties.encodingbytes=tfmdata.encodingbytes or 1
+ properties.subfont=tfmdata.subfont or nil
properties.embedding=tfmdata.embedding or "subset"
properties.tounicode=tfmdata.tounicode or 1
properties.cidinfo=tfmdata.cidinfo or nil
@@ -9549,6 +9548,7 @@ function constructors.finalize(tfmdata)
tfmdata.name=nil
tfmdata.psname=nil
tfmdata.encodingbytes=nil
+ tfmdata.subfont=nil
tfmdata.embedding=nil
tfmdata.tounicode=nil
tfmdata.cidinfo=nil
@@ -13981,7 +13981,7 @@ if not modules then modules={} end modules ['font-cff']={
license="see context related readme files"
}
local next,type,tonumber,rawget=next,type,tonumber,rawget
-local byte,char,gmatch=string.byte,string.char,string.gmatch
+local byte,char,gmatch,sub=string.byte,string.char,string.gmatch,string.sub
local concat,remove,unpack=table.concat,table.remove,table.unpack
local floor,abs,round,ceil,min,max=math.floor,math.abs,math.round,math.ceil,math.min,math.max
local P,C,R,S,C,Cs,Ct=lpeg.P,lpeg.C,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Ct
@@ -14088,6 +14088,37 @@ local defaultstrings={ [0]=
"Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003",
"Black","Bold","Book","Light","Medium","Regular","Roman","Semibold",
}
+local standardnames={ [0]=
+ false,false,false,false,false,false,false,false,false,false,false,
+ false,false,false,false,false,false,false,false,false,false,false,
+ false,false,false,false,false,false,false,false,false,false,
+ "space","exclam","quotedbl","numbersign","dollar","percent",
+ "ampersand","quoteright","parenleft","parenright","asterisk","plus",
+ "comma","hyphen","period","slash","zero","one","two","three","four",
+ "five","six","seven","eight","nine","colon","semicolon","less",
+ "equal","greater","question","at","A","B","C","D","E","F","G","H",
+ "I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W",
+ "X","Y","Z","bracketleft","backslash","bracketright","asciicircum",
+ "underscore","quoteleft","a","b","c","d","e","f","g","h","i","j",
+ "k","l","m","n","o","p","q","r","s","t","u","v","w","x","y",
+ "z","braceleft","bar","braceright","asciitilde",false,false,false,
+ false,false,false,false,false,false,false,false,false,false,false,
+ false,false,false,false,false,false,false,false,false,false,false,
+ false,false,false,false,false,false,false,false,false,"exclamdown",
+ "cent","sterling","fraction","yen","florin","section","currency",
+ "quotesingle","quotedblleft","guillemotleft","guilsinglleft",
+ "guilsinglright","fi","fl",false,"endash","dagger","daggerdbl",
+ "periodcentered",false,"paragraph","bullet","quotesinglbase",
+ "quotedblbase","quotedblright","guillemotright","ellipsis","perthousand",
+ false,"questiondown",false,"grave","acute","circumflex","tilde",
+ "macron","breve","dotaccent","dieresis",false,"ring","cedilla",false,
+ "hungarumlaut","ogonek","caron","emdash",false,false,false,false,
+ false,false,false,false,false,false,false,false,false,false,false,
+ false,"AE",false,"ordfeminine",false,false,false,false,"Lslash",
+ "Oslash","OE","ordmasculine",false,false,false,false,false,"ae",
+ false,false,false,"dotlessi",false,false,"lslash","oslash","oe",
+ "germandbls",false,false,false,false
+}
local cffreaders={
readbyte,
readushort,
@@ -14449,6 +14480,7 @@ do
local x=0
local y=0
local width=false
+ local lsb=0
local r=0
local stems=0
local globalbias=0
@@ -14472,6 +14504,9 @@ do
local factors=false
local axis=false
local vsindex=0
+ local justpass=false
+ local seacs={}
+ local procidx=nil
local function showstate(where)
report("%w%-10s : [%s] n=%i",depth*2,where,concat(stack," ",1,top),top)
end
@@ -15011,14 +15046,14 @@ do
top=0
end
local function divide()
- if version==1 then
+ if version=="cff" then
local d=stack[top]
top=top-1
stack[top]=stack[top]/d
end
end
local function closepath()
- if version==1 then
+ if version=="cff" then
if trace_charstrings then
showstate("closepath")
end
@@ -15026,54 +15061,65 @@ do
top=0
end
local function hsbw()
- if version==1 then
+ if version=="cff" then
if trace_charstrings then
showstate("hsbw")
end
+ lsb=stack[top-1] or 0
width=stack[top]
end
top=0
end
- local function seac()
- if version==1 then
+ local function sbw()
+ if version=="cff" then
if trace_charstrings then
- showstate("seac")
+ showstate("sbw")
end
+ lsb=stack[top-3]
+ width=stack[top-1]
end
top=0
end
- local function sbw()
- if version==1 then
+ local function seac()
+ if version=="cff" then
if trace_charstrings then
- showstate("sbw")
+ showstate("seac")
end
- width=stack[top-1]
end
top=0
end
+ local popped=3
+ local hints=3
local function callothersubr()
- if version==1 then
+ if version=="cff" then
if trace_charstrings then
- showstate("callothersubr (unsupported)")
+ showstate("callothersubr")
end
+ if stack[top]==hints then
+ popped=stack[top-2]
+ else
+ popped=3
+ end
+ top=top-(stack[top-1]+2)
+ else
+ top=0
end
- top=0
end
local function pop()
- if version==1 then
+ if version=="cff" then
if trace_charstrings then
- showstate("pop (unsupported)")
+ showstate("pop")
end
top=top+1
- stack[top]=0
+ stack[top]=popped
else
top=0
end
end
local function setcurrentpoint()
- if version==1 then
+ if version=="cff" then
if trace_charstrings then
- showstate("pop (unsupported)")
+ showstate("setcurrentpoint (unsupported)")
end
x=x+stack[top-1]
y=y+stack[top]
@@ -15199,6 +15245,39 @@ do
vhcurveto,
hvcurveto,
}
+ local reverse={ [0]="unsupported",
+ "getstem",
+ "unsupported",
+ "getstem",
+ "vmoveto",
+ "rlineto",
+ "hlineto",
+ "vlineto",
+ "rrcurveto",
+ "unsupported",
+ "unsupported",
+ "unsupported",
+ "unsupported",
+ "hsbw",
+ "unsupported",
+ "setvsindex",
+ "blend",
+ "unsupported",
+ "getstem",
+ "getmask",
+ "getmask",
+ "rmoveto",
+ "hmoveto",
+ "getstem",
+ "rcurveline",
+ "rlinecurve",
+ "vvcurveto",
+ "hhcurveto",
+ "unsupported",
+ "unsupported",
+ "vhcurveto",
+ "hvcurveto",
+ }
local subactions={
[000]=dotsection,
[001]=getstem3,
@@ -15312,7 +15391,7 @@ do
local function call(scope,list,bias)
depth=depth+1
if top==0 then
- showstate(formatters["unknown %s call %s"](scope,"?"))
+ showstate(formatters["unknown %s call %s, case %s"](scope,"?",1))
top=0
else
local index=stack[top]+bias
@@ -15324,13 +15403,12 @@ do
if tab then
process(tab)
else
- showstate(formatters["unknown %s call %s"](scope,index))
+ showstate(formatters["unknown %s call %s, case %s"](scope,index,2))
top=0
end
end
depth=depth-1
end
- local justpass=false
process=function(tab)
local i=1
local n=#tab
@@ -15401,6 +15479,17 @@ do
r=r+1;result[r]=chars[12]
r=r+1;result[r]=chars[t]
top=0
+ elseif t==6 then
+ seacs[procidx]={
+ asb=stack[1],
+ adx=stack[2],
+ ady=stack[3],
+ base=stack[4],
+ accent=stack[5],
+ width=width,
+ lsb=lsb,
+ }
+ top=0
else
local a=subactions[t]
if a then
@@ -15430,44 +15519,52 @@ do
i=i+s+1
elseif t==1 or t==3 or t==18 or operation==23 then
p_getstem()
-if true then
- if top>0 then
- for i=1,top do
- r=r+1;result[r]=encode[stack[i]]
+ if true then
+ if top>0 then
+ for i=1,top do
+ r=r+1;result[r]=encode[stack[i]]
+ end
+ top=0
end
+ r=r+1;result[r]=chars[t]
+ else
top=0
end
- r=r+1;result[r]=chars[t]
-else
- top=0
-end
i=i+1
elseif t==19 or t==20 then
local s=p_getmask() or 0
-if true then
- if top>0 then
- for i=1,top do
- r=r+1;result[r]=encode[stack[i]]
+ if true then
+ if top>0 then
+ for i=1,top do
+ r=r+1;result[r]=encode[stack[i]]
+ end
+ top=0
end
+ r=r+1;result[r]=chars[t]
+ for j=1,s do
+ i=i+1
+ r=r+1;result[r]=chars[tab[i]]
+ end
+ else
+ i=i+s
top=0
end
- r=r+1;result[r]=chars[t]
- for j=1,s do
- i=i+1
- r=r+1;result[r]=chars[tab[i]]
- end
-else
- i=i+s
- top=0
-end
i=i+1
elseif t==9 then
top=0
i=i+1
elseif t==13 then
- local s=hsbw() or 0
- i=i+s+1
+ hsbw()
+ if version=="cff" then
+ r=r+1;result[r]=encode[lsb]
+ r=r+1;result[r]=chars[22]
+ else
+ end
+ i=i+1
else
+ if trace_charstrings then
+ showstate(reverse[t] or "<action>")
+ end
if top>0 then
for i=1,top do
r=r+1;result[r]=encode[stack[i]]
@@ -15488,7 +15585,7 @@ end
end
else
if trace_charstrings then
- showvalue("<action>",t)
+ showstate(reverse[t] or "<action>")
end
top=0
i=i+1
@@ -15507,7 +15604,7 @@ end
((l<1240 and 107) or (l<33900 and 1131) or 32768)+1
end
end
- local function processshape(tab,index)
+ local function processshape(tab,index,hack)
if not tab then
glyphs[index]={
boundingbox={ 0,0,0,0 },
@@ -15520,10 +15617,13 @@ end
x=0
y=0
width=false
+ lsb=0
r=0
top=0
stems=0
result={}
+ popped=3
+ procidx=index
xmin=0
xmax=0
ymin=0
@@ -15537,6 +15637,9 @@ end
updateregions(vsindex)
end
process(tab)
+ if hack then
+ return x,y
+ end
local boundingbox={
round(xmin),
round(ymin),
@@ -15591,6 +15694,8 @@ end
axis=false
regions=data.regions
justpass=streams==true
+ popped=3
+ seacs={}
if regions then
regions={ regions }
axis=data.factors or false
@@ -15604,6 +15709,8 @@ end
locals=false
globals=false
strings=false
+ popped=3
+ seacs={}
end
local function setwidths(private)
if not private then
@@ -15633,6 +15740,29 @@ end
for index=1,#charstrings do
processshape(charstrings[index],index-1)
end
+ if justpass and next(seacs) then
+ local charset=data.dictionaries[1].charset
+ if charset then
+ local lookup=table.swapped(charset)
+ for index,v in next,seacs do
+ local bindex=lookup[standardnames[v.base]]
+ local aindex=lookup[standardnames[v.accent]]
+ local bglyph=bindex and glyphs[bindex]
+ local aglyph=aindex and glyphs[aindex]
+ if bglyph and aglyph then
+ local jp=justpass
+ justpass=false
+ local x,y=processshape(charstrings[bindex+1],bindex,true)
+ justpass=jp
+ local base=bglyph.stream
+ local accent=aglyph.stream
+ local moveto=encode[-x-v.asb+v.adx]..chars[22]..encode[-y+v.ady]..chars[ 4]
+ base=sub(base,1,#base-1)
+ glyphs[index].stream=base..moveto..accent
+ end
+ end
+ end
+ end
stopparsing(fontdata,data)
else
report("no charstrings")
@@ -15649,6 +15779,7 @@ end
vsindex=dictionary.vsindex or 0
glyphs=glphs or {}
justpass=streams==true
+ seacs={}
globalbias,localbias=setbias(globals,locals,nobias)
nominalwidth,defaultwidth=setwidths(dictionary.private)
processshape(tab,index-1)
@@ -32380,7 +32511,6 @@ do
local pdfshapes={}
local inkscape=runner()
if inkscape then
- local indices=fonts.getindices(tfmdata)
local descriptions=tfmdata.descriptions
local nofshapes=#svgshapes
local f_svgfile=formatters["temp-otf-svg-shape-%i.svg"]