summaryrefslogtreecommitdiff
path: root/tex
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
parent1373cbe7fd26acc28c673ebee8eeab3ec120f294 (diff)
downloadcontext-3eb2d078f0023266585aec42d98326d72567b9d6.tar.gz
2016-07-15 23:35:00
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/context-version.pdfbin4270 -> 4266 bytes
-rw-r--r--tex/context/base/mkiv/colo-ini.lua38
-rw-r--r--tex/context/base/mkiv/colo-ini.mkiv217
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/font-lib.mkvi1
-rw-r--r--tex/context/base/mkiv/font-otl.lua49
-rw-r--r--tex/context/base/mkiv/font-otr.lua2
-rw-r--r--tex/context/base/mkiv/font-tmp.lua118
-rw-r--r--tex/context/base/mkiv/font-web.lua182
-rw-r--r--tex/context/base/mkiv/lang-txt.lua28
-rw-r--r--tex/context/base/mkiv/math-noa.lua46
-rw-r--r--tex/context/base/mkiv/publ-imp-apa.mkvi143
-rw-r--r--tex/context/base/mkiv/publ-imp-aps.mkvi72
-rw-r--r--tex/context/base/mkiv/publ-imp-cite.mkvi68
-rw-r--r--tex/context/base/mkiv/publ-imp-default.mkvi16
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9192 -> 9209 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin367147 -> 367371 bytes
-rw-r--r--tex/context/base/mkiv/util-fil.lua35
-rw-r--r--tex/context/interface/mkiv/i-color.xml87
-rw-r--r--tex/context/interface/mkiv/i-common-value.xml23
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin821565 -> 796268 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin60795 -> 60792 bytes
-rw-r--r--tex/context/modules/mkiv/x-setups-basics.mkiv38
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua67
-rw-r--r--tex/generic/context/luatex/luatex-plain-tfm.lua120
26 files changed, 791 insertions, 563 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 0d2201e42..4b36feacb 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua
index f094259e0..1213a637f 100644
--- a/tex/context/base/mkiv/colo-ini.lua
+++ b/tex/context/base/mkiv/colo-ini.lua
@@ -37,6 +37,8 @@ local transparencies = attributes.transparencies
local colorintents = attributes.colorintents
local registrations = backends.registrations
+local v_reset = interfaces.variables.reset
+
local texsetattribute = tex.setattribute
local texgetattribute = tex.getattribute
local texgetcount = tex.getcount
@@ -290,8 +292,32 @@ colors.forcedmodel = forcedmodel
colors.couple = true
-local function definetransparency(name,n)
- transparent[name] = n
+local function definetransparency(name,n,global)
+ if n == v_reset then
+ definetransparent(name, 0, global) -- or attributes.unsetvalue
+ return
+ end
+ local a = tonumber(n)
+ if a then
+ transparent[name] = a -- 0 .. 16
+ return
+ end
+ local a = transparent[name]
+ if a then
+ transparent[name] = a
+ return
+ end
+ local settings = settings_to_hash_strict(n)
+ if settings then
+ local a, t = settings.a, settings.t
+ if a and t then
+ definetransparent(name, transparencies.register(name,transparent[a] or tonumber(a) or 1,tonumber(t) or 1), global)
+ else
+ definetransparent(name, 0, global)
+ end
+ else
+ inherittransparent(name, n, global)
+ end
end
colors.definetransparency = definetransparency
@@ -1090,7 +1116,13 @@ implement {
implement {
name = "definetransparency",
actions = definetransparency,
- arguments = { "string", "integer" }
+ arguments = { "string", "string" }
+}
+
+implement {
+ name = "definetransparencyglobal",
+ actions = definetransparency,
+ arguments = { "string", "string", true }
}
implement {
diff --git a/tex/context/base/mkiv/colo-ini.mkiv b/tex/context/base/mkiv/colo-ini.mkiv
index 8376a9687..915a5559b 100644
--- a/tex/context/base/mkiv/colo-ini.mkiv
+++ b/tex/context/base/mkiv/colo-ini.mkiv
@@ -99,13 +99,14 @@
%D \stopcombination
%D \stoptyping
-\unexpanded\def\definecolor {\dodoubleargument\colo_basics_define}
-\unexpanded\def\defineglobalcolor {\dodoubleargument\colo_basics_define_global}
-\unexpanded\def\defineprocesscolor {\dotripleargument\colo_basics_define_process}
-\unexpanded\def\definenamedcolor {\dodoubleargument\colo_basics_define_named}
-\unexpanded\def\definespotcolor {\dotripleargument\colo_basics_define_spot}
-\unexpanded\def\definemultitonecolor{\doquadrupleempty\colo_basics_define_multitone}
-\unexpanded\def\definetransparency {\dodoubleargument\colo_basics_define_transpancy}
+\unexpanded\def\definecolor {\dodoubleargument\colo_basics_define}
+\unexpanded\def\defineglobalcolor {\dodoubleargument\colo_basics_define_global}
+\unexpanded\def\defineprocesscolor {\dotripleargument\colo_basics_define_process}
+\unexpanded\def\definenamedcolor {\dodoubleargument\colo_basics_define_named}
+\unexpanded\def\definespotcolor {\dotripleargument\colo_basics_define_spot}
+\unexpanded\def\definemultitonecolor {\doquadrupleempty\colo_basics_define_multitone}
+\unexpanded\def\definetransparency {\dodoubleargument\colo_basics_define_transpancy}
+\unexpanded\def\defineglobaltransparency{\dodoubleargument\colo_basics_define_transpancy_global}
%D \macros
%D {startcolor,stopcolor,color,graycolor}
@@ -128,42 +129,154 @@
\let\g_color\empty
\let\g_style\empty
-\unexpanded\def\switchtocolor[#1]{\csname#1\endcsname}
+\unexpanded\def\switchtocolor[#1]{\begincsname#1\endcsname}
-\unexpanded\def\color [#1]{\bgroup
- \def\g_color{\colo_helpers_activate{#1}}%
- \afterassignment\g_color
- \let\nexttoken}
+% \unexpanded\def\color [#1]{\bgroup
+% \def\g_color{\colo_helpers_activate{#1}}%
+% \afterassignment\g_color
+% \let\nexttoken}
+%
+% \unexpanded\def\graycolor [#1]{\bgroup
+% \def\g_color{\colo_helpers_set_model\s!gray\colo_helpers_activate{#1}}%
+% \afterassignment\g_color
+% \let\nexttoken}
+%
+% \unexpanded\def\startcolor [#1]{\begingroup
+% \colo_helpers_activate{#1}}
+%
+% \unexpanded\def\stopcolor {\endgroup}
+%
+% \unexpanded\def\colored [#1]{\bgroup
+% \def\g_color{\colo_basics_defined_and_activated{#1}}%
+% \afterassignment\g_color
+% \let\nexttoken}
+%
+% \unexpanded\def\fastcolored[#1]#2{\begingroup % is this command still needed?
+% \colo_basics_defined_and_activated{#1}%
+% #2%
+% \endgroup}
+%
+% \unexpanded\def\directcolored[#1]{\colo_basics_defined_and_activated{#1}}
+%
+% \unexpanded\def\fastcolor [#1]#2{\begingroup % is this command still needed?
+% \colo_helpers_activate{#1}%
+% #2%
+% \endgroup}
+%
+% \unexpanded\def\directcolor [#1]{\colo_helpers_activate{#1}}
+%
+% \afterassignment was a left-over artifact
-\unexpanded\def\graycolor [#1]{\bgroup
- \def\g_color{\colo_helpers_set_model\s!gray\colo_helpers_activate{#1}}%
- \afterassignment\g_color
- \let\nexttoken}
+% transparency
-\unexpanded\def\startcolor [#1]{\begingroup
- \colo_helpers_activate{#1}}
+\unexpanded\def\transparent[#1]%
+ {\bgroup
+ \edef\currenttransparencyname{#1}%
+ % the \relax catches a non existent csname
+ \ifx\currenttransparencyname\v!reset
+ \attribute\transparencyattribute\attributeunsetvalue
+ \else
+ \begincsname\??transparencysetter\currenttransparencyname\endcsname\relax
+ \fi
+ \let\nexttoken}
-\unexpanded\def\stopcolor {\endgroup}
+\unexpanded\def\starttransparent[#1]%$
+ {\begingroup
+ \edef\currenttransparencyname{#1}%
+ \ifx\currenttransparencyname\v!reset
+ \attribute\transparencyattribute\attributeunsetvalue
+ \else
+ \begincsname\??transparencysetter\currenttransparencyname\endcsname\relax
+ \fi}
-\unexpanded\def\colored [#1]{\bgroup
- \def\g_color{\colo_basics_defined_and_activated{#1}}%
- \afterassignment\g_color
- \let\nexttoken}
+\unexpanded\def\stoptransparent
+ {\endgroup}
-\unexpanded\def\fastcolored[#1]#2{\begingroup % is this command still needed?
- \colo_basics_defined_and_activated{#1}%
- #2%
- \endgroup}
+% color
-\unexpanded\def\directcolored[#1]{\colo_basics_defined_and_activated{#1}}
+\unexpanded\def\coloronly[#1]%
+ {\bgroup
+ \edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop_only
+ \else
+ \colo_helpers_activate_yes_only
+ \fi
+ \let\nexttoken}
+
+\unexpanded\def\startcoloronly[#1]%$
+ {\begingroup
+ \edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop_only
+ \else
+ \colo_helpers_activate_yes_only
+ \fi}
+
+\unexpanded\def\stopcoloronly
+ {\endgroup}
+
+% color + transparency
-\unexpanded\def\fastcolor [#1]#2{\begingroup % is this command still needed?
- \colo_helpers_activate{#1}%
- #2%
- \endgroup}
+\unexpanded\def\color[#1]%
+ {\bgroup
+ \edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi
+ \let\nexttoken}
+
+\unexpanded\def\graycolor[#1]%
+ {\bgroup
+ \colo_helpers_set_model\s!gray\colo_helpers_activate{#1}%
+ \let\nexttoken}
+
+\unexpanded\def\startcolor[#1]%$
+ {\begingroup
+ \edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi}
-\unexpanded\def\directcolor [#1]{\colo_helpers_activate{#1}}
+\unexpanded\def\stopcolor
+ {\endgroup}
+\unexpanded\def\colored[#1]%
+ {\bgroup
+ \colo_basics_defined_and_activated{#1}%
+ \let\nexttoken}
+
+\unexpanded\def\fastcolored[#1]#2%
+ {\begingroup % is this command still needed?
+ \colo_basics_defined_and_activated{#1}%
+ #2%
+ \endgroup}
+
+\unexpanded\def\directcolored[#1]%
+ {\colo_basics_defined_and_activated{#1}}
+
+\unexpanded\def\fastcolor [#1]#2%
+ {\begingroup % is this command still needed?
+ \edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi
+ #2%
+ \endgroup}
+
+\unexpanded\def\directcolor[#1]%
+ {\edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi}
%D The following command is obsolete:
@@ -690,20 +803,24 @@
\csname\??transparencysetter#1\endcsname
\fi}
+\def\colo_helpers_activate_dummy
+ {\csname\??colorsetter \v_colo_dummy_name\endcsname
+ \csname\??transparencysetter\v_colo_dummy_name\endcsname}
+
\let\dofastcoloractivation\colo_helpers_fast_activate
% so far
-\def\colo_helpers_activate % two-step is not that much faster but less tracing
- {\ifx\currentcolorprefix\empty
+\def\colo_helpers_activate#1% two-step is not that much faster but less tracing
+ {\edef\currentcolorname{#1}%
+ \ifx\currentcolorprefix\empty
\expandafter\colo_helpers_activate_nop
\else
\expandafter\colo_helpers_activate_yes
\fi}
-\def\colo_helpers_activate_yes#1%
- {\edef\currentcolorname{#1}%
- \ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
+\def\colo_helpers_activate_yes
+ {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
\lastnamedcs
\csname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname
\else\ifcsname\??colorsetter\currentcolorname\endcsname
@@ -711,16 +828,23 @@
\csname\??transparencysetter\currentcolorname\endcsname
\fi\fi}
-\def\colo_helpers_activate_nop#1%
- {\edef\currentcolorname{#1}%
- \ifcsname\??colorsetter\currentcolorname\endcsname
+\def\colo_helpers_activate_nop
+ {\ifcsname\??colorsetter\currentcolorname\endcsname
\lastnamedcs
\csname\??transparencysetter\currentcolorname\endcsname
\fi}
-\def\colo_helpers_activate_dummy
- {\csname\??colorsetter \v_colo_dummy_name\endcsname
- \csname\??transparencysetter\v_colo_dummy_name\endcsname}
+\def\colo_helpers_activate_yes_only
+ {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
+ \lastnamedcs
+ \else\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \fi\fi}
+
+\def\colo_helpers_activate_nop_only
+ {\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \fi}
\let\dousecolorparameter\colo_helpers_activate
@@ -856,7 +980,10 @@
%D Transparencies (only):
\def\colo_basics_define_transpancy[#1][#2]%
- {\clf_definetransparency{#1}#2\relax}
+ {\clf_definetransparency{#1}{#2}}
+
+\def\colo_basics_define_transpancy_global[#1][#2]%
+ {\clf_definetransparencyglobal{#1}{#2}}
% A goodie that replaces the startMPcolor hackery
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index ad6c764c2..cad11bcd0 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2016.07.14 19:52}
+\newcontextversion{2016.07.15 23:30}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 255b31b9f..1a6eccdb9 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2016.07.14 19:52}
+\edef\contextversion{2016.07.15 23:30}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi
index 3bfe308ff..6b891542c 100644
--- a/tex/context/base/mkiv/font-lib.mkvi
+++ b/tex/context/base/mkiv/font-lib.mkvi
@@ -27,6 +27,7 @@
% the otf font loader:
\registerctxluafile{font-otr}{1.001} % opentype fontloader
+\registerctxluafile{font-web}{1.001} % opentype fontloader
\registerctxluafile{font-cff}{1.001} % quadratic outlines
\registerctxluafile{font-ttf}{1.001} % cubic outlines
%registerctxluafile{font-tmp}{1.001} % temporary placeholder
diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua
index a35db5b0a..bdce80db2 100644
--- a/tex/context/base/mkiv/font-otl.lua
+++ b/tex/context/base/mkiv/font-otl.lua
@@ -574,10 +574,48 @@ local function copytotfm(data,cache_id)
end
end
+-- These woff files are a kind of joke in a tex environment because one can simply convert
+-- them to ttf/otf and use them as such (after all, we cache them too). The successor format
+-- woff2 is more complex so there we can as well call an external converter which in the end
+-- makes this code kind of obsolete before it's even used. Although ... it might become a
+-- more general conversion plug in.
+
+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) -- todo infoonly
+ 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) -- for the moment here
+
local name = specification.name
local sub = specification.sub
local subindex = specification.subindex
@@ -811,9 +849,14 @@ end
readers.opentype = opentypereader -- kind of useless and obsolete
-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
-- this will be overloaded
diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua
index 7d0bf046c..7c81285c1 100644
--- a/tex/context/base/mkiv/font-otr.lua
+++ b/tex/context/base/mkiv/font-otr.lua
@@ -94,8 +94,10 @@ otf.readers = readers
----- streamreader = utilities.streams -- faster on big files
local streamreader = utilities.files -- faster on identify
+local streamwriter = utilities.files
readers.streamreader = streamreader
+readers.streamwriter = streamwriter
local openfile = streamreader.open
local closefile = streamreader.close
diff --git a/tex/context/base/mkiv/font-tmp.lua b/tex/context/base/mkiv/font-tmp.lua
deleted file mode 100644
index 36fc01dbc..000000000
--- a/tex/context/base/mkiv/font-tmp.lua
+++ /dev/null
@@ -1,118 +0,0 @@
-if not modules then modules = { } end modules ['font-tmp'] = {
- version = 1.001,
- comment = "companion to font-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- There is a complete feature loader but it needs a bit of testing, first so this
--- one does design size only (as needed for identifying).
-
-local next, type = next, type
-
-local report = logs.reporter("otf reader")
-
-local readers = fonts.handlers.otf.readers
-local streamreader = readers.streamreader
-
-local readushort = streamreader.readcardinal2 -- 16-bit unsigned integer
-local readulong = streamreader.readcardinal4 -- 24-bit unsigned integer
------ readshort = streamreader.readinteger2 -- 16-bit signed integer
-local readtag = streamreader.readtag
-local skipshort = streamreader.skipshort
-local setposition = streamreader.setposition
-
-local plugins = { }
-
-function plugins.size(f,fontdata,tableoffset,parameters)
- if not fontdata.designsize then
- setposition(f,tableoffset+parameters)
- local designsize = readushort(f)
- if designsize > 0 then
- fontdata.designsize = designsize
- skipshort(f,2)
- fontdata.minsize = readushort(f)
- fontdata.maxsize = readushort(f)
- end
- end
-end
-
-local function readscripts(f,fontdata,what)
- local datatable = fontdata.tables[what]
- if not datatable then
- return
- end
- local tableoffset = datatable.offset
- setposition(f,tableoffset)
- local version = readulong(f)
- if version ~= 0x00010000 then
- report("table version %a of %a is not supported (yet), maybe font %s is bad",version,what,fontdata.filename)
- return
- end
- --
- local scriptoffset = tableoffset + readushort(f)
- local featureoffset = tableoffset + readushort(f)
- local lookupoffset = tableoffset + readushort(f)
- --
- setposition(f,scriptoffset)
- local nofscripts = readushort(f)
- local scripts = { }
- for i=1,nofscripts do
- scripts[readtag(f)] = scriptoffset + readushort(f)
- end
- local languagesystems = table.setmetatableindex("table") -- we share when possible
- for script, offset in next, scripts do
- setposition(f,offset)
- local defaultoffset = readushort(f)
- local noflanguages = readushort(f)
- local languages = { }
- if defaultoffset > 0 then
- languages.dflt = languagesystems[offset + defaultoffset]
- end
- for i=1,noflanguages do
- local language = readtag(f)
- local offset = offset + readushort(f)
- languages[language] = languagesystems[offset]
- end
- scripts[script] = languages
- end
- --
- setposition(f,featureoffset)
- local features = { }
- local noffeatures = readushort(f)
- for i=1,noffeatures do
- features[i] = {
- tag = readtag(f),
- offset = readushort(f)
- }
- end
- --
- for i=1,noffeatures do
- local feature = features[i]
- local offset = featureoffset + feature.offset
- setposition(f,offset)
- local parameters = readushort(f) -- feature.parameters
- local noflookups = readushort(f)
- skipshort(f,noflookups+1)
- if parameters > 0 then
- feature.parameters = parameters
- local plugin = plugins[feature.tag]
- if plugin then
- plugin(f,fontdata,offset,parameters)
- end
- end
- end
-end
-
-function readers.gsub(f,fontdata,specification)
- if specification.details then
- readscripts(f,fontdata,"gsub")
- end
-end
-
-function readers.gpos(f,fontdata,specification)
- if specification.details then
- readscripts(f,fontdata,"gpos")
- end
-end
diff --git a/tex/context/base/mkiv/font-web.lua b/tex/context/base/mkiv/font-web.lua
new file mode 100644
index 000000000..8ea57f301
--- /dev/null
+++ b/tex/context/base/mkiv/font-web.lua
@@ -0,0 +1,182 @@
+if not modules then modules = { } end modules ['font-otr'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Okay, compressing fonts this way is rather simple but one might wonder what the gain
+-- is in this time of 4K youtube movies and most of the web pages wasting space and
+-- bandwidth on advertisements. For version 2 we can use "woff2_decompress" from google
+-- and in a tex environment one can as well store the ttf/otf files in the tex tree. So,
+-- eventually we might even remove this code when version 1 is obsolete.
+
+local readers = fonts and fonts.handlers.otf.readers
+
+local streamreader = readers and readers.streamreader or utilities.files
+local streamwriter = readers and readers.streamwriter or utilities.files
+
+local readstring = streamreader.readstring
+local readcardinal2 = streamreader.readcardinal2
+local readcardinal4 = streamreader.readcardinal4
+
+local writestring = streamwriter.writestring
+local writecardinal4 = streamwriter.writecardinal4
+local writecardinal2 = streamwriter.writecardinal2
+local writebyte = streamwriter.writebyte
+
+local getsize = streamreader.getsize
+local setposition = streamreader.setposition
+local getposition = streamreader.getposition
+
+local decompress = zlib.decompress
+
+local infotags = {
+ ["os/2"] = true,
+ ["head"] = true,
+ ["maxp"] = true,
+ ["hhea"] = true,
+ ["hmtx"] = true,
+ ["post"] = true,
+ ["cmap"] = true,
+}
+
+local report = logs.reporter("fonts","woff")
+
+local function woff2otf(inpname,outname,infoonly)
+
+ local outname = outname or file.replacesuffix(inpname,"otf")
+ local inp = io.open(inpname,"rb")
+
+ if not inp then
+ report("invalid input file %a",inpname)
+ return
+ end
+
+ local signature = readstring(inp,4)
+
+ if not (signature == "wOFF" or signature == "wOF2") then
+ inp:close()
+ report("invalid signature in %a",inpname)
+ return
+ end
+
+ local flavor = readstring(inp,4)
+
+ if not (flavor == "OTTO" or flavor == "true" or flavor == "\0\1\0\0") then
+ inp:close()
+ report("unsupported flavor %a in %a",flavor,inpname)
+ return
+ end
+
+ if signature == "wOF2" then
+ inp:close()
+ if false then
+ os.execute("woff2_decompress " .. inpname .. " " .. outname)
+ return outname, flavor
+ else
+ report("skipping version 2 file %a",inpname)
+ return
+ end
+ end
+
+ local out = io.open(outname,"wb")
+
+ if not out then
+ inp:close()
+ report("invalid output file %a",outname)
+ return
+ end
+
+ local header = {
+ signature = signature,
+ flavor = flavor,
+ length = readcardinal4(inp),
+ numtables = readcardinal2(inp),
+ reserved = readcardinal2(inp),
+ totalsfntsize = readcardinal4(inp),
+ majorversion = readcardinal2(inp),
+ minorversion = readcardinal2(inp),
+ metaoffset = readcardinal4(inp),
+ metalength = readcardinal4(inp),
+ metaoriglength = readcardinal4(inp),
+ privoffset = readcardinal4(inp),
+ privlength = readcardinal4(inp),
+ }
+
+ local entries = { }
+
+ for i=1,header.numtables do
+ local entry = {
+ tag = readstring (inp,4),
+ offset = readcardinal4(inp),
+ compressed = readcardinal4(inp),
+ size = readcardinal4(inp),
+ checksum = readcardinal4(inp),
+ }
+ if not infoonly or infotags[lower(entry.tag)] then
+ entries[#entries+1] = entry
+ end
+ end
+
+ local nofentries = #entries
+ local entryselector = 0 -- we don't need these
+ local searchrange = 0 -- we don't need these
+ local rangeshift = 0 -- we don't need these
+
+ writestring (out,flavor)
+ writecardinal2(out,nofentries)
+ writecardinal2(out,entryselector)
+ writecardinal2(out,searchrange)
+ writecardinal2(out,rangeshift)
+
+ local offset = 12 + nofentries * 16
+ local offsets = { }
+
+ for i=1,nofentries do
+ local entry = entries[i]
+ local size = entry.size
+ writestring(out,entry.tag)
+ writecardinal4(out,entry.checksum)
+ writecardinal4(out,offset) -- the new offset
+ writecardinal4(out,size)
+ offsets[i] = offset
+ offset = offset + size
+ local p = 4 - offset % 4
+ if p > 0 then
+ offset = offset + p
+ end
+ end
+
+ for i=1,nofentries do
+ local entry = entries[i]
+ local offset = offsets[i]
+ local size = entry.size
+ setposition(inp,entry.offset+1)
+ local data = readstring(inp,entry.compressed)
+ if #data ~= size then
+ data = decompress(data)
+ end
+ setposition(out,offset+1)
+ writestring(out,data)
+ local p = 4 - offset + size % 4
+ if p > 0 then
+ for i=1,p do
+ writebyte(out,0)
+ end
+ end
+ end
+
+ inp:close()
+ out:close()
+
+ return outname, flavor
+
+end
+
+if readers then
+ readers.woff2otf = woff2otf
+else
+ return woff2otf
+end
diff --git a/tex/context/base/mkiv/lang-txt.lua b/tex/context/base/mkiv/lang-txt.lua
index 1575b7543..c3474e011 100644
--- a/tex/context/base/mkiv/lang-txt.lua
+++ b/tex/context/base/mkiv/lang-txt.lua
@@ -2773,6 +2773,16 @@ data.labels={
es = "Informe técnico",
},
},
+ ["patent"] = {
+ labels = {
+ en = "Patent",
+ nl = "Octrooi",
+ fr = "Brevet",
+ de = "Patent",
+ it = "Brevetto",
+ es = "Patente",
+ },
+ },
--
["editor"] = {
labels = {
@@ -2858,14 +2868,14 @@ data.labels={
--
["p"] = {
labels = {
- en = "p",
- de = "S",
+ en = "p.",
+ de = "S.",
},
},
["pp"] = {
labels = {
- en = "pp",
- de = "S",
+ en = "pp.",
+ de = "S.",
},
},
["pages"] = {
@@ -2886,6 +2896,16 @@ data.labels={
es = "y",
},
},
+ ["with"] = {
+ labels = {
+ en = "with",
+ nl = "met",
+ fr = "avec",
+ de = "mit",
+ it = "con",
+ es = "con",
+ },
+ },
["others"] = {
labels = {
en = "et al.",
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua
index 4532bf5cb..a291b3a59 100644
--- a/tex/context/base/mkiv/math-noa.lua
+++ b/tex/context/base/mkiv/math-noa.lua
@@ -1007,6 +1007,7 @@ end)
-- todo: set alternate for specific symbols
-- todo: no need to do this when already loaded
+-- todo: use a fonts.hashes.mathalternates
do
@@ -1043,6 +1044,7 @@ do
alternates = alternates,
registered = registered,
presets = { },
+hashes = setmetatableindex("table")
}
resources.mathalternates = mathalternates
end
@@ -1103,11 +1105,11 @@ do
local a_mathalternate = privateattribute("mathalternate")
local alternate = { } -- processors.alternate = alternate
+ local fontdata = fonts.hashes.identifiers
+ local fontresources = fonts.hashes.resources
local function getalternate(fam,tag)
- local id = font_of_family(fam)
- local tfmdata = fontdata[id]
- local resources = tfmdata.resources -- was tfmdata.shared
+ local resources = fontresources[font_of_family(fam)]
local attribute = unsetvalue
if resources then
local mathalternates = resources.mathalternates
@@ -1145,25 +1147,6 @@ do
arguments = { "integer", "string" }
}
--- local function setalternate(fam,tag)
--- local id = font_of_family(fam)
--- local tfmdata = fontdata[id]
--- local resources = tfmdata.resources -- was tfmdata.shared
--- if resources then
--- local mathalternates = resources.mathalternates
--- if mathalternates then
--- local v = mathalternates.alternates[tag]
--- if v then
--- local a = texgetattribute(a_mathalternate)
--- if a and a > 0 then
--- v = setbit(a,v)
--- end
--- texsetattribute(a_mathalternate,v)
--- end
--- end
--- end
--- end
-
local function setalternate(fam,tag)
local a = texgetattribute(a_mathalternate)
local v = getalternate(fam,tag)
@@ -1183,24 +1166,31 @@ do
local a = getattr(pointer,a_mathalternate)
if a and a > 0 then
setattr(pointer,a_mathalternate,0)
- local tfmdata = fontdata[getfont(pointer)]
- local resources = tfmdata.resources -- was tfmdata.shared
+ local fontid = getfont(pointer)
+ local resources = fontresources[fontid]
if resources then
local mathalternates = resources.mathalternates
if mathalternates then
local attributes = mathalternates.attributes
local registered = mathalternates.registered
+ local hashes = mathalternates.hashes
for i=1,#registered do
local r = registered[i]
if hasbit(a,r) then
- local what = attributes[r]
local char = getchar(pointer)
- local alt = otf.getalternate(tfmdata,char,what.feature,what.value)
- if alt ~= char then
- if trace_alternates then
+ local alt = hashes[i][char]
+ if alt == nil then
+ local what = attributes[r]
+ alt = otf.getalternate(fontdata[fontid],char,what.feature,what.value) or false
+ if alt == char then
+ alt = false
+ elseif trace_alternates then
report_alternates("alternate %a, value %a, replacing glyph %U by glyph %U",
tostring(what.feature),tostring(what.value),getchar(pointer),alt)
end
+ hashes[i][char] = alt
+ end
+ if alt then
setchar(pointer,alt)
break
end
diff --git a/tex/context/base/mkiv/publ-imp-apa.mkvi b/tex/context/base/mkiv/publ-imp-apa.mkvi
index 8031c34b1..5d11ef62f 100644
--- a/tex/context/base/mkiv/publ-imp-apa.mkvi
+++ b/tex/context/base/mkiv/publ-imp-apa.mkvi
@@ -355,6 +355,18 @@
\c!right={)}]
\definebtx
+ [apa:\s!cite:lefttext]
+ [apa:\s!cite]
+ [\c!left=,
+ \c!right={\btxspace}]
+
+\definebtx
+ [apa:\s!cite:righttext]
+ [apa:\s!cite]
+ [\c!left={\btxcomma},
+ \c!right=]
+
+\definebtx
[apa:\s!cite:year]
[apa:\s!cite]
[\c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
@@ -418,8 +430,8 @@
\definebtx
[apa:\s!cite:url]
[apa:\s!cite]
- [\c!left={[},
- \c!right={]}]
+ [\c!left={(},
+ \c!right={)}]
\definebtx
[apa:\s!cite:doi]
@@ -463,23 +475,14 @@
\setupbtxlabeltext
[en]
- [%apa:and=and,
- apa:number={no.},
+ [apa:number={no.},
apa:edition={ed.},
apa:Editor={Ed.},
apa:Editors={Eds.},
apa:Volume={Vol.},
apa:Volumes={Vols.},
- %apa:others={et al.},
- apa:with=with,
- %apa:page={p.},
- %apa:pages={pp.},
apa:nd={n.d.}, % no date
- %apa:mastersthesis={Master's thesis},
- %apa:phdthesis={Doctoral dissertation},
- %apa:technicalreport={Tech. Rep.}, % Technical report
apa:supplement={Suppl.}, % Supplement (not used?)
- apa:patent=Patent,
apa:MotionPicture={Motion picture},
apa:Producer=Producer,
apa:Producers=Producers,
@@ -490,27 +493,17 @@
apa:Translator={Trans.}, % Translator(s)
apa:Advanced={Advanced online publication},
apa:Retrieved={Available from}] % {Retrieved from},
- %apa:In=In]
\setupbtxlabeltext
[nl]
- [%apa:and=en,
- apa:number={nr.},
+ [apa:number={nr.},
apa:edition={ed.}, % editie
apa:Editor=Editor, % Ed./Eds.
apa:Editors=Editors,
apa:Volume={Vol.},
apa:Volumes={Vols.},
- %apa:others={et al.},
- apa:with=met,
- %apa:page={p.},
- %apa:pages={pp.},
apa:nd={g.d.} % geen datum
- %apa:mastersthesis=Masterproef,
- %apa:phdthesis=Proefschrift,
- %apa:technicalreport={Technisch rapport}, % Technical report
apa:supplement=Supplement,
- apa:patent=Octrooi,
apa:MotionPicture=Film, % ?
apa:Producer=Producent, % ?
apa:Producers=Producents, % ?
@@ -521,27 +514,17 @@
apa:Translator=Vertaler,
apa:Advanced={Geavanceerde online publicatie},
apa:Retrieved={Beschikbaar vanaf}] % {Ontvangen van},
- %apa:In=In]
\setupbtxlabeltext
[fr]
- [%apa:and=et,
- apa:number={n\high{o}},
+ [apa:number={n\high{o}},
apa:edition={édition},
apa:Editor=Éditeur,
apa:Editors=Éditeurs,
apa:Volume=Volume,
apa:Volumes=Volumes,
- %apa:others={et al.},
- apa:with=avec,
- %apa:page={p.},
- %apa:pages={pp.},
apa:nd={s.d.} % sans date
- %apa:mastersthesis={Thèse de master (DEA, DESS, master)},
- %apa:phdthesis={Thèse de doctorat},
- %apa:technicalreport={Rapport technique},
apa:supplement=Supplément,
- apa:patent=Brevet,
apa:MotionPicture={Film cinématographique},
apa:Producer=Producteur,
apa:Producers=Producteurs,
@@ -552,27 +535,17 @@
apa:Translator=Traducteur,
apa:Advanced={Publication en ligne anticipée},
apa:Retrieved={Disponible à}] % {Téléchargé de},
- %apa:In=Dans]
\setupbtxlabeltext
[de]
- [%apa:and=und,
- apa:number={nr.},
+ [apa:number={nr.},
apa:edition=Auf\/lage,
apa:Editor=Herausgeber, % Hrsg./Hg.
apa:Editors=Herausgeber,
apa:Volume=Band, % Bd.
apa:Volumes={Bände},
- %apa:others={et al.},
- apa:with=mit,
- %apa:page={S.},
- %apa:pages={S.},
apa:nd={o.D.}, % ohne Datum (mostly: o.J. / ohne Jahr)
- %apa:mastersthesis={Masterarbeit},
- %apa:phdthesis={Dissertation},
- %apa:technicalreport={Technischer Bericht},
apa:supplement={Beilage}, % Supplement
- apa:patent=Patent,
apa:MotionPicture=Kinofilm, % ?
apa:Producer=Producer, % ?
apa:Producers=Produzenten, % ?
@@ -583,29 +556,19 @@
apa:Translator={Übersetzer}, % Übers.
apa:Advanced={Erweiterte Online-Publikation},
apa:Retrieved={heruntergeladen von}]
- %apa:In=In]
% thanks: Andrea Valle
\setupbtxlabeltext
[it]
- [%apa:and=e,
- apa:number={nº},
+ [apa:number={nº},
apa:edition={ed.}, % edizione
apa:Editor={A cura di},
apa:Editors={A cura di},
apa:Volume={Vol.}, % Volume
apa:Volumes={Vol.}, % Volumi
- %apa:others={et al.},
- apa:with=con,
- %apa:page={p.},
- %apa:pages={pp.},
apa:nd={s.d.}, % senza data
- %apa:mastersthesis={Tesi di laurea},
- %apa:phdthesis={Tesi di dottorato},
- %apa:technicalreport={Relazione tecnica},
apa:supplement={Supplemento},
- apa:patent=Brevetto,
apa:MotionPicture=Film, % ?
apa:Producer=Produttore,
apa:Producers=Produttori,
@@ -616,27 +579,17 @@
apa:Translator={Trad.}, % Translator(s)
apa:Advanced={Pre-pubblicazione on line},
apa:Retrieved={Accessible online}]
- %apa:In=In]
\setupbtxlabeltext
[es]
- [%apa:and=y,
- apa:number={nº},
+ [apa:number={nº},
apa:edition={ed.}, % edición
apa:Editor=Editor, % Ed./Eds.
apa:Editors=Editores,
apa:Volume={Vol.}, % Volumen
apa:Volumes={Vols.}, % Volúmenes
- %apa:others={et al.},
- apa:with=con,
- %apa:page={p.},
- %apa:pages={pp.},
apa:nd={s.f.}, % sin fecha
- %apa:mastersthesis={Tesis de maestría},
- %apa:phdthesis={Tesis doctoral},
- %apa:technicalreport={Informe técnico},
apa:supplement=Suplemento,
- apa:patent=Patente,
apa:MotionPicture=Cinematográfica,
apa:Producer=Productor,
apa:Producers=Productores,
@@ -647,48 +600,32 @@
apa:Translator=Traductor,
apa:Advanced={Publicación en línea avanzada},
apa:Retrieved={Disponible desde}] % {Obtenido de},
- %apa:In=En]
% cite setups
% The following differs from the default returning n.d. if year is empty
-\startsetups btx:apa:nd
- \btxlabeltext{apa:nd}
-\stopsetups
-
\startsetups btx:apa:cite:author:year
- \texdefinition{\s!btx:\s!cite:concat}
- %\btxparameter\c!left
\ifx\currentbtxfirst\empty
- \fastsetup{btx:apa:nd}
- \else
- \texdefinition {\s!btx:\s!cite:inject} {
- \btxcitereference
- \currentbtxfirst
- }
- \ifx\currentbtxsecond\empty \else
- \btxparameter\c!range
- \texdefinition {\s!btx:\s!cite:inject} {
- \currentbtxsecond
- }
- \fi
- \btxflushsuffix
+ \def\currentbtxfirst{\fastsetup{\s!btx:apa:nd}}
\fi
- %\btxparameter\c!right
+ \fastsetup{\s!btx:\s!cite:author:year}
\stopsetups
\startsetups btx:apa:cite:author:years
- \fastsetup{btx:apa:cite:author:year}
+ \ifx\currentbtxfirst\empty
+ \def\currentbtxfirst{\fastsetup{\s!btx:apa:nd}}
+ \fi
+ \fastsetup{\s!btx:\s!cite:author:years}
\stopsetups
% used in publ-imp-page.mkvi
\startsetups [btx:apa:list:page-or-pages]
\ifx\currentbtxlastpage\empty
- \btxlabeltext{p}.
+ \btxlabeltext{p}
\else
- \btxlabeltext{pp}.
+ \btxlabeltext{pp}
\fi
\btxnbsp
\stopsetups
@@ -820,6 +757,10 @@
}
\stoptexdefinition
+\startsetups btx:apa:nd
+ \btxlabeltext{apa:nd}
+\stopsetups
+
\starttexdefinition unexpanded btx:apa:suffixedyear
\btxdoifelse {year} {
\btxflush{year}
@@ -883,7 +824,7 @@
}
\btxdoif {withauthor} {
\btxleftparenthesis
- \btxlabeltext{apa:with}
+ \btxlabeltext{with}
\btxspace
\btxflush{withauthor}
\btxrightparenthesis
@@ -978,9 +919,9 @@
\btxdoif {pages} {
\texdefinition{btx:apa:leftparenthesis-or-comma}
\btxoneorrange {pages} {
- \btxlabeltext{p}.
+ \btxlabeltext{p}
} {
- \btxlabeltext{pp}.
+ \btxlabeltext{pp}
}
\btxnbsp
\btxflush{pages}
@@ -1030,9 +971,9 @@
\btxcomma
\doif {\currentbtxcategory} {newspaper} {
\btxoneorrange {pages} {
- \btxlabeltext{p}.
+ \btxlabeltext{p}
} {
- \btxlabeltext{pp}.
+ \btxlabeltext{pp}
}
\btxnbsp
}
@@ -1090,9 +1031,6 @@
% use \btxentry here?
\starttexdefinition unexpanded btx:apa:url
- \btxspace
- \btxlabeltext{apa:Retrieved}
- \btxspace
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1110,7 +1048,6 @@
% use \btxentry here?
\starttexdefinition unexpanded btx:apa:doi
- \btxspace
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1135,9 +1072,13 @@
\starttexdefinition unexpanded btx:apa:url-doi-note
\doif {\btxfoundname{doi}} {url} {
+ \btxspace
+ \btxlabeltext{apa:Retrieved}
+ \btxspace
\texdefinition{btx:apa:url}
}
\doif {\btxfoundname{doi}} {doi} {
+ \btxspace
\texdefinition{btx:apa:doi}
}
\texdefinition{btx:apa:note}
@@ -1365,7 +1306,7 @@
\btxflush{nationality}
}
\btxspace
- \btxlabeltext{apa:patent}
+ \btxlabeltext{patent}
\btxdoif {number} {
\btxspace
\btxlabeltext{apa:number}
diff --git a/tex/context/base/mkiv/publ-imp-aps.mkvi b/tex/context/base/mkiv/publ-imp-aps.mkvi
index 73ea9775b..5099c5d9f 100644
--- a/tex/context/base/mkiv/publ-imp-aps.mkvi
+++ b/tex/context/base/mkiv/publ-imp-aps.mkvi
@@ -379,8 +379,8 @@
\definebtx
[aps:\s!cite:url]
[aps:\s!cite]
- [\c!left={[},
- \c!right={]}]
+ [\c!left={(},
+ \c!right={)}]
\definebtx
[aps:\s!cite:doi]
@@ -429,139 +429,85 @@
\setupbtxlabeltext
[en]
- [%aps:and=and,
- aps:number={no.},
+ [aps:number={no.},
aps:edition={ed.},
aps:Editor={Ed.},
aps:Editors={Eds.},
aps:Volume={Vol.},
aps:Volumes={Vols.},
- %aps:others={et al.},
- %aps:page={p.},
- %aps:pages={pp.},
- %aps:mastersthesis={Master's thesis},
- %aps:phdthesis={Doctoral dissertation},
- %aps:technicalreport={Tech. Rep.}, % Technical report
aps:supplement={Suppl.}, % Supplement (not used?)
- aps:patent=Patent,
aps:inpress={in press},
aps:tobe={to be published},
aps:unpublished={unpublished}]
- %aps:In=In]
% Check this (google translate!!):
\setupbtxlabeltext
[nl]
- [%aps:and=en,
- aps:number={nr.},
+ [aps:number={nr.},
aps:edition={ed.}, % editie
aps:Editor=Editor, % Ed./Eds.
aps:Editors=Editors,
aps:Volume={Vol.},
aps:Volumes={Vols.},
- %aps:others={et al.},
- %aps:page={p.},
- %aps:pages={pp.},
- %aps:mastersthesis=Masterproef,
- %aps:phdthesis=Proefschrift,
- %aps:technicalreport={Technisch rapport}, % Technical report
aps:supplement=Supplement,
- aps:patent=Octrooi,
aps:inpress={in press}, % CHECK THESE!
aps:tobe={worden gepubliceerd},
aps:unpublished={onuitgegeven}]
- %aps:In=In]
\setupbtxlabeltext
[fr]
- [%aps:and=et,
- aps:number={n\high{o}},
+ [aps:number={n\high{o}},
aps:edition={édition},
aps:Editor=Éditeur,
aps:Editors=Éditeurs,
aps:Volume=Volume,
aps:Volumes=Volumes,
- %aps:others={et al.},
- %aps:page={p.},
- %aps:pages={pp.},
- %aps:mastersthesis={Thèse de master (DEA, DESS, master)},
- %aps:phdthesis={Thèse de doctorat},
- %aps:technicalreport={Rapport technique},
aps:supplement=Supplément,
- aps:patent=Brevet,
aps:inpress={sous impression},
aps:tobe={à paraître},
aps:unpublished={inédit}] % pour un livre
- %aps:In=Dans]
\setupbtxlabeltext
[de]
- [%aps:and=und,
- aps:number={nr.},
+ [aps:number={nr.},
aps:edition=Auf\/lage,
aps:Editor=Herausgeber, % Hrsg./Hg.
aps:Editors=Herausgeber,
aps:Volume=Band, % Bd.
aps:Volumes={Bände},
- %aps:others={et al.},
- %aps:page={S.},
- %aps:pages={S.},
- %aps:mastersthesis={Masterarbeit},
- %aps:phdthesis={Dissertation},
- %aps:technicalreport={Technischer Bericht},
aps:supplement={Beilage}, % Supplement
- aps:patent=Patent,
aps:inpress={in der Presse}, % CHECK THESE!
aps:tobe={veröffentlicht werden},
aps:unpublished={unveröffentlicht}]
- %aps:In=In]
% thanks: Andrea Valle
\setupbtxlabeltext
[it]
- [%aps:and=e,
- aps:number={nº},
+ [aps:number={nº},
aps:edition={ed.}, % edizione
aps:Editor={A cura di},
aps:Editors={A cura di},
aps:Volume={Vol.}, % Volume
aps:Volumes={Vol.}, % Volumi
- %aps:others={et al.},
- %aps:page={p.},
- %aps:pages={pp.},
- %aps:mastersthesis={Tesi di laurea},
- %aps:phdthesis={Tesi di dottorato},
- %aps:technicalreport={Relazione tecnica},
aps:supplement={Supplemento},
- aps:patent=Brevetto,
aps:inpress={in press}, % CHECK THESE!
aps:tobe={da pubblicare},
aps:unpublished={inedito}]
- %aps:In=In]
\setupbtxlabeltext
[es]
- [%aps:and=y,
- aps:number={nº},
+ [aps:number={nº},
aps:edition={ed.}, % edición
aps:Editor=Editor, % Ed./Eds.
aps:Editors=Editores,
aps:Volume={Vol.}, % Volumen
aps:Volumes={Vols.}, % Volúmenes
- %aps:others={et al.},
- %aps:page={p.},
- %aps:pages={pp.},
- %aps:mastersthesis={Tesis de maestría},
- %aps:phdthesis={Tesis doctoral},
- %aps:technicalreport={Informe técnico},
aps:supplement=Suplemento,
- aps:patent=Patente,
aps:inpress={en prensa}, % CHECK THESE!
aps:tobe={que se publicará},
aps:unpublished={inédito}]
- %aps:In=En]
% cite setups
@@ -1063,7 +1009,7 @@
\btxflush{nationality}
}
\btxspace
- \btxlabeltext{aps:patent}
+ \btxlabeltext{patent}
\btxdoif {number} {
\btxspace
\btxlabeltext{aps:number}
diff --git a/tex/context/base/mkiv/publ-imp-cite.mkvi b/tex/context/base/mkiv/publ-imp-cite.mkvi
index cb1c46fe4..be23326b8 100644
--- a/tex/context/base/mkiv/publ-imp-cite.mkvi
+++ b/tex/context/base/mkiv/publ-imp-cite.mkvi
@@ -61,6 +61,26 @@
<empty>
\stopsetups
+\startsetups btx:cite:lefttext
+ \ifx\currentbtxlefttext\empty
+ \else
+ \setbtxparameterset{\s!cite}{lefttext}
+ \btxparameter\c!left
+ \currentbtxlefttext
+ \btxparameter\c!right
+ \fi
+\stopsetups
+
+\startsetups btx:cite:righttext
+ \ifx\currentbtxrighttext\empty
+ \else
+ \setbtxparameterset{\s!cite}{righttext}
+ \btxparameter\c!left
+ \currentbtxrighttext
+ \btxparameter\c!right
+ \fi
+\stopsetups
+
\startsetups btx:cite:invalid
\btxcitereference
{\tt <\currentbtxreference>}
@@ -103,7 +123,8 @@
\startsetups btx:cite:normal
\texdefinition{\s!btx:\s!cite:concat}
- \currentbtxlefttext
+ %\currentbtxlefttext
+ \fastsetup{\s!btx:\s!cite:lefttext}
\ifx\currentbtxfirst\empty
\fastsetup{\s!btx:\s!cite:\s!empty}
\else\ifx\currentbtxsecond\empty
@@ -140,12 +161,14 @@
}
}
\fi\fi
- \currentbtxrighttext
+ %\currentbtxrighttext
+ \fastsetup{\s!btx:\s!cite:righttext}
\stopsetups
\startsetups btx:cite:range
\texdefinition{\s!btx:\s!cite:concat}
- \currentbtxlefttext
+ %\currentbtxlefttext
+ \fastsetup{\s!btx:\s!cite:lefttext}
\ifx\currentbtxfirst\empty
\fastsetup{\s!btx:\s!cite:\s!empty}
\else
@@ -161,14 +184,16 @@
}
}
\fi
- \currentbtxrighttext
+ %\currentbtxrighttext
+ \fastsetup{\s!btx:\s!cite:righttext}
\stopsetups
% somehow related to keywords:
\startsetups btx:cite:listelement
\texdefinition{\s!btx:\s!cite:concat}
- \currentbtxlefttext
+ %\currentbtxlefttext
+ \fastsetup{\s!btx:\s!cite:lefttext}
\ifx\currentbtxfirst\empty
\fastsetup{\s!btx:\s!cite:\s!empty}
\else
@@ -177,14 +202,17 @@
\currentbtxfirst
}
\fi
- \currentbtxrighttext
+ %\currentbtxrighttext
+ \fastsetup{\s!btx:\s!cite:righttext}
\stopsetups
\startsetups \s!btx:\s!cite:entry
\texdefinition{\s!btx:\s!cite:concat}
- \currentbtxlefttext
+ %\currentbtxlefttext
+ \fastsetup{\s!btx:\s!cite:lefttext}
\btxhandleciteentry
- \currentbtxrighttext
+ %\currentbtxrighttext
+ \fastsetup{\s!btx:\s!cite:righttext}
\stopsetups
% these three are goodies to get something but are not set up as it makes no
@@ -259,7 +287,7 @@
\fastsetup{\s!btx:\s!cite:normal}
\stopsetups
-% the following is kind of specific, but can be used in many renderings
+% the following are kind of specific, but can be used in many renderings
\startsetups btx:cite:url
\ifx\currentbtxfirst\empty
@@ -267,13 +295,29 @@
\else\ifconditional\btxinteractive
\goto {
\btxcitereference
- \hyphenatedurl{\doif{\currentbtxcitealternative}{doi}{doi:}\currentbtxfirst}
+ \hyphenatedurl{\currentbtxfirst}
+ } [
+ url(\currentbtxfirst)
+ ]
+ \else
+ \btxcitereference
+ \hyphenatedurl{\currentbtxfirst}
+ \fi\fi
+\stopsetups
+
+\startsetups btx:cite:doi
+ \ifx\currentbtxfirst\empty
+ \fastsetup{\s!btx:\s!cite:\s!empty}
+ \else\ifconditional\btxinteractive
+ \goto {
+ \btxcitereference
+ \hyphenatedurl{doi:\currentbtxfirst}
} [
- url(\doif{\currentbtxcitealternative}{doi}{http://dx.doi.org/}\currentbtxfirst)
+ url(http://dx.doi.org/\currentbtxfirst)
]
\else
\btxcitereference
- \hyphenatedurl{\doif{\currentbtxcitealternative}{doi}{doi:}\currentbtxfirst}
+ \hyphenatedurl{doi:\currentbtxfirst}
\fi\fi
\stopsetups
diff --git a/tex/context/base/mkiv/publ-imp-default.mkvi b/tex/context/base/mkiv/publ-imp-default.mkvi
index 9918c8934..3a88d28ff 100644
--- a/tex/context/base/mkiv/publ-imp-default.mkvi
+++ b/tex/context/base/mkiv/publ-imp-default.mkvi
@@ -508,12 +508,14 @@
%D Experiment:
-\startsetups btx:default:cite:lefttext
- \currentbtxlefttext
-\stopsetups
-
-\startsetups btx:default:cite:righttext
- \currentbtxrighttext
-\stopsetups
+%D See publ-imp-cite.mkvi
+%
+%\startsetups btx:default:cite:lefttext
+% \currentbtxlefttext
+%\stopsetups
+
+%\startsetups btx:default:cite:righttext
+% \currentbtxrighttext
+%\stopsetups
\stopbtxrenderingdefinitions
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 6a33fa332..c8d2ebb99 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 7b4cd12d0..ce6b42056 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua
index 47d9d0316..eeb6856c6 100644
--- a/tex/context/base/mkiv/util-fil.lua
+++ b/tex/context/base/mkiv/util-fil.lua
@@ -6,8 +6,10 @@ if not modules then modules = { } end modules ['util-fil'] = {
license = "see context related readme files"
}
-local byte = string.byte
+local byte = string.byte
+local char = string.char
local extract = bit32.extract
+local floor = math.floor
-- Here are a few helpers (the starting point were old ones I used for parsing
-- flac files). In Lua 5.3 we can probably do this better. Some code will move
@@ -36,6 +38,8 @@ 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)
@@ -180,3 +184,32 @@ end
function files.skiplong(f,n)
f:read(4*(n or 1))
end
+
+-- writers (kind of slow)
+
+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
+
diff --git a/tex/context/interface/mkiv/i-color.xml b/tex/context/interface/mkiv/i-color.xml
index 157f56ea2..ffc9d338b 100644
--- a/tex/context/interface/mkiv/i-color.xml
+++ b/tex/context/interface/mkiv/i-color.xml
@@ -77,24 +77,7 @@
<cd:constant type="cd:number"/>
</cd:parameter>
<cd:parameter name="a">
- <cd:constant type="cd:number"/>
- <cd:constant type="none"/>
- <cd:constant type="normal"/>
- <cd:constant type="multiply"/>
- <cd:constant type="screen"/>
- <cd:constant type="overlay"/>
- <cd:constant type="softlight"/>
- <cd:constant type="hardlight"/>
- <cd:constant type="colordodge"/>
- <cd:constant type="colorburn"/>
- <cd:constant type="darken"/>
- <cd:constant type="lighten"/>
- <cd:constant type="difference"/>
- <cd:constant type="exclusion"/>
- <cd:constant type="hue"/>
- <cd:constant type="saturation"/>
- <cd:constant type="color"/>
- <cd:constant type="luminosity"/>
+ <cd:resolve name="value-transparency"/>
</cd:parameter>
<cd:parameter name="t">
<cd:constant type="cd:number"/>
@@ -158,24 +141,7 @@
<cd:resolve name="keyword-color"/>
<cd:assignments list="yes">
<cd:parameter name="a">
- <cd:constant type="cd:number"/>
- <cd:constant type="none"/>
- <cd:constant type="normal"/>
- <cd:constant type="multiply"/>
- <cd:constant type="screen"/>
- <cd:constant type="overlay"/>
- <cd:constant type="softlight"/>
- <cd:constant type="hardlight"/>
- <cd:constant type="colordodge"/>
- <cd:constant type="colorburn"/>
- <cd:constant type="darken"/>
- <cd:constant type="lighten"/>
- <cd:constant type="difference"/>
- <cd:constant type="exclusion"/>
- <cd:constant type="hue"/>
- <cd:constant type="saturation"/>
- <cd:constant type="color"/>
- <cd:constant type="luminosity"/>
+ <cd:resolve name="value-transparency"/>
</cd:parameter>
<cd:parameter name="t">
<cd:constant type="cd:number"/>
@@ -207,13 +173,34 @@
</cd:arguments>
</cd:command>
- <cd:command name="definetransparency" file="colo-ini.mkiv">
+ <cd:command name="definetransparency" variant="1" file="colo-ini.mkiv">
<cd:arguments>
<cd:resolve name="keyword-name"/>
<cd:resolve name="keyword-number"/>
</cd:arguments>
</cd:command>
+ <cd:command name="definetransparency" variant="2" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-name"/>
+ <cd:assignments list="yes">
+ <cd:parameter name="a">
+ <cd:resolve name="value-transparency"/>
+ </cd:parameter>
+ <cd:parameter name="t">
+ <cd:constant type="cd:number"/>
+ </cd:parameter>
+ </cd:assignments>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="definetransparency" variant="3" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-name"/>
+ <cd:resolve name="keyword-name"/>
+ </cd:arguments>
+ </cd:command>
+
<cd:command name="switchtocolor" file="colo-ini.mkiv">
<cd:arguments>
<cd:resolve name="keyword-color"/>
@@ -227,6 +214,20 @@
</cd:arguments>
</cd:command>
+ <cd:command name="coloronly" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-color"/>
+ <cd:content/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="transparent" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-color"/>
+ <cd:content/>
+ </cd:arguments>
+ </cd:command>
+
<cd:command name="graycolor" file="colo-ini.mkiv">
<cd:arguments>
<cd:resolve name="keyword-color"/>
@@ -256,6 +257,18 @@
</cd:arguments>
</cd:command>
+ <cd:command name="coloronly" type="environment" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-color"/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="transparent" type="environment" file="colo-ini.mkiv">
+ <cd:arguments>
+ <cd:resolve name="keyword-color"/>
+ </cd:arguments>
+ </cd:command>
+
<cd:command name="directcolor" file="colo-ini.mkiv">
<cd:arguments>
<cd:resolve name="keyword-color"/>
diff --git a/tex/context/interface/mkiv/i-common-value.xml b/tex/context/interface/mkiv/i-common-value.xml
index f111292b8..20079351f 100644
--- a/tex/context/interface/mkiv/i-common-value.xml
+++ b/tex/context/interface/mkiv/i-common-value.xml
@@ -11,6 +11,27 @@
<cd:constant type="cd:command"/>
</cd:define>
+ <cd:define name="value-transparency">
+ <cd:constant type="cd:number"/>
+ <cd:constant type="none"/>
+ <cd:constant type="normal"/>
+ <cd:constant type="multiply"/>
+ <cd:constant type="screen"/>
+ <cd:constant type="overlay"/>
+ <cd:constant type="softlight"/>
+ <cd:constant type="hardlight"/>
+ <cd:constant type="colordodge"/>
+ <cd:constant type="colorburn"/>
+ <cd:constant type="darken"/>
+ <cd:constant type="lighten"/>
+ <cd:constant type="difference"/>
+ <cd:constant type="exclusion"/>
+ <cd:constant type="hue"/>
+ <cd:constant type="saturation"/>
+ <cd:constant type="color"/>
+ <cd:constant type="luminosity"/>
+ </cd:define>
+
<!-- mathstyle = ... -->
<cd:define name="value-mathstyle">
@@ -543,4 +564,4 @@
<cd:constant type="editor"/>
</cd:define>
-</cd:interface> \ No newline at end of file
+</cd:interface>
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index 36e8d242e..ef3eda61d 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index 06a6d30e9..1dc8b1bcd 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/context/modules/mkiv/x-setups-basics.mkiv b/tex/context/modules/mkiv/x-setups-basics.mkiv
index b1555f039..28e1a577b 100644
--- a/tex/context/modules/mkiv/x-setups-basics.mkiv
+++ b/tex/context/modules/mkiv/x-setups-basics.mkiv
@@ -69,7 +69,8 @@
\unexpanded\def\setupalwcolor{}
\unexpanded\def\setupoptcolor{darkgray}
-\unexpanded\def\setupvarword#1{{\sl\detokenize{#1}}}
+% \unexpanded\def\setupvarword#1{{\sl\detokenize{#1}}}
+\unexpanded\def\setupvarword#1{\detokenize{#1}}
\unexpanded\def\setupintword#1{\WORD{\detokenize{#1}}}
\unexpanded\def\setuptxtword#1{\detokenize{#1}}
@@ -229,7 +230,7 @@
local g = getsetupstring(s)
if not find(s,"^cd:") then
setuptxtword(g)
- elseif find(s,"%-.$") then
+ elseif find(s,"%-.$") then -- singular | plural
setupvarword(g)
else
setupintword(g) -- cap
@@ -744,26 +745,35 @@
\unexpanded\def\show_setup_any#1#2%
{\bgroup
\global\advance\c_cmd_current_argument\plusone
+ \doif{\xmlatt{#1}{optional}}{yes}\donetrue\donefalse
\setbox0=\hbox
- {\doifelse{\xmlatt{#1}{list}}{yes}
+ {\ifdone\sl\fi
+ \doifelse{\xmlatt{#1}{list}}{yes}
{\getsetupstring{cd:#2-l}}%
{\getsetupstring{cd:#2-s}}}%
\setbox2=\hbox to \wd0
{\hss
- \raise1.25\exheight\hbox
- {\txx\ifcase\c_cmd_maximum_argument \relax
- \or*\else\the\c_cmd_current_argument
- \fi}%
+ \ifcase\c_cmd_kind\else
+ \ifcase\c_cmd_maximum_argument \relax
+ \or
+ \raise1.25\exheight\hbox
+ {\txx *}%
+ \else
+ \raise1.25\exheight\hbox
+ {\txx\the\c_cmd_current_argument}%
+ \fi
+ \fi
\hss}%
\setbox4=\hbox to \wd0
{\hss
- \lower2\exheight\hbox
- \bgroup
- \txx
- \doif {\xmlatt{#1}{optional}} {yes}
- {\getsetupstring{cd:optional}}%
- \egroup
- \hss}%
+ \ifdone
+ \lower2\exheight\hbox
+ \bgroup
+ \txx
+ \getsetupstring{cd:optional}%
+ \egroup
+ \hss
+ \fi}%
\ht2\ht\strutbox
\dp4\dp\strutbox
\hskip.5\emwidth
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