summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-07-15 23:43:51 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-07-15 23:43:51 +0200
commit3eb2d078f0023266585aec42d98326d72567b9d6 (patch)
tree115ce667ddeb5c3e4a3c2ba6e14ff1869c63fbd5 /tex/generic
parent1373cbe7fd26acc28c673ebee8eeab3ec120f294 (diff)
downloadcontext-3eb2d078f0023266585aec42d98326d72567b9d6.tar.gz
2016-07-15 23:35:00
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua67
-rw-r--r--tex/generic/context/luatex/luatex-plain-tfm.lua120
2 files changed, 63 insertions, 124 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index ed3791419..e293f83d7 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 : 07/14/16 19:52:26
+-- merge date : 07/15/16 23:30:10
do -- begin closure to overcome local limits and interference
@@ -4103,7 +4103,9 @@ if not modules then modules={} end modules ['util-fil']={
license="see context related readme files"
}
local byte=string.byte
+local char=string.char
local extract=bit32.extract
+local floor=math.floor
utilities=utilities or {}
local files={}
utilities.files=files
@@ -4122,6 +4124,7 @@ end
function files.size(f)
return f:seek("end")
end
+files.getsize=files.size
function files.setposition(f,n)
if zerobased[f] then
f:seek("set",n)
@@ -4242,6 +4245,28 @@ end
function files.skiplong(f,n)
f:read(4*(n or 1))
end
+function files.writecardinal2(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(b,a)
+end
+function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+end
+function files.writestring(f,s)
+ f:write(char(byte(s,1,#s)))
+end
+function files.writebyte(f,b)
+ f:write(char(b))
+end
end -- closure
@@ -7608,7 +7633,9 @@ handlers.otf=otf
local readers=otf.readers or {}
otf.readers=readers
local streamreader=utilities.files
+local streamwriter=utilities.files
readers.streamreader=streamreader
+readers.streamwriter=streamwriter
local openfile=streamreader.open
local closefile=streamreader.close
local setposition=streamreader.setposition
@@ -15613,10 +15640,38 @@ local function copytotfm(data,cache_id)
}
end
end
+local converters={
+ woff={
+ cachename="webfonts",
+ action=otf.readers.woff2otf,
+ }
+}
+local function checkconversion(specification)
+ local filename=specification.filename
+ local converter=converters[lower(file.suffix(filename))]
+ if converter then
+ local base=file.basename(filename)
+ local name=file.removesuffix(base)
+ local attr=lfs.attributes(filename)
+ local size=attr and attr.size or 0
+ local time=attr and attr.modification or 0
+ if size>0 then
+ local cleanname=containers.cleanname(name)
+ local cachename=caches.setfirstwritablefile(cleanname,converter.cachename)
+ if not io.exists(cachename) or (time~=lfs.attributes(cachename).modification) then
+ report_otf("caching font %a in %a",filename,cachename)
+ converter.action(filename,cachename)
+ lfs.touch(cachename,time,time)
+ end
+ specification.filename=cachename
+ end
+ end
+end
local function otftotfm(specification)
local cache_id=specification.hash
local tfmdata=containers.read(constructors.cache,cache_id)
if not tfmdata then
+ checkconversion(specification)
local name=specification.name
local sub=specification.sub
local subindex=specification.subindex
@@ -15824,9 +15879,13 @@ local function opentypereader(specification,suffix)
end
end
readers.opentype=opentypereader
-function readers.otf (specification) return opentypereader(specification,"otf") end
-function readers.ttf (specification) return opentypereader(specification,"ttf") end
-function readers.ttc (specification) return opentypereader(specification,"ttf") end
+function readers.otf(specification) return opentypereader(specification,"otf") end
+function readers.ttf(specification) return opentypereader(specification,"ttf") end
+function readers.ttc(specification) return opentypereader(specification,"ttf") end
+function readers.woff(specification)
+ checkconversion(specification)
+ opentypereader(specification,"")
+end
function otf.scriptandlanguage(tfmdata,attr)
local properties=tfmdata.properties
return properties.script or "dflt",properties.language or "dflt"
diff --git a/tex/generic/context/luatex/luatex-plain-tfm.lua b/tex/generic/context/luatex/luatex-plain-tfm.lua
deleted file mode 100644
index 4a08fb4c7..000000000
--- a/tex/generic/context/luatex/luatex-plain-tfm.lua
+++ /dev/null
@@ -1,120 +0,0 @@
-if not modules then modules = { } end modules ['luatex-plain-tfm'] = {
- version = 1.001,
- comment = "companion to luatex-*.tex",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- \font\foo=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr;pfb=csr10 at 12pt
--- \font\bar=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr at 12pt
---
--- \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par
--- \bar áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par
-
-local outfiles = { }
-
-return function(specification)
-
- local size = specification.size
- local name = specification.name
- local feat = specification.features and specification.features.normal
-
- if not feat then
- return
- end
-
- local tfm = feat.tfm
- local enc = feat.enc or tfm
- local pfb = feat.pfb
-
- if not tfm then
- return
- end
-
- local tfmfile = tfm .. ".tfm"
- local encfile = enc .. ".enc"
-
- local tfmdata, id = fonts.constructors.readanddefine("file:"..tfmfile,size)
-
- local encoding = fonts.encodings.load(encfile)
- if encoding then
- encoding = encoding.hash
- else
- encoding = false
- end
-
- local unicoding = fonts.encodings.agl and fonts.encodings.agl.unicodes
-
- if tfmdata and encoding and unicoding then
-
- tfmdata = table.copy(tfmdata) -- good enough for small fonts
-
- local characters = { }
- local originals = tfmdata.characters
- local indices = { }
- local parentfont = { "font", 1 }
- local private = fonts.constructors.privateoffset
-
- -- create characters table
-
- for name, index in table.sortedhash(encoding) do -- predictable order
- local unicode = unicoding[name]
- local original = originals[index]
- if not unicode then
- unicode = private
- private = private + 1
- report_tfm("glyph %a in font %a gets private unicode %U",name,tfmfile,private)
- end
- characters[unicode] = original
- indices[index] = unicode
- original.name = name -- so one can lookup weird names
- original.commands = { parentfont, { "char", index } }
- end
-
- -- redo kerns and ligatures
-
- for k, v in next, characters do
- local kerns = v.kerns
- if kerns then
- local t = { }
- for k, v in next, kerns do
- local i = indices[k]
- t[i] = v
- end
- v.kerns = t
- end
- local ligatures = v.ligatures
- if ligatures then
- local t = { }
- for k, v in next, ligatures do
- t[indices[k]] = v
- v.char = indices[v.char]
- end
- v.ligatures = t
- end
- end
-
- -- wrap up
-
- tfmdata.fonts = { { id = id } }
- tfmdata.characters = characters
-
- -- resources
-
- local outfile = outfiles[tfmfile]
-
- if outfile == nil then
- if pfb then
- outfile = pfb .. ".pfb"
- pdf.mapline(tfm .. "<" .. outfile)
- else
- outfile = false
- end
- outfiles[tfmfile] = outfile
- end
-
- end
-
- return tfmdata
-end