这个直线文本渐变解决方案在我更新到 texlive 2017 之前一直有效。遗憾的是它似乎不再起作用了。
下面的 MWE 依赖于两个 LuaTex 文件:
我尝试修复 texlive 2016,直线 2016 修复但那没有用。我没有得到色彩鲜艳的文字,而是得到了以下内容:
梅威瑟:
\RequirePackage{luatex85}
\documentclass {scrartcl}
\usepackage {fontspec} %% this loads luaotfload as well
\setmainfont {Antykwa Poltawskiego}
\usepackage{luatexbase}
\input beegradients.tex
\definegradientgroup [red-green-blue][255*0*0, 0*255*0, 0*0*255]
\begin {document}
\startbeegradients [red-green-blue]
A large rose-tree stood near the entrance of the garden: the roses growing on it were white, but there were three gardeners at it, busily painting them red. Alice thought this a very curious thing, and she went nearer to watch them, and just as she came up to them she heard one of them say, `Look out now, Five! Don't go splashing paint over me like that!'
\stopbeegradients
\end {document}
日志档案:
This is LuaTeX, Version 1.0.4 (TeX Live 2017) (format=lualatex 2017.12.17) 23 DEC 2017 09:57
restricted system commands enabled.
**beelinestesting.tex
(./beelinestesting.tex
LaTeX2e <2017-04-15>
Lua module: luaotfload-main 2017/01/29 2.80001 OpenType layout system.
Lua module: lualibs 2017-02-01 2.5 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2017-02-01 2.5 ConTeXt Lua libraries -- extended co
llection.(using write cache: /home/aaron/.texlive2017/texmf-var/luatex-cache/gen
eric)(using read cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic /
home/aaron/.texlive2017/texmf-var/luatex-cache/generic)
luaotfload | conf : Root cache directory is /home/aaron/.texlive2017/texmf-var/l
uatex-cache/generic/names.
luaotfload | init : Loading fontloader “fontloader-2017-02-11.lua” from kpse
-resolved path “/usr/local/texlive/2017/texmf-dist/tex/luatex/luaotfload/fontl
oader-2017-02-11.lua”.
Lua-only attribute luaotfload@state = 1
Lua-only attribute luaotfload@noligature = 2
Lua-only attribute luaotfload@syllabe = 3
luaotfload | init : Context OpenType loader version “3.027”
Inserting `luaotfload.node_processor' at position 1 in `pre_linebreak_filter'.
Inserting `luaotfload.node_processor' at position 1 in `hpack_filter'.
Inserting `luaotfload.define_font' at position 1 in `define_font'.
Lua-only attribute luaotfload_color_attribute = 4
luaotfload | conf : Root cache directory is /home/aaron/.texlive2017/texmf-var/l
uatex-cache/generic/names.
Inserting `luaotfload.aux.set_sscale_dimens' at position 1 in `luaotfload.patch_
font'.
Inserting `luaotfload.aux.patch_cambria_domh' at position 2 in `luaotfload.patch
_font'.
Inserting `luaotfload.aux.fixup_fontdata' at position 1 in `luaotfload.patch_fon
t_unsafe'.
Inserting `luaotfload.aux.set_capheight' at position 3 in `luaotfload.patch_font
'.
Inserting `luaotfload.rewrite_fontname' at position 4 in `luaotfload.patch_font'
.
luaotfload | main : initialization completed in 0.090 seconds
Babel <3.15> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/generic/luatex85/luatex85.sty
Package: luatex85 2016/06/15 v1.4 pdftex aliases for luatex
)
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2017/09/07 v3.24 KOMA-Script document class (article)
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrkbase.sty
Package: scrkbase 2017/09/07 v3.24 KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrbase.sty
Package: scrbase 2017/09/07 v3.24 KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package: scrlfile 2017/09/07 v3.24 KOMA-Script package (loading files)
)))
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/tocbasic.sty
Package: tocbasic 2017/09/07 v3.24 KOMA-Script package (handling toc-files)
\scr@dte@tocline@numberwidth=\skip41
\scr@dte@tocline@numbox=\box26
)
Package tocbasic Info: omitting babel extension for `toc'
(tocbasic) because of feature `nobabel' available
(tocbasic) for `toc' on input line 133.
Package tocbasic Info: omitting babel extension for `lof'
(tocbasic) because of feature `nobabel' available
(tocbasic) for `lof' on input line 135.
Package tocbasic Info: omitting babel extension for `lot'
(tocbasic) because of feature `nobabel' available
(tocbasic) for `lot' on input line 136.
Class scrartcl Info: File `scrsize11pt.clo' used instead of
(scrartcl) file `scrsize11.clo' to setup font sizes on input line 2080
.
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrsize11pt.clo
File: scrsize11pt.clo 2017/09/07 v3.24 KOMA-Script font size class option (11pt)
luaotfload | db : Font names database loaded from /home/aaron/.texlive2017/texmf
-var/luatex-cache/generic/names/luaotfload-names.luc(load luc: /home/aaron/.texl
ive2017/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc))
(/usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/typearea.sty
Package: typearea 2017/09/07 v3.24 KOMA-Script package (type area)
\ta@bcor=\skip42
\ta@div=\count79
\ta@hblk=\skip43
\ta@vblk=\skip44
\ta@temp=\skip45
\footheight=\skip46
Package typearea Info: These are the values describing the layout:
(typearea) DIV = 10
(typearea) BCOR = 0.0pt
(typearea) \paperwidth = 597.50793pt
(typearea) \textwidth = 418.25555pt
(typearea) DIV departure = -6%
(typearea) \evensidemargin = 17.3562pt
(typearea) \oddsidemargin = 17.3562pt
(typearea) \paperheight = 845.04694pt
(typearea) \textheight = 595.80026pt
(typearea) \topmargin = -25.16531pt
(typearea) \headheight = 17.0pt
(typearea) \headsep = 20.40001pt
(typearea) \topskip = 11.0pt
(typearea) \footskip = 47.6pt
(typearea) \baselineskip = 13.6pt
(typearea) on input line 1686.
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\scr@dte@part@maxnumwidth=\skip47
\scr@dte@section@maxnumwidth=\skip48
\scr@dte@subsection@maxnumwidth=\skip49
\scr@dte@subsubsection@maxnumwidth=\skip50
\scr@dte@paragraph@maxnumwidth=\skip51
\scr@dte@subparagraph@maxnumwidth=\skip52
LaTeX Info: Redefining \textsubscript on input line 4161.
\abovecaptionskip=\skip53
\belowcaptionskip=\skip54
\c@pti@nb@sid@b@x=\box27
\c@figure=\count86
\c@table=\count87
Class scrartcl Info: Redefining `\numberline' on input line 5319.
\bibindent=\dimen102
)
(/usr/local/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2017/12/16 L3 programming layer (loader)
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3-code.tex
Package: expl3 2017/12/16 L3 programming layer (code)
\ucharcat@table=\catcodetable5
\c_max_int=\count88
\l_tmpa_int=\count89
\l_tmpb_int=\count90
\g_tmpa_int=\count91
\g_tmpb_int=\count92
\g__intarray_font_int=\count93
\g__prg_map_int=\count94
\c_log_iow=\count95
\l_iow_line_count_int=\count96
\l__iow_line_target_int=\count97
\l__iow_one_indent_int=\count98
\l__iow_indent_int=\count99
\c_zero_dim=\dimen103
\c_max_dim=\dimen104
\l_tmpa_dim=\dimen105
\l_tmpb_dim=\dimen106
\g_tmpa_dim=\dimen107
\g_tmpb_dim=\dimen108
\c_zero_skip=\skip55
\c_max_skip=\skip56
\l_tmpa_skip=\skip57
\l_tmpb_skip=\skip58
\g_tmpa_skip=\skip59
\g_tmpb_skip=\skip60
\c_zero_muskip=\muskip10
\c_max_muskip=\muskip11
\l_tmpa_muskip=\muskip12
\l_tmpb_muskip=\muskip13
\g_tmpa_muskip=\muskip14
\g_tmpb_muskip=\muskip15
\l_keys_choice_int=\count100
\c__fp_leading_shift_int=\count101
\c__fp_middle_shift_int=\count102
\c__fp_trailing_shift_int=\count103
\c__fp_big_leading_shift_int=\count104
\c__fp_big_middle_shift_int=\count105
\c__fp_big_trailing_shift_int=\count106
\c__fp_Bigg_leading_shift_int=\count107
\c__fp_Bigg_middle_shift_int=\count108
\c__fp_Bigg_trailing_shift_int=\count109
\c__fp_rand_size_int=\count110
\c__fp_rand_four_int=\count111
\c__fp_rand_eight_int=\count112
\l__sort_length_int=\count113
\l__sort_min_int=\count114
\l__sort_top_int=\count115
\l__sort_max_int=\count116
\l__sort_true_max_int=\count117
\l__sort_block_int=\count118
\l__sort_begin_int=\count119
\l__sort_end_int=\count120
\l__sort_A_int=\count121
\l__sort_B_int=\count122
\l__sort_C_int=\count123
\l__tl_build_start_index_int=\count124
\l__tl_build_index_int=\count125
\l__tl_analysis_normal_int=\count126
\l__tl_analysis_index_int=\count127
\l__tl_analysis_nesting_int=\count128
\l__tl_analysis_type_int=\count129
\l__regex_internal_a_int=\count130
\l__regex_internal_b_int=\count131
\l__regex_internal_c_int=\count132
\l__regex_balance_int=\count133
\l__regex_group_level_int=\count134
\l__regex_mode_int=\count135
\c__regex_cs_in_class_mode_int=\count136
\c__regex_cs_mode_int=\count137
\l__regex_catcodes_int=\count138
\l__regex_default_catcodes_int=\count139
\c__regex_catcode_L_int=\count140
\c__regex_catcode_O_int=\count141
\c__regex_catcode_A_int=\count142
\c__regex_all_catcodes_int=\count143
\l__regex_show_lines_int=\count144
\l__regex_min_state_int=\count145
\l__regex_max_state_int=\count146
\l__regex_left_state_int=\count147
\l__regex_right_state_int=\count148
\l__regex_capturing_group_int=\count149
\l__regex_min_pos_int=\count150
\l__regex_max_pos_int=\count151
\l__regex_curr_pos_int=\count152
\l__regex_start_pos_int=\count153
\l__regex_success_pos_int=\count154
\l__regex_curr_char_int=\count155
\l__regex_curr_catcode_int=\count156
\l__regex_last_char_int=\count157
\l__regex_case_changed_char_int=\count158
\l__regex_curr_state_int=\count159
\l__regex_step_int=\count160
\l__regex_min_active_int=\count161
\l__regex_max_active_int=\count162
\l__regex_replacement_csnames_int=\count163
\l__regex_match_count_int=\count164
\l__regex_min_submatch_int=\count165
\l__regex_submatch_int=\count166
\l__regex_zeroth_submatch_int=\count167
\g__debug_trace_regex_int=\count168
\c_empty_box=\box28
\l_tmpa_box=\box29
\l_tmpb_box=\box30
\g_tmpa_box=\box31
\g_tmpb_box=\box32
\l__box_top_dim=\dimen109
\l__box_bottom_dim=\dimen110
\l__box_left_dim=\dimen111
\l__box_right_dim=\dimen112
\l__box_top_new_dim=\dimen113
\l__box_bottom_new_dim=\dimen114
\l__box_left_new_dim=\dimen115
\l__box_right_new_dim=\dimen116
\l__box_internal_box=\box33
\l__coffin_internal_box=\box34
\l__coffin_internal_dim=\dimen117
\l__coffin_offset_x_dim=\dimen118
\l__coffin_offset_y_dim=\dimen119
\l__coffin_x_dim=\dimen120
\l__coffin_y_dim=\dimen121
\l__coffin_x_prime_dim=\dimen122
\l__coffin_y_prime_dim=\dimen123
\c_empty_coffin=\box35
\l__coffin_aligned_coffin=\box36
\l__coffin_aligned_internal_coffin=\box37
\l_tmpa_coffin=\box38
\l_tmpb_coffin=\box39
\l__coffin_display_coffin=\box40
\l__coffin_display_coord_coffin=\box41
\l__coffin_display_pole_coffin=\box42
\l__coffin_display_offset_dim=\dimen124
\l__coffin_display_x_dim=\dimen125
\l__coffin_display_y_dim=\dimen126
\l__coffin_bounding_shift_dim=\dimen127
\l__coffin_left_corner_dim=\dimen128
\l__coffin_right_corner_dim=\dimen129
\l__coffin_bottom_corner_dim=\dimen130
\l__coffin_top_corner_dim=\dimen131
\l__coffin_scaled_total_height_dim=\dimen132
\l__coffin_scaled_width_dim=\dimen133
)
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/l3pdfmode.def
File: l3pdfmode.def 2017/03/18 v L3 Experimental driver: PDF mode
\l__driver_color_stack_int=\count169
\l__driver_tmp_box=\box43
))
Package: xparse 2017/12/16 L3 Experimental document command parser
\l__xparse_current_arg_int=\count170
\g__xparse_grabber_int=\count171
\l__xparse_m_args_int=\count172
\l__xparse_mandatory_args_int=\count173
\l__xparse_v_nesting_int=\count174
)
Package: fontspec 2017/11/09 v2.6g Font selection for XeLaTeX and LuaLaTeX
Lua module: fontspec 2017/11/09 2.6g Font selection for XeLaTeX and LuaLaTeX
(/usr/local/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
Package: fontspec-luatex 2017/11/09 v2.6g Font selection for XeLaTeX and LuaLaTe
X
\l__fontspec_script_int=\count175
\l__fontspec_language_int=\count176
\l__fontspec_strnum_int=\count177
\l__fontspec_tmp_int=\count178
\l__fontspec_em_int=\count179
\l__fontspec_emdef_int=\count180
\l__fontspec_strong_int=\count181
\l__fontspec_strongdef_int=\count182
\l__fontspec_tmpa_dim=\dimen134
\l__fontspec_tmpb_dim=\dimen135
\l__fontspec_tmpc_dim=\dimen136
\g__file_internal_ior=\read1
由于字符限制,必须删减一些日志。
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2017/04/05 v2.0i Standard LaTeX package
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/tuenc.def
File: tuenc.def 2017/04/05 v2.0i Standard LaTeX file
LaTeX Font Info: Redeclaring font encoding TU on input line 82.
))
.................................................
>"AntykwaPoltawskiego/I:mode=node;script=latn;language=DFLT;+tlig;"
. - 'italic small caps' (m/itsc) with NFSS spec.:
. <->"AntykwaPoltawskiego/I:mode=node;script=latn;language=DFLT;+tlig;+smcp;"
. - 'bold italic' (bx/it) with NFSS spec.:
. <->"AntykwaPoltawskiego/BI:mode=node;script=latn;language=DFLT;+tlig;"
. - 'bold italic small caps' (bx/itsc) with NFSS spec.:
. <->"AntykwaPoltawskiego/BI:mode=node;script=latn;language=DFLT;+tlig;+smcp;"
.................................................
LaTeX Info: Redefining \rmfamily on input line 4.
(/usr/local/texlive/2017/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
Package: luatexbase 2015/10/04 v1.3 luatexbase interface to LuaTeX
(/usr/local/texlive/2017/texmf-dist/tex/luatex/ctablestack/ctablestack.sty
Package: ctablestack 2015/10/01 v1.0 Catcode table stable support
\@catcodetablestackcnt=\count184
)
\CatcodeTableOther=\catcodetable6
\CatcodeTableExpl=\catcodetable7
)
(/usr/local/texlive/2017/texmf-dist/tex/generic/beegradients/beegradients.tex
Lua module: beegradients 2013-09-07 17:03:42+0200 42)
(./beelinestesting.aux)
\openout1 = beelinestesting.aux
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 10.
LaTeX Font Info: ... okay on input line 10.
.................................................
. fontspec info: "setup-math"
.
. Adjusting the maths setup (use [no-math] to avoid this).
.................................................
\symlegacymaths=\mathgroup4
LaTeX Font Info: Overwriting symbol font `legacymaths' in version `bold'
(Font) OT1/cmr/m/n --> OT1/cmr/bx/n on input line 10.
LaTeX Font Info: Redeclaring math accent \acute on input line 10.
LaTeX Font Info: Redeclaring math accent \grave on input line 10.
LaTeX Font Info: Redeclaring math accent \ddot on input line 10.
LaTeX Font Info: Redeclaring math accent \tilde on input line 10.
LaTeX Font Info: Redeclaring math accent \bar on input line 10.
LaTeX Font Info: Redeclaring math accent \breve on input line 10.
LaTeX Font Info: Redeclaring math accent \check on input line 10.
LaTeX Font Info: Redeclaring math accent \hat on input line 10.
LaTeX Font Info: Redeclaring math accent \dot on input line 10.
LaTeX Font Info: Redeclaring math accent \mathring on input line 10.
LaTeX Font Info: Redeclaring math symbol \colon on input line 10.
LaTeX Font Info: Redeclaring math symbol \Gamma on input line 10.
LaTeX Font Info: Redeclaring math symbol \Delta on input line 10.
LaTeX Font Info: Redeclaring math symbol \Theta on input line 10.
LaTeX Font Info: Redeclaring math symbol \Lambda on input line 10.
LaTeX Font Info: Redeclaring math symbol \Xi on input line 10.
LaTeX Font Info: Redeclaring math symbol \Pi on input line 10.
LaTeX Font Info: Redeclaring math symbol \Sigma on input line 10.
LaTeX Font Info: Redeclaring math symbol \Upsilon on input line 10.
LaTeX Font Info: Redeclaring math symbol \Phi on input line 10.
LaTeX Font Info: Redeclaring math symbol \Psi on input line 10.
LaTeX Font Info: Redeclaring math symbol \Omega on input line 10.
LaTeX Font Info: Redeclaring math symbol \mathdollar on input line 10.
LaTeX Font Info: Redeclaring symbol font `operators' on input line 10.
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
(Font) `operators' in the math version `normal' on input line 10.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) OT1/cmr/m/n --> TU/AntykwaPoltawskiego(0)/m/n on input l
ine 10.
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
(Font) `operators' in the math version `bold' on input line 10.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) OT1/cmr/bx/n --> TU/AntykwaPoltawskiego(0)/m/n on input
line 10.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) TU/AntykwaPoltawskiego(0)/m/n --> TU/AntykwaPoltawskiego
(0)/m/n on input line 10.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `normal'
(Font) OT1/cmr/m/it --> TU/AntykwaPoltawskiego(0)/m/it on input
line 10.
LaTeX Font Info: Overwriting math alphabet `\mathbf' in version `normal'
(Font) OT1/cmr/bx/n --> TU/AntykwaPoltawskiego(0)/bx/n on input
line 10.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `normal'
(Font) OT1/cmss/m/n --> TU/lmss/m/n on input line 10.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `normal'
(Font) OT1/cmtt/m/n --> TU/lmtt/m/n on input line 10.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) TU/AntykwaPoltawskiego(0)/m/n --> TU/AntykwaPoltawskiego
(0)/bx/n on input line 10.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `bold'
(Font) OT1/cmr/bx/it --> TU/AntykwaPoltawskiego(0)/bx/it on inp
ut line 10.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `bold'
(Font) OT1/cmss/bx/n --> TU/lmss/bx/n on input line 10.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `bold'
(Font) OT1/cmtt/m/n --> TU/lmtt/bx/n on input line 10.
! Undefined control sequence.
\startbeegradients ->\lltxb@ifnextchar
[\startbeegradientsindeed {\startbeeg...
l.11 \startbeegradients
[red-green-blue]
?
! Use of \startbeegradientsindeed doesn't match its definition.
\startbeegradients ... [\startbeegradientsindeed {
\startbeegradientsindeed []}
l.11 \startbeegradients
[red-green-blue]
?
Module beegradients Warning: Cannot inject node processor: no gradient group def
ined. on input line 11
! Too many }'s.
\startbeegradients ...\startbeegradientsindeed []}
l.11 \startbeegradients
[red-green-blue]
?
[1
{/usr/local/texlive/2017/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./beelinestesting.aux))
Here is how much of LuaTeX's memory you used:
11971 strings out of 494483
100000,552014 words of node,token memory allocated
413 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 5 attribute, 53 glue_spec, 5 attribute_list
, 1 write, 1 pdf_literal nodes
avail lists: 2:21,3:4,4:4,5:25,6:319,7:84,8:1,9:12,10:3,11:13
15973 multiletter control sequences out of 65536+600000
30 fonts using 6586047 bytes
46i,6n,67p,8880b,238s stack positions out of 5000i,500n,10000p,200000b,100000s
</usr/local/texlive/2017/texmf-dist/fonts/opentype/gust/poltawski/antpolt-regula
r.otf>
Output written on beelinestesting.pdf (1 page, 5565 bytes).
PDF statistics: 15 PDF objects out of 1000 (max. 8388607)
8 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 131072)
1 words of extra memory for PDF output out of 10000 (max. 100000000)
任何帮助实现此功能的人都将不胜感激。谢谢!
答案1
目前,pdf 文字的节点子类型是 16,而不是 8。(可能应该通过名称获取数字,而不是依赖内部数字,但这里我只是将 8 改为 16。)
你的测试文件
\RequirePackage{luatex85}
\documentclass {scrartcl}
\usepackage {fontspec} %% this loads luaotfload as well
\setmainfont {Antykwa Poltawskiego}
\usepackage{luatexbase}
\makeatletter
%\def\RequireLuaModule#1{\directlua{require("#1")}}
\let\lltxb@ifnextchar\@ifnextchar
\makeatother
\input beegradients.tex
\definegradientgroup [red-green-blue][255*0*0, 0*255*0, 0*0*255]
\begin {document}
\startbeegradients [red-green-blue]
A large rose-tree stood near the entrance of the garden: the roses growing on it were white, but there were three gardeners at it, busily painting them red. Alice thought this a very curious thing, and she went nearer to watch them, and just as she came up to them she heard one of them say, `Look out now, Five! Don't go splashing paint over me like that!'
\stopbeegradients
\end {document}
lua代码
packagedata = packagedata or { }
packagedata.beegradients = { }
local beegradients = packagedata.beegradients
local processorid = "beegradients" --- name of callback
local err, warn, info
if luatexbase then
err, warn, info = luatexbase.provides_module {
name = "beegradients",
version = 42,
date = "2013-09-07 17:03:42+0200",
descriptions = "http://tex.stackexchange.com/q/131883/14066",
author = "Philipp Gesang",
copyright = "Philipp Gesang",
license = "BSD 2 clause",
}
end
local lpeg = require "lpeg"
local C, Cf, Cg, Ct = lpeg.C, lpeg.Cf, lpeg.Cg, lpeg.Ct
local P, R, S = lpeg.P, lpeg.R, lpeg.S
local lpegmatch = lpeg.match
local unpack = unpack or table.unpack
local stringformat = string.format
local stringis_empty = string.is_empty
local tableswapped = table.swapped
local nodes = nodes
local nodecodes = nodes.nodecodes or tableswapped (node.types ())
local hlist_t = nodecodes.hlist
local vlist_t = nodecodes.vlist
local glyph_t = nodecodes.glyph
local disc_t = nodecodes.disc
local whatsit_t = nodecodes.whatsit
local pdf_literal_t = 16
local traversenodes = node.traverse
local traversenodetype = node.traverse_id
local countnodes = node.count
local newnode = node.new
local copynode = node.copy
local insertnodebefore = node.insert_before
local insertnodeafter = node.insert_after
require "lualibs" --- requires extended set including util-prs.lua
local settingstoarray = utilities and utilities.parsers.settings_to_array
if not settingstoarray then --- old Lualibs
local comma = P","
local spacechar = S" \f\n\r\t\v"
local separator = comma * spacechar^0
local item = C((1 - comma - spacechar)^1)
local p_settings = spacechar^0
* item
* (separator * item)^0
* (separator + spacechar^0)
settingstoarray = function (settings)
return lpegmatch (Ct (p_settings), settings)
end
end
local practically_zero = 0.003921568627451
local practically_one = 0.99607843137255
local parse_gradient do
local tonumber16 = function (n) return tonumber (n, 16) end
local digit = R"09"
local hexdigit = R("09", "af", "AF")
local dash = P"-"
local colon = P":"
local asterisk = P"*"
--- values:
--- hexcolor -> 0xf00ba7 (triplet of hex octets, r->g->b)
--- deccolor -> 123*44*111 (triplet of decimal octets: r->g->b)
--- speccolor -> r:210*g:32*b:145 (prefixed octets, any order)
local hexcolor = Ct (P"0x" * Cg (hexdigit * hexdigit / tonumber16, "r")
* Cg (hexdigit * hexdigit / tonumber16, "g")
* Cg (hexdigit * hexdigit / tonumber16, "b"))
local decexp = digit * digit^-1 * digit^-1
local deccolor = Ct (Cg (decexp / tonumber, "r") * asterisk
* Cg (decexp / tonumber, "g") * asterisk
* Cg (decexp / tonumber, "b"))
local specexp = C(S"rgb") * colon * (C(decexp) / tonumber)
local speccolor = Cf (Ct ""
* Cg (specexp) * asterisk
* Cg (specexp) * asterisk
* Cg (specexp),
rawset)
local colexp = hexcolor + deccolor + speccolor
local zero = { 0, 0, 0 } --- fallback
--- string -> float * float * float
parse_color = function (raw)
local color = lpegmatch (colexp, raw)
local r = color.r / 255
local g = color.g / 255
local b = color.b / 255
if r < practically_zero then r = 0 end
if r > practically_one then r = 1 end
if g < practically_zero then g = 0 end
if g > practically_one then g = 1 end
if b < practically_zero then b = 0 end
if b > practically_one then b = 1 end
return { r, g, b }
end
end
local gradients = { } --- (float * float * float) list
--- string -> unit
local definegradients = function (groupid, raw)
local group = gradients [groupid]
if group then
warn (stringformat ("Gradient group %q already defined, redefining.",
groupid))
else
group = { }
end
local definitions = settingstoarray (raw)
if #definitions < 1 then
warn (stringformat ("Need at least one definition in gradient group %q, skipping.",
groupid))
return nil
end
for i = 1, #definitions do
local definition = definitions [i]
if definition and not stringis_empty (definition) then
group [#group + 1] = parse_color (definition)
end
end
gradients [groupid] = group
end
beegradients.define = definegradients
local pdf_literal = newnode(whatsit_t, pdf_literal_t)
local get_colornode = function (r, g, b)
local push, pop = copynode (pdf_literal), copynode (pdf_literal)
local pushcolor = stringformat ("%.3g %.3g %.3g rg", r, g, b)
local popcolor = "0 g"
push.mode, push.data = 1, pushcolor
pop.mode, pop.data = 1, popcolor
return push, pop
end
--- more accurate, recursive glyph counter than node.count;
--- this includes, for instance, the lowered -Y´E¡ in \TeX
--- node_t -> int? -> int
local countglyphs countglyphs = function (hd, cnt)
cnt = cnt or 0
for n in traversenodes (hd) do
local nid = n.id
if nid == glyph_t or nid == disc_t then
cnt = cnt + 1
elseif nid == hlist_t or nid == vlist_t then
cnt = countglyphs (n.list, cnt)
end
end
return cnt
end
--- node_t -> float -> float -> float ->
-- -> float -> float -> float -> node_t
local colorize_glyphs colorize_glyphs = function (hd, done,
r, g, b,
rstep, gstep, bstep)
local cur = hd
while cur do
local id = cur.id
if id == glyph_t or id == disc_t then
local before, after = get_colornode (r, g, b)
local curprev, curnext = cur.prev, cur.next
before.next, cur.prev = cur, before
after.prev, cur.next = cur, after
if not curprev then --- first
hd = before
else
before.prev, curprev.next = curprev, before
end
if curnext then
after.next, curnext.prev = curnext, after
end -- else last node
done = done + 1
cur = curnext
if cur then
r = r + rstep
g = g + gstep
b = b + bstep
--- safeguard against rounding
if r < practically_zero then r = 0 end
if r > practically_one then r = 1 end
if g < practically_zero then g = 0 end
if g > practically_one then g = 1 end
if b < practically_zero then b = 0 end
if b > practically_one then b = 1 end
end
elseif id == hlist_t or id == vlist_t then
local list = cur.list
if list then
cur.list, done = colorize_glyphs (cur.list, done,
r, g, b,
rstep, gstep, bstep)
end
cur = cur.next
else
cur = cur.next
end
end
--print (stringformat ("final> %.3f %.3f %.3f -A× %d", r, g, b, done))
return hd, done
end
local lineprocessor = function (hd, from, to)
local list = hd.list
local nglyphs = countglyphs (list)
local nsteps = nglyphs - 1
local rstart, gstart, bstart = unpack (from)
local rstep = (to [1] - rstart) / nsteps
local gstep = (to [2] - gstart) / nsteps
local bstep = (to [3] - bstart) / nsteps
--print (stringformat ("from> %.3f %.3f %.3f", rstart, gstart, bstart))
--print (stringformat ("to> %.3f %.3f %.3f", to [1], to [2], to [3]))
--print (stringformat ("step> %.3f %.3f %.3f × %d", rstep, gstep, bstep, nglyphs))
--print (">>", nglyphs, countnodes (glyph_t, list), from, to)
local glyphs_done
hd.list, glyphs_done = colorize_glyphs (list, 0,
rstart, gstart, bstart,
rstep, gstep, bstep)
--print (">>", nglyphs, glyphs_done, from, to)
end
local currentgroup
local currentgradient = 1
local processor = function (hd)
local group = gradients [currentgroup]
local ngradients = #group
if not group then
warn (stringformat ("No such gradient group: %q, bailing out.",
currentgroup))
return hd
end
for line in traversenodetype (hlist_t, hd) do
local fromcolor = group [currentgradient]
currentgradient = currentgradient + 1
if currentgradient > ngradients then
currentgradient = 1
end
local tocolor = group [currentgradient]
lineprocessor (line, fromcolor, tocolor)
end
return hd
end
local active = false
local enable = function (groupid)
if not stringis_empty (groupid) then
if currentgroup ~= groupid then -- reset gradient pointer
currentgradient = 1
end
currentgroup = groupid
end
if currentgroup == nil then
warn "Cannot inject node processor: no gradient group defined."
return
end
if active == false then
info (stringformat ("Injecting node processor, active group %q.",
currentgroup))
luatexbase.add_to_callback ("post_linebreak_filter",
processor,
processorid)
active = true
end
end
local disable = function ()
if active == true then
info "Removing node processor."
luatexbase.remove_from_callback ("post_linebreak_filter",
processorid)
active = false
end
end
beegradients.enable = enable
beegradients.disable = disable