[latex3-commits] [latex3/luaotfload] dev: MAke default DVI driver configurable and add support for xdvipsk (7fc26b7f)
github at latex-project.org
github at latex-project.org
Sat Jul 29 20:51:29 CEST 2023
Repository : https://github.com/latex3/luaotfload
On branch : dev
Link : https://github.com/latex3/luaotfload/commit/7fc26b7f0dc16a3968ad8c5150eecd55842208f9
>---------------------------------------------------------------
commit 7fc26b7f0dc16a3968ad8c5150eecd55842208f9
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Sat Jul 29 20:51:29 2023 +0200
MAke default DVI driver configurable and add support for xdvipsk
>---------------------------------------------------------------
7fc26b7f0dc16a3968ad8c5150eecd55842208f9
doc/luaotfload.conf.rst | 42 ++++++++++++++++++++++-------------
src/luaotfload-configuration.lua | 48 ++++++++++++++++++++++++++++++----------
src/luaotfload-dvi.lua | 11 +++++++--
3 files changed, 72 insertions(+), 29 deletions(-)
diff --git a/doc/luaotfload.conf.rst b/doc/luaotfload.conf.rst
index f6d50fa8..4eda01f0 100644
--- a/doc/luaotfload.conf.rst
+++ b/doc/luaotfload.conf.rst
@@ -277,21 +277,23 @@ version.
Section ``run``
-----------------------------------------------------------------------
-+------------------+--------+------------------------------+
-| variable | type | default |
-+------------------+--------+------------------------------+
-| anon-sequence | s | ``"tex,path,name"`` |
-+------------------+--------+------------------------------+
-| color-callback | s | ``"post_linebreak_filter"`` |
-+------------------+--------+------------------------------+
-| definer | s | ``"patch"`` |
-+------------------+--------+------------------------------+
-| log-level | n | ``0`` |
-+------------------+--------+------------------------------+
-| resolver | s | ``"cached"`` |
-+------------------+--------+------------------------------+
-| fontloader | s | ``"default"`` |
-+------------------+--------+------------------------------+
++---------------------+--------+------------------------------+
+| variable | type | default |
++---------------------+--------+------------------------------+
+| anon-sequence | s | ``"tex,path,name"`` |
++---------------------+--------+------------------------------+
+| color-callback | s | ``"post_linebreak_filter"`` |
++---------------------+--------+------------------------------+
+| definer | s | ``"patch"`` |
++---------------------+--------+------------------------------+
+| log-level | n | ``0`` |
++---------------------+--------+------------------------------+
+| resolver | s | ``"cached"`` |
++---------------------+--------+------------------------------+
+| fontloader | s | ``"default"`` |
++---------------------+--------+------------------------------+
+| default_dvi_driver | s | ``"dvisvgm"`` |
++---------------------+--------+------------------------------+
Unqualified font lookups are treated with the flexible “anonymous”
mechanism. This involves a chain of lookups applied successively until
@@ -365,6 +367,16 @@ and resolves every request individually. (Since to the restructuring of
the font name index in Luaotfload 2.4 the performance difference
between the cached and uncached lookups should be marginal.)
+When luaotfload is used in ``DVI`` mode, the ``default_dvi_driver`` option
+determines how OpenType fonts are represented in the DVI output. In most
+cases the default value ``dvisvgm`` should be set, it uses a format
+supported by multiple backends including ``dvipdfmx`` and ``dvisvgm``
+which uses GIDs to identify characters.
+Setting this to ``xdvipsk`` uses an unstable internal format instead
+which will change depending on the luaotfload, engine, or font version.
+No one should rely on the mapping between DVI character codes and font glyphs
+in this mode unless they tightly control all involved versions and are deeply
+familiar with the implementation.
FILES
=======================================================================
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 2d7a8efb..527c2f64 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -189,6 +189,10 @@ local permissible_color_callbacks = {
pre_output_filter = "pre_output_filter",
}
+local known_dvi_drivers = {
+ xdvipsk = 'xdvipsk',
+ dvisvgm = 'dvisvgm',
+}
-------------------------------------------------------------------------------
--- DEFAULTS
@@ -206,12 +210,13 @@ local default_config = {
designsize_dimen= "bp",
},
run = {
- anon_sequence = default_anon_sequence,
- resolver = "cached",
- definer = "patch",
- log_level = 0,
- color_callback = "post_linebreak_filter",
- fontloader = default_fontloader (),
+ anon_sequence = default_anon_sequence,
+ resolver = "cached",
+ definer = "patch",
+ log_level = 0,
+ color_callback = "post_linebreak_filter",
+ fontloader = default_fontloader (),
+ default_dvi_driver = "dvisvgm"
},
misc = {
bisect = false,
@@ -596,6 +601,24 @@ local option_spec = {
return permissible_color_callbacks.default
end,
},
+ default_dvi_driver = {
+ in_t = string_t,
+ out_t = string_t,
+ transform = function (driver)
+ local mapped = known_dvi_drivers[driver]
+ if mapped then
+ logreport ("log", 5, "conf",
+ "Using default DVI driver %q if used in DVI mode.",
+ mapped)
+ return mapped
+ end
+ logreport ("log", 0, "conf",
+ "Requested default DVI driver %q invalid, "
+ .. "falling back to dvisvgm.",
+ driver)
+ return known_dvi_drivers.dvisvgm
+ end,
+ },
},
misc = {
bisect = { in_t = boolean_t, }, --- doesn’t make sense in a config file
@@ -740,12 +763,13 @@ local formatters = {
lookups_file = { false, format_string },
},
run = {
- anon_sequence = { false, format_list },
- color_callback = { false, format_string },
- definer = { false, format_string },
- fontloader = { true, format_string },
- log_level = { false, format_integer },
- resolver = { false, format_string },
+ anon_sequence = { false, format_list },
+ color_callback = { false, format_string },
+ definer = { false, format_string },
+ fontloader = { true, format_string },
+ log_level = { false, format_integer },
+ resolver = { false, format_string },
+ default_dvi_driver = { false, format_string },
},
}
diff --git a/src/luaotfload-dvi.lua b/src/luaotfload-dvi.lua
index 44b43d56..785c1109 100644
--- a/src/luaotfload-dvi.lua
+++ b/src/luaotfload-dvi.lua
@@ -31,6 +31,9 @@ local vlist_t = node.id'vlist'
local disc_t = node.id'disc'
local glyph_t = node.id'glyph'
+require'luaotfload-configuration'
+local configuration = config.luaotfload
+
-- DVI output support
--
-- When writing DVI files, we can't assume that the DVI reader has access to our
@@ -132,7 +135,11 @@ local function process(head, font)
end end
end
local function manipulate(tfmdata, _, dvi_kind)
- if dvi_kind ~= 'dvisvgm' then
+ if dvi_kind == 'xdvipsk' then
+ -- xdvipsk wants to read tea leaves instead of using reasonable interfaces.
+ -- They will have to make sense of whatever output this produces.
+ return
+ elseif dvi_kind ~= 'dvisvgm' then
texio.write_nl(string.format('WARNING (luaotfload): Unsupported DVI backend %q, falling back to dvisvgm.', dvi_kind))
end
-- Legacy fonts can be written to the DVI file directly
@@ -178,7 +185,7 @@ end
fonts.constructors.features.otf.register {
name = "dvifont",
- default = "dvisvgm",
+ default = configuration.run.default_dvi_driver,
manipulators = {
node = manipulate,
base = manipulate,
More information about the latex3-commits
mailing list.