diff options
| -rw-r--r-- | doc/luaotfload.conf.rst | 23 | ||||
| -rw-r--r-- | src/luaotfload-configuration.lua | 32 | 
2 files changed, 44 insertions, 11 deletions
diff --git a/doc/luaotfload.conf.rst b/doc/luaotfload.conf.rst index b0d19d9..2a339ce 100644 --- a/doc/luaotfload.conf.rst +++ b/doc/luaotfload.conf.rst @@ -6,9 +6,9 @@                       Luaotfload configuration file  ----------------------------------------------------------------------- -:Date:                  2014-06-09 +:Date:                  2015-04-20  :Copyright:             GPL v2.0 -:Version:               2.5 +:Version:               2.6  :Manual section:        5  :Manual group:          text processing @@ -98,8 +98,9 @@ VARIABLES  Variables in belong into a configuration section and their values must  be of a certain type. Some of them have further constraints. For  example, the “color callback” must be a string of one of the values -``pre_linebreak_filter`` or ``pre_output_filter``, defined in the -section *run*. +``post_linebreak_filter``, ``pre_linebreak_filter``, or +``pre_output_filter``, defined in the section *run* of the +configuration file.  Currently, the configuration is organized into four sections: @@ -267,7 +268,7 @@ Section ``run``  +------------------+--------+------------------------------+  |  variable        |  type  |  default                     |  +------------------+--------+------------------------------+ -|  color-callback  |   s    |  ``"pre_linebreak_filter"``  | +|  color-callback  |   s    |  ``"post_linebreak_filter"`` |  +------------------+--------+------------------------------+  |  definer         |   s    |  ``"patch"``                 |  +------------------+--------+------------------------------+ @@ -278,10 +279,14 @@ Section ``run``  The ``color-callback`` option determines the stage at which fonts that  defined with a ``color=xxyyzz`` feature will be colorized. By default -this happens in a ``pre_linebreak_filter`` but alternatively the -``pre_output_filter`` may be chosen, which is faster but might produce -inconsistent output. The latter also was the default in the 1.x series -of Luaotfload. +this happens in a ``post_linebreak_filter`` but alternatively the +``pre_linebreak_filter`` or ``pre_output_filter`` may be chosen, which +is faster but might produce inconsistent output. The +``pre_output_filter`` used to be the default in the 1.x series of +Luaotfload, whilst later versions up to and including 2.5 hooked into +the ``pre_linebreak_filter`` which naturally didn’t affect any glyphs +inserting during hyphenation. Both are kept around as options to +restore the previous behavior if necessary.  The ``definer`` allows for switching the ``define_font`` callback.  Apart from the default ``patch`` one may also choose the ``generic`` diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 657d671..7791503 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -144,6 +144,23 @@ local registered_loaders = {    tl2013     = "tl2013",  } +--[[doc-- + +  The ``post_linebreak_filter`` has been made the default callback for +  hooking the colorizer into. This helps with the linebreaking whose +  inserted hyphens would remain unaffected by the coloring otherwise. + +  http://tex.stackexchange.com/q/238539/14066 + +--doc]]-- + +local permissible_color_callbacks = { +  default               = "post_linebreak_filter", +  pre_linebreak_filter  = "pre_linebreak_filter", +  post_linebreak_filter = "post_linebreak_filter", +  pre_output_filter     = "pre_output_filter", +} +  -------------------------------------------------------------------------------  ---                                DEFAULTS @@ -479,9 +496,20 @@ local option_spec = {      color_callback = {        in_t      = string_t,        out_t     = string_t, -      transform = function (cb) +      transform = function (cb_spec)          --- These are the two that make sense. -        return cb == "pre_output_filter" and cb or "pre_linebreak_filter" +        local cb = permissible_color_callbacks[cb_spec] +        if cb then +          logreport ("log", 3, "conf", +                     "Using callback \"%s\" for font colorization.", +                     cb) +          return cb +        end +        logreport ("log", 0, "conf", +                    "Requested callback identifier \"%s\" invalid, " +                    .. "falling back to default.", +                    cb_spec) +        return permissible_color_callbacks.default        end,      },    },  | 
