From fc15d93f32bf84b94217ab306a452d3a39ee4063 Mon Sep 17 00:00:00 2001 From: Marius Date: Mon, 30 Sep 2013 21:00:37 +0300 Subject: beta 2013.09.30 19:49 --- tex/context/base/anch-pgr.mkiv | 2 + tex/context/base/attr-lay.lua | 2 +- tex/context/base/back-pdf.mkiv | 2 + tex/context/base/buff-imp-mp.lua | 2 + tex/context/base/buff-imp-tex.lua | 2 +- tex/context/base/buff-ini.mkiv | 6 + tex/context/base/buff-ver.mkiv | 3 + tex/context/base/char-def.lua | 6 +- tex/context/base/colo-ini.mkiv | 3 + tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4108 -> 4119 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/core-con.mkiv | 5 + tex/context/base/core-uti.lua | 21 +- tex/context/base/font-emp.mkvi | 2 + tex/context/base/font-ini.mkvi | 33 +- tex/context/base/font-mat.mkvi | 46 +- tex/context/base/font-sel.lua | 629 +++++++++++++++++++++ tex/context/base/font-sel.mkvi | 320 +++++++++++ tex/context/base/font-sty.mkvi | 5 + tex/context/base/l-lpeg.lua | 3 + tex/context/base/math-rad.mkvi | 4 +- tex/context/base/meta-fnt.lua | 1 + tex/context/base/mlib-pdf.lua | 10 +- tex/context/base/mult-mps.lua | 2 + tex/context/base/node-fnt.lua | 7 +- tex/context/base/page-mul.mkiv | 28 +- tex/context/base/s-present-tiles.mkiv | 2 +- tex/context/base/status-files.pdf | Bin 24761 -> 24835 bytes tex/context/base/status-lua.log | 2 +- tex/context/base/strc-doc.lua | 152 ++--- tex/context/base/strc-lst.mkvi | 2 + tex/context/base/strc-reg.lua | 77 ++- tex/context/base/strc-reg.mkiv | 22 +- tex/context/base/strc-sec.mkiv | 5 + tex/context/base/tabl-nte.mkiv | 8 +- tex/context/base/tabl-tbl.mkiv | 4 +- tex/context/base/tabl-xtb.mkvi | 1 + tex/context/base/task-ini.lua | 4 + tex/context/base/type-ini.mkvi | 2 + tex/context/base/typo-del.mkiv | 2 + tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 42 files changed, 1267 insertions(+), 166 deletions(-) create mode 100644 tex/context/base/font-sel.lua create mode 100644 tex/context/base/font-sel.mkvi (limited to 'tex') diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 8ed9913ae..c18a1b669 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -444,6 +444,8 @@ \def\currentposition{#1}\MPpositiongraphic{#2}{#3}% \fi} +\let\anch_positions_meta_graphic_handle_indeed\relax + \appendtoks \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert \to \everyinsertpositionaction diff --git a/tex/context/base/attr-lay.lua b/tex/context/base/attr-lay.lua index 4bcc70b0c..176af1a2c 100644 --- a/tex/context/base/attr-lay.lua +++ b/tex/context/base/attr-lay.lua @@ -133,8 +133,8 @@ attributes.viewerlayers.handler = nodes.installattributehandler { namespace = viewerlayers, initializer = initializer, finalizer = states.finalize, - -- processor = states.stacked, processor = states.stacker, + -- processor = states.stacked, } local stack, enabled, global = { }, false, false diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 4ea76e1b5..948a14138 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -262,6 +262,8 @@ {\back_object_stop \egroup} +\let\back_object_stop\relax + % attr {/Group << /S /Transparency /I false /K true >>} \def\back_object_register#1#2% diff --git a/tex/context/base/buff-imp-mp.lua b/tex/context/base/buff-imp-mp.lua index 34e3459c6..bcd18dd47 100644 --- a/tex/context/base/buff-imp-mp.lua +++ b/tex/context/base/buff-imp-mp.lua @@ -36,6 +36,8 @@ local MetapostSnippetConstructor = verbatim.MetapostSnippetConstructor local MetapostSnippetBoundary = verbatim.MetapostSnippetBoundary local MetapostSnippetSpecial = verbatim.MetapostSnippetSpecial local MetapostSnippetComment = verbatim.MetapostSnippetComment +local MetapostSnippetQuote = verbatim.MetapostSnippetQuote +local MetapostSnippetString = verbatim.MetapostSnippetString local MetapostSnippetNamePrimitive = verbatim.MetapostSnippetNamePrimitive local MetapostSnippetNamePlain = verbatim.MetapostSnippetNamePlain local MetapostSnippetNameMetafun = verbatim.MetapostSnippetNameMetafun diff --git a/tex/context/base/buff-imp-tex.lua b/tex/context/base/buff-imp-tex.lua index 9e61de016..097dff212 100644 --- a/tex/context/base/buff-imp-tex.lua +++ b/tex/context/base/buff-imp-tex.lua @@ -41,7 +41,7 @@ local handler = visualizers.newhandler { -- todo: unicode letters in control sequences (slow as we need to test the nature) local comment = S("%") -local name = P("\\") * (patterns.letter + S("@!?"))^1 +local name = P("\\") * (patterns.letter + S("@!?_"))^1 local escape = P("\\") * (patterns.anything - patterns.newline)^-1 -- else we get \n local group = S("${}") local boundary = S('[]()<>#="') diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 3b754b532..4ea3042b6 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -61,6 +61,9 @@ \def\buff_grab_direct_indeed_a[#1][#2][#3][#4]{\buff_start_indeed {#1}{#2}{#3}{#4}} \def\buff_grab_direct_indeed_b[#1][#2][#3][#4]{\buff_start_indeed\empty{#1}{#2}{#3}} +\let\buff_finish\relax +\let\buff_gobble\relax + \unexpanded\def\buff_pickup#1#2#3#4#5% name, startsequence, stopsequence, before, after {\begingroup % (1) #4% @@ -140,6 +143,9 @@ \unexpanded\def\buff_get_stored_indeed#1% {\ctxcommand{getbuffer("#1")}} +\unexpanded\def\getdefinedbuffer[#1]% + {\buff_get_stored{#1}{\thedefinedbuffer{#1}}}% + \unexpanded\def\inlinebuffer {\dosingleempty\buff_get_inline} diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 7ebadea41..8d5fc3220 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -689,6 +689,9 @@ \unexpanded\def\buff_verbatim_type_defined_buffer {\dotripleempty\buff_verbatim_type_defined_buffer_indeed} +\unexpanded\def\typedefinedbuffer[#1]% + {\buff_verbatim_type_defined_buffer[\v!buffer][\thedefinedbuffer{#1}]}% + \appendtoks \setuevalue{\e!type\currentbuffer}{\buff_verbatim_type_defined_buffer[\v!buffer][\currentdefinedbuffer]}% \to \everydefinebuffer diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua index 827c6a5ff..1261bd45a 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -64250,8 +64250,10 @@ characters.data={ description="DIAMETER SIGN", direction="on", linebreak="al", - mathclass="ordinary", - mathname="varnothing", + mathspec={ + { class="ord", name="varnothing" }, + { class="ord", name="diameter" }, + }, unicodeslot=0x2300, }, [0x2301]={ diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 3fae31cbe..6aa51b218 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -121,6 +121,9 @@ % \testfeatureonce{100000}{\color[red]{}} % 1.046 => 0.541 +\let\g_color\empty +\let\g_style\empty + \unexpanded\def\switchtocolor[#1]{\csname#1\endcsname} \unexpanded\def\color [#1]{\bgroup diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 5cfb7b5de..4541bcf0f 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.09.21 13:53} +\newcontextversion{2013.09.30 19:49} %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/context-version.pdf b/tex/context/base/context-version.pdf index dcef079b9..15bffc01e 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 9209790b5..2dba3c5e8 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.09.21 13:53} +\edef\contextversion{2013.09.30 19:49} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index 7febdcf39..375d77072 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -15,6 +15,8 @@ \registerctxluafile{core-con}{1.001} +% todo: iso date ranges (from/to) + \unprotect \ifdefined\currentlanguage \else \let\currentlanguage\empty \fi @@ -97,6 +99,9 @@ \def\koreannumeralsp #1{\ctxcommand{alphabetic(\number#1,"korean-parent")}} \def\koreannumeralsc #1{\ctxcommand{alphabetic(\number#1,"korean-circle")}} +\let\koreanparentnumerals\koreannumeralsp +\let\koreancirclenumerals\koreannumeralsc + \def\chinesenumerals #1{\ctxcommand{chinesenumerals (\number#1)}} \def\chinesecapnumerals#1{\ctxcommand{chinesecapnumerals(\number#1,"cap")}} \def\chineseallnumerals#1{\ctxcommand{chineseallnumerals(\number#1,"all")}} diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index a11fba309..cbbdeff23 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -279,11 +279,11 @@ statistics.register("randomizer", function() end end) --- local kg_per_watt_per_second = 1 / 15000000 --- local watts_per_core = 50 --- local speedup_by_other_engine = 1.2 --- local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine --- local used_wood_factor = (50 / 15000000) / 1.2 +local kg_per_watt_per_second = 1 / 15000000 +local watts_per_core = 50 +local speedup_by_other_engine = 1.2 +local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine +local used_wood_factor = (50 / 15000000) / 1.2 function statistics.formatruntime(runtime) if not environment.initex then -- else error when testing as not counters yet @@ -295,13 +295,14 @@ function statistics.formatruntime(runtime) if shipped > 0 or pages > 0 then local persecond = shipped / runtime if pages == 0 then pages = shipped end --- if jit then --- local saved = watts_per_core * runtime * kg_per_watt_per_second / speedup_by_other_engine --- local saved = used_wood_factor * runtime +if jit then +local saved = watts_per_core * runtime * kg_per_watt_per_second / speedup_by_other_engine +local saved = used_wood_factor * runtime -- return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second, %f kg tree saved by using luajittex",runtime,pages,shipped,persecond,saved) --- else + return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second, %f g tree saved by using luajittex",runtime,pages,shipped,persecond,saved*1000) +else return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second",runtime,pages,shipped,persecond) --- end +end else return format("%s seconds",runtime) end diff --git a/tex/context/base/font-emp.mkvi b/tex/context/base/font-emp.mkvi index 1713eda70..34a1ea9cc 100644 --- a/tex/context/base/font-emp.mkvi +++ b/tex/context/base/font-emp.mkvi @@ -117,6 +117,8 @@ %D The next feature was not present in previous versions. It %D takes care of \type {\em \bf ...} situations. +\let\font_emphasis_saved_emphasis_boldface\relax + \def\font_emphasis_set_emphasis_boldface {\let\font_emphasis_saved_emphasis_boldface\bf \let\font_emphasis_set_emphasis_boldface\relax diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi index a627310e0..521901e05 100644 --- a/tex/context/base/font-ini.mkvi +++ b/tex/context/base/font-ini.mkvi @@ -1679,7 +1679,7 @@ \unexpanded\def\font_helpers_set_font_set_font_option_body#method#body#message% {\normalizebodyfontsize\normalizedsetfont{#body}% redundant for some calls \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \else - \font_helpers_define_unknown_font{#body}% + \font_helpers_define_unknown_font\normalizedsetfont \fi \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \localbodyfontsize\normalizedsetfont @@ -2136,6 +2136,37 @@ %D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$ %D \stoptyping +%D \macros +%D {usebodyfont} +%D +%D This looks nicer then a switch in the preamble +%D +%D \starttyping +%D \usebodyfont[pagella,10pt] +%D \usebodyfont[termes,10pt] +%D \usebodyfont[dejavu,10pt] +%D +%D \setupbodyfont[dejavu] +%D +%D \starttext +%D test +%D \stoptext +%D \stoptyping + +% \unexpanded\def\usebodyfont[#1]% +% {\pushmacro\fontclass +% \switchtobodyfont[#1]% +% \popmacro\fontclass +% \ifx\fontclass\empty\else\setupbodyfont\relax\fi} + +\unexpanded\def\usebodyfont[#1]% + {\pushmacro\fontclass + \font_helpers_set_font\zerocount{#1}% + \popmacro\fontclass + \ifx\fontclass\empty \else + \font_basics_setupbodyfont_nop + \fi} + %D Handy for manuals: \unexpanded\def\fontchar#character% diff --git a/tex/context/base/font-mat.mkvi b/tex/context/base/font-mat.mkvi index 4fe44a2da..c8ee2630b 100644 --- a/tex/context/base/font-mat.mkvi +++ b/tex/context/base/font-mat.mkvi @@ -66,8 +66,8 @@ \definesystemattribute[mathfamily][public] -\newconditional\c_font_bidirectional_math_strategy % can be default, not that much overhead: \settrue\c_font_bidirectional_math_strategy -\newconditional\c_font_complete_bold_math_strategy \settrue\c_font_complete_bold_math_strategy +\newconditional\c_font_bidirectional_mathstrategy % can be default, not that much overhead: \settrue\c_font_bidirectional_mathstrategy +\newconditional\c_font_complete_bold_mathstrategy \settrue\c_font_complete_bold_mathstrategy \def\mathtextsuffix {-text} \def\mathscriptsuffix {-script} @@ -224,9 +224,9 @@ \edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}% % ... \ifx\m_font_class_direction\v!both - \settrue\c_font_bidirectional_math_strategy + \settrue\c_font_bidirectional_mathstrategy \else - \setfalse\c_font_bidirectional_math_strategy + \setfalse\c_font_bidirectional_mathstrategy \fi \to \t_font_math_strategies @@ -257,32 +257,32 @@ \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr} \appendtoks - \ifconditional\c_font_bidirectional_math_strategy + \ifconditional\c_font_bidirectional_mathstrategy \font_helpers_bidirectional_mathstrategy_yes \else \font_helpers_bidirectional_mathstrategy_nop \fi \to \t_font_math_strategies -\def\font_helpers_complete_bold_math_strategy_yes_bidi +\def\font_helpers_complete_bold_mathstrategy_yes_bidi {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl \ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mb_lr\else - \font_helpers_complete_bold_math_strategy_yes_bidi_changed + \font_helpers_complete_bold_mathstrategy_yes_bidi_changed \fi} -\def\font_helpers_complete_bold_math_strategy_yes_bidi_changed +\def\font_helpers_complete_bold_mathstrategy_yes_bidi_changed {\textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr} -\def\font_helpers_complete_bold_math_strategy_yes +\def\font_helpers_complete_bold_mathstrategy_yes {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr\relax \ifnum\fontid\textfont\c_font_fam_mb_rl=\fontid\textfont\c_font_fam_mb\else - \font_helpers_complete_bold_math_strategy_yes_changed + \font_helpers_complete_bold_mathstrategy_yes_changed \fi} -\def\font_helpers_complete_bold_math_strategy_yes_changed +\def\font_helpers_complete_bold_mathstrategy_yes_changed {\textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb @@ -290,12 +290,12 @@ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mb \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb} -\def\font_helpers_complete_bold_math_strategy_nop +\def\font_helpers_complete_bold_mathstrategy_nop {\ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mr\else - \font_helpers_complete_bold_math_strategy_nop_changed + \font_helpers_complete_bold_mathstrategy_nop_changed \fi} -\def\font_helpers_complete_bold_math_strategy_nop_changed +\def\font_helpers_complete_bold_mathstrategy_nop_changed {\textfont \c_font_fam_mb \textfont \c_font_fam_mr \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr @@ -306,19 +306,19 @@ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr} -\def\font_helpers_apply_complete_bold_math_strategy - {\ifconditional\c_font_complete_bold_math_strategy - \ifconditional\c_font_bidirectional_math_strategy - \font_helpers_complete_bold_math_strategy_yes_bidi +\def\font_helpers_apply_complete_bold_mathstrategy + {\ifconditional\c_font_complete_bold_mathstrategy + \ifconditional\c_font_bidirectional_mathstrategy + \font_helpers_complete_bold_mathstrategy_yes_bidi \else - \font_helpers_complete_bold_math_strategy_yes + \font_helpers_complete_bold_mathstrategy_yes \fi \else - \font_helpers_complete_bold_math_strategynop + \font_helpers_complete_bold_mathstrategy_nop \fi} \appendtoks - \font_helpers_apply_complete_bold_math_strategy + \font_helpers_apply_complete_bold_mathstrategy \to \t_font_math_strategies \ifdefined\defaultmathfamily \else @@ -330,7 +330,7 @@ \to \everymathematics \unexpanded\def\font_helpers_synchronize_math_family_mr - {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy + {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy \ifconditional\c_math_right_to_left \plustwo \else @@ -341,7 +341,7 @@ \fi} \unexpanded\def\font_helpers_synchronize_math_family_mb - {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy + {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy \ifconditional\c_math_right_to_left \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi \else diff --git a/tex/context/base/font-sel.lua b/tex/context/base/font-sel.lua new file mode 100644 index 000000000..7d535caa8 --- /dev/null +++ b/tex/context/base/font-sel.lua @@ -0,0 +1,629 @@ +if not modules then modules = { } end modules ['font-sel'] = { + version = 1.000, + comment = "companion to font-sel.mkvi", + author = "Wolfgang Schuster", + copyright = "Wolfgang Schuster", + license = "GNU General Public License" +} + +local context = context +local cleanname = fonts.names.cleanname +local gsub, splitup, find = string.gsub, string.splitup, string.find +local formatters = string.formatters + +local v_yes = interfaces.variables.yes +local v_simplefonts = interfaces.variables.simplefonts +local v_selectfont = interfaces.variables.selectfont +local v_default = interfaces.variables.default + +local selectfont = fonts.select or { } +fonts.select = selectfont + +local data = selectfont.data or { } +selectfont.data = data + +local fallbacks = selectfont.fallbacks or { } +selectfont.fallbacks = fallbacks + +local methods = selectfont.methods or { } +selectfont.methods = methods + +local getlookups = fonts.names.getlookups +local registerdesignsizes = fonts.goodies.designsizes.register + +local alternatives = { + ["tf"] = "regular", + ["it"] = "italic", + ["sl"] = "slanted", + ["bf"] = "bold", + ["bi"] = "bolditalic", + ["bs"] = "boldslanted", + ["sc"] = "smallcaps", +} + +local styles = { + ["rm"] = "serif", + ["ss"] = "sans", + ["tt"] = "mono", + ["hw"] = "handwriting", + ["cg"] = "calligraphy", + ["mm"] = "math", +} + +local sizes = { + ["default"] = { + { 40, "4pt" }, + { 50, "5pt" }, + { 60, "6pt" }, + { 70, "7pt" }, + { 80, "8pt" }, + { 90, "9pt" }, + { 100, "10pt" }, + { 110, "11pt" }, + { 120, "12pt" }, + { 144, "14.4pt" }, + { 173, "17.3pt" }, + }, + ["dtp"] = { + { 50, "5pt" }, + { 60, "6pt" }, + { 70, "7pt" }, + { 80, "8pt" }, + { 90, "9pt" }, + { 100, "10pt" }, + { 110, "11pt" }, + { 120, "12pt" }, + { 130, "13pt" }, + { 140, "14pt" }, + { 160, "16pt" }, + { 180, "18pt" }, + { 220, "22pt" }, + { 280, "28pt" }, + } +} + +local synonyms = { + ["rm"] = { + ["tf"] = "Serif", + ["it"] = "SerifItalic", + ["sl"] = "SerifSlanted", + ["bf"] = "SerifBold", + ["bi"] = "SerifBoldItalic", + ["bs"] = "SerifBoldSlanted", + ["sc"] = "SerifCaps", + }, + ["ss"] = { + ["tf"] = "Sans", + ["it"] = "SansItalic", + ["sl"] = "SansSlanted", + ["bf"] = "SansBold", + ["bi"] = "SansBoldItalic", + ["bs"] = "SansBoldSlanted", + ["sc"] = "SansCaps", + }, + ["tt"] = { + ["tf"] = "Mono", + ["it"] = "MonoItalic", + ["sl"] = "MonoSlanted", + ["bf"] = "MonoBold", + ["bi"] = "MonoBoldItalic", + ["bs"] = "MonoBoldSlanted", + ["sc"] = "MonoCaps", + }, + ["hw"] = { + ["tf"] = "Handwriting", + }, + ["cg"] = { + ["tf"] = "Calligraphy", + }, + ["mm"] = { + ["tf"] = "MathRoman", + ["bf"] = "MathBold", + } +} + +local replacement = { + ["style"] = { + ["it"] = "tf", + ["sl"] = "it", + ["bf"] = "tf", + ["bi"] = "bf", + ["bs"] = "bi", + ["sc"] = "tf", + }, + ["weight"] = { + ["it"] = "tf", + ["sl"] = "tf", + ["bf"] = "tf", + ["bi"] = "bf", + ["bs"] = "bf", + ["sc"] = "tf", + }, +} + +local names = { + ["selectfont"] = { -- weight, style, width, variant, italic + ["regular"] = { weight = "normal", style = "normal", width = "normal", variant = "normal", italic = false }, + ["italic"] = { weight = "normal", style = "italic", width = "normal", variant = "normal", italic = true }, + ["slanted"] = { weight = "normal", style = "slanted", width = "normal", variant = "normal", italic = true }, + ["medium"] = { weight = "medium", style = "normal", width = "normal", variant = "normal", italic = false }, + ["mediumitalic"] = { weight = "medium", style = "italic", width = "normal", variant = "normal", italic = true }, + ["mediumcaps"] = { weight = "medium", style = "normal", width = "normal", variant = "smallcaps", italic = true }, + ["bold"] = { weight = "bold", style = "normal", width = "normal", variant = "normal", italic = false }, + ["bolditalic"] = { weight = "bold", style = "italic", width = "normal", variant = "normal", italic = true }, + ["boldslanted"] = { weight = "bold", style = "slanted", width = "normal", variant = "normal", italic = true }, + ["smallcaps"] = { weight = "normal", style = "normal", width = "normal", variant = "smallcaps", italic = false }, + }, + ["simplefonts"] = { + ["light"] = { "lightregular", "light" }, + ["lightitalic"] = { "lightitalic", "lightit", "lightoblique" }, + ["lightcaps"] = { "smallcapslight" }, + ["regular"] = { "roman", "regular", "book", "" }, + ["italic"] = { "italic", "it", "oblique", "kursiv", "bookitalic", "bookit" }, + ["medium"] = { "mediumregular", "medregular", "medium" }, + ["mediumitalic"] = { "mediumitalic", "meditalic" }, + ["mediumcaps"] = { "mediumcaps" }, + ["bold"] = { "bold", "bd", "kraeftig", "mediumregular", "semibold", "demi" }, + ["bolditalic"] = { "bolditalic", "boldit", "bdit", "boldoblique", "mediumitalic", "semibolditalic", "demiitalic" }, + ["smallcaps"] = { "smallcaps", "capitals", "sc" }, + ["heavy"] = { "heavyregular", "heavy" }, + ["heavyitalic"] = { "heavyitalic" }, + }, + ["default"] = { -- weight, width, italic + ["thin"] = { weight = { 100, 200, 300, 400, 500 }, width = 5, italic = false }, + ["extralight"] = { weight = { 200, 100, 300, 400, 500 }, width = 5, italic = false }, + ["light"] = { weight = { 300, 200, 100, 400, 500 }, width = 5, italic = false }, + ["regular"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = false }, + ["italic"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = true }, + ["medium"] = { weight = { 500, 400, 300, 200, 100 }, width = 5, italic = false }, + ["demibold"] = { weight = { 600, 700, 800, 900 }, width = 5, italic = false }, + ["bold"] = { weight = { 700, 600, 800, 900 }, width = 5, italic = false }, + ["bolditalic"] = { weight = { 700, 600, 800, 900 }, width = 5, italic = true }, + ["smallcaps"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = false }, + ["heavy"] = { weight = { 800, 900, 700, 600 }, width = 5, italic = false }, + ["black"] = { weight = { 900, 800, 700, 600 }, width = 5, italic = false }, + } +} + +names.simplefonts.slanted = names.simplefonts.italic +names.simplefonts.boldslanted = names.simplefonts.bolditalic + +names.default.normal = names.default.regular +names.default.slanted = names.default.italic +names.default.semibold = names.default.demibold +names.default.boldslanted = names.default.bolditalic + +local mathsettings = { + ["asanamath"] = { + extras = "asana-math", + goodies = { + ["tf"] = "anana-math", + }, + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["cambriamath"] = { + extras = "cambria-math", + goodies = { + ["tf"] = "cambria-math", + }, + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["neoeuler"] = { + extras = "euler-math", + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["latinmodernmath"] = { + extras = "lm,lm-math", + goodies = { + ["tf"] = "lm", + }, + features = { + ["tf"] = "math\\mathsizesuffix,lm-math", + }, + }, + ["lucidabrightmathot"] = { + extras = "lucida-opentype-math", + goodies = { + ["tf"] = "lucida-opentype-math", + }, + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["texgyrepagellamath"] = { + extras = "texgyre", + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["texgyrebonummath"] = { + extras = "texgyre", + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["texgyretermesmath"] = { + extras = "texgyre", + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, + ["xitsmath"] = { + extras = "xits-math", + goodies = { + ["tf"] = "xits-math", + }, + features = { + ["tf"] = "math\\mathsizesuffix", + }, + }, +} + +function commands.defineselectfont(settings) + local index = #data + 1 + data[index] = settings + selectfont.searchfiles(index) + context(index) +end + +local function savefont(data,alternative,entries) + local f = data.fonts + if not f then + f = { } + data.fonts = f + end + f[alternative] = entries +end + +methods[v_simplefonts] = function(data,alternative,style) + local family = data.metadata.family + local names = names["simplefonts"][style] or names["simplefonts"]["regular"] + for _, name in next, names do + local filename = cleanname(formatters["%s%s"](family,name)) + local fullname = getlookups{ fullname = filename } + local fontname = getlookups{ fontname = filename } + local cleanfilename = getlookups{ cleanfilename = filename } + if #fullname > 0 then + savefont(data,alternative,fullname) + break + elseif #fontname > 0 then + savefont(data,alternative,fontname) + break + elseif #cleanfilename > 0 then + savefont(data,alternative,cleanfilename) + break + end + end +end + +methods[v_default] = function(data,alternative,style) + local family = data.metadata.family + local spec = names["default"][style] or names["default"]["regular"] + local weights = spec["weight"] + for _, weight in next, weights do + local pattern = getlookups{ + familyname = cleanname(family), + pfmweight = weight, + pfmwidth = spec["width"], + } + if #pattern > 0 then + local fontfiles = { } + for _, fontfile in next, pattern do + if (fontfile["angle"] and spec["italic"] == true) or (not fontfile["angle"] and spec["italic"] == false) then + fontfiles[#fontfiles + 1] = fontfile + end + end + savefont(data,alternative,fontfiles) + break + end + end +end + +methods[v_selectfont] = function(data,alternative,style) + local family = data.metadata.family + local spec = names["selectfont"][style] or names["selectfont"]["regular"] + local pattern = getlookups{ + familyname = cleanname(family), + weight = spec["weight"], + style = spec["style"], + width = spec["width"], + variant = spec["variant"] + } + if #pattern > 0 then + local fontfiles = { } + for _, fontfile in next, pattern do + if (fontfile["angle"] and spec["italic"] == true) or (not fontfile["angle"] and spec["italic"] == false) then + fontfiles[#fontfiles + 1] = fontfile + end + end + savefont(data,alternative,fontfiles) + end +end + +methods["name"] = function(data,alternative,filename) + local data = data + local family = data.metadata.family + local filename = cleanname(gsub(filename,"*",family)) + local fullname = getlookups{ fullname = filename } + local fontname = getlookups{ fontname = filename } + if #fullname > 0 then + savefont(data,alternative,fullname) + elseif #fontname > 0 then + savefont(data,alternative,fontname) + end +end + +methods["file"] = function(data,alternative,filename) + local data = data + local family = data.metadata.family + local filename = gsub(file.removesuffix(filename),"*",family) + local filename = getlookups{ cleanfilename = cleanname(filename) } + if #filename > 0 then + savefont(data,alternative,filename) + end +end + +methods["spec"] = function(data,alternative,filename) + local family = data.metadata.family + local weight, style, width, variant = splitup(filename,"-") + local pattern = getlookups{ + familyname = cleanname(family), + weight = weight or "normal", + style = style or "normal", + width = width or "normal", + variant = variant or "normal", + } + if #pattern > 0 then + savefont(data,alternative,pattern) + end +end + +methods["style"] = function(data,alternative,style) + local method = data.options.alternative or nil + (methods[method] or methods[v_default])(data,alternative,style) +end + +function selectfont.searchfiles(index) + local data = data[index] + for alternative, _ in next, alternatives do + local filename = data.files[alternative] + local method = data.options.alternative + local family = data.metadata.family + local style = alternatives[alternative] + if filename == "" then + local pattern = getlookups{ familyname = cleanname(family) } + if #pattern == 1 then -- needs to be improved + savefont(data,"tf",pattern) + break + else + (methods[method] or methods[v_default])(data,alternative,style) + end + else + method, filename = splitup(filename,":") + if not filename then + filename = method + method = "name" + end + (methods[method] or methods["name"])(data,alternative,filename) + end + end +end + +local function definefontsynonym(data,alternative,index,fallback) + local fontdata = data.fonts and data.fonts[alternative] + local style = data.metadata.style + local typeface = data.metadata.typeface + local mathsettings = mathsettings[cleanname(data.metadata.family)] + local features = mathsettings and mathsettings["features"] and (mathsettings["features"][alternative] or mathsettings["features"]["tf"]) or data.features[alternative] + local goodies = mathsettings and mathsettings["goodies"] and (mathsettings["goodies"] [alternative] or mathsettings["goodies"] ["tf"]) or "" + local parent = replacement["style"][alternative] or "" + local fontname, fontfile, fontparent + if fallback then + fontname = formatters["%s-%s-%s-fallback-%s"](typeface, style, alternative, index) + fontfile = formatters["%s-%s-%s-%s"] (typeface, style, alternative, index) + fontparent = formatters["%s-%s-%s-%s"] (typeface, style, parent, index) + else + fontname = synonyms[style][alternative] + fontfile = formatters["%s-%s-%s"](typeface, style, alternative) + fontparent = formatters["%s-%s-%s"](typeface, style, parent) + end + if fontdata then + for _, size in next, sizes["default"] do + for _, entry in next, fontdata do + if entry["minsize"] and entry["maxsize"] then + if size[1] > entry["minsize"] and size[1] <= entry["maxsize"] then + registerdesignsizes( fontfile, size[2], entry["filename"] ) + end + end + end + end + for _, entry in next, fontdata do + local filename = entry["filename"] + local designsize = entry["designsize"] or 100 + if designsize == 100 or designsize == 120 or designsize == 0 then + registerdesignsizes( fontfile, "default", filename ) + break + end + end + if fallback then + context.definefontsynonym( { fontname }, { fontfile }, { features = features } ) + else + context.definefontsynonym( { fontname }, { fontfile }, { features = features, fallbacks = fontfile, goodies = goodies } ) + end + else + if fallback then + context.definefontsynonym( { fontname }, { fontparent }, { features = features } ) + else + context.definefontsynonym( { fontname }, { fontparent }, { features = features, fallbacks = fontfile, goodies = goodies } ) + end + end +end + +local function definetypescript(index) + local data = data[index] + local entry = data.fonts + local mathsettings = mathsettings[cleanname(data.metadata.family)] + local goodies = mathsettings and mathsettings.extras or data.options.goodies + local typeface = data.metadata.typeface + local style = data.metadata.style + if entry and entry["tf"] then + context.startfontclass( { typeface } ) + if goodies ~= "" then + goodies = utilities.parsers.settings_to_array(goodies) + for _, goodie in next, goodies do + context.loadfontgoodies( { goodie } ) + end + end + for alternative, _ in next, alternatives do + if synonyms[style][alternative] then -- prevent unnecessary synonyms for handwriting, calligraphy and math + definefontsynonym(data,alternative) + end + end + context.stopfontclass() + else + -- regular style not available, loading aborted + end +end + +function selectfont.registerfallback(typeface,style,index) + local t = fallbacks[typeface] + if not t then + fallbacks[typeface] = { [style] = { index } } + else + local s = t[style] + if not s then + fallbacks[typeface][style] = { index } + else + fallbacks[typeface][style][#s+1] = index + end + end +end + +local function definetextfontfallback(data,alternative,index) + local typeface = data.metadata.typeface + local style = data.metadata.style + local features = data.features[alternative] + local range = data.options.range + local rscale = data.options.scale ~= "" and data.options.scale or 1 + local check = data.options.check ~= "" and data.options.check or "yes" + local force = data.options.force ~= "" and data.options.force or "yes" + local synonym = formatters["%s-%s-%s-fallback-%s"](typeface, style, alternative, index) + local fallback = formatters["%s-%s-%s"] (typeface, style, alternative) + if index == 1 then + context.resetfontfallback( { fallback } ) + end + context.definefontfallback( { fallback }, { synonym }, { range }, { rscale = rscale, check = check, force = force } ) +end + +local function definetextfallback(entry,index) + local data = data[index] + local typeface = data.metadata.typeface + context.startfontclass( { typeface } ) + for alternative, _ in next, alternatives do + definefontsynonym (data,alternative,entry,true) + definetextfontfallback(data,alternative,entry) + end + context.stopfontclass() +end + +local function definemathfontfallback(data,alternative,index) + local typeface = data.metadata.typeface + local style = data.metadata.style + local range = data.options.range + local rscale = data.options.scale ~= "" and data.options.scale or 1 + local check = data.options.check ~= "" and data.options.check or "yes" + local force = data.options.force ~= "" and data.options.force or "yes" + local offset = data.options.offset + local features = data.features[alternative] + local fontdata = data.fonts and data.fonts[alternative] + local fallback = formatters["%s-%s-%s"](typeface, style, alternative) + if index == 1 then + context.resetfontfallback( { fallback } ) + end + for _, entry in next, fontdata do + local filename = entry["filename"] + local designsize = entry["designsize"] or 100 + if designsize == 100 or designsize == 120 or designsize == 0 then + context.definefontfallback( { fallback }, { formatters["%s*%s"](filename,features) }, { range }, { rscale = rscale, check = check, force = force, offset = offset } ) + break + end + end +end + +local function definemathfallback(entry,index) + local data = data[index] + local typeface = data.metadata.typeface + local style = data.metadata.style + context.startfontclass( { typeface } ) + for alternative, _ in next, alternatives do + if synonyms[style][alternative] then + definemathfontfallback(data,alternative,entry) + end + end + context.stopfontclass() +end + +local function definefallbackfont(index) + local data = data[index] + local f = fallbacks[data.metadata.typeface] + if f then + local s = f[data.metadata.style] + if s then + for entry, fallback in next, s do + if data.metadata.style == "mm" then + definemathfallback(entry,fallback) + else + definetextfallback(entry,fallback) + end + end + end + end +end + +local function definetextfont(index) + local data = data[index] + local fontclass = data.metadata.typeface + local shortstyle = data.metadata.style + local style = styles[data.metadata.style] + local designsize = data.options.opticals == v_yes and "auto" or "default" + local scale = data.options.scale ~= "" and data.options.scale or 1 + context.definetypeface( { fontclass }, { shortstyle }, { style }, { "" }, { "default" }, { designsize = designsize, rscale = scale } ) +end + +local function definemathfont(index) + local data = data[index] + local fontclass = data.metadata.typeface + local shortstyle = data.metadata.style + local style = styles[data.metadata.style] + local scale = data.options.scale ~= "" and data.options.scale or 1 + local typescript = cleanname(data.metadata.family) + local entries = data.fonts + if entries then + context.definetypeface( { fontclass }, { shortstyle }, { style }, { "" }, { "default" }, { rscale = scale } ) + else + context.definetypeface( { fontclass }, { shortstyle }, { style }, { typescript }, { "default" }, { rscale = scale } ) + end +end + +function selectfont.definetypeface(index) + local data = data[index] + if data.metadata.style == "mm" then + definefallbackfont(index) + definetypescript (index) + definemathfont (index) + else + definefallbackfont(index) + definetypescript (index) + definetextfont (index) + end + -- inspect(data) +end + +commands.definefontfamily = selectfont.definetypeface +commands.definefallbackfamily = selectfont.registerfallback diff --git a/tex/context/base/font-sel.mkvi b/tex/context/base/font-sel.mkvi new file mode 100644 index 000000000..f91baa5d8 --- /dev/null +++ b/tex/context/base/font-sel.mkvi @@ -0,0 +1,320 @@ +%D \module +%D [ file=font-sel, +%D version=2013.09.28, +%D title=\CONTEXT\ User Module, +%D subtitle=Selectfont, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright=Wolfgang Schuster, +%D license=GNU General Public License] + +\writestatus{loading}{ConTeXt User Module / Selectfont} + +\registerctxluafile{font-sel}{1.000} + +\unprotect + +\installcorenamespace {selectfont} +\installsimplecommandhandler \??selectfont {selectfont} + +\unexpanded\def\selectfont_setparameters[#settings]% + {\begingroup + \setupcurrentselectfont[#settings]% + \edef\p_selectfont_preset{\selectfontparameter\c!preset}% + \ifx\p_selectfont_preset\empty \else + \processcommacommand[\p_selectfont_preset]\selectfont_preset_process + \setupcurrentselectfont[#settings]% + \fi + \setexpandedselectfontparameter\c!style {\expandnamespaceparameter\??selectfontstyle \selectfontparameter\c!style \s!rm }% + \setexpandedselectfontparameter\c!alternative{\expandnamespaceparameter\??selectfontalternative\selectfontparameter\c!alternative\v!default}% + \xdef\selectfont_index{\ctxcommand{ + defineselectfont { + metadata = { + typeface = "\selectfontparameter\c!name", + style = "\selectfontparameter\c!style", + family = "\selectfontparameter\c!family", + }, + options = { + opticals = "\selectfontparameter\c!opticalsize", + scale = "\selectfontparameter\c!scale", + goodies = "\selectfontparameter\c!goodies", + alternative = "\selectfontparameter\c!alternative", + range = "\selectfontparameter\c!range", % fallback only + offset = "\selectfontparameter\c!offset", % fallback only + check = "\selectfontparameter\c!check", % fallback only + force = "\selectfontparameter\c!force", % fallback only + }, + files = { + ["tf"] = "\selectfontparameter\c!regularfont", + ["bf"] = "\selectfontparameter\c!boldfont", + ["it"] = "\selectfontparameter\c!italicfont", + ["sl"] = "\selectfontparameter\c!slantedfont", + ["bi"] = "\selectfontparameter\c!bolditalicfont", + ["bs"] = "\selectfontparameter\c!boldslantedfont", + ["sc"] = "\selectfontparameter\c!smallcapsfont", + }, + features = { + ["tf"] = "\selectfontparameter\c!regularfeatures", + ["bf"] = "\selectfontparameter\c!boldfeatures", + ["it"] = "\selectfontparameter\c!italicfeatures", + ["sl"] = "\selectfontparameter\c!slantedfeatures", + ["bi"] = "\selectfontparameter\c!bolditalicfeatures", + ["bs"] = "\selectfontparameter\c!boldslantedfeatures", + ["sc"] = "\selectfontparameter\c!smallcapsfeatures", + } + }}}% + \endgroup} + +%D \macros +%D {defineselectfontstyle} + +\installcorenamespace {selectfontstyle} + +\unexpanded\def\defineselectfontstyle + {\dodoubleargument\selectfont_style_define} + +\def\selectfont_style_define[#styles][#shortstyle]% + {\processcommalist[#styles]{\selectfont_style_define_indeed{#shortstyle}}} + +\def\selectfont_style_define_indeed#shortstyle#style% + {\setvalue{\??selectfontstyle#style}{#shortstyle}} + +\defineselectfontstyle [\s!rm,\s!serif] [\s!rm] +\defineselectfontstyle [\s!ss,\s!sans] [\s!ss] +\defineselectfontstyle [\s!tt,\s!mono] [\s!tt] +\defineselectfontstyle [\s!hw,\s!handwriting] [\s!hw] +\defineselectfontstyle [\s!cg,\s!calligraphy] [\s!cg] +\defineselectfontstyle [\s!mm,\s!math] [\s!mm] + +%D \macros +%D {definefontfamilypreset} + +\installcorenamespace {selectfontpreset} + +\unexpanded\def\defineselectfontpreset + {\dodoubleargument\selectfont_preset_define} + +\def\selectfont_preset_define[#name][#settings]% + {\doifassignmentelse{#settings} + {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}} + {\setvalue{\??selectfontpreset#name}{\csname\??selectfontpreset#settings\endcsname}}} + +\def\selectfont_preset_process#name% + {\ifcsname\??selectfontpreset#name\endcsname + \csname\??selectfontpreset#name\endcsname + \else + % unknown preset + \fi} + +\let\definefontfamilypreset\defineselectfontpreset + +\definefontfamilypreset [\s!chinese ] [\c!range={0x00400-0x2FA1F}] +\definefontfamilypreset [\s!japanese] [\c!range={0x00400-0x2FA1F}] +\definefontfamilypreset [\s!korean ] [\c!range={0x00400-0x2FA1F}] + +%D \macros +%D {defineselectfontalternative} +%D +%D The results between the old {\em simplefonts} and the new {\em selectfont} +%D can be different because simplefonts the name entries in the database to find +%D the styles for a font while selectfont the newer spec-method to the find the +%D files for each style. +%D +%D The used method depends on the command one uses to load a font but it is +%D also possible to switch between them with the {\em alternative} key, possible +%D values are: +%D +%D \startitemize[packed] +%D \startitem selectfont and \stopitem +%D \startitem simplefonts. \stopitem +%D \stopitemize + +\installcorenamespace {selectfontalternative} + +\unexpanded\def\defineselectfontalternative + {\dodoubleargument\selectfont_alternative_define} + +\def\selectfont_alternative_define[#name][#alternative]% + {\setvalue{\??selectfontalternative#name}{#alternative}} + +\defineselectfontalternative [\v!selectfont ] [\v!selectfont ] +\defineselectfontalternative [\v!simplefonts] [\v!simplefonts] +\defineselectfontalternative [\v!default ] [\v!default ] + +%D \macros +%D {definefontfamily,definefallbackfamily} +%D +%D The \tex{definefontfamily} creates like \tex{definetypeface} a collection of font +%D with different styles which can be later called with the \tex{setupbodyfont} command. +%D +%D The command takes three mendatory commands which are (a) the name of the fontclass, +%D (b) the styles of the font and (c) the name of the font. +%D +%D \starttyping +%D \definefontfamily [dejavu] [serif] [DejaVu Serif] +%D \definefontfamily [dejavu] [sans] [DejaVu Sans] +%D \definefontfamily [dejavu] [mono] [DejaVu Sans Mono] +%D \definefontfamily [dejavu] [math] [XITS Math] [scale=1.1] +%D +%D \definefontfamily [office] [serif] [Times New Roman] +%D \definefontfamily [office] [sans] [Arial] [scale=0.9] +%D \definefontfamily [office] [mono] [Courier] +%D \definefontfamily [office] [math] [TeX Gyre Termes Math] +%D +%D \definefontfamily [linux] [serif] [Linux Libertine O] +%D \definefontfamily [linux] [sans] [Linux Biolinum O] +%D \definefontfamily [linux] [mono] [Latin Modern Mono] +%D \definefontfamily [linux] [math] [TeX Gyre Pagella Math] [scale=0.9] +%D +%D \setupbodyfont[dejavu] +%D +%D \starttext +%D +%D \rm Serif \ss Sans \tt Mono \m{1+2=3} +%D +%D \switchtobodyfont[office] +%D +%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3} +%D +%D \switchtobodyfont[linux] +%D +%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3} +%D +%D \stoptext +%D \stoptyping +%D +%D When a document contains different languages and the global font lacks some characters +%D for one language, one could set a different font where these charcters are taken from. +%D This fallback font (there can be more than one for a certain style) could be set with +%D the \tex{definefallbackfamily} command which takes the same argument as +%D the \tex{definefontfamily} command. +%D +%D \starttyping +%D \definefallbackfamily [mainface] [serif] [DejaVu Serif] [range=cyrillic,force=yes] +%D \definefontfamily [mainface] [serif] [TeX Gyre Pagella] +%D +%D \setupbodyfont[mainface] +%D +%D \setuplanguage[en][patterns={us,ru}] +%D +%D \starttext +%D +%D \input knuth +%D +%D Традиционная систематика лишайников оказывается во многом условна и +%D +%D \stoptext +%D \stoptyping +%D +%D Another feature of the module is the \type{opticalsize} key which allows one to enable +%D optical sizes when they are a feature of the requested font. +%D +%D \starttyping +%D \definefontfamily[mainface][serif][Latin Modern Roman][opticalsize=yes] +%D +%D \setupbodyfont[mainface] +%D +%D \starttext +%D \scale[width=\textwidth]{\switchtobodyfont [6pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [8pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [10pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [12pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont[17.3pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \stoptext +%D \stoptyping + +% regularfont = … | * … | name:… | name:* … | file:… | file:* … | spec:…-…-… | style:medium + +\unexpanded\def\definefontfamily + {\doquadrupleempty\selectfont_family_define} + +\def\selectfont_family_define[#typeface][#style][#family][#settings]% + {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]% + \ctxcommand{definefontfamily(\selectfont_index)}} + +\unexpanded\def\definefallbackfamily + {\doquadrupleempty\selectfont_fallback_define} + +\def\selectfont_fallback_define[#typeface][#style][#family][#settings]% + {\doifassignmentelse{#settings} + {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]} + {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}% + \edef\p_selectfont_style{\expandnamespacevalue\??selectfontstyle{#style}\s!rm}% + \ctxcommand{definefallbackfamily("#typeface","\p_selectfont_style",\selectfont_index)}} + +%D \macros +%D {setupfontfamily,setupfallbackfamily} +%D +%D For simple documents which don’t need complex font settings one could use +%D the \tex{setupfontfamily} command where the requested font is enabled immediately +%D without the need to load it with \tex{setupbodyfont}. The downside of this method +%D is that processing of the document takes longer with each additional font which +%D is set with \tex{setupfontfamily}. +%D +%D \starttyping +%D \setupfontfamily [serif] [DejaVu Serif] +%D \setupfontfamily [sans] [DejaVu Sans] +%D \setupfontfamily [mono] [DejaVu Sans Mono] +%D \setupfontfamily [math] [XITS Math] [scale=1.1] +%D +%D \starttext +%D +%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3} +%D +%D \stoptext +%D \stoptyping + +\newcount\c_selectfont_family +\newtoks \t_selectfont_fallback +\newtoks \t_selectfont_styles + +\unexpanded\def\setupfontfamily + {\dotripleempty\selectfont_family_setup} + +\def\selectfont_family_setup[#style][#family][#settings]% + {\normalexpanded{\t_selectfont_styles{\selectfont_set_font_family[#style][#family][#settings]\the\t_selectfont_styles}}% + \selectfont_set_font_indeed} + +\unexpanded\def\selectfont_set_default + {\selectfont_set_font_family[\v!serif][Latin Modern Roman][\c!opticalsize=\v!yes]% + \selectfont_set_font_family[\v!sans] [Latin Modern Sans] [\c!opticalsize=\v!yes]% + \selectfont_set_font_family[\v!mono] [Latin Modern Mono] [\c!opticalsize=\v!yes,\c!features=\s!none]} + +\unexpanded\def\setupfallbackfamily + {\dotripleempty\selectfont_fallback_setup} + +\def\selectfont_fallback_setup[#style][#family][#settings]% + {\normalexpanded{\t_selectfont_fallback{\the\t_selectfont_fallback\selectfont_set_font_fallback[#style][#family][#settings]}}} + +\def\selectfont_set_font_indeed + {\global\advance\c_selectfont_family\plusone + \edef\m_selectfont_typeface{\v!selectfont-\number\c_selectfont_family}% + \the\t_selectfont_fallback + \the\t_selectfont_styles + \selectfont_set_default + \setupbodyfont[\m_selectfont_typeface,\rootselectfontparameter\c!style]} + +\unexpanded\def\selectfont_set_font_family[#style]#dummy[#family]#dummy[#settings]% + {\ifcsname\m_selectfont_typeface#style\endcsname \else + \expandafter\let\csname\m_selectfont_typeface#style\endcsname\relax + \selectfont_family_define[\m_selectfont_typeface][#style][#family][#settings]% + \fi} + +\unexpanded\def\selectfont_set_font_fallback[#style]#dummy[#family]#dummy[#settings]% + {\selectfont_fallback_define[\m_selectfont_typeface][#style][#family][#settings]} + +%D You can apply a different feature set to each style of a font but if nothing +%D is set the global features are used. + +\setupselectfont + [ \c!features=\s!default, + \c!regularfeatures=\selectfontparameter\c!features, + \c!boldfeatures=\selectfontparameter\c!features, + \c!italicfeatures=\selectfontparameter\c!features, + \c!slantedfeatures=\selectfontparameter\c!features, + \c!bolditalicfeatures=\selectfontparameter\c!features, + \c!boldslantedfeatures=\selectfontparameter\c!features, + \c!smallcapsfeatures=\s!smallcaps, + \c!style=\s!rm] + +\protect \ No newline at end of file diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi index d9781f407..03fa598c2 100644 --- a/tex/context/base/font-sty.mkvi +++ b/tex/context/base/font-sty.mkvi @@ -172,6 +172,8 @@ %D The new one: +\setfalse\fontattributeisset + \unexpanded\def\dousestyleparameter#value% {\edef\currentstyleparameter{#value}% \ifx\currentstyleparameter\empty\else @@ -342,6 +344,9 @@ \font_styles_define_style_collection_a\s!default \fi} +\let\font_styles_define_style_collection_a\relax +\let\font_styles_define_style_collection_b\relax + \unexpanded\def\definestyleinstance {\doquadrupleargument\font_styles_define_style_instance} diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 58c552419..399b3ad65 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -466,6 +466,9 @@ function lpeg.replacer(one,two,makefunction,isutf) -- in principle we should sor end end +-- local pattern1 = P(1-P(pattern))^0 * P(pattern) : test for not nil +-- local pattern2 = (P(pattern) * Cc(true) + P(1))^0 : test for true (could be faster, but not much) + function lpeg.finder(lst,makefunction) -- beware: slower than find with 'patternless finds' local pattern if type(lst) == "table" then diff --git a/tex/context/base/math-rad.mkvi b/tex/context/base/math-rad.mkvi index b3a6a24c9..541a7038e 100644 --- a/tex/context/base/math-rad.mkvi +++ b/tex/context/base/math-rad.mkvi @@ -77,10 +77,10 @@ \setvalue{\??mathradicalalternative\v!normal}#body% {\edef\p_color{\mathradicalparameter\c!color}% \ifx\p_color\empty - \rootradical\currentmathradicaldegree{#body}% + \rootradical{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first \else\ifx\currentmathradicaldegree\empty \pushcolor[\p_color]% - \rootradical\currentmathradicaldegree + \rootradical{\currentmathradicaldegree}% {\popcolor#body}% \else \pushcolor[\p_color]% diff --git a/tex/context/base/meta-fnt.lua b/tex/context/base/meta-fnt.lua index 75d8f2699..3d8263d3a 100644 --- a/tex/context/base/meta-fnt.lua +++ b/tex/context/base/meta-fnt.lua @@ -127,6 +127,7 @@ local function process(mpxformat,name,instances,scalefactor) } } end +-- inspect(lists) lists.version = metapost.variables.fontversion or "1.000" metapost.reset(mpxformat) -- saves memory lists = containers.write(mpfonts.cache, hash, lists) diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index 4fa97a7c7..6cb094e3e 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -277,11 +277,11 @@ local key = C((1-equal)^1) * equal local newline = S("\n\r")^1 local number = (((1-space-newline)^1) / tonumber) * (space^0) local variable = - lpeg.P("1:") * key * number - + lpeg.P("2:") * key * C((1-newline)^0) - + lpeg.P("3:") * key * (P("false") * Cc(false) + P("true") * Cc(true)) - + lpeg.S("456") * P(":") * key * Ct(number^1) - + lpeg.P("7:") * key * Ct(Ct(number * number^-5)^1) + lpeg.P("1:") * key * number + + lpeg.P("2:") * key * C((1-newline)^0) + + lpeg.P("3:") * key * (P("false") * Cc(false) + P("true") * Cc(true)) + + lpeg.S("4568") * P(":") * key * Ct(number^1) + + lpeg.P("7:") * key * Ct(Ct(number * number^-5)^1) local pattern = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset) diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua index c1e05f265..5a320487a 100644 --- a/tex/context/base/mult-mps.lua +++ b/tex/context/base/mult-mps.lua @@ -105,6 +105,8 @@ return { "graypart", "graycolor", -- "mm", "pt", "dd", "bp", "cm", "pc", "cc", "in", + -- + "triplet", "quadruplet", }, internals = { -- we need to remove duplicates above -- diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua index 6d5ed6ca0..f74f27e7c 100644 --- a/tex/context/base/node-fnt.lua +++ b/tex/context/base/node-fnt.lua @@ -126,8 +126,11 @@ function handlers.characters(head) attrfonts[font] = used end if not used[attr] then - used[attr] = setfontdynamics[font][attr] - a = a + 1 + local fd = setfontdynamics[font] + if fd then + used[attr] = fd[attr] + a = a + 1 + end end else local used = usedfonts[font] diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv index 9e0861af9..24286106a 100644 --- a/tex/context/base/page-mul.mkiv +++ b/tex/context/base/page-mul.mkiv @@ -1158,26 +1158,28 @@ \def\setlocalcolumnfloats {\settrue\onlylocalcolumnfloats \everypar\everylocalcolumnfloatspar - \let\page_mul_flush_float\doflushcolumnfloat + \let\page_mul_flush_float \doflushcolumnfloat \let\page_mul_flush_floats\doflushcolumnfloats} \def\setglobalcolumnfloats {\setfalse\onlylocalcolumnfloats \reseteverypar - \let\page_mul_flush_float\relax + \let\page_mul_flush_float \relax \let\page_mul_flush_floats\noflushcolumnfloats} - \def\noflushcolumnfloats - {\bgroup - \xdef\localsavednoffloats{\the\savednoffloats}% - \global\savednoffloats\globalsavednoffloats - \page_otr_command_flush_top_insertions - \xdef\globalsavenoffloats{\the\savednoffloats}% - \ifnum\globalsavednoffloats=\zerocount - \setlocalcolumnfloats - \fi - \global\savednoffloats\localsavednoffloats - \egroup} + % \def\noflushcolumnfloats + % {\bgroup + % \xdef\localsavednoffloats{\the\savednoffloats}% + % \global\savednoffloats\globalsavednoffloats + % \page_otr_command_flush_top_insertions + % \xdef\globalsavenoffloats{\the\savednoffloats}% + % \ifnum\globalsavednoffloats=\zerocount + % \setlocalcolumnfloats + % \fi + % \global\savednoffloats\localsavednoffloats + % \egroup} + % + \def\noflushcolumnfloats{\doflushcolumnfloats} % not yet redone %D We need to calculate the amount of free space in a columns. When there is not %D enough room, we migrate the float to the next column. These macro's are diff --git a/tex/context/base/s-present-tiles.mkiv b/tex/context/base/s-present-tiles.mkiv index 80ea5249f..1a0c95f0d 100644 --- a/tex/context/base/s-present-tiles.mkiv +++ b/tex/context/base/s-present-tiles.mkiv @@ -13,7 +13,7 @@ %D The Bacho\TeX\ 2013 style. -\setupbodyfont[palatino,14.4pt] +\setupbodyfont[pagella,14.4pt] \setuppapersize[S6][S6] diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 7324eec33..a44ff4b48 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.log b/tex/context/base/status-lua.log index 125142be3..75b246b6f 100644 --- a/tex/context/base/status-lua.log +++ b/tex/context/base/status-lua.log @@ -1,6 +1,6 @@ (cont-yes.mkiv -ConTeXt ver: 2013.09.21 13:53 MKIV beta fmt: 2013.9.21 int: english/english +ConTeXt ver: 2013.09.30 19:49 MKIV beta fmt: 2013.9.30 int: english/english system > 'cont-new.mkiv' loaded (cont-new.mkiv) diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index a3aeb31e7..5be5727f5 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -737,13 +737,13 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref applyprocessor(connector) end else -if groupsuffix and kind ~= "prefix" then - if result then - result[#result+1] = strippedprocessor(groupsuffix) - else - applyprocessor(groupsuffix) - end -end + if groupsuffix and kind ~= "prefix" then + if result then + result[#result+1] = strippedprocessor(groupsuffix) + else + applyprocessor(groupsuffix) + end + end if stopper then if result then result[#result+1] = strippedprocessor(stopper) @@ -769,94 +769,104 @@ end function sections.findnumber(depth,what) -- needs checking (looks wrong and slow too) local data = data.status[depth or data.depth] - if data then - local index = data.references.section - local collected = sections.collected - local sectiondata = collected[index] - if sectiondata and sectiondata.hidenumber ~= true then -- can be nil - local quit = what == v_previous or what == v_next - if what == v_first or what == v_previous then - for i=index,1,-1 do - local s = collected[i] - if s then - local n = s.numbers - if #n == depth and n[depth] and n[depth] ~= 0 then - sectiondata = s - if quit then - break - end - elseif #n < depth then + if not data then + return + end + local references = data.references + if not references then + return + end + local index = references.section + local collected = sections.collected + local sectiondata = collected[index] + if sectiondata and sectiondata.hidenumber ~= true then -- can be nil + local quit = what == v_previous or what == v_next + if what == v_first or what == v_previous then + for i=index,1,-1 do + local s = collected[i] + if s then + local n = s.numbers + if #n == depth and n[depth] and n[depth] ~= 0 then + sectiondata = s + if quit then break end + elseif #n < depth then + break end end - elseif what == v_last or what == v_next then - for i=index,#collected do - local s = collected[i] - if s then - local n = s.numbers - if #n == depth and n[depth] and n[depth] ~= 0 then - sectiondata = s - if quit then - break - end - elseif #n < depth then + end + elseif what == v_last or what == v_next then + for i=index,#collected do + local s = collected[i] + if s then + local n = s.numbers + if #n == depth and n[depth] and n[depth] ~= 0 then + sectiondata = s + if quit then break end + elseif #n < depth then + break end end end - return sectiondata end + return sectiondata end end function sections.finddata(depth,what) local data = data.status[depth or data.depth] - if data then - -- if sectiondata and sectiondata.hidenumber ~= true then -- can be nil - local index = data.references.listindex - if index then - local collected = structures.lists.collected - local quit = what == v_previous or what == v_next - if what == v_first or what == v_previous then - for i=index-1,1,-1 do - local s = collected[i] - if not s then + if not data then + return + end + local references = data.references + if not references then + return + end + local index = references.listindex + if not index then + return + end + local collected = structures.lists.collected + local quit = what == v_previous or what == v_next + if what == v_first or what == v_previous then + for i=index-1,1,-1 do + local s = collected[i] + if not s then + break + elseif s.metadata.kind == "section" then -- maybe check on name + local n = s.numberdata.numbers + if #n == depth and n[depth] and n[depth] ~= 0 then + data = s + if quit then break - elseif s.metadata.kind == "section" then -- maybe check on name - local n = s.numberdata.numbers - if #n == depth and n[depth] and n[depth] ~= 0 then - data = s - if quit then - break - end - elseif #n < depth then - break - end end + elseif #n < depth then + break end - elseif what == v_last or what == v_next then - for i=index+1,#collected do - local s = collected[i] - if not s then + end + end + elseif what == v_last or what == v_next then + for i=index+1,#collected do + local s = collected[i] + if not s then + break + elseif s.metadata.kind == "section" then -- maybe check on name + local n = s.numberdata.numbers + if #n == depth and n[depth] and n[depth] ~= 0 then + data = s + if quit then break - elseif s.metadata.kind == "section" then -- maybe check on name - local n = s.numberdata.numbers - if #n == depth and n[depth] and n[depth] ~= 0 then - data = s - if quit then - break - end - elseif #n < depth then - break - end end + elseif #n < depth then + break end end end - return data end + return data end function sections.internalreference(sectionname,what) -- to be used in pagebuilder (no marks used) diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi index 15a499c8b..7cef924b7 100644 --- a/tex/context/base/strc-lst.mkvi +++ b/tex/context/base/strc-lst.mkvi @@ -1262,6 +1262,8 @@ % \resetinteractionparameter\c!contrastcolor \fi} +\let\strc_lists_set_style_color\strc_lists_set_style_color_normal + %D A helper: \def\strc_lists_limitated_text#text% diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index 2356acb9b..7e7736e2b 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -13,32 +13,35 @@ local utfchar = utf.char local lpegmatch = lpeg.match local allocate = utilities.storage.allocate -local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end) +local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end) -local report_registers = logs.reporter("structure","registers") +local report_registers = logs.reporter("structure","registers") -local structures = structures -local registers = structures.registers -local helpers = structures.helpers -local sections = structures.sections -local documents = structures.documents -local pages = structures.pages -local references = structures.references +local structures = structures +local registers = structures.registers +local helpers = structures.helpers +local sections = structures.sections +local documents = structures.documents +local pages = structures.pages +local references = structures.references -local mappings = sorters.mappings -local entries = sorters.entries -local replacements = sorters.replacements +local mappings = sorters.mappings +local entries = sorters.entries +local replacements = sorters.replacements -local processors = typesetters.processors -local splitprocessor = processors.split +local processors = typesetters.processors +local splitprocessor = processors.split -local texgetcount = tex.getcount +local texgetcount = tex.getcount -local variables = interfaces.variables -local context = context -local commands = commands +local variables = interfaces.variables +local context = context +local commands = commands -local matchingtilldepth, numberatdepth = sections.matchingtilldepth, sections.numberatdepth +local matchingtilldepth = sections.matchingtilldepth +local numberatdepth = sections.numberatdepth + +local absmaxlevel = 5 -- \c_strc_registers_maxlevel -- some day we will share registers and lists (although there are some conceptual -- differences in the application of keywords) @@ -661,18 +664,39 @@ local function collapsepages(pages) return #pages end +-- todo: determine max + function registers.flush(data,options,prefixspec,pagespec) local collapse_singles = options.compress == variables.yes local collapse_ranges = options.compress == variables.all local result = data.result + local done = { } -- reused + local maxlevel = 0 + -- + for i=1,#result do + local data = result[i].data + for d=1,#data do + local m = #data[d].list + if m > maxlevel then + maxlevel = m + end + end + end + if maxlevel > absmaxlevel then + maxlevel = absmaxlevel + report_registers("limiting level to %a",maxlevel) + end + -- context.startregisteroutput() for i=1,#result do -- ranges need checking ! local sublist = result[i] - local done = { false, false, false, false } local data = sublist.data local d, n = 0, 0 context.startregistersection(sublist.tag) + for i=1,maxlevel do + done[i] = false + end for d=1,#data do local entry = data[d] if entry.metadata.kind == "see" then @@ -685,20 +709,26 @@ function registers.flush(data,options,prefixspec,pagespec) end end end + local e = { } -- reused while d < #data do d = d + 1 local entry = data[d] - local e = { false, false, false, false } local metadata = entry.metadata local kind = metadata.kind local list = entry.list - for i=1,4 do -- max 4 + for i=1,maxlevel do + e[i] = false + end + for i=1,maxlevel do if list[i] then e[i] = list[i][1] end if e[i] ~= done[i] then if e[i] and e[i] ~= "" then done[i] = e[i] + for j=i+1,maxlevel do + done[j] = false + end if n == i then context.stopregisterentries() context.startregisterentries(n) @@ -722,6 +752,9 @@ function registers.flush(data,options,prefixspec,pagespec) end else done[i] = false + for j=i,maxlevel do + done[j] = false + end end end end diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index 8c9f040f0..febb4c0b0 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -116,6 +116,7 @@ %D \stoptyping \newconditional\c_strc_registers_defining +\setnewconstant\c_strc_registers_maxlevel \plusfive \ifdefined\Word \else \unexpanded\def\Word#1{#1} \fi @@ -131,7 +132,7 @@ \setuevalue{\e!place\currentregister}{\placeregister[\currentregister]}% \setuevalue{\e!complete\currentregister}{\completeregister[\currentregister]}% \setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister]}% - \dorecurse\plusthree {% weird, expanded should not be needed + \dorecurse\c_strc_registers_maxlevel{% weird, expanded should not be needed \normalexpanded{\defineregister[\currentregister:\recurselevel][\currentregister]}% %\defineregister[\currentregister:\recurselevel][\currentregister]% \letregisterparameter{\c!entries:\recurselevel}\empty % needed as we use detokenize (ok, we can @@ -672,14 +673,29 @@ \dostoptagged \endgroup} +% \unexpanded\def\startregisterentries#1% depth +% {\endgraf +% \begingroup +% \dostarttagged\t!registerentries\empty +% \let\savedcurrentregister\currentregister +% \edef\currentregister{\currentregister:#1}% +% \useregisterstyleandcolor\c!textstyle\c!textcolor +% \advance\leftskip\numexpr#1-\plusone\relax\dimexpr\d_strc_registers_distance\relax +% \hangindent\registerparameter\c!distance\relax +% \hangafter\plusone +% \let\currentregister\savedcurrentregister} + \unexpanded\def\startregisterentries#1% depth {\endgraf \begingroup + \scratchcounter\ifnum#1>\c_strc_registers_maxlevel\c_strc_registers_maxlevel\else#1\fi\relax \dostarttagged\t!registerentries\empty \let\savedcurrentregister\currentregister - \edef\currentregister{\currentregister:#1}% + \edef\currentregister{\currentregister:\number\scratchcounter}% \useregisterstyleandcolor\c!textstyle\c!textcolor - \advance\leftskip\numexpr#1-\plusone\relax\dimexpr\d_strc_registers_distance\relax + \ifnum\scratchcounter>\plusone + \advance\leftskip\d_strc_registers_distance\relax + \fi \hangindent\registerparameter\c!distance\relax \hangafter\plusone \let\currentregister\savedcurrentregister} diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index aadda56db..2836b018b 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -432,6 +432,9 @@ \unexpanded\def\startnamedsection {\dotripleempty\strc_sectioning_start_named_section} +% todo: add grouping but where: before/after trickery .. probably inside because one can always add +% grouping to the before/after settings + \unexpanded\def\strc_sectioning_start_named_section[#1]% [#2][#3] {\pushmacro\currentnamedsection \edef\currentnamedsection{#1}% @@ -588,11 +591,13 @@ \headparameter\c!beforesection % beware, no users vars set yet \the\everybeforehead \strc_sectioning_handle{#1}{#2}{#3}% name -- -- -- userdata (we might move the tagged to here) + % potential: \bgroup (can be optional: grouped = yes) \headparameter\c!insidesection} \unexpanded\def\strc_sectioning_stop[#1]% !!! also used at lua end {\dostoptagged \dostoptagged + % potential: \egroup %\globalpopmacro\currenthead % so we do a hard recover \xdef\currenthead{#1}% recover \headparameter\c!aftersection diff --git a/tex/context/base/tabl-nte.mkiv b/tex/context/base/tabl-nte.mkiv index 4a9774cb0..af74a2abe 100644 --- a/tex/context/base/tabl-nte.mkiv +++ b/tex/context/base/tabl-nte.mkiv @@ -102,9 +102,9 @@ \unexpanded\def\startTABLEbody{\dosingleempty\tabl_nte_start_body} \let\stopTABLEbody\relax \unexpanded\def\startTABLEfoot{\dosingleempty\tabl_nte_start_foot} \let\stopTABLEfoot\relax -\def\tabl_nte_start_head[#1]#2\stopTABLEhead{\appendtoks\doTABLEsection[#1]{#2}\to\TBLhead} -\def\tabl_nte_start_next[#1]#2\stopTABLEnext{\appendtoks\doTABLEsection[#1]{#2}\to\TBLnext} -\def\tabl_nte_start_body[#1]#2\stopTABLEbody{\appendtoks\doTABLEsection[#1]{#2}\to\TBLbody} -\def\tabl_nte_start_foot[#1]#2\stopTABLEfoot{\appendtoks\doTABLEsection[#1]{#2}\to\TBLfoot} +\def\tabl_nte_start_head[#1]#2\stopTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head} +\def\tabl_nte_start_next[#1]#2\stopTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next} +\def\tabl_nte_start_body[#1]#2\stopTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body} +\def\tabl_nte_start_foot[#1]#2\stopTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot} \protect \endinput diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 57b5dd9c8..f04c45e18 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1923,7 +1923,7 @@ \tabl_tabulate_nobreak_inject \stoptabulatenoalign} -\let\tabl_tabulate_BL_second\tabl_tabulate_TL_second +\let\tabl_tabulate_BL_second_indeed\tabl_tabulate_TL_second_indeed \def\tabl_tabulate_HL_second {\csname @@ -2016,6 +2016,8 @@ \let\tabl_tabulate_flush_collected \empty \let\tabl_tabulate_flush_collected_indeed\empty +\let\v_tabl_tabulate_align\!!zerocount + \def\tabl_tabulate_set_local_hsize {\setlocalhsize \hsize\localhsize} diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index f63f83080..556bec5ce 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -153,6 +153,7 @@ \let\stopxtable\relax \def\tabl_x_default_buffer{x_table_\number\c_tabl_x_nesting} +\let\tabl_x_current_buffer\empty \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua index 1022483a0..9c7e7ce63 100644 --- a/tex/context/base/task-ini.lua +++ b/tex/context/base/task-ini.lua @@ -12,6 +12,10 @@ if not modules then modules = { } end modules ['task-ini'] = { -- we can disable more handlers and enable then when really used (*) -- -- todo: two finalizers: real shipout (can be imposed page) and page shipout (individual page) +-- +-- todo: consider moving the kernel kerning/ligaturing functions in the main font loop because +-- there we know if they are needed; doesn't save time but; if we overload unh* commands to +-- not apply the font handler, we can remove all checks for subtypes 255 local tasks = nodes.tasks local appendaction = tasks.appendaction diff --git a/tex/context/base/type-ini.mkvi b/tex/context/base/type-ini.mkvi index 0ce14ef9f..a4d576d80 100644 --- a/tex/context/base/type-ini.mkvi +++ b/tex/context/base/type-ini.mkvi @@ -601,6 +601,8 @@ \def\font_typescripts_inherit_check_step#style{\setevalue{\??typescriptinheritances#name:#style}{#parentclass}}% \processcommalist[#styles]\font_typescripts_inherit_check_step}}} +\let\font_typescripts_inherit_check_step\relax + %D This hooks into the font mechanism with: \def\font_typescripts_inherit_check_indeed#name% called often diff --git a/tex/context/base/typo-del.mkiv b/tex/context/base/typo-del.mkiv index 82cc7472d..603471f75 100644 --- a/tex/context/base/typo-del.mkiv +++ b/tex/context/base/typo-del.mkiv @@ -334,6 +334,8 @@ \def\typo_delimited_start_par {\dosingleempty\typo_delimited_start_par_indeed} +\let\typo_delimited_stop_par_indeed\endgraf + \def\typo_delimited_start_par_indeed[#1]% {\let\typo_delimited_stop\typo_delimited_stop_par \doifsomething{\delimitedtextparameter\c!spacebefore} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 810538a7f..4a1087fbb 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 09/21/13 13:53:05 +-- merge date : 09/30/13 19:49:15 do -- begin closure to overcome local limits and interference -- cgit v1.2.3