From 59e7679528d75e5d523acddf69dabdce42d53734 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 14 Aug 2019 12:32:10 +0200 Subject: 2019-08-14 11:34:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/attr-ini.mkiv | 59 ++- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 2 +- tex/context/base/mkiv/lxml-tab.lua | 5 +- tex/context/base/mkiv/node-aux.lua | 17 +- tex/context/base/mkiv/node-nut.lua | 12 +- tex/context/base/mkiv/page-one.mkiv | 8 +- tex/context/base/mkiv/status-files.pdf | Bin 26626 -> 26647 bytes tex/context/base/mkiv/status-lua.pdf | Bin 267827 -> 267852 bytes tex/context/base/mkiv/strc-flt.mkvi | 51 ++- tex/context/base/mkiv/typo-drp.lua | 420 ++++++++++----------- tex/context/base/mkiv/typo-drp.mkiv | 18 +- tex/context/base/mkiv/typo-fln.lua | 54 +-- tex/context/base/mkiv/typo-fln.mkiv | 2 +- tex/context/interface/mkiv/i-context.pdf | Bin 889788 -> 889903 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61165 -> 61165 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 20 files changed, 356 insertions(+), 302 deletions(-) (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 2ee1c8da4..a7ee56e1e 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.08.11 20:03} +\newcontextversion{2019.08.14 11:26} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 7ee0869d6..3d0cf4de2 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} %D For those who want to use this: diff --git a/tex/context/base/mkiv/attr-ini.mkiv b/tex/context/base/mkiv/attr-ini.mkiv index 22e3ba259..e4215ff00 100644 --- a/tex/context/base/mkiv/attr-ini.mkiv +++ b/tex/context/base/mkiv/attr-ini.mkiv @@ -57,31 +57,60 @@ \def\attr_basics_define {\attr_basics_define_indeed\s!public} \def\attr_basics_define_system{\attr_basics_define_indeed\s!private} +% todo: define global ! + % here public means 'visible' so it's not to be confused with 'public' at the lua end +% \def\attr_basics_define_indeed#1[#2][#3]% +% {\ifcsname\??attributecount#2\endcsname\else +% \scratchcounter\clf_defineattribute{#2}{#1}\relax +% %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}% +% \expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter +% \expandafter\newconstant \csname\??attributeid#2\endcsname +% \csname\??attributeid#2\endcsname\scratchcounter +% % some attributes are always global +% \doifelseinset\s!global{#3}% +% {\etoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% \doifinset\s!nomath{#3}% +% {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% \doifinset\s!public{#3}% +% {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% +% \doifinset\s!pickup{#3}% +% {\expandafter\newconstant\csname\??attributepickup#2\endcsname +% \csname\??attributepickup#2\endcsname\attributeunsetvalue +% \etoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% +% \ifcsname#2\s!attribute\endcsname +% \expandafter\edef\csname\s!pickup#2\s!attribute\endcsname +% {\csname\??attributepickup#2\endcsname\csname\??attributecount#2\endcsname}% +% \expandafter\edef\csname\s!forget#2\s!attribute\endcsname +% {\csname\??attributepickup#2\endcsname\attributeunsetvalue}% +% \fi}% +% \fi} + \def\attr_basics_define_indeed#1[#2][#3]% {\ifcsname\??attributecount#2\endcsname\else \scratchcounter\clf_defineattribute{#2}{#1}\relax %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}% - \expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter - \expandafter\newconstant \csname\??attributeid#2\endcsname - \csname\??attributeid#2\endcsname\scratchcounter + \global\expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter + \global\expandafter\newconstant \csname\??attributeid#2\endcsname + \global\csname\??attributeid#2\endcsname\scratchcounter % some attributes are always global \doifelseinset\s!global{#3}% - {\etoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% - {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% \doifinset\s!nomath{#3}% - {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% \doifinset\s!public{#3}% - {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% + {\expandafter\glet\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% \doifinset\s!pickup{#3}% - {\expandafter\newconstant\csname\??attributepickup#2\endcsname - \csname\??attributepickup#2\endcsname\attributeunsetvalue - \etoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% + {\global\expandafter\newconstant\csname\??attributepickup#2\endcsname + \global\csname\??attributepickup#2\endcsname\attributeunsetvalue + \xtoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% \ifcsname#2\s!attribute\endcsname - \expandafter\edef\csname\s!pickup#2\s!attribute\endcsname + \expandafter\xdef\csname\s!pickup#2\s!attribute\endcsname {\csname\??attributepickup#2\endcsname\csname\??attributecount#2\endcsname}% - \expandafter\edef\csname\s!forget#2\s!attribute\endcsname + \expandafter\xdef\csname\s!forget#2\s!attribute\endcsname {\csname\??attributepickup#2\endcsname\attributeunsetvalue}% \fi}% \fi} @@ -95,9 +124,13 @@ % \unexpanded\def\pickupattributelater#1% % {\csname\??attributepickup#1\endcsname\csname\??attributecount#1\endcsname} +% \unexpanded\def\newattribute#1% +% {\attr_basics_define_indeed\s!public[\csstring#1][]% +% \expandafter\let\expandafter#1\csname\??attributeid\csstring#1\endcsname} + \unexpanded\def\newattribute#1% {\attr_basics_define_indeed\s!public[\csstring#1][]% - \expandafter\let\expandafter#1\csname\??attributeid\csstring#1\endcsname} + \expandafter\glet\expandafter#1\csname\??attributeid\csstring#1\endcsname} % expandable so we can \edef them for speed diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 11d81d603..99f1c2d9c 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.08.11 20:03} +\newcontextversion{2019.08.14 11:26} %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 bb8a89065..8694533e8 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index f7ea6ad6a..d6aaa9b2c 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index a779cd50c..3ade1c92b 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -984,8 +984,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay, data - if resolvers then - okay, data = resolvers.loadbinfile(n) + local loadbinfile = resolvers and resolvers.loadbinfile + if loadbinfile then + okay, data = loadbinfile(n) else data = io.loaddata(n) okay = data and data ~= "" diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua index 45db8807a..e116a2cdc 100644 --- a/tex/context/base/mkiv/node-aux.lua +++ b/tex/context/base/mkiv/node-aux.lua @@ -21,6 +21,7 @@ local glyph_code = nodecodes.glyph local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local attributelist_code = nodecodes.attributelist -- temporary +local localpar_code = nodecodes.localpar local nuts = nodes.nuts local tonut = nuts.tonut @@ -34,6 +35,7 @@ local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getattr = nuts.getattr local getboth = nuts.getboth +local getprev = nuts.getprev local getcomponents = nuts.getcomponents local getwidth = nuts.getwidth local setwidth = nuts.setwidth @@ -49,8 +51,6 @@ local setprev = nuts.setprev local setcomponents = nuts.setcomponents local setattrlist = nuts.setattrlist ------ traverse_nodes = nuts.traverse ------ traverse_id = nuts.traverse_id local nextnode = nuts.traversers.node local nextglyph = nuts.traversers.glyph local flush_node = nuts.flush @@ -59,7 +59,6 @@ local hpack_nodes = nuts.hpack local unset_attribute = nuts.unset_attribute local first_glyph = nuts.first_glyph local copy_node = nuts.copy ------ copy_node_list = nuts.copy_list local find_tail = nuts.tail local getbox = nuts.getbox local count = nuts.count @@ -73,6 +72,7 @@ local unsetvalue = attributes.unsetvalue local current_font = font.current local texsetbox = tex.setbox +local texnest = tex.nest local report_error = logs.reporter("node-aux:error") @@ -472,3 +472,14 @@ end -- end -- end -- end + +function nuts.setparproperty(action,...) + local tail = tonut(texnest[texnest.ptr].tail) + while tail do + if getid(tail) == localpar_code then + return action(tail,...) + else + tail = getprev(tail) + end + end +end diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index d60727eee..158f74a98 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -774,14 +774,22 @@ end nuts.getprop = function(n,k) local p = propertydata[n] if p then - return p[k] + if k then + return p[k] + else + return p + end end end nuts.rawprop = function(n,k) local p = rawget(propertydata,n) if p then - return p[k] + if k then + return p[k] + else + return p + end end end diff --git a/tex/context/base/mkiv/page-one.mkiv b/tex/context/base/mkiv/page-one.mkiv index 9572b3769..dc157fbeb 100644 --- a/tex/context/base/mkiv/page-one.mkiv +++ b/tex/context/base/mkiv/page-one.mkiv @@ -445,7 +445,13 @@ \fi % should be an option \endgroup - \scratchdimenone\dimexpr\pagetotal+\floatheight+\d_strc_floats_top-\pageshrink\relax + \scratchdimenone\dimexpr + \pagetotal + +\floatheight + +\d_strc_floats_top + +\d_strc_floats_overflow + -\pageshrink + \relax \scratchdimentwo\pagegoal \relax % needed \ifcase\c_page_one_float_method diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 1cac838de..3aeda1ce0 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index cc2cf3f29..dd252229f 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-flt.mkvi b/tex/context/base/mkiv/strc-flt.mkvi index 5572a3c6f..584cf915f 100644 --- a/tex/context/base/mkiv/strc-flt.mkvi +++ b/tex/context/base/mkiv/strc-flt.mkvi @@ -899,6 +899,7 @@ \newdimen\d_strc_floats_top \newdimen\d_strc_floats_bottom +\newdimen\d_strc_floats_overflow % \def\strc_floats_calculate_skip#target#skip% % {\begingroup @@ -947,6 +948,7 @@ \global\c_page_one_float_method \floatparameter\c!textmethod \global\c_page_floats_n_of_top \rootfloatparameter\c!ntop \global\c_page_floats_n_of_bottom\rootfloatparameter\c!nbottom + \global\d_strc_floats_overflow \zeropoint \ifconditional\c_strc_floats_par_float \global\d_strc_floats_top \zeropoint \global\d_strc_floats_bottom \zeropoint @@ -1642,7 +1644,6 @@ \fi\fi \strc_floats_align_content{\copy\b_strc_floats_content}}} - \def\strc_floats_prepare_page_caption {\edef\p_strc_floats_caption_width {\floatcaptionparameter\c!width}% \edef\p_strc_floats_caption_minwidth{\floatcaptionparameter\c!minwidth}% @@ -1819,7 +1820,7 @@ {\strc_floats_align_content{\box\b_strc_floats_content}} \def\strc_floats_build_box_next_right#1% - {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi % skip, no pack + {\ifconditional\c_strc_floats_par_float \hpack \else \expandafter \strc_floats_align_content \fi % skip, no pack {\d_strc_float_temp_height\ht\b_strc_floats_content \box\b_strc_floats_content \doifnotinset\v!hang\floatcaptionlocation @@ -1827,7 +1828,7 @@ \vbox to\d_strc_float_temp_height{#1}}} \def\strc_floats_build_box_next_left#1% - {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi % skip, no pack + {\ifconditional\c_strc_floats_par_float \hpack \else \expandafter \strc_floats_align_content \fi % skip, no pack {\d_strc_float_temp_height\ht\b_strc_floats_content \vbox to\d_strc_float_temp_height{#1}% \doifnotinset\v!hang\floatcaptionlocation @@ -1852,6 +1853,36 @@ \vbox to\d_strc_float_temp_height{#1}% \box\b_strc_floats_content}} +% \def\strc_floats_build_box_next_right_margin_indeed#1#2% +% {\ifconditional\c_strc_floats_par_float +% \hpack\bgroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \box\b_strc_floats_content +% \hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}% +% \egroup +% \else +% \begingroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \everyrightofalignedline{\hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}}% +% \strc_floats_align_content{\box\b_strc_floats_content}% +% \endgroup +% \fi} +% +% \def\strc_floats_build_box_next_left_margin_indeed#1#2% +% {\ifconditional\c_strc_floats_par_float +% \hpack\bgroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}% +% \box\b_strc_floats_content +% \egroup +% \else +% \begingroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}}% +% \strc_floats_align_content{\box\b_strc_floats_content}% +% \endgroup +% \fi} + \def\strc_floats_build_box_next_right_margin_indeed#1#2% {\ifconditional\c_strc_floats_par_float \hpack\bgroup @@ -1862,7 +1893,12 @@ \else \begingroup \d_strc_float_temp_height\ht\b_strc_floats_content - \everyrightofalignedline{\hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}}% + \setbox\scratchboxone\vbox{#2}% + \ifdim\htdp\scratchboxone>\htdp\b_strc_floats_content + \global\d_strc_floats_overflow\dimexpr\htdp\scratchboxone-\htdp\b_strc_floats_content\relax + \fi + \ht\scratchboxone\d_strc_float_temp_height + \everyrightofalignedline{\hsmash{\hskip#1\box\scratchboxone}}% \strc_floats_align_content{\box\b_strc_floats_content}% \endgroup \fi} @@ -1877,7 +1913,12 @@ \else \begingroup \d_strc_float_temp_height\ht\b_strc_floats_content - \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}}% + \setbox\scratchboxone\vbox{#2}% + \ifdim\htdp\scratchboxone>\htdp\b_strc_floats_content + \global\d_strc_floats_overflow\dimexpr\htdp\scratchboxone-\htdp\b_strc_floats_content\relax + \fi + \ht\scratchboxone\d_strc_float_temp_height + \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\scratchboxone\relax\box\scratchboxone}}% \strc_floats_align_content{\box\b_strc_floats_content}% \endgroup \fi} diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua index 6ac59d00c..2f51e5dc0 100644 --- a/tex/context/base/mkiv/typo-drp.lua +++ b/tex/context/base/mkiv/typo-drp.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['typo-drp'] = { license = "see context related readme files" } --- This ons is sensitive for order (e.g. when combined with first line +-- This one is sensitive for order (e.g. when combined with first line -- processing. -- todo: use isglyph @@ -28,6 +28,7 @@ local enableaction = tasks.enableaction local disableaction = tasks.disableaction local nuts = nodes.nuts +local tonut = nodes.tonut local getnext = nuts.getnext local getprev = nuts.getprev @@ -36,6 +37,9 @@ local getid = nuts.getid local getattr = nuts.getattr local getwhd = nuts.getwhd +local getprop = nuts.getprop +local setprop = nuts.setprop + local setattr = nuts.setattr local setlink = nuts.setlink local setprev = nuts.setprev @@ -46,6 +50,7 @@ local setwhd = nuts.setwhd local setkern = nuts.setkern local setoffsets = nuts.setoffsets local setglyphdata = nuts.setglyphdata +local setattr = nuts.setattr local hpack_nodes = nuts.hpack @@ -70,7 +75,6 @@ local v_last = variables.last local texget = tex.get local texset = tex.set -local texsetattribute = tex.setattribute local unsetvalue = attributes.unsetvalue local glyph_code = nodecodes.glyph @@ -89,16 +93,16 @@ local a_colormodel = attributes.private('colormodel') local category = characters.category -local settings = nil - -function initials.set(specification) - settings = specification or { } - settings.enabled = true +local function set(par,specification) enableaction("processors","typesetters.initials.handler") if trace_initials then report_initials("enabling initials") end - texsetattribute(a_initial,1) + setprop(par,a_initial,specification) +end + +function initials.set(specification) + nuts.setparproperty(set,specification) end interfaces.implement { @@ -123,256 +127,224 @@ interfaces.implement { } } --- dropped caps experiment (will be done properly when luatex --- stores the state in the local par node) .. btw, search still --- works with dropped caps, as does an export - --- we need a 'par' attribute and in fact for dropped caps we don't need --- need an attribute ... dropit will become s state counter (or end up --- in the localpar user data - --- for the moment, each paragraph gets a number as id (attribute) ..problem --- with nesting .. or anyhow, needed for tagging anyway - -- todo: prevent linebreak .. but normally a initial ends up at the top of -- a page so this has a low priority actions[v_default] = function(head,setting) - local id = getid(head) - if id == localpar_code then -- and getsubtype(head) == 0 - -- begin of par - local first = getnext(head) - local indent = false - -- parbox .. needs to be set at 0 - if first and getid(first) == hlist_code then - first = getnext(first) - indent = true - end - -- we need to skip over kerns and glues (signals) - while first and getid(first) ~= glyph_code do - first = getnext(first) - end - if first and getid(first) == glyph_code then - local ma = setting.ma or 0 - local ca = setting.ca - local ta = setting.ta - local last = first - local distance = setting.distance or 0 - local voffset = setting.voffset or 0 - local hoffset = setting.hoffset or 0 - local parindent = texget("parindent") - local baseline = texget("baselineskip",false) - local lines = tonumber(setting.n) or 0 - local dynamic = setting.dynamic - local font = setting.font - local method = settings_to_hash(setting.method) - local length = tonumber(setting.m) or 1 - -- - -- 1 char | n chars | skip first quote | ignore punct | keep punct - -- - if getattr(first,a_initial) then - for current in nextnode, getnext(first) do - if getattr(current,a_initial) then - last = current - else - break - end - end - elseif method[v_auto] then - local char = getchar(first) - local kind = category(char) - if kind == "po" or kind == "pi" then - if method[v_first] then - -- remove quote etc before initial - local next = getnext(first) - if not next then - -- don't start with a quote or so - return head - end - last = nil - for current in nextglyph, next do - head, first = remove_node(head,first,true) - first = current - last = first - break - end - if not last then - -- no following glyph or so - return head - end - else - -- keep quote etc with initial - local next = getnext(first) - if not next then - -- don't start with a quote or so - return head - end - for current in nextglyph, next do - last = current - break - end - if last == first then - return head - end - end - elseif kind == "pf" then - -- error: final quote + -- begin of par + local first = getnext(head) + local indent = false + -- parbox .. needs to be set at 0 + if first and getid(first) == hlist_code then + first = getnext(first) + indent = true + end + -- we need to skip over kerns and glues (signals) + while first and getid(first) ~= glyph_code do + first = getnext(first) + end + if first and getid(first) == glyph_code then + local ma = setting.ma or 0 + local ca = setting.ca + local ta = setting.ta + local last = first + local distance = setting.distance or 0 + local voffset = setting.voffset or 0 + local hoffset = setting.hoffset or 0 + local parindent = texget("parindent") + local baseline = texget("baselineskip",false) + local lines = tonumber(setting.n) or 0 + local dynamic = setting.dynamic + local font = setting.font + local method = settings_to_hash(setting.method) + local length = tonumber(setting.m) or 1 + -- + -- 1 char | n chars | skip first quote | ignore punct | keep punct + -- + if getattr(first,a_initial) then + for current in nextnode, getnext(first) do + if getattr(current,a_initial) then + last = current else - -- okay + break end - -- maybe also: get all A. B. etc - local next = getnext(first) - if next then - for current, char in nextglyph, next do - local kind = category(char) - if kind == "po" then - if method[v_last] then - -- remove period etc after initial - remove_node(head,current,true) - else - -- keep period etc with initial - last = current - end - end - break + end + elseif method[v_auto] then + local char = getchar(first) + local kind = category(char) + if kind == "po" or kind == "pi" then + if method[v_first] then + -- remove quote etc before initial + local next = getnext(first) + if not next then + -- don't start with a quote or so + return head end - end - else - for current in nextglyph, first do - last = current - if length <= 1 then + last = nil + for current in nextglyph, next do + head, first = remove_node(head,first,true) + first = current + last = first break - else - length = length - 1 end - end - end - local current = first - while true do - local id = getid(current) - if id == kern_code then - setkern(current,0) - elseif id == glyph_code then - local next = getnext(current) - if font then - setfont(current,font) + if not last then + -- no following glyph or so + return head end - if dynamic > 0 then - setglyphdata(current,dynamic) + else + -- keep quote etc with initial + local next = getnext(first) + if not next then + -- don't start with a quote or so + return head end --- apply font - --- local g = nuts.copy(current) --- g.subtype = 0 --- nodes.handlers.characters(g) --- nodes.handlers.protectglyphs(g) --- setchar(current,g.char) --- nuts.flush_node(g) - - -- can be a helper - if ca and ca > 0 then - setattr(current,a_colormodel,ma == 0 and 1 or ma) - setattr(current,a_color,ca) + for current in nextglyph, next do + last = current + break end - if ta and ta > 0 then - setattr(current,a_transparency,ta) + if last == first then + return head end - -- - end - if current == last then - break - else - current = getnext(current) end + elseif kind == "pf" then + -- error: final quote + else + -- okay end - -- We pack so that successive handling cannot touch the dropped cap. Packaging - -- in a hlist is also needed because we cannot locally adapt e.g. parindent (not - -- yet stored in with localpar). - local prev = getprev(first) - local next = getnext(last) - -- - setprev(first) - setnext(last) - local dropper = hpack_nodes(first) - local width, height, depth = getwhd(dropper) - setwhd(dropper,0,0,0) - -- - setlink(prev,dropper) - setlink(dropper,next) - -- + -- maybe also: get all A. B. etc + local next = getnext(first) if next then - local current = next - while current do - local id = getid(current) - if id == glue_code or id == kern_code then - local next = getnext(current) - -- remove_node(current,current,true) -- created an invalid next link and dangling remains - remove_node(head,current,true) - current = next - else - break + for current, char in nextglyph, next do + local kind = category(char) + if kind == "po" then + if method[v_last] then + -- remove period etc after initial + remove_node(head,current,true) + else + -- keep period etc with initial + last = current + end end + break end end - -- - local hoffset = width + hoffset + distance + (indent and parindent or 0) + else for current in nextglyph, first do - setoffsets(current,-hoffset,-voffset) -- no longer - height here - if current == last then + last = current + if length <= 1 then break + else + length = length - 1 end end - -- - first = dropper - -- - if setting.location == v_margin then - -- okay - else - if lines == 0 then -- safeguard, not too precise - lines = ceil((height+voffset) / baseline) + end + local current = first + while true do + local id = getid(current) + if id == kern_code then + setkern(current,0) + elseif id == glyph_code then + local next = getnext(current) + if font then + setfont(current,font) end - -- We cannot set parshape yet ... when we can I'll add a slope - -- option (positive and negative, in emwidth). - local hangafter = - lines - local hangindent = width + distance - if trace_initials then - report_initials("setting hangafter to %i and hangindent to %p",hangafter,hangindent) + if dynamic > 0 then + setglyphdata(current,dynamic) end - texset("hangafter",hangafter) - texset("hangindent",hangindent) + -- can be a helper + if ca and ca > 0 then + setattr(current,a_colormodel,ma == 0 and 1 or ma) + setattr(current,a_color,ca) + end + if ta and ta > 0 then + setattr(current,a_transparency,ta) + end + -- end - if indent then - insert_after(first,first,new_kern(-parindent)) + if current == last then + break + else + current = getnext(current) end end + -- We pack so that successive handling cannot touch the dropped cap. Packaging + -- in a hlist is also needed because we cannot locally adapt e.g. parindent (not + -- yet stored in with localpar). + local prev = getprev(first) + local next = getnext(last) + -- + setprev(first) + setnext(last) + local dropper = hpack_nodes(first) + local width, height, depth = getwhd(dropper) + setwhd(dropper,0,0,0) + -- + setlink(prev,dropper) + setlink(dropper,next) + -- + if next then + local current = next + while current do + local id = getid(current) + if id == glue_code or id == kern_code then + local next = getnext(current) + -- remove_node(current,current,true) -- created an invalid next link and dangling remains + remove_node(head,current,true) + current = next + else + break + end + end + end + -- + local hoffset = width + hoffset + distance + (indent and parindent or 0) + for current in nextglyph, first do + setoffsets(current,-hoffset,-voffset) -- no longer - height here + if current == last then + break + end + end + -- + first = dropper + -- + if setting.location == v_margin then + -- okay + else + if lines == 0 then -- safeguard, not too precise + lines = ceil((height+voffset) / baseline) + end + -- We cannot set parshape yet ... when we can I'll add a slope + -- option (positive and negative, in emwidth). + local hangafter = - lines + local hangindent = width + distance + if trace_initials then + report_initials("setting hangafter to %i and hangindent to %p",hangafter,hangindent) + end + texset("hangafter",hangafter) + texset("hangindent",hangindent) + end + if indent then + insert_after(first,first,new_kern(-parindent)) + end end return head end +-- we can count ... when all done, we can disable ... + function initials.handler(head) - local start = head - local attr = nil - while start do - attr = getattr(start,a_initial) - if attr then - break - elseif getid(start) == glyph then - break - else - start = getnext(start) - end - end - if attr then - -- here as we can process nested boxes first so we need to keep state - disableaction("processors","typesetters.initials.handler") - -- texsetattribute(attribute,unsetvalue) - local alternative = settings.alternative or v_default - local action = actions[alternative] or actions[v_default] - if action then - if trace_initials then - report_initials("processing initials, alternative %a",alternative) + if getid(head) == localpar_code then + local settings = getprop(head,a_initial) + if settings then + disableaction("processors","typesetters.initials.handler") + local alternative = settings.alternative or v_default + local action = actions[alternative] or actions[v_default] + if action then + if trace_initials then + report_initials("processing initials, alternative %a",alternative) + end + return action(head,settings) end - return action(head,settings) end end return head diff --git a/tex/context/base/mkiv/typo-drp.mkiv b/tex/context/base/mkiv/typo-drp.mkiv index 917b4255b..25b006b2f 100644 --- a/tex/context/base/mkiv/typo-drp.mkiv +++ b/tex/context/base/mkiv/typo-drp.mkiv @@ -88,25 +88,22 @@ \begingroup \edef\currentinitial{#1}% \setupcurrentinitial[#2]% - \scratchcounter \initialparameter\c!n\relax - \scratchdistance\initialparameter\c!distance\relax - \scratchhoffset \initialparameter\c!hoffset \relax - \edef\p_voffset{\initialparameter\c!voffset}% - \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax \resetfontfeature % might be needed in more places \doifelsenothing{\initialparameter\c!style} {\definedfont[\initialparameter\s!font]} {\useinitialstyleparameter\c!style}% \useinitialcolorparameter\c!color - \edef\p_text{\initialparameter\c!text}% optional + \edef\p_voffset{\initialparameter\c!voffset}% + \scratchcounter \initialparameter\c!n\relax + \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax \clf_setinitial location {\initialparameter\c!location}% enabled true\space n \scratchcounter m \numexpr\initialparameter\c!m\relax method {\initialparameter\c!method}% - distance \scratchdistance - hoffset \scratchhoffset + distance \dimexpr\initialparameter\c!distance\relax + hoffset \dimexpr\initialparameter\c!hoffset\relax voffset \scratchvoffset ma \attribute\colormodelattribute ca \attribute\colorattribute @@ -114,9 +111,8 @@ font \fontid\font dynamic \font_dynamic_value % it's a bit over the top to support this here \relax - \stopluacode - \kern\zeropoint % we need a node - \p_text + \attribute\initialattribute\plusone + \initialparameter\c!text \endgroup \glet\typo_initial_handle\relax} diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua index 7ed70296f..3124e80c7 100644 --- a/tex/context/base/mkiv/typo-fln.lua +++ b/tex/context/base/mkiv/typo-fln.lua @@ -48,12 +48,15 @@ local setdisc = nuts.setdisc local setlink = nuts.setlink local setfont = nuts.setfont local setglyphdata = nuts.setglyphdata +local getprop = nuts.getprop +local setprop = nuts.setprop local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local kern_code = nodecodes.kern local glue_code = nodecodes.glue +local localpar_code = nodecodes.localpar local spaceskip_code = nodes.gluecodes.spaceskip @@ -84,26 +87,21 @@ local a_colormodel = attributes.private('colormodel') local texget = tex.get -local texsetattribute = tex.setattribute -local unsetvalue = attributes.unsetvalue - local variables = interfaces.variables local v_default = variables.default local v_line = variables.line local v_word = variables.word ------ is_letter = characters.is_letter ------ categories = characters.categories - -local settings = nil - -function firstlines.set(specification) - settings = specification or { } +local function set(par,specification) enableaction("processors","typesetters.firstlines.handler") if trace_firstlines then report_firstlines("enabling firstlines") end - texsetattribute(a_firstline,1) + setprop(par,a_firstline,specification) +end + +function firstlines.set(specification) + nuts.setparproperty(set,specification) end implement { @@ -123,7 +121,6 @@ implement { } actions[v_line] = function(head,setting) - -- local attribute = fonts.specifiers.contextnumber(setting.feature) -- was experimental local dynamic = setting.dynamic local font = setting.font local noflines = setting.n or 1 @@ -372,29 +369,18 @@ end actions[v_default] = actions[v_line] function firstlines.handler(head) - local start = head - local attr = nil - while start do - attr = getattr(start,a_firstline) - if attr then - break - elseif getid(start) == glyph_code then - break - else - start = getnext(start) - end - end - if attr then - -- here as we can process nested boxes first so we need to keep state - disableaction("processors","typesetters.firstlines.handler") - -- texsetattribute(attribute,unsetvalue) - local alternative = settings.alternative or v_default - local action = actions[alternative] or actions[v_default] - if action then - if trace_firstlines then - report_firstlines("processing firstlines, alternative %a",alternative) + if getid(head) == localpar_code then + local settings = getprop(head,a_firstline) + if settings then + disableaction("processors","typesetters.firstlines.handler") + local alternative = settings.alternative or v_default + local action = actions[alternative] or actions[v_default] + if action then + if trace_firstlines then + report_firstlines("processing firstlines, alternative %a",alternative) + end + return action(head,settings) end - return action(head,settings) end end return head diff --git a/tex/context/base/mkiv/typo-fln.mkiv b/tex/context/base/mkiv/typo-fln.mkiv index bcf67af9b..6cca39f91 100644 --- a/tex/context/base/mkiv/typo-fln.mkiv +++ b/tex/context/base/mkiv/typo-fln.mkiv @@ -88,7 +88,7 @@ font \fontid\font dynamic \font_dynamic_value \relax - \kern\zeropoint % we need a node +% \kern\zeropoint % we need a node % \hskip\zeropoint\s!plus\emwidth\relax % can be an option \endgroup \glet\typo_firstline_handle\relax} diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 0060c1245..9c6b51114 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index bac5181ea..6176d9f3a 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 3120f4513..e64be4310 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 : 08/11/19 20:03:46 +-- merge date : 08/14/19 11:26:57 do -- begin closure to overcome local limits and interference -- cgit v1.2.3