diff options
author | Marius <mariausol@gmail.com> | 2012-01-10 13:33:35 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-01-10 13:33:35 +0200 |
commit | d44c3d2b9ac2a797c610b9b472527119c08bf206 (patch) | |
tree | 09dca91a6255797b040b88c2ea348e162c0842e4 /tex | |
parent | 2ee95c7070f4d16d25209332378cb27e599292f7 (diff) | |
download | context-d44c3d2b9ac2a797c610b9b472527119c08bf206.tar.gz |
beta 2012.01.09 10:08
Diffstat (limited to 'tex')
74 files changed, 6808 insertions, 6636 deletions
diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 42347ada1..2ebeb69f6 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -458,7 +458,7 @@ \setpositiondataplus {p:\number\parposcounter}\zeropoint\strutht\strutdp {\the\hsize,\the\dimexpr\leftskip\relax,\the\dimexpr\rightskip\relax,\the\hangindent,\the\hangafter,\the\parindent}% - %\normalhbox{\registerparsymbol}% + %\hbox{\registerparsymbol}% \iftracepositions\registerparsymbol\fi} \unexpanded\def\traceposstring#1#2#3% diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index 474651fea..29930744e 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -459,7 +459,10 @@ function colors.definemultitonecolor(name,multispec,colorspec,selfspec) colorset[name] = true-- maybe we can store more end -local function mpcolor(model,ca,ta,default) -- will move to mlib-col +-- will move to mlib-col as colors in m,p are somewhat messy due to the fact +-- that we cannot cast + +local function mpcolor(model,ca,ta,default) local cv = colorvalues[ca] if cv then local tv = transparencyvalues[ta] @@ -474,8 +477,13 @@ local function mpcolor(model,ca,ta,default) -- will move to mlib-col return format("transparent(%s,%s,(%s,%s,%s))",tv[1],tv[2],cv[3],cv[4],cv[5]) elseif model == 4 then return format("transparent(%s,%s,cmyk(%s,%s,%s,%s))",tv[1],tv[2],cv[6],cv[7],cv[8],cv[9]) - else + elseif model == 5 then return format('transparent(%s,%s,multitonecolor("%s",%s,"%s","%s"))',tv[1],tv[2],cv[10],cv[11],cv[12],cv[13]) + else + return format("transparent(%s,%s,(%s,%s,%s))",tv[1],tv[2],cv[3],cv[4],cv[5]) +-- this will become (see ** in meta-ini.mkiv) +-- +-- return format("transparent(%s,%s,(%s))",tv[1],tv[2],cv[2]) end else if model == 2 then @@ -484,8 +492,13 @@ local function mpcolor(model,ca,ta,default) -- will move to mlib-col return format("(%s,%s,%s)",cv[3],cv[4],cv[5]) elseif model == 4 then return format("cmyk(%s,%s,%s,%s)",cv[6],cv[7],cv[8],cv[9]) - else + elseif model == 5 then return format('multitonecolor("%s",%s,"%s","%s")',cv[10],cv[11],cv[12],cv[13]) + else + return format("(%s,%s,%s)",cv[3],cv[4],cv[5]) +-- this will become (see ** in meta-ini.mkiv) +-- +-- return format("%s",(cv[2])) end end else @@ -494,41 +507,6 @@ local function mpcolor(model,ca,ta,default) -- will move to mlib-col end end ---~ local function mpcolor(model,ca,ta,default) -- will move to mlib-col ---~ local cv = colorvalues[ca] ---~ if cv then ---~ local tv = transparencyvalues[ta] ---~ if model == 1 then ---~ model = cv[1] ---~ end ---~ model = forcedmodel(model) ---~ if tv then ---~ if model == 2 then ---~ return format("(%s,%s,%s) withtransparency (%s,%s)",tv[1],tv[2],cv[3],cv[4],cv[5]) ---~ elseif model == 3 then ---~ return format("(%s,%s,%s) withtransparency (%s,%s)",tv[1],tv[2],cv[3],cv[4],cv[5]) ---~ elseif model == 4 then ---~ return format("(%s,%s,%s,%s) withtransparency(%s,%s)",tv[1],tv[2],cv[6],cv[7],cv[8],cv[9]) ---~ else ---~ return format('multitonecolor("%s",%s,"%s","%s") withtransparency (%s,%s)',tv[1],tv[2],cv[10],cv[11],cv[12],cv[13]) ---~ end ---~ else ---~ if model == 2 then ---~ return format("(%s,%s,%s)",cv[3],cv[4],cv[5]) ---~ elseif model == 3 then ---~ return format("(%s,%s,%s)",cv[3],cv[4],cv[5]) ---~ elseif model == 4 then ---~ return format("cmyk(%s,%s,%s,%s)",cv[6],cv[7],cv[8],cv[9]) ---~ else ---~ return format('multitonecolor("%s",%s,"%s","%s")',cv[10],cv[11],cv[12],cv[13]) ---~ end ---~ end ---~ else ---~ default = default or 0 -- rgb ! ---~ return format("(%s,%s,%s)",default,default,default) ---~ end ---~ end - local function mpoptions(model,ca,ta,default) -- will move to mlib-col return format("withcolor %s",mpcolor(model,ca,ta,default)) end diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index cddefe996..44016bcc2 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -909,7 +909,7 @@ % \normal added else fails in metafun manual (leaders do a hard scan) -\unexpanded\def\forcecolorhack{\leaders\hrule\normalhskip\zeropoint} +\unexpanded\def\forcecolorhack{\leaders\hrule\hskip\zeropoint} %D We default to the colors defined in \type {colo-imp-rgb} and %D support both \RGB\ and \CMYK\ output. Transparencies are defined diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 29e571a44..67647920d 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -91,7 +91,7 @@ %D %D I changed this into one that adapts itself: -\unexpanded\def\Context +\unexpanded\def\Context % wrong usage of \getscaledglyph {\dontleavehmode \begingroup C\kern -.0667em\getscaledglyph{.8}\empty{O\kern -.0667emN\kern @@ -108,11 +108,11 @@ \unexpanded\def\setMFPfont% more sensitive for low level changes {\font\logofont=logo% - \ifx\fontalternative\c!bf\else - \ifx\fontalternative\c!it\else - \ifx\fontalternative\c!sl\else - \ifx\fontalternative\c!bi\else - \ifx\fontalternative\c!bs\else + \ifx\fontalternative\s!bf\else + \ifx\fontalternative\s!it\else + \ifx\fontalternative\s!sl\else + \ifx\fontalternative\s!bi\else + \ifx\fontalternative\s!bs\else \fi\fi\fi\fi\fi 10 at \currentfontscale\bodyfontsize % there is no afm in the minimals yet \logofont} @@ -186,11 +186,11 @@ \iffontchar\font"018E\relax \char"018E% \else - \ifx\fontalternative\c!bf \mirror{E}\else - \ifx\fontalternative\c!it\syst_logos_xetex_e\else - \ifx\fontalternative\c!sl\syst_logos_xetex_e\else - \ifx\fontalternative\c!bi\syst_logos_xetex_e\else - \ifx\fontalternative\c!bs\syst_logos_xetex_e\else + \ifx\fontalternative\s!bf \mirror{E}\else + \ifx\fontalternative\s!it\syst_logos_xetex_e\else + \ifx\fontalternative\s!sl\syst_logos_xetex_e\else + \ifx\fontalternative\s!bi\syst_logos_xetex_e\else + \ifx\fontalternative\s!bs\syst_logos_xetex_e\else \mirror{E}\fi\fi\fi\fi\fi \fi}% \kern-.1667em\TeX} @@ -231,10 +231,10 @@ % % a further iteration from the list, patched again -% \ifx\fontalternative\c!it -\else -% \ifx\fontalternative\c!sl -\else -% \ifx\fontalternative\c!bi -\else -% \ifx\fontalternative\c!bs -\fi\fi\fi\fi +% \ifx\fontalternative\s!it -\else +% \ifx\fontalternative\s!sl -\else +% \ifx\fontalternative\s!bi -\else +% \ifx\fontalternative\s!bs -\fi\fi\fi\fi \unexpanded\def\LuaTeX {\dontleavehmode diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index cdaa6555b..48c6cd4ea 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.01.02 21:59} +\newcontextversion{2012.01.09 10:08} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index f15350801..7c4855dcf 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{2012.01.02 21:59} +\newcontextversion{2012.01.09 10:08} %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/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 2b75912ca..538e5983c 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 3f70be95d..105c08445 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index e6112b831..d5978661a 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.02 21:59} +\edef\contextversion{2012.01.09 10:08} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index b9b1a545d..08671380f 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.02 21:59} +\edef\contextversion{2012.01.09 10:08} %D For those who want to use this: @@ -228,6 +228,7 @@ \loadmarkfile{spac-ali} \loadmarkfile{spac-hor} \loadmarkfile{spac-ver} +\loadmarkfile{spac-lin} \loadmarkfile{spac-pag} \loadmarkfile{spac-fnt} \loadmarkfile{spac-par} @@ -279,8 +280,6 @@ \loadmarkfile{typo-pag} \loadmarkfile{typo-mar} -% \loadmkvifile{file-job} % why so late? - \loadmarkfile{buff-ini} \loadmarkfile{buff-ver} \loadmarkfile{buff-par} @@ -324,11 +323,13 @@ \loadmkvifile{scrn-hlp} \loadmarkfile{char-enc} % will move up -\loadmarkfile{font-ini} % will move up +\loadmkvifile{font-ini} % will move up +\loadmkvifile{font-emp} +\loadmarkfile{font-pre} \loadmarkfile{font-unk} \loadmarkfile{font-tra} \loadmarkfile{font-uni} -\loadmarkfile{font-col} +\loadmkvifile{font-col} \loadmarkfile{font-gds} \loadmarkfile{lxml-css} @@ -349,10 +350,8 @@ \loadmkvifile{typo-txt} \loadmarkfile{typo-par} -\loadmarkfile{type-ini} +\loadmkvifile{type-ini} \loadmarkfile{type-set} -\loadmarkfile{type-def} -\loadmarkfile{type-lua} \loadmarkfile{scrp-ini} diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv index 13cfd5bc4..03d0ffa74 100644 --- a/tex/context/base/core-def.mkiv +++ b/tex/context/base/core-def.mkiv @@ -26,10 +26,12 @@ % initialization order: -\ifdefined\firststagepreloadfonts \else \let\firststagepreloadfonts \relax \fi -\ifdefined\secondstagepreloadfonts \else \let\secondstagepreloadfonts\relax \fi -\ifdefined\thirdstagepreloadfonts \else \let\thirdstagepreloadfonts \relax \fi -\ifdefined\fourthstagepreloadfonts \else \let\fourthstagepreloadfonts\relax \fi +\ifdefined\font_preloads_at_every_job \else \let\font_preloads_at_every_job \relax \fi +\ifdefined\font_preloads_at_start_text \else \let\font_preloads_at_start_text\relax \fi +\ifdefined\font_preloads_at_stop_text \else \let\font_preloads_at_stop_text \relax \fi + +\appendtoks \font_preloads_at_start_text \to \everystarttext +\appendtoks \font_preloads_at_stop_text \to \everystoptext %prependtoks \preloadtypescript \to \everyjob \appendtoks \showcontextbanner \to \everyjob @@ -37,7 +39,7 @@ \appendtoks \calculatecurrenttime \to \everyjob \appendtoks \loadsystemfiles \to \everyjob \appendtoks \loadoptionfile \to \everyjob % can load files ! -\appendtoks \firststagepreloadfonts \to \everyjob +\appendtoks \font_preloads_at_every_job \to \everyjob \appendtoks \settopskip \to \everyjob \appendtoks \initializemainlanguage \to \everyjob %appendtoks \MPLIBregister \to \everyjob @@ -62,9 +64,6 @@ \prependtoks \lefttoright \to \everybeforeoutput -\appendtoks \secondstagepreloadfonts \to \everystarttext -\appendtoks \fourthstagepreloadfonts \to \everystoptext - % temporary here: \unexpanded\def\arg{\mathortext\normalmatharg\normaltextarg} diff --git a/tex/context/base/font-col.lua b/tex/context/base/font-col.lua index b5437e249..f8add1e4e 100644 --- a/tex/context/base/font-col.lua +++ b/tex/context/base/font-col.lua @@ -90,7 +90,7 @@ end -- todo: provide a lua variant (like with definefont) -function collections.clone_one(name) +function collections.registermain(name) local last = font.current() if trace_collecting then report_fonts("def: registering font %s with name %s",last,name) @@ -98,7 +98,7 @@ function collections.clone_one(name) list[#list+1] = last end -function collections.clone_two(name) +function collections.clonevector(name) statistics.starttiming(fonts) local d = definitions[name] local t = { } @@ -169,27 +169,29 @@ function collections.prepare(name) report_fonts("def: applying collection %s to %s (file: %s)",name,current,filename) end list = { } - context.dostartcloningfonts() -- move this to tex \dostart... + context.pushcatcodes("prt") -- context.unprotect() + context.font_fallbacks_start_cloning() for i=1,#d do local f = d[i] local name = f.font local scale = f.rscale or 1 if lpegmatch(okay,name) then - context.doclonefonta(name,scale) -- define with unique specs + context.font_fallbacks_clone_unique(name,scale) else - context.doclonefontb(name,scale) -- define with inherited specs + context.font_fallbacks_clone_inherited(name,scale) end - context.doclonefontstageone(name) -- registering main font + context.font_fallbacks_register_main(name) end - context.doclonefontstagetwo(name) -- preparing clone vectors - context.dostopcloningfonts() + context.font_fallbacks_prepare_clone_vectors(name) + context.font_fallbacks_stop_cloning() + context.popcatcodes() -- context.protect() elseif trace_collecting then local filename = file.basename(fontdata[current].properties.filename or "?") report_fonts("def: error in applying collection %s to %s (file: %s)",name,current,filename) end end -function collections.message(message) +function collections.report(message) if trace_collecting then report_fonts("tex: %s",message) end @@ -226,9 +228,9 @@ end -- interface -commands.definefontcollection = collections.define -commands.resetfontcollection = collections.reset -commands.preparefontcollection = collections.prepare -commands.fontcollectionmessage = collections.message -commands.clonefontcollection_one = collections.clone_one -commands.clonefontcollection_two = collections.clone_two +commands.fontcollectiondefine = collections.define +commands.fontcollectionreset = collections.reset +commands.fontcollectionprepare = collections.prepare +commands.fontcollectionreport = collections.report +commands.fontcollectionregister = collections.registermain +commands.fontcollectionclone = collections.clonevector diff --git a/tex/context/base/font-col.mkiv b/tex/context/base/font-col.mkvi index cbe183868..d78c082e3 100644 --- a/tex/context/base/font-col.mkiv +++ b/tex/context/base/font-col.mkvi @@ -29,72 +29,67 @@ \unprotect -\unexpanded\def\definefontfallback - {\doquadrupleempty\dodefinefontfallback} +\unexpanded\def\definefontfallback{\doquadrupleempty\font_fallbacks_define} +\unexpanded\def\resetfontfallback {\dodoubleempty \font_fallbacks_reset } -\def\dodefinefontfallback[#1][#2][#3][#4]% - {\ctxcommand{definefontcollection("#1","#2",\!!bs#3\!!es,\!!bs#4\!!es)}} +\def\font_fallbacks_define[#name][#font][#ranges][#settings]% + {\ctxcommand{fontcollectiondefine("#name","#font",\!!bs#ranges\!!es,\!!bs#settings\!!es)}} -\def\resetfontfallback - {\dodoubleempty\doresetfontfallback} +\def\font_fallbacks_reset[#name][#font]% + {\ctxcommand{fontcollectionreset("#name","#font")}} -\def\doresetfontfallback[#1][#2]% - {\ctxcommand{resetfontcollection("#1","#2")}} - -% add fallbacks to last font - -\def\dodefinefontfallbacks#1% - {\ctxcommand{preparefontcollection("#1")}} +\def\font_fallbacks_prepare#name% + {\ctxcommand{fontcollectionprepare("#name")}} % add fallbacks to last font % we might as well move the handling to lua but then we need to pass the % fallbacks, skewchar etc. -\setfalse\doingfontfallbacks +\newconditional\c_font_fallbacks_in_progress -\def\dodefinefontfallbacksindeed#1% +\def\font_fallbacks_prepare_indeed#fallbacks% {\begingroup - \settrue\doingfontfallbacks + \settrue\c_font_fallbacks_in_progress \lastrawfontcall % sets current font id - \dodefinefontfallbacks#1% + \font_fallbacks_prepare#fallbacks% \endgroup} +\let\m_font_fallbacks\empty % set in the font-ini + \appendtoks - \ifconditional\doingfontfallbacks\else - \ifx\@@fontfallbacks\empty - \ifx\@@fontclassfallbacks\empty + \ifconditional\c_font_fallbacks_in_progress\else + \ifx\m_font_fallbacks\empty + \ifx\m_font_class_fallbacks\empty \else - \dodefinefontfallbacksindeed\@@fontclassfallbacks + \font_fallbacks_prepare_indeed\m_font_class_fallbacks \fi \else - \dodefinefontfallbacksindeed\@@fontfallbacks + \font_fallbacks_prepare_indeed\m_font_fallbacks \fi \fi \to\everydefinefont -\def\dostartcloningfonts - {\bgroup +\def\font_fallbacks_start_cloning + {\begingroup \let\savedfontspec\somefontspec} -\def\dostopcloningfonts - {\egroup} +\def\font_fallbacks_stop_cloning + {\endgroup} -\def\doclonefonta#1#2% kind of dododefinefont - {\ctxcommand{fontcollectionmessage("defining #1 (relative scale: #2)")}% brrr - \autofontsizefalse +\def\font_fallbacks_clone_unique#specification#scale% kind of dododefinefont + {\ctxcommand{fontcollectionreport("defining #specification (relative scale: #scale)")}% brrr + \setfalse\font_auto_font_size \let\lastfontidentifier\s!dummy - \def\localrelativefontsize{#2}% - \let\localabsolutefontsize\fontbody - \lowleveldefinefont{#1}\rawfontidentifier - \csname\rawfontidentifier\endcsname - \autofontsizefalse - %\setfontcharacteristics - }%\the\everyfontswitch} - -\def\doclonefontb#1% #2 - {\doclonefonta{#1 \savedfontspec}} - -\def\doclonefontstageone#1{\ctxcommand{clonefontcollection_one("#1")}} -\def\doclonefontstagetwo#1{\ctxcommand{clonefontcollection_two("#1")}} + \def\v_font_size_relative{#scale}% + \let\v_font_size_absolute\fontbody + \font_helpers_low_level_define{#specification}\v_font_identifier_basic + \csname\v_font_identifier_basic\endcsname + \setfalse\font_auto_font_size} % no \setfontcharacteristics and \the\everyfontswitch needed + +\def\font_fallbacks_clone_inherited#font% also a secod argument + {\font_fallbacks_clone_unique{#font \savedfontspec}} + +\def\font_fallbacks_register_main #name{\ctxcommand{fontcollectionregister("#name")}} +\def\font_fallbacks_prepare_clone_vectors#name{\ctxcommand{fontcollectionclone("#name")}} % check : only replace when present in replacement font (default: no) % force : force replacent even when basefont has glyph (default: yes) diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 6a7e0f5d3..2684c4851 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -1489,3 +1489,11 @@ to scale virtual characters.</p> function commands.setfontofid(id) context.getvalue(csnames[id]) end + +-- more interfacing: + +commands.definefontfeature = fonts.specifiers.presetcontext + +function commands.featurelist(...) + context(fonts.specifiers.contexttostring(...)) +end diff --git a/tex/context/base/font-emp.mkvi b/tex/context/base/font-emp.mkvi new file mode 100644 index 000000000..65aa7a520 --- /dev/null +++ b/tex/context/base/font-emp.mkvi @@ -0,0 +1,231 @@ +%D \module +%D [ file=font-emp, +%D version=20120106, % (moved from font-ini) +%D title=\CONTEXT\ Font Macros, +%D subtitle=Emphasis, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Emphasis} + +\unprotect + +%D \macros +%D {em,emphasistypeface,emphasisboldface} +%D +%D The next macro started as a copy of Donald Arseneau's +%D \type{\em} (\TUGNEWS\ Vol.~3, no.~1, 1994). His +%D implementation was a bit more sophisticated version of the +%D standard \LATEX\ one. We further enhanced the macro, so now +%D it also adapts itself to boldface mode. Because we favor +%D {\sl slanted} type over {\it italic}, we made the emphasis +%D adaptable, for instance: +%D +%D \starttyping +%D \def\emphasistypeface {\it} +%D \def\emphasisboldface {\bi} +%D \stoptyping +%D +%D But we prefer: +%D +%D \starttyping +%D \unexpanded\def\emphasistypeface{\sl} +%D \unexpanded\def\emphasisboldface{\bs} +%D \stoptyping +%D +%D or even better: + +\let\m_font_emphasized_typeface\empty + +\def\font_emphasis_checked_typeface#slanted#italic% + {\edef\m_font_emphasized_typeface{\bodyfontvariable\s!em}% + \ifx\m_font_emphasized_typeface\v!slanted + #slanted% + \else\ifx\m_font_emphasized_typeface\v!italic + #italic% + \else\ifx\m_font_emphasized_typeface\empty + #slanted% + \else + \csname\m_font_emphasized_typeface\endcsname + \fi\fi\fi} + +\unexpanded\def\emphasistypeface{\font_emphasis_checked_typeface\sl\it} +\unexpanded\def\emphasisboldface{\font_emphasis_checked_typeface\bs\bi} + +\unexpanded\def\normalboldface % public + {\relax\ifx\fontalternative\s!it\bi + \else \ifx\fontalternative\s!sl\bs + \else \bf\fi\fi} + +\unexpanded\def\normaltypeface % public + {\relax + \ifx\fontalternative\s!bi \it \else + \ifx\fontalternative\s!bs \sl \else + \tf \fi\fi} + +\unexpanded\def\swaptypeface % public + {\relax + \ifx\fontalternative\s!it \tf \else + \ifx\fontalternative\s!sl \tf \else + \ifx\fontalternative\s!bf \emphasisboldface \else + \ifx\fontalternative\s!bs \bf \else + \ifx\fontalternative\s!bi \bf \else + \emphasistypeface \fi\fi\fi\fi\fi} + +\let\typeface\normaltypeface % public +\let\boldface\normalboldface % public +\let\swapface\swaptypeface % public + +%D To be set with the default body font environment: \type +%D {em} being \type {slanted} or \type {italic}. + +% maybe a \csname...\fontalternative\endcsname + +\newconditional\c_font_emphasis_needed + +\unexpanded\def\em + {\relax + \ifdim\slantperpoint>\zeropoint + \settrue\c_font_emphasis_needed + \else + \setfalse\c_font_emphasis_needed + \fi + \font_emphasis_set_emphasis_boldface % new + \ifx\fontalternative\s!it + \unexpanded\def\emphasistypeface{\it}\tf + \else\ifx\fontalternative\s!sl + \unexpanded\def\emphasistypeface{\sl}\tf + \else\ifx\fontalternative\s!bf + \emphasisboldface + \else\ifx\fontalternative\s!bs + \unexpanded\def\emphasisboldface{\bs}\bf + \else\ifx\fontalternative\s!bi + \unexpanded\def\emphasisboldface{\bi}\bf + \else + \emphasistypeface + \fi\fi\fi\fi\fi + \ifconditional\c_font_emphasis_needed\else + \expandafter\aftergroup + \fi + \emphasiscorrection} + +%D The next feature was not present in previous versions. It +%D takes care of \type {\em \bf ...} situations. + +\def\font_emphasis_set_emphasis_boldface + {\let\font_emphasis_saved_emphasis_boldface\bf + \let\font_emphasis_set_emphasis_boldface\relax + \let\bf\font_emphasis_bold_bold} + +\unexpanded\def\font_emphasis_bold_bold + {%\relax + \let\bf\relax % new + \ifx\fontalternative\s!it + \bi + \else\ifx\fontalternative\s!sl + \bs + \else + \font_emphasis_saved_emphasis_boldface + \fi\fi + \let\bf\font_emphasis_saved_emphasis_boldface} + +%D Donald's (adapted) macros take the next character into +%D account when placing italic correction. As a bonus we also +%D look for something that looks like a dash, in which case we +%D don't correct. + +\let\italiccorrection=\/ % tex primitive + +\def\emphasiscorrection % public, not in raw alignment groups, else omit problem + {\ifhmode\ifnum\currentgrouptype=\aligngroupcode\else + \expandafter\expandafter\expandafter\font_emphasis_look + \fi\fi} + +\def\font_emphasis_look + {\begingroup + \futurelet\nexttoken\font_emphasis_test} + +\def\font_emphasis_test + {\ifcat\noexpand\nexttoken,% still ok? + \expandafter\font_emphasis_a + \else + \expandafter\font_emphasis_b + \fi} + +\def\font_emphasis_a + {\futurelet\nexttoken\font_emphasis_correction} + +\def\font_emphasis_correction + {\setbox\scratchbox\hbox{\nexttoken}% tricky as next can be a macro + \ifdim\ht\scratchbox=\zeropoint % probably a space + \expandafter\font_emphasis_b + \else\ifdim\ht\scratchbox<.3\exheight + \expandafter\expandafter\expandafter\endgroup + \else + \expandafter\expandafter\expandafter\font_emphasis_b + \fi\fi} + +\def\font_emphasis_b + {\scratchskip\lastskip + \ifdim\scratchskip=\zeropoint\relax % == \ifzeropt\scratchskip + \italiccorrection\relax + \else + \unskip\italiccorrection\hskip\scratchskip + \fi + \endgroup} + +%D We end with some examples which show the behavior when +%D some punctuation is met. We also show how the mechanism +%D adapts itself to bold, italic and slanted typing. +%D +%D \startbuffer +%D test {test}test \par +%D test {\sl test}test \par +%D test {\em test}test \par +%D test {\em test}--test \par +%D +%D test {test}, test \par +%D test {\em test}, test \par +%D +%D test {\em test {\em test {\em test} test} test} test \par +%D test {\bf test {\em test {\em test} test} test} test \par +%D test {\sl test {\em test {\em test} test} test} test \par +%D test {\it test {\em test {\em test} test} test} test \par +%D \stopbuffer +%D +%D \typebuffer +%D +%D We get: +%D +%D \startpacked +%D \getbuffer +%D \stoppacked + +%D \macros +%D {emphbf,emphit,emphsl,emphtf} +%D +%D The next emphasis alternatives are for \THANH. They adapt +%D their style as good as possible. These macros are obsolete +%D in \MKIV. + +\unexpanded\def\emphbf{\groupedcommand{\bf\def\emphit{\bi}\def\emphsl{\bs}}{}} +\unexpanded\def\emphit{\groupedcommand{\it\def\emphbf{\bi}\def\emphsl{\sl}}{}} +\unexpanded\def\emphsl{\groupedcommand{\sl\def\emphbf{\bs}\def\emphit{\it}}{}} +\unexpanded\def\emphtf{\groupedcommand{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}{}} + +%D \startbuffer +%D TEXT {\emphbf text \emphit text \emphtf text \emphsl text} TEXT +%D TEXT \emphbf{text \emphit{text} \emphtf{text} \emphsl{text}} TEXT +%D \stopbuffer +%D +%D \typebuffer +%D \startlines +%D \getbuffer +%D \stoplines + +\protect \endinput diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua index fc255d395..331ffbdfa 100644 --- a/tex/context/base/font-ext.lua +++ b/tex/context/base/font-ext.lua @@ -797,7 +797,7 @@ local function showboundingbox(tfmdata,key,value) end end -fonts.constructors.newfeatures("otf").register { +registerotffeature { name = "boundingbox", description = "show boundingbox", manipulators = { diff --git a/tex/context/base/font-gds.mkiv b/tex/context/base/font-gds.mkiv index d0c5be17d..2305a0edd 100644 --- a/tex/context/base/font-gds.mkiv +++ b/tex/context/base/font-gds.mkiv @@ -42,7 +42,7 @@ \unexpanded\def\setfontcolorscheme % will move to the lua end {\ctxcommand{enablefontcolorschemes()}% - \xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}% + \unexpanded\xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}% \setfontcolorscheme} \unexpanded\def\resetfontcolorscheme diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv deleted file mode 100644 index a76418478..000000000 --- a/tex/context/base/font-ini.mkiv +++ /dev/null @@ -1,4691 +0,0 @@ -%D \module -%D [ file=font-ini, -%D version=1998.09.11, % (second) -%D version=2001.02.20, % (third) -%D title=\CONTEXT\ Font Macros, -%D subtitle=Initialization, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -% runtime commands will move to modules - -% at some point fontclass will always have a value so that quite some -% code can go away - -% todo: reconsider design sizes ... kick 'm out which removes the size -% code and simplifies things considerably. After all, there will be no -% lm math in sizes. - -% todo: (so that we can delay font loading to \starttext - -% simplification ... we no longer deal with specific mmtfa specifications - -% todo: always fontclass, then less testing -% todo: bodyfontvariable: parent - -% \definefontfeature[smallcaps][smcp=yes,script=latn] -% \definefontfeature[smallcaps][SmallCapitals=yes,script=latn] -% \definefontfeature[smallcaps][Small Capitals=yes,script=latn] -% \definefontfeature[smallcaps][small capitals=yes,script=latn] -% \definefontfeature[smallcaps][smallcapitals=yes,script=latn] -% -% \definedfont[cambria*smallcaps] test - -% \starttext -% \definefontfeature[basekerned][default][mode=base] -% \definefontfeature[nodekerned][default][mode=node] -% \definefontfeature[nonekerned][default][mode=base,kern=no] -% \setupcolors[state=start] -% \startoverlay -% {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }} -% {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }} -% {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }} -% \stopoverlay -% \stoptext - -% \enabletrackers[otf.kerns] -% -% \definefontfeature[withkern][default][mode=node] -% \definefontfeature[nokern] [default][mode=node,kern=no] -% \definefontfeature[single] [default][mode=node,cpsp=yes] -% \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no] -% -% {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} -% {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} -% {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} -% {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} - -% figure out why \fontbody is not expanded - -\writestatus{loading}{ConTeXt Font Macros / Initialization} - -\registerctxluafile{font-ini}{1.001} -\registerctxluafile{font-log}{1.001} -\registerctxluafile{font-con}{1.001} -\registerctxluafile{font-enc}{1.001} -%registerctxluafile{font-agl}{1.001} % loaded when needed, saves 100K in format -\registerctxluafile{font-cid}{1.001} % cid maps -\registerctxluafile{font-map}{1.001} -\registerctxluafile{font-syn}{1.001} - -\registerctxluafile{font-tfm}{1.001} - -\registerctxluafile{font-afm}{1.001} - -\registerctxluafile{font-oti}{1.001} % otf initialization -\registerctxluafile{font-ott}{1.001} % otf tables (first) -\registerctxluafile{font-otf}{1.001} % otf main -\registerctxluafile{font-otb}{1.001} % otf main base -\registerctxluafile{node-inj}{1.001} % we might split it off -\registerctxluafile{font-otn}{1.001} % otf main node -\registerctxluafile{font-otd}{1.001} % otf dynamics (does an overload) -\registerctxluafile{font-ota}{1.001} % otf analyzers (needs dynamics) -\registerctxluafile{font-otp}{1.001} % otf pack -\registerctxluafile{font-otc}{1.001} % otf context -\registerctxluafile{font-oth}{1.001} % otf helpers - -\registerctxluafile{font-pat}{1.001} % patchers - -\registerctxluafile{node-fnt}{1.001} % here - -\registerctxluafile{font-lua}{1.001} - -\registerctxluafile{font-vf} {1.001} -\registerctxluafile{font-enh}{1.001} - -\registerctxluafile{font-gds}{1.001} % currently only otf - -\registerctxluafile{font-def}{1.001} -\registerctxluafile{font-ctx}{1.001} % after def as it overloads - -\registerctxluafile{font-ext}{1.001} -\registerctxluafile{font-fbk}{1.001} -\registerctxluafile{font-chk}{1.001} - -\registerctxluafile{font-aux}{1.001} - -\unprotect - -% \def\fontrange#1% -% {\dofontrange{#1 =\bodyfontsize}} -% -% \def\dofontrange#1% -% {\dodofontrange#1 \relax}% \fontstringA -% -% \def\dodofontrange#1 #2 % -% {\ifdim\bodyfontsize#2% -% #1\expandafter\gobbleuntilrelax -% \else -% \expandafter\dodofontrange -% \fi} -% -% \definefont -% [crap] -% [\fontrange -% {Regular <10pt -% RegularBold <12pt -% RegularSlanted <15pt -% Regular} sa 1] -% -% may be better: -% -% \definefontrange -% [crap] -% [Regular <10pt -% RegularBold <12pt -% RegularSlanted <15pt] -% [Regular sa 1] -% -% -% \dostepwiserecurse{2}{15}{1} -% {{\switchtobodyfont[\recurselevel pt]\crap test}\endgraf} - -% adapted, else wrong interlinespace - -\unexpanded\def\setfontparameters - {\synchronizefontsfalse - \the\everybodyfont - \synchronizefontstrue} - -% handy - -\newcounter\pushedfont - -\unexpanded\def\savefont - {\edef\savedfont{\the\font}% - \pushmacro\savedfont} - -\unexpanded\def\restorefont - {\popmacro\savedfont - \savedfont} - -\unexpanded\def\pushcurrentfont - {\edef\popcurrentfont - {\def\noexpand\fontbody {\fontbody}% - \def\noexpand\fontstyle {\fontstyle}% - \def\noexpand\fontalternative{\fontalternative}% - \def\noexpand\fontsize {\fontsize}% - \checkbigmathsynchronization - \synchronizefont}} - -% \definetypeface[one][rm][serif][computer-roman][default] -% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9] -% -% {\one \bf test \two test} -% {\one \bf test \pushcurrentfont \two \popcurrentfont test} - -%D \macros -%D {definedfont,startfont,doiffontcharelse} -%D -%D A couple of relatively new macros: - -% \newtoks \everydefinedfont % not ot be confused with \everydefinefont - -\let\thedefinedfont\relax - -\def\dodefinedfont[#1]% - {\featureinheritancemode\featureinheritancefontonly - \iffirstargument\definefont[thedefinedfont][#1]\fi % we can speed this one up - \thedefinedfont - \the\everydefinedfont} - -\unexpanded\def\definedfont - {\dosingleempty\dodefinedfont} - -\unexpanded\def\startfont - {\begingroup\definedfont} - -\unexpanded\def\stopfont - {\endgroup} - -\def\doiffontcharelse#1#2% - {\begingroup - \definedfont[#1]% - \iffontchar\font#2\relax - \endgroup\expandafter\firstoftwoarguments - \else - \endgroup\expandafter\secondoftwoarguments - \fi} - -%D For more detailed (and historic information) we refer to the file -%D \type {font-ini.mkii}. Here we have a much simplified lower level -%D implementation due to a different approach to math. Also the chapter -%D on fonts in the reference manual explains a lot. - -%D \macros -%D {rm,ss,tt,hw,cg} -%D -%D Fonts are defined in separate files. When we define a font, -%D we distinguish between several styles. In most cases we will -%D use: -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC roman regular serif \NC \type{\rm} \NC\FR -%D \NC sansserif sans support \NC \type{\ss} \NC\MR -%D \NC type teletype mono \NC \type{\tt} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D The number of styles is not limited to these three. When -%D using Lucida Bright we can for instance also define: -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC handwritten \NC \type{\hw} \NC\FR -%D \NC calligraphic \NC \type{\cg} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D Within such a font set (\type{cmr}) and style (\type{\rm}) -%D we can define a number of text font alternatives: -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC typeface \NC \type{\tf} \NC\FR -%D \NC boldface \NC \type{\bf} \NC\MR -%D \NC slanted \NC \type{\sl} \NC\MR -%D \NC italic \NC \type{\it} \NC\MR -%D \NC boldslanted \NC \type{\bs} \NC\MR -%D \NC bolditalic \NC \type{\bi} \NC\MR -%D \NC smallcaps \NC \type{\sc} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D Internally fonts are stored as combination of size, style -%D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. -%D Users are not confronted with sizes, but use the style or -%D style+alternative to activate them. -%D -%D During the definition of a bodyfont one can also declare the -%D available larger alternatives: -%D -%D \starttyping -%D \tf \tfa \tfb \tfc ... -%D \bf \bfa \bfb \bfc ... -%D \sl \sla \slb \slc ... -%D \stoptyping -%D -%D The smaller ones are automatically supplied and derived from -%D the the bodyfont environment. -%D -%D \starttyping -%D \tfx \tfxx -%D \bfx \bfxx -%D \slx \slxx -%D \stoptyping -%D -%D There are only two smaller alternatives per style. The -%D larger alternatives on the other hand have no limitations. -%D -%D These larger alternatives are mostly used in chapter and -%D section titles or on title pages. When one switches to a -%D larger alternative, the bold an other ones automatically -%D adapt themselves: -%D -%D \startbuffer -%D \tfd Hi \bf there\sl, here \tfb I \bf am -%D \stopbuffer -%D -%S \startnarrower -%D \typebuffer -%S \stopnarrower -%D -%D therefore becomes: -%D -%D \startexample -%D \getbuffer -%D \stopexample -%D -%D Maybe this mechanism isn't always as logic, but as said -%D before, we tried to make it as intuitive as possible. -%D -%D So a specific kind of glyph can be characterized by: -%D -%D \startnarrower -%D family (cmr) + bodyfont (12pt) + style (rm) + alternative (bf) + size (a) -%D \stopnarrower -%D -%D The last component (the size) is optional. -%D -%D We introduced \type{\tf} as command to call for the current -%D normally sized typeface. This commands results in roman, -%D sans serif, teletype or whatever style is in charge. Such -%D rather massive switches of style sometimes take more -%D processing time than comfortable. Of course there is a -%D workaround for this: we can call fonts directly by means of -%D commands like: -%D -%D \starttyping -%D \rmtf \sssl \tttf \rmbsa -%D \stoptyping -%D -%D One should realize that this fast calls have limitations, -%D they lack for instance automatic super- and subscript -%D support. -%D -%D This leaves us two more commands: \type{\tx} and -%D \type{\txx}. These activate a smaller and even more smaller -%D font than the current one and adapt themselves to the -%D current alternative, so when \type{\bf} is active, -%D \type{\tx} gives a smaller boldface, which in turn can be -%D called directly by \type{\bfx}. -%D -%D These two smaller alternatives are specified by the bodyfont -%D environment and therefore not necessarily have similar sizes -%D as \type{\scriptsize} and \type{\scriptscriptsize}. The main -%D reason for this incompatibility (which can easily be undone) -%D lays in the fact that we often want a bit bigger characters -%D than in math mode. In \CONTEXT\ for instance the \type{\tx} -%D and \type{\txx} commands are used for surrogate -%D \cap{smallcaps} which support both nesting and alternatives, -%D like in {\bf\cap{a \cap{small} world}}, which was typeset by -%D -%D \starttyping -%D \bf\cap{a \cap{small} world} -%D \stoptyping -%D -%D And compare $\rm \scriptstyle THIS$ with the slightly larger -%D \cap{THIS}: \ruledhbox{$\rm \scriptstyle scriptstyle: THIS$} -%D or \ruledhbox{\cap{x style: THIS}} makes a big difference. -%D -%D The \type{x..d} sizes should be used grouped. If you -%D don't group them, i.e. call them in a row, \CONTEXT\ will -%D not be able to sort out your intention (\type {x} inside -%D \type {d} inside \type {x}. etc.). The following table -%D demonstrates this: -%D -%D \def\FontState{\setstrut\ruledhbox{\strut Hello}} -%D -%D \starttabulate[|||||] -%D \HL -%D \NC \rlap{\quad\bf grouped} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR -%D \HL -%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR -%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR -%D \NC \type{\tf} \NC \tf \FontState \NC \tf \tx \FontState \NC \tf \txx \FontState \NC \NR -%D \NC \type{\tfa} \NC \tfa \FontState \NC \tfa \tx \FontState \NC \tfa \txx \FontState \NC \NR -%D \NC \type{\tfb} \NC \tfb \FontState \NC \tfb \tx \FontState \NC \tfb \txx \FontState \NC \NR -%D \NC \type{\tfc} \NC \tfc \FontState \NC \tfc \tx \FontState \NC \tfc \txx \FontState \NC \NR -%D \NC \type{\tfd} \NC \tfd \FontState \NC \tfd \tx \FontState \NC \tfd \txx \FontState \NC \NR -%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR -%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR -%D \HL -%D \stoptabulate -%D -%D \blank -%D -%D \starttabulate[|||||] -%D \HL -%D \NC \rlap{\quad\bf stacked} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR -%D \HL -%D \NC \type{\tfx} -%D \NC \tfx \FontState -%D \NC \tfx \tx \FontState -%D \NC \tfx \txx \FontState -%D \NC \NR -%D \NC \type{\tfxx} -%D \NC \tfx\tfxx \FontState -%D \NC \tfx\tfxx \tx \FontState -%D \NC \tfx\tfxx \txx \FontState -%D \NC \NR -%D \NC \type{\tf} -%D \NC \tfx\tfxx\tf \FontState -%D \NC \tfx\tfxx\tf \tx \FontState -%D \NC \tfx\tfxx\tf \txx \FontState -%D \NC \NR -%D \NC \type{\tfa} -%D \NC \tfx\tfxx\tf\tfa \FontState -%D \NC \tfx\tfxx\tf\tfa \tx \FontState -%D \NC \tfx\tfxx\tf\tfa \txx \FontState -%D \NC \NR -%D \NC \type{\tfb} -%D \NC \tfx\tfxx\tf\tfa\tfb \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb \tx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb \txx \FontState -%D \NC \NR -%D \NC \type{\tfc} -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \tx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \txx \FontState -%D \NC \NR -%D \NC \type{\tfd} -%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \tx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \txx \FontState -%D \NC \NR -%D \NC \type{\tfx} -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \tx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \txx \FontState -%D \NC \NR -%D \NC \type{\tfxx} -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \tx \FontState -%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \txx \FontState -%D \NC \NR -%D \HL -%D \stoptabulate -%D -%D Remark: math support has changed a bit. - -%D \macros -%D {uchar} -%D -%D This macro prepares \CONTEXT\ for \UNICODE\ support. By -%D defining it here, we have at least an safeguard for utility -%D file reading. - -\ifdefined\uchar\else \unexpanded\def\uchar#1#2{[#1,#2]} \fi - -%D We define some (very private) constants to improve speed, -%D memory usage and consistency. - -\installcorenamespace {fontfile} % file synonyms -\installcorenamespace {fontsize} % bodyfont size prefix (12pt etc) -\installcorenamespace {fontstyle} % full style prefix (roman etc) -\installcorenamespace {fontshortstyle} % short style prefix (rm etc) -\installcorenamespace {fontclassyes} % fontclass -\installcorenamespace {fontclassnop} % nofontclass - -%D \macros -%D {fontclass, defaultfontclass} -%D -%D The fontclass model was introduced a while after we implement -%D the basic font model and at that time we still defaulted to -%D no model at all. Nowadays we default to the \type {modern} -%D fontclass. - -\let\fontclass \empty -\let\defaultfontclass\empty - -\def\fontclassname#1#2% - {\ifcsname\??fontfile#1#2\endcsname - \fontclassname{#1}{\csname\??fontfile#1#2\endcsname}% - \else\ifcsname\??fontfile#2\endcsname - \fontclassname{#1}{\csname\??fontfile#2\endcsname}% - \else - #2% - \fi\fi} - -\def\defineclassfontsynonym - {\dotripleargument\dodefineclassfontsynonym} - -\def\dodefineclassfontsynonym[#1][#2][#3]% - {\definefontsynonym[#1][\fontclassname{#2}{#3}]} - -%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] -% -%\defineclassfontsynonym [KopFont] [officina] [SerifBold] -%D \macros -%D {textonly} -%D -%D Traditionally math has a big impact on font definitions, mainly -%D because we need to define alphabet variants using families and -%D fonts. This means that one can easily get 10 fonts loaded per -%D math size. In \MKIV\ we use a different approach: one family -%D which has either a virtual font made of traditional fonts, or -%D an \OPENTYPE\ font that has it all. -%D -%D We currently use only one math family but in the future we -%D might consider using a second one for bold math. For the -%D moment we keep the \MKII\ method of using a token register -%D for definitions but we already dropped the text and symbols -%D ones since they now live in the same family. - -\newtoks \mathstrategies - -\newif\ifsynchronizemathfonts \synchronizemathfontstrue - -\def\synchronizemath % math stuff in mmode - {\ifsynchronizemathfonts\the\mathstrategies\fi} - -\def\textonly{\synchronizemathfontsfalse} % document this - -%D The main math font definer. We have removed some optimized -%D code simply because we now always have a fontclass. We could -%D check for fontclass being default or empty and save a few -%D tests but it does not help us when no math is defined. - -%D Because we want to keep mr=.. and mb=... settings (read: not -%D break downward compatibility by enforcing mrlr etc) we need a -%D bit more code that optimal. - -\let\mrfam \zerocount % math regular -\let\mrfamlr\plusone % math regular l2r -\let\mrfamrl\plustwo % math regular r2l - -\let\mbfam \plusthree % math bold -\let\mbfamlr\plusfour % math bold l2r -\let\mbfamrl\plusfive % math bold r2l - -\definesystemattribute[mathfamily][public] - -\newconditional\bidirectionalmathstrategy % can be default, not that much overhead: \settrue\bidirectionalmathstrategy -\newconditional\completeboldmathstrategy \settrue\completeboldmathstrategy - -\def\mathtextsuffix {-text} -\def\mathscriptsuffix {-script} -\def\mathscriptscriptsuffix{-scriptscript} - -\let\currentmathsize\empty - -\def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi} - -% Beware: truefontname also does a fallback on defaultfontclass so there -% can be some interference here, which is why we use a different method -% for bold. - -\def\dodosetmathfamily - {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse - \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else - \ifcsname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue - \csname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \dodosetmathfamilyx - \fi\fi} - -\def\dodosetmathfamilyx - {\ifcsname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse - \csname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else - \ifcsname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue - \csname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \dodosetmathfamilyxx - \fi\fi} - -\def\dodosetmathfamilyxx - {\ifcsname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse - \csname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else - \ifcsname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue - \csname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \nullfont \autofontsizetrue - \fi\fi} - -\def\dosetmathfamilyindeed#1#2% \currentmathsize etc are also used later on - {\let\savedfontbody\fontbody - \let\fontfamily#2% - \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetmathfamily\scriptscriptfont#1\font - \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetmathfamily\scriptfont #1\font - \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetmathfamily\textfont #1\font - \let\currentmathsize\empty - \let\fontbody\savedfontbody - \autofontsizefalse} - -\def\dodosetboldmathfamily#1#2#3% - {\ifcsname\fontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse - \csname\fontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname #1#2\font \else - \ifcsname\fontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue - \csname\fontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname #1#2\font \else - #1#2#1#3% - \fi\fi} - -% \def\dodosetboldmathfamily#1#2#3% -% {\ifcsname\fontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse -% \csname\fontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else -% \ifcsname\fontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue -% \csname\fontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \else -% \the#1#3% -% \fi\fi -% #1#2\font} - -\def\dosetboldmathfamilyindeed#1#2#3% \mbfam \c!mb \mrfam - {\let\savedfontclass\defaultfontclass - \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one - \let\savedfontbody\fontbody - \let\fontfamily#2% - \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetboldmathfamily\scriptscriptfont#1#3% - \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetboldmathfamily\scriptfont #1#3% - \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetboldmathfamily\textfont #1#3% - \let\currentmathsize\empty - \let\fontbody\savedfontbody - \let\defaultfontclass\savedfontclass - \autofontsizefalse} - -% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0)) -% -% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know -% all sizes so we postpone the optimization to the first starttext -% -% pitfall: we should reset 'm when a fontclass name is reused - -\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions - -\def\dosetmathfamily#1#2% fam tag - {\ifconditional\optimizemathfontdefinitions - \ifcsname*\fontclass\textface\c!mm#21\fontsize1*\endcsname - \dopresetmathfamilyindeed#1#2% - \else - \dosetmathfamilyindeed#1#2% - \fi - \else - \dosetmathfamilyindeed#1#2% - \fi} - -\def\dosetboldmathfamily#1#2#3% fam tag - {\ifconditional\optimizemathfontdefinitions - \ifcsname*\fontclass\textface\c!mm#21\fontsize1*\endcsname - \dopresetmathfamilyindeed#1#2% - \else - \dosetboldmathfamilyindeed#1#2#3% - \fi - \else - \dosetboldmathfamilyindeed#1#2#3% - \fi} - -\def\dopresetmathfamilyindeed#1#2% - {\scriptscriptfont#1\csname*\fontclass\scriptscriptface\c!mm#23\fontsize3*\endcsname - \scriptfont #1\csname*\fontclass\scriptface \c!mm#22\fontsize2*\endcsname - \textfont #1\csname*\fontclass\textface \c!mm#21\fontsize1*\endcsname} - -\let\resetfontclassmathfamilies\gobbleoneargument -\let\dosavefontclassmathfamily \gobbletwoarguments - -% \appendtoks -% \glet\dosavefontclassmathfamily\dosavefontclassmathfamilyindeed -% \to \everystarttext - -% It would be nice if characters could be defined in a neutral way (say fam 255) and -% be mapped to a real family during noad list construction. However, this changes -% tex in critical places so for the moment we simulate this using manipulation. - -\appendtoks - % new per 20100817 - \checkbodyfontenvironment[\scriptscriptface]% pretty slow when many switches - \checkbodyfontenvironment[\scriptface]% - \checkbodyfontenvironment[\textface]% -\to \mathstrategies - -% For tracing purposes we use three families but in l2r mode 1 and 2 are copies of 0 -% while in rl mode 0 is a copy of 1. There is no real overhead involved in this. This -% also permits different font definitions for normal and mixed. - -\appendtoks % can be analyzed once - % why here .. - \edef\@@fontclassdirection{\ifcsname\fontclass\c!mm\s!direction\endcsname\csname\fontclass\c!mm\s!direction\endcsname\fi}% - % ... - \ifx\@@fontclassdirection\v!both - \settrue\bidirectionalmathstrategy - \else - \setfalse\bidirectionalmathstrategy - \fi -\to \mathstrategies - -\def\bidirectionalmathstrategyyes - {\dosetmathfamily \mrfamlr\c!mrlr - \dosetmathfamily \mrfamrl\c!mrrl - \textfont \mrfam \textfont \mrfamlr - \scriptfont \mrfam \scriptfont \mrfamlr - \scriptscriptfont\mrfam \scriptscriptfont\mrfamlr} - -\def\bidirectionalmathstrategynop - {\dosetmathfamily \mrfam \c!mr - \textfont \mrfamrl\textfont \mrfam - \scriptfont \mrfamrl\scriptfont \mrfam - \scriptscriptfont\mrfamrl\scriptscriptfont\mrfam - \textfont \mrfamlr\textfont \mrfam - \scriptfont \mrfamlr\scriptfont \mrfam - \scriptscriptfont\mrfamlr\scriptscriptfont\mrfam} - -\appendtoks - \ifconditional\bidirectionalmathstrategy - \bidirectionalmathstrategyyes - \else - \bidirectionalmathstrategynop - \fi -\to \mathstrategies - -\def\completeboldmathstrategyyesbidi - {\dosetboldmathfamily\mbfamlr\c!mblr\mrfamlr - \dosetboldmathfamily\mbfamrl\c!mbrl\mrfamrl - \textfont \mbfam \textfont \mbfamlr - \scriptfont \mbfam \scriptfont \mbfamlr - \scriptscriptfont\mbfam \scriptscriptfont\mbfamlr} - -\def\completeboldmathstrategyyes - {\dosetboldmathfamily\mbfam\c!mb\mrfam - \textfont \mbfamrl\textfont \mbfam - \scriptfont \mbfamrl\scriptfont \mbfam - \scriptscriptfont\mbfamrl\scriptscriptfont\mbfam - \textfont \mbfamlr\textfont \mbfam - \scriptfont \mbfamlr\scriptfont \mbfam - \scriptscriptfont\mbfamlr\scriptscriptfont\mbfam} - -\def\completeboldmathstrategynop - {\textfont \mbfam \textfont \mrfam - \scriptfont \mbfam \scriptfont \mrfam - \scriptscriptfont\mbfam \scriptscriptfont\mrfam - \textfont \mbfamrl\textfont \mrfamrl - \scriptfont \mbfamrl\scriptfont \mrfamrl - \scriptscriptfont\mbfamrl\scriptscriptfont\mrfamrl - \textfont \mbfamlr\textfont \mrfamlr - \scriptfont \mbfamlr\scriptfont \mrfamlr - \scriptscriptfont\mbfamlr\scriptscriptfont\mrfamlr} - -\def\applycompleteboldmathstrategy - {\ifconditional\completeboldmathstrategy - \ifconditional\bidirectionalmathstrategy - \completeboldmathstrategyyesbidi - \else - \completeboldmathstrategyyes - \fi - \else - \completeboldmathstrategynop - \fi} - -\appendtoks - \applycompleteboldmathstrategy -\to \mathstrategies - -\appendtoks - \fam\defaultmathfamily % all characters and symbols are in this family -\to \everymathematics - -\unexpanded\def\synchronizemathfamilymr - {\attribute\mathfamilyattribute\ifconditional\bidirectionalmathstrategy - \ifconditional\c_math_right_to_left - \plustwo - \else - \plusone - \fi - \else - \zerocount - \fi} - -\unexpanded\def\synchronizemathfamilymb - {\attribute\mathfamilyattribute\ifconditional\bidirectionalmathstrategy - \ifconditional\c_math_right_to_left - \ifconditional\pseudoboldmathstate\pluseight\else\plusfive\fi - \else - \ifconditional\pseudoboldmathstate\plusseven\else\plusfour\fi - \fi - \else - \ifconditional\pseudoboldmathstate\plussix\else\plusthree\fi - \fi} - -\installcorenamespace{fontmathsynchronizer} -\installcorenamespace{fontmathstoredstrategy} - -\letvalue{\??fontmathsynchronizer\c!tf }\synchronizemathfamilymr -\letvalue{\??fontmathsynchronizer\c!sl }\synchronizemathfamilymr -\letvalue{\??fontmathsynchronizer\c!it }\synchronizemathfamilymr -\letvalue{\??fontmathsynchronizer\c!bf }\synchronizemathfamilymb -\letvalue{\??fontmathsynchronizer\c!bs }\synchronizemathfamilymb -\letvalue{\??fontmathsynchronizer\c!bi }\synchronizemathfamilymb -\letvalue{\??fontmathsynchronizer\empty}\synchronizemathfamilymr - -\def\synchronizemathfamily - {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname} - -\ifdefined \fontid - - \appendtoks - \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree - \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathpartialboldstrategy % enables partial bold math - \else - \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathfullboldstrategy % enables full bold math - \fi - \to \mathstrategies - -\else - - \appendtoks - \edef\currentmathfontmr{\fontname\textfont\zerocount}% - \edef\currentmathfontmb{\fontname\textfont\plusthree}% - \ifx\currentmathfontmr\currentmathfontmb - \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathpartialboldstrategy % enables partial bold math - \else - \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathfullboldstrategy % enables full bold math - \fi - \to \mathstrategies - -\fi - -\def\synchronizemathboldstrategy {\csname\??fontmathstoredstrategy\fontclass\endcsname} - -\newconditional\pseudoboldmathstate - -\def\dosetmathpartialboldstrategy{\settrue \pseudoboldmathstate} -\def\dosetmathfullboldstrategy {\setfalse\pseudoboldmathstate} - -\appendtoks - \synchronizemathboldstrategy -\to \everymathematics - -% Bold is somewhat special as we might want both full-bold-math mixed -% regular-math, as well as automatic adaption to outer bold (in titles -% and inline text bold) so we will need explicit switches as well as -% an automatic one. (We will use lucida as an example.) - -\unexpanded\def\mr - {\ifmmode - \synchronizemathfamilymr - \else - \setcurrentfontalternative\c!mr - \fi} - -\unexpanded\def\mb - {\ifmmode - \synchronizeboldfamilymb - \else - \setcurrentfontalternative\c!mb - \fi} - -\appendtoks - \synchronizemathfamily % auto bold -\to \everymathematics - -%D All used styles, like rm, ss and tt, are saved in a comma -%D separated list. Appart from practical limitations one can -%D define as many styles as needed. - -\def\fontrelativesizelist{\s!text,\s!script,\s!scriptscript,\c!x,\c!xx,\c!big,\c!small} - -%D There are several ways to specify a font. Three of them are -%D pure \TeX\ ones, the fourth one is new: -%D -%D \starttyping -%D \font\name=cmr12 -%D \font\name=cmr12 at 10pt -%D \font\name=cmr12 scaled 2 -%D \font\name=cmr12 sa 1.440 -%D \stoptyping -%D -%D The non||\TEX\ alternative \type{sa} stands for {\em scaled -%D at}. This means as much as: scale the bodyfontsize with this -%D factor. The scaled option is not that useful as one needs to -%D know the design size. -%D -%D Because \type {sa} (scaled at) and \type {mo} (mapped on) -%D are not low level \TEX\ supported alternatives, we have to -%D test for it ourselves. In doing so, we need an auxiliary -%D \DIMENSION. We cannot use \type{\scratchdimen} because font -%D loading can happen at any moment due to postponed loading. -%D We could instead have used dirty grouping tricks, but this -%D one works too. - -% \enableexperiments[fonts.autorscale] -% -% \starttypescript[mscore] -% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default] -% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860] -% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065] -% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020] -% \stoptypescript -% -% \starttext -% \setupbodyfont[mscore,12pt] -% \startTEXpage -% test \ss test \tt test -% \stopTEXpage -% \stoptext - -\let\defaultrelativefontsize \plusone -\let\localrelativefontsize \plusone -\def\localabsolutefontsize {\fontbody} - -\let\relativefontsize \defaultrelativefontsize - -% \def\saverelativefontsize#1#2% #1=rm|ss|.. #2=waarde -% {\setxvalue{\fontclass#1\s!rscale}{#2}} - -\def\checkrelativefontid - {\ifcsname\??tf\fontclass\s!rname\endcsname - \@EA\let\@EA\relativefontid\csname\??tf\fontclass\s!rname\endcsname - \else - \@EA\xdef\csname\??tf\fontclass\s!rname\endcsname{\the\lastfontid}% - \let\relativefontid\empty - \fi} - -\def\checkrelativefontid % not yet supported as we then need to trigger \rm\tf or so first - {\let\relativefontsize\minusone - \let\relativefontsize\defaultrelativefontsize} - -\def\checkrelativefontsize#1% - {\edef\relativefontsize - {\ifcsname\fontclass#1\s!rscale\endcsname - \csname\fontclass#1\s!rscale\endcsname - \else\ifcsname\defaultfontclass#1\s!rscale\endcsname - \csname\defaultfontclass#1\s!rscale\endcsname - \else - \defaultrelativefontsize - \fi\fi}% - \ifx\relativefontsize\v!auto - \let\relativefontsize\plusone - \checkrelativefontid - \else - \let\relativefontid\minusone - \fi} - -%D Scaling macros: -%D -%D This system is somewhat complicated by two (possible conflicting) -%D demands: -%D -%D \startitemize -%D \item We support wildcards like \type {sa *} which will adapt -%D to the current size. This is also the default specification. -%D \item We support named scales like \type {sa d}; beware: \type -%D {x} and \type {xx} are valid scales but they are not alway -%D the same as the ones used in for instance \type {\bfx} because -%D there the sized come from the bodyfont environment. In the -%D future there maybe a switch that also honors the environment -%D in named scales. -%D \stopitemize - -%D Keep in mind that the smaller sizes are just for text super and -%D subscripts while larger sizes can be used in titles where for -%D instance math follows the size. - -% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par -% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par -% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par -% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par -% -% *:x{\definedfont[Serif sa *]x}\par -% 1:x{\definedfont[Serif sa 1]x}\par -% 2:x{\definedfont[Serif sa 2]x}\par -% 3:x{\definedfont[Serif sa 3]x}\par -% 4:x{\definedfont[Serif sa 4]x}\par -% 5:x{\definedfont[Serif sa 5]x}\par -% -% {\definedfont[cmbx10 at 10pt]x\definedfont[cmbx8 at 10pt]x} - -\def\safontscale{\number\dimexpr\localabsolutefontsize\relax} -\def\mofontscale{\number\dimexpr\setmappedfontsize\localabsolutefontsize\relax} - -\let\somefontname\s!unknown -\let\somefontspec\s!unknown -\let\somefontsize\zerocount - -\newcount\scaledfontmode -\newdimen\scaledfontsize -\newtoks \everydefinefont -\newcount\lastfontid - -\def\currentfontbodysize - {\ifcsname\??ft\s!default\somefontsize\endcsname - \csname\??ft\s!default\somefontsize\endcsname - \else - \somefontsize - \fi} - -\let\relativefontid\empty - -% 0 = none -% 1 = fontonly -% 2 = classonly -% 3 = fontfirst -% 4 = classfirst - -\setnewconstant\featureinheritancefontnone \zerocount -\setnewconstant\featureinheritancefontonly \plusone -\setnewconstant\featureinheritanceclassonly \plustwo -\setnewconstant\featureinheritancefontfirst \plusthree -\setnewconstant\featureinheritanceclassfirst\plusfour - -\setnewconstant\featureinheritancedefault \featureinheritancefontfirst -\setnewconstant\featureinheritancemode \featureinheritancedefault - -\newdimen\scaledtextface - -\unexpanded\def\lowleveldefinefont#1#2% #2 = cs - {% we can now set more at the lua end - \ctxcommand{definefont_one(\!!bs\luaescapestring{#1}\!!es)}% the escapestring catches at \somedimen - % sets \scaledfontmode and \somefontname and \somefontsize - \ifcase\scaledfontmode\relax - % none, avoid the designsize if possible - \scaledfontsize-\plusthousand\scaledpoint - \or - % at - \scaledfontsize\somefontsize - \or - % sa - \scaledfontsize\localabsolutefontsize\relax - \scaledfontsize\currentfontbodysize\scaledfontsize - \or - % mo - \scaledfontsize\setmappedfontsize\localabsolutefontsize - \scaledfontsize\currentfontbodysize\scaledfontsize - \or - % scaled, don't use this one as it's unpredictable - \scaledfontsize-\somefontsize\scaledpoint - \fi - \relax - \scaledfontsize\localrelativefontsize\scaledfontsize - \ifautofontsize - \scaledfontsize\currentfontbodyscale\scaledfontsize - \scaledtextface\currentfontbodyscale\dimexpr\textface\relax - \else - \scaledtextface\textface - \fi - \edef\somefontspec{at \number\scaledfontsize sp}% - \edef\somefontfile{\truefontname\somefontname}% - \ifx\somefontfile\s!unknown - \edef\somefontfile{\defaultfontfile}% - \fi - \ifx\somefontfile\s!unknown - \edef\somefontfile{\defaultfontfile}% - \fi - \updatefontparameters - \updatefontclassparameters - \ctxcommand{definefont_two( - \ifx\fontclass\empty false\else true\fi, - "#2", % cs, trailing % is gone - \!!bs\somefontfile\!!es, - \number\scaledfontsize, - \number\featureinheritancemode, - "\@@fontclassfeatures", - "\@@fontfeatures", - "\@@fontclassfallbacks", - "\@@fontfallbacks", - 0\currentmathsize, - \number\scaledtextface, - "\relativefontid", % experiment - "\@@fontclassgoodies", % experiment (not yet used) - "\@@fontgoodies" % experiment - )}% - \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks) - \expandafter\let\expandafter\lastrawfontcall\csname#2\endcsname - \the\everydefinefont - \featureinheritancemode\featureinheritancedefault} - -% Why these expanded and rscale not ... maybe not worth the trouble (delayed -% expansion actually would be better i.e. macros in feature specs). Test -% without pre-expansion. - -\def\updatefontclassparameters - {\edef\@@fontclassdirection{\ifcsname\fontclass\fontstyle\s!direction\endcsname\csname\fontclass\fontstyle\s!direction\endcsname\fi}% - \edef\@@fontclassfeatures {\ifcsname\fontclass\fontstyle\s!features \endcsname\csname\fontclass\fontstyle\s!features \endcsname\fi}% - \edef\@@fontclassfallbacks{\ifcsname\fontclass\fontstyle\s!fallbacks\endcsname\csname\fontclass\fontstyle\s!fallbacks\endcsname\fi}% - \edef\@@fontclassgoodies {\ifcsname\fontclass\fontstyle\s!goodies \endcsname\csname\fontclass\fontstyle\s!goodies \endcsname\fi}} - -% resolve - -\def\@@thefeaturesyes#1% - {\ifcsname\??fontfile\fontclass#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile\fontclass#1\s!features \endcsname\else - \ifcsname\??fontfile #1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile #1\s!features \endcsname\else - \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thefeaturesyes \csname\??fontfile\fontclass #1\endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thefeaturesyes \csname\??fontfile #1\endcsname\else - \let \@@fontfeatures \empty \fi\fi\fi\fi} - -\def\@@thefallbacksyes#1% - {\ifcsname\??fontfile\fontclass#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile\fontclass#1\s!fallbacks\endcsname\else - \ifcsname\??fontfile #1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile #1\s!fallbacks\endcsname\else - \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thefallbacksyes\csname\??fontfile\fontclass #1\endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thefallbacksyes\csname\??fontfile #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi\fi\fi} - -\def\@@thegoodiesyes#1% - {\ifcsname\??fontfile\fontclass#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile\fontclass#1\s!goodies \endcsname\else - \ifcsname\??fontfile #1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile #1\s!goodies \endcsname\else - \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thegoodiesyes \csname\??fontfile\fontclass #1\endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thegoodiesyes \csname\??fontfile #1\endcsname\else - \let \@@fontgoodies \empty \fi\fi\fi\fi} - -\def\@@thefeaturesnop#1% - {\ifcsname\??fontfile#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile#1\s!features \endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thefeaturesnop \csname\??fontfile #1\endcsname\else - \let \@@fontfeatures \empty \fi\fi} - -\def\@@thefallbacksnop#1% - {\ifcsname\??fontfile#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile#1\s!fallbacks\endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thefallbacksnop\csname\??fontfile #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi} - -\def\@@thegoodiesnop#1% - {\ifcsname\??fontfile#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile#1\s!goodies \endcsname\else - \ifcsname\??fontfile #1\endcsname\@EA \@@thegoodiesnop \csname\??fontfile #1\endcsname\else - \let \@@fontgoodies \empty \fi\fi} - -\def\updatefontparametersyes - {\@@thefeaturesyes \somefontname - \@@thefallbacksyes\somefontname - \@@thegoodiesyes \somefontname} - -\def\updatefontparametersnop - {\@@thefeaturesnop \somefontname - \@@thefallbacksnop\somefontname - \@@thegoodiesnop \somefontname} - -\def\updatefontparameters - {\ifx\fontclass\empty\updatefontparametersnop\else\updatefontparametersyes\fi} - -\let\@@fontclassfeatures \empty -\let\@@fontclassfallbacks\empty - -\let\@@fontfallbacks\empty -\let\@@fontfeatures \empty -\let\@@fontgoodies \empty - -\let\@@hyphenchar \empty % todo, will go to encoding - -%D This brings down maps processing from 466 to 309 seconds -%D ($-33$\%) and mfonts from 42 to 34 seconds ($-15$\%). - -\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue - -%D When fontclasses are used, we define the font global, -%D since namespaces are used. Otherwise we parse the specs -%D each time. - -\let\fontfile\s!unknown - -% \definefontfeature[slanted] [default][slant=.25] -% \definefontfeature[stretched][default][stretch=2] -% -% \start \definedfont[SerifBold*slanted at 20pt] \ruledhbox{Test!} \stop -% \start \definedfont[SerifBold*stretched at 20pt] \ruledhbox{Test!} \stop - -% \definefontfeature[default] [liga=yes,texligatures=yes,texquotes=yes] -% \definefontfeature[default-caps][liga=yes,texligatures=yes,texquotes=yes,smcp=yes,script=latn] -% -% \starttypescript [serif] [palatino-nova-regular] [name] -% \definefontsynonym[Serif] [palatinonova-regular][features=default] -% \definefontsynonym[SerifCaps][palatinonova-regular][features=default-caps] % also sets Serif -% \stoptypescript -% -% \starttypescript [serif] [palatino-nova-regular] [name] -% \definefontsynonym[Serif] [palatinonova-regular*default] -% \definefontsynonym[SerifCaps] [palatinonova-regular*default-caps] -% \stoptypescript - -% \definetypeface[mainface][rm][serif][palatino-nova-regular][default] \setupbodyfont[mainface] -% -% \starttext -% ``Test'' -- --- ff fi fl \sc ``Test'' -- --- ff fi fl -% \stoptext - -% \starttext -% \definefont -% [blabla] -% [name:Latin Modern Something] -% \definefont -% [blabla] -% [file:texnansi-lmr10] -% \blabla test -% \definefont -% [blabla] -% [texnansi-lmtt10] -% \blabla test -% \stoptext - -% \starttext -% -% \setupcolors[state=start] -% -% \definefontfeature -% [default-base] -% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes] -% \definefontfeature -% [default-node] -% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes,mode=node] -% \definefontfeature -% [default-none] -% [script=latn,language=dflt,liga=yes,kern=no, tlig=yes,trep=yes] -% -% \startoverlay -% {\vtop{\color[red] {\font\test=name:lmroman12regular*default-node \test \input ward \input zapf \input linden }}} -% {\vtop{\color[green]{\font\test=name:lmroman12regular*default-base \test \input ward \input zapf \input linden }}} -% {\vtop{\color[blue] {\font\test=name:lmroman12regular*default-none \test \input ward \input zapf \input linden }}} -% \stopoverlay -% -% \blank -% -% \startoverlay -% {\vtop{\color[red] {\font\test=name:texgyrepagella*default-node \test \input ward \input zapf \input linden }}} -% {\vtop{\color[green]{\font\test=name:texgyrepagella*default-base \test \input ward \input zapf \input linden }}} -% {\vtop{\color[blue] {\font\test=name:texgyrepagella*default-none \test \input ward \input zapf \input linden }}} -% \stopoverlay -% -% \blank -% -% \startoverlay -% {\vtop{\color[red] {\font\test=name:palatinonovaregular*default-node \test \input ward \input zapf \input linden }}} -% {\vtop{\color[green]{\font\test=name:palatinonovaregular*default-base \test \input ward \input zapf \input linden }}} -% {\vtop{\color[blue] {\font\test=name:palatinonovaregular*default-none \test \input ward \input zapf \input linden }}} -% \stopoverlay -% -% \startoverlay -% {\vtop{\color[red] {\font\test=name:OfficinaSerifBookITC*default-node \test \input ward \input zapf \input linden }}} -% {\vtop{\color[green]{\font\test=name:OfficinaSerifBookITC*default-base \test \input ward \input zapf \input linden }}} -% {\vtop{\color[blue] {\font\test=name:OfficinaSerifBookITC*default-none \test \input ward \input zapf \input linden }}} -% \stopoverlay -% -% \definefontfeature[superdefault][default][compose=yes] -% -% {\font\oeps=name:lmroman10regular*default at 30pt \oeps test \char7683} -% {\font\oeps=name:lmroman10regular*superdefault at 30pt \oeps test \char7683} -% -% \stoptext - -\def \defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone -\edef\nullfontname {\fontname\nullfont} - -%D \macros -%D {everyfont,everyfontswitch} -%D -%D For special purposes, we provide a hook. - -% \newevery \everyfont \relax -% \newevery \everyfontswitch \relax - -%D We also accept \type{sa a}||\type{sa d} as specification. - -%D \macros -%D {definefontsynonym, doifelsefontsynonym, -%D expandfontsynonym, truefontname, truefontdata} -%D -%D While looking for fonts, fontsynonyms are used for accessing -%D the files! -%D -%D \starttyping -%D \definefontsynonym[Serif][Lucida-Bright] -%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi] -%D \stoptyping - -\def\classfont#1#2{#1#2} % \definefont[whatever][\classfont{xx}{yy} at 10pt] - -% We need to move the feature into the filename else it may be -% overloaded by another reference. For instance the definition of -% a regular and caps variant can use the same font. - -% We could use an indirect method ... store in 'array' and refer to -% slot. -% -% or nicer .. use parent chain - -\unexpanded\def\definefontsynonym[#1]#2[#3]% - {\edef\@@fontname{#1}% - \edef\@@fontfile{#3}% - \ifx\fontclass\empty - \expandafter\dodefinefontsynonymnop - \else - \expandafter\dodefinefontsynonymyes - \fi} - -\def\dodefinefontsynonymnop - {\@EA\let\csname\??fontfile\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion - \doifnextoptionalelse\dododefinefontsynonymnop\nonodefinefontsynonymnop} - -\def\dodefinefontsynonymyes - {\@EA\let\csname\??fontfile\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion - \doifnextoptionalelse\dododefinefontsynonymyes\nonodefinefontsynonymyes} - -\def\dododefinefontsynonymnop[#1]% - {\let\@@ff@@features \undefined - \let\@@ff@@fallbacks\undefined - \let\@@ff@@goodies \undefined - \expandafter\dogetfontparameternop#1,]=,} - -\def\dododefinefontsynonymyes[#1]% - {\let\@@ff@@features \undefined - \let\@@ff@@fallbacks\undefined - \let\@@ff@@goodies \undefined - \expandafter\dogetfontparameteryes#1,]=,} - -\def\dogetfontparameternop#1=#2,% - {\if]#1% - \dodododefinefontsynonymnop - \else - \expandafter\def\csname @@ff@@#1\endcsname{#2}% - \expandafter\dogetfontparameternop - \fi} - -\def\dogetfontparameteryes#1=#2,% - {\if]#1% - \dodododefinefontsynonymyes - \else - \expandafter\def\csname @@ff@@#1\endcsname{#2}% - \expandafter\dogetfontparameteryes - \fi} - -% helpers, some day these will be toks and counts - -\def\fntsetdefname {\global\let\somefontname\defaultfontfile} -\def\fntsetsomename{\gdef\somefontname} % {#1} -\def\fntsetnopsize {\let\somefontsize\empty} -\def\fntsetsomesize{\def\somefontsize} % {#1} - -% end of helpers - -\def\nonodefinefontsynonymnop - {\@EA\let\csname\??fontfile\@@fontname\s!features \endcsname\undefined - \@EA\let\csname\??fontfile\@@fontname\s!fallbacks\endcsname\undefined - \@EA\let\csname\??fontfile\@@fontname\s!goodies \endcsname\undefined} - -\def\nonodefinefontsynonymyes - {\global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!features \endcsname\undefined - \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!fallbacks\endcsname\undefined - \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!goodies \endcsname\undefined} - -\def\dodododefinefontsynonymnop - {\@EA\let\csname\??fontfile\@@fontname\s!features \endcsname\@@ff@@features - \@EA\let\csname\??fontfile\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \@EA\let\csname\??fontfile\@@fontname\s!goodies \endcsname\@@ff@@goodies} - -\def\dodododefinefontsynonymyes - {\global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!features \endcsname\@@ff@@features - \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies} - -\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater - -\unexpanded\def\setupfontsynonym - {\dodoubleempty\dosetupfontsynonym} - -\def\dosetupfontsynonym[#1][#2]% not yet supported, will do when needed - {} - -\def\truefontname#1% - {\@EA\dotruefontname#1*\empty*\relax} - -\def\dotruefontname#1*#2#3*#4\relax - {\ifcsname\??fontfile\fontclass#1\endcsname - \ifx#2\empty - \@EA\truefontname\csname\??fontfile\fontclass#1\endcsname - \else - \@EA\redotruefontname\csname\??fontfile\fontclass#1\endcsname*#2#3% - \fi - \else\ifcsname\??fontfile\defaultfontclass#1\endcsname - \ifx#2\empty - \@EA\truefontname\csname\??fontfile\defaultfontclass#1\endcsname - \else - \@EA\redotruefontname\csname\??fontfile\defaultfontclass#1\endcsname*#2#3% - \fi - \else\ifcsname\??fontfile#1\endcsname - \ifx#2\empty - \@EA\truefontname\csname\??fontfile#1\endcsname - \else - \@EA\redotruefontname\csname\??fontfile#1\endcsname*#2#3% - \fi - \else - #1\ifx#2\empty\else*#2#3\fi - \fi\fi\fi} - -\def\redotruefontname#1% - {\@EA\dodotruefontname#1*\relax} - -\def\dodotruefontname#1*#2\relax - {\ifcsname\??fontfile\fontclass#1\endcsname - \@EA\redotruefontname\csname\??fontfile\fontclass#1\endcsname - \else\ifcsname\??fontfile\defaultfontclass#1\endcsname - \@EA\redotruefontname\csname\??fontfile\defaultfontclass#1\endcsname - \else\ifcsname\??fontfile#1\endcsname - \@EA\redotruefontname\csname\??fontfile#1\endcsname - \else - #1% - \fi\fi\fi} - -\def\expandfontsynonym#1#2% #2 := onelevelexpansion(#1) - {\ifcsname\??fontfile\fontclass#2\endcsname - \expandafter\def\expandafter#1\expandafter{\csname\??fontfile\fontclass#2\endcsname}% - \else\ifcsname\??fontfile\defaultfontclass#2\endcsname - \expandafter\def\expandafter#1\expandafter{\csname\??fontfile\defaultfontclass#2\endcsname}% - \fi\fi} - -\def\doifelsefontsynonym#1% - {\ifcsname\??fontfile\fontclass#1\endcsname - \expandafter\firstoftwoarguments - \else\ifcsname\??fontfile\defaultfontclass#1\endcsname - \doubleexpandafter\firstoftwoarguments - \else - \doubleexpandafter\secondoftwoarguments - \fi\fi} - -% \definetypeface[palatino][rm][serif][palatino,allbold][default] -% -% \startfontclass[palatino] -% \definefontsynonym [Serif] [SerifBold] -% \definefontsynonym [SerifItalic] [SerifBoldItalic] -% \definefontsynonym [SerifSlanted] [SerifBoldSlanted] -% \definefontsynonym [SerifCaps] [SerifBold] -% \stopfontclass -% -% \setupbodyfont[palatino] - -\unexpanded\def\startfontclass - {\dosingleempty\dostartfontclass} - -\def\dostartfontclass[#1]% - {\pushmacro\fontclass - \doifelse{#1}\v!each - {\let\fontclass\empty} - {\doifsomething{#1}{\def\fontclass{#1}}}} - -\unexpanded\def\stopfontclass - {\popmacro\fontclass} - -%D \macros -%D {tracedfontname} -%D -%D A goody: - -\def\tracedfontname#1% - {#1\ifcsname\??fontfile\fontclass#1\endcsname - \@EA\tracedfontname\csname\??fontfile\fontclass#1\endcsname - \else\ifcsname\??fontfile#1\endcsname - \@EA\tracedfontname\csname\??fontfile#1\endcsname - \fi\fi} - -%D \macros -%D {definefont} -%D -%D Before we implement the main definition macro, we first show -%D one for local use: -%D -%D \starttyping -%D \definefont[Some][LucidaBright at 100pt] \Some some -%D \definefont[More][LucidaBright scaled 3000] \More more -%D \definefont[Nice][LucidaBright mo 2] \Nice nice -%D \definefont[Text][LucidaBright sa 5.4] \Text last -%D \stoptyping -%D -%D The implementation looks as follows: - -\unexpanded\def\definefont - {\dotripleempty\dodefinefont} - -\def\dodefinefont[#1][#2][#3]% [name][spec][1.6 | line=10pt | setup_id] - {\ifthirdargument - \setuvalue{#1}{\redodefinefont{#1}{#2}{#3}}% - \else - \setuvalue{#1}{\dododefinefont{#1}{#2}}% - \fi} - -\def\redodefinefont#1#2#3% - {\dododefinefont{#1}{#2}% - \doifsetupselse{#3} - {\setups[#3]} % don't forget to document this ! - {\setuplocalinterlinespace[#3]% - \setupspacing}} % needed ? - -\unexpanded\def\definefrozenfont - {\dotripleempty\dodefinefrozenfont} - -\def\dodefinefrozenfont[#1][#2][#3]% - {\dodefinefont[#1][#2][#3]% - \expandafter\let\csname\lastfontidentifier\expandafter\endcsname\csname\rawfontidentifier\endcsname} - -%D The \type {*} makes the switch local, so that we can redefine a -%D logical name and/or change the size in between. - -%D todo: now mathsize twice in name (so it can go here) - -\newif\ifautofontsize \autofontsizetrue - -\let\lastfontidentifier\empty - -\def\rawfontidentifier{**\lastfontidentifier\fontsize\currentmathsize**} -\def\newfontidentifier{*\fontclass\lastfontidentifier\fontsize\currentmathsize*} - -\let\oldrawfontidentifier\rawfontidentifier -\let\oldnewfontidentifier\newfontidentifier - -\def\newfontidentifier{*\fontclass\lastfontidentifier\fontstyle\fontsize*} % no \currentmathsize - -\def\dododefinefont#1#2% - {\featureinheritancemode\featureinheritancefontonly - \edef\lastfontidentifier{#1}% - \let\localrelativefontsize\defaultrelativefontsize - \let\localabsolutefontsize\fontbody - \lowleveldefinefont{#2}\rawfontidentifier - \csname\rawfontidentifier\endcsname - \autofontsizefalse - \setfontcharacteristics - \the\everyfontswitch - \let\rawfontidentifier\oldrawfontidentifier} - -\unexpanded\def\xxdododefinefont#1% - {\edef\lastfontidentifier{#1}% - \ifcsname\newfontidentifier\endcsname - \expandafter\xxdododefinefontnop - \else - \expandafter\xxdododefinefontyes - \fi} - -\def\xxdododefinefontyes#1#2#3% \autofontsizetrue is set by calling routine - {\def\localrelativefontsize{#1}% - \def\localabsolutefontsize{#2}% - \lowleveldefinefont{#3}\newfontidentifier - \csname\newfontidentifier\endcsname - \autofontsizefalse - \ifskipfontcharacteristics \else - \setfontcharacteristics - \the\everyfontswitch - \fi - \let\newfontidentifier\oldnewfontidentifier} - -\def\xxdododefinefontnop#1#2#3% \autofontsizetrue is set by calling routine - {\csname\newfontidentifier\endcsname - \autofontsizefalse - \ifskipfontcharacteristics \else - \setfontcharacteristics - \the\everyfontswitch - \fi - \let\newfontidentifier\oldnewfontidentifier} - -%D \macros -%D {mapfontsize} -%D -%D For special purposes, like in math, you may want to use -%D slightly different sizes than the ones given. This happens -%D for instance with the Math Times fonts. Mapped font sizes -%D can be specified by using the \type {mo} key instead of -%D \type {sa} in font definitions. -%D -%D \startbuffer -%D \mapfontsize[10pt][11pt] -%D \mapfontsize[11pt][12pt] -%D \mapfontsize[12pt][13pt] -%D -%D \definefont[test][Serif]\test TEST \par -%D \definefont[test][Serif sa 5]\test TEST \par -%D \definefont[test][Serif mo 5]\test TEST \par -%D \definefont[test][Serif sa d]\test TEST \par -%D \definefont[test][Serif at 60pt]\test TEST \par -%D \definefont[test][Serif scaled 6000]\test TEST \par -%D \stopbuffer -%D -%D \typebuffer -%D -%D \startpacked -%D \getbuffer -%D \stoppacked - -\def\mapfontsize - {\dodoubleargument\domapfontsize} - -\def\domapfontsize[#1][#2]% - {\setvalue{\??ft*\the\dimexpr#1\relax}{#2}} - -\def\setmappedfontsize#1% - {\ifcsname\??ft*#1\endcsname - \csname\??ft*#1\endcsname - \else - #1% - \fi} - -%D \macros -%D {getfontname} -%D -%D The names of the fonts can be called with the rather simple -%D macro \type{\getfontname}. When for instance we pass -%D \type{12ptrmtf} as argument, we get \getfontname{12ptrmtf}. - -\def\getfontname#1% - {\csname\??ft#1\endcsname} - -%D To be documented. - -\let\fontsizelist \empty -\let\fontalternativelist\empty -\let\fontstylelist \empty - -\def\docheckfontnamecombinations#1% - {\def\dodocheckfontnamecombinations##1% - {\def\dododocheckfontnamecombinations####1{\checkbodyfont{####1}{##1}{#1}}% - \processcommacommand[\fontstylelist]\dododocheckfontnamecombinations}% - \processcommacommand[\fontalternativelist]\dodocheckfontnamecombinations} - -\def\checkfontnamecombinations % we need to split math and text here ... todo (math only has mr and mb) - {\processcommacommand[\fontsizelist]\docheckfontnamecombinations} - -\unexpanded\def\definefontsize[#1]% sneller met toks - {\addtocommalist{#1}\fontsizelist - \checkfontnamecombinations} - -\unexpanded\def\definefontalternative[#1]% - {\addtocommalist{#1}\fontalternativelist - \checkfontnamecombinations} - -%D \macros -%D {currentfontscale,currentfontbodyscale} -%D -%D Sometimes we need to have access to the font scale -%D including the \type{a}||\type{d} sizes. The next macro -%D returns the current scaling factor. Take a look at -%D \type {cont-log.tex} for an example of its use. - -\def\currentfontscale - {\csname\??ft\s!default - \ifcsname\??ft\s!default\xfontsize\endcsname \xfontsize \else - \ifcsname\??ft\s!default\s!text \endcsname \s!text \fi\fi - \endcsname} - -\def\currentfontbodyscale - {\csname\??ft\s!default - \ifcsname\??ft\s!default\fontsize\endcsname \fontsize \else - \ifcsname\??ft\s!default\s!text \endcsname \s!text \fi\fi - \endcsname} - -\setvalue{\??ft\s!default}{1} - -%D Both alternatives use \type {\xfontsize}, a macro that -%D expands to the current size in terms of \type {a} \unknown -%D \type {d}, nothing, or \type {x} \unknown \type {xx}. - -%D In the following macros we use \type{\currentxfontsize} to -%D hold the current x||size of the font. This enables us to -%D support for instance \type{\sl} inside a \type{\tx} switch. - -\newconstant\currentxfontsize - -\def\xfontsize{\ifcase\currentxfontsize\fontsize\or\c!x\else\c!xx\fi} - -%D A typical use of this command is in commands that switch -%D to another font bypassing the font mechanism: -%D -%D \starttyping -%D \font\myfont=\truefontname{MyFont} at \the\dimexpr\currentfontscale\bodyfontsize\relax -%D \stoptyping - -%D Now we enter the area of font switching. The switching -%D mechanism has to take care of several situations, like: -%D -%D \startitemize[packed] -%D \item changing the overal document fonts (including margins, -%D headers and footers) -%D \item changing local fonts (only the running text) -%D \item smaller and even more smaller alternatives (super- -%D and subscripts) -%D \stopitemize -%D -%D \TEX\ offers a powerfull family mechanism for super- and -%D subscripts in math mode. In text mode however, we don't use -%D families for the smaller alternatives, and therefore have -%D to take care of it otherwise. - -%D \macros -%D {definebodyfontenvironment,setupbodyfontenvironment} -%D -%D The relationship between the several sizes of a font, is -%D defined by: -%D -%D \showsetup{definebodyfontenvironment} -%D -%D Later on we will see how these parameters are used, so for -%D the moment we stick with an example: -%D -%D \starttyping -%D \definebodyfontenvironment -%D [12pt] -%D [ text=12pt, -%D script=9pt, -%D scriptscript=7pt, -%D x=10pt, -%D xx=8pt, -%D big=12pt, -%D small=10pt] -%D \stoptyping -%D -%D The first argument specifies the bodyfont size to which the -%D settings apply. All second parameters are specified in -%D dimensions and tell us more about related sizes. -%D -%D Afterwards, one can change values with -%D -%D \showsetup{setupbodyfontenvironment} -%D -%D Due to the fact that \type{\c!text} and \type{\s!text} can -%D have a similar meaning, and therefore can lead to an -%D unwanted loop, we temporary redefine \type{\c!text}. For -%D the moment this in only place that some trickery is needed -%D to fool the multilingual interface. However, long ago -%D we decided to stick to \type {\s!text} in definitions as it closely -%D relates to the math model where text, script and scriptscript -%D are used untranslated. Also, we are now english at the low -%D level so it cannot go wrong anymore. -%D -%D When instead of a size the keyword \type{unknown} is -%D passed, fractions (relations) are used instead of fixed -%D sizes. - -\let\bodyfontenvironmentlist\empty - -\newcount\@@fontdefhack % check if this is still needed - -% \def\@@beginfontdef -% {\ifcase\@@fontdefhack -% \let\k!savedtext \k!text \let\k!text \s!text -% \let\k!saveddefault \k!default \let\k!default \s!default -% \fi -% \advance\@@fontdefhack \plusone } - -% \def\@@endfontdef -% {\advance\@@fontdefhack \minusone -% \ifcase\@@fontdefhack -% \let\k!default \k!saveddefault -% \let\k!text \k!savedtext -% \fi} - -%%%%%%%%%%%%%%%%%%%%%%%% - -% The problem is that the key in a getparameters is resolved -% to the underlying interface language (english). But values -% are kept as they are. However, some of the keys in a font -% definition are used as values later on. -% -% The only place where this happens (for historical reason mostly) -% is in the bodyfont definitions and setup, so we can use a limited -% case. -% -% \let \c!big \v!big : expansion time (user) -% \let \c!small \v!small : expansion time (user) -% \let \c!text \s!text : definition time -% % \c!script \s!script : definition time -% % \c!scriptscript \s!scriptscript : definition time -% % \c!em : definition time -% % \c!interlineskip : definition time -% \let \c!default \s!default : definition time -% \let \k!default \s!default : definition time -% -% Doing the k! definitions local will save us 500 has entries. - -\letvalue{\k!prefix!\v!big }\c!big -\letvalue{\k!prefix!\v!small }\c!small -\letvalue{\k!prefix!\v!text }\s!text -\letvalue{\k!prefix!\v!default}\s!default - -\let\normalc!big \c!big -\let\normalc!small \c!small -\let\normalc!text \c!text % should not happen as we expect text -\let\normalc!default \c!default -\let\normalk!default \k!default - -\newtoks\everybeginfontdef -\newtoks\everyendfontdef - -\appendtoks - \let\c!text \s!text - \let\c!default\s!default -\to \everybeginfontdef - -\appendtoks - \let\c!text \normalc!text - \let\c!default\normalc!default -\to \everyendfontdef - -\def\@@beginfontdef - {\ifcase\@@fontdefhack - \the\everybeginfontdef - \fi - \advance\@@fontdefhack\plusone} - -\def\@@endfontdef - {\advance\@@fontdefhack \minusone - \ifcase\@@fontdefhack - \the\everyendfontdef - \fi} - -%%%%%%%%%%%%%%%%%%%%%%%% todo: inheritance with parent - -\unexpanded\def\definebodyfontenvironment - {\dotripleempty\dodefinebodyfontenvironment} - -\def\dodefinebodyfontenvironment[#1][#2][#3]% class size settings - {\ifthirdargument - \@@beginfontdef - \doifelse{#2}\s!default - {\getparameters[\??ft\s!default][#3]} - {\edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}% - \addtocommalist\tempbodyfontsize\bodyfontenvironmentlist - \@EA\dododefinebodyfontenvironment\@EA[\tempbodyfontsize][#1][#3]}% - \@@endfontdef - \else - \ifx\fontclass\empty\else - \writestatus\m!fonts{beware: fontclass ignored (if needed use: [fontclass][size][settings])}% - \fi - \pushmacro\fontclass - \let\fontclass\empty - \definebodyfontenvironment[\fontclass][#1][#2]% change */* - \popmacro\fontclass - \fi} - -\def\dododefinebodyfontenvironment[#1][#2][#3]% size class settings - {%\@@beginfontdef % \s!text goes wrong in testing because the 12pt alternative will called when typesetting the test (or so) - \ifcsname\??ft#2#1\c!em\endcsname - % we test for em as we assume it to be set - \else - % speeding this up saves 0.01 sec on a run (tested 20100817) - % but some day we will clean this up anyway - \def\dodododefinebodyfontenvironment##1% - {\scratchdimen\csname\??ft\s!default##1\endcsname\dimexpr#1\relax - \edef\tempbodyfontsize{\thenormalizedbodyfontsize\scratchdimen}% - \letvalue{\??ft#2#1##1}\tempbodyfontsize}% - \processcommacommand[\fontrelativesizelist]\dodododefinebodyfontenvironment - \copyparameters - [\??ft#2#1][\??ft\s!default]% - [\c!interlinespace,\c!em]% - \fi - \getparameters[\??ft#2#1][#3]% - %\@@endfontdef - % new code, see remark - \ifproductionrun - \ifcsname\??fontsize#1\endcsname - % only once - \else - % prevent loop (hence \empty) - \letvalueempty{\??fontsize#1}% - \pushmacro\fontclass % new per 26102009 - \edef\fontclass{#2}% % new per 26102009 - \defineunknownfont{#1}% - \popmacro\fontclass % new per 26102009 - \fi - \fi - % so far - \setvalue{\??fontsize#1}{\docompletefontswitch[#1]}} - -%D {\bf Remark:} We need to cover the following cases, -%D otherwise users can get confused: -%D -%D \starttyping -%D \setupbodyfont[23pt] -%D -%D \definebodyfontenvironment[23pt] -%D \setupbodyfont[23pt] -%D -%D \definebodyfontenvironment[23pt] -%D \definebodyfont[23pt][rm,ss,tt][default] -%D \setupbodyfont[23pt] -%D \stoptyping - -%D Beware: while some font defs can be global, the bodyfont -%D environment checks local. This means that multiple local -%D checks resulting in definitions are not that efficient. -%D So, apart from an occasional switch, one should define an -%D environment at the outer level. - -% \def\checkbodyfontenvironment[#1]% -% {\definebodyfontenvironment[\fontclass][#1][]} -% -% \def\checkbodyfontenvironment[#1]% -% {\ifcsname\??ft\fontclass#1\c!em\endcsname -% % we test for em as we assume it to be set -% \else -% \definebodyfontenvironment[\fontclass][#1][]% -% \fi} -% -% will be adapted with parent chain: - -\def\checkbodyfontenvironment[#1]% - {\ifcsname\??ft #1\c!em\endcsname\else\docheckbodyfontenvironment\empty {#1}\fi - \ifcsname\??ft\fontclass#1\c!em\endcsname\else\docheckbodyfontenvironment\fontclass{#1}\fi} - -\def\dodocheckbodyfontenvironment#1#2% text script scriptscript x xx big small - {\setevalue{\??ft#1\tempbodyfontsize#2}% - {\thenormalizedbodyfontsize{\csname\??ft\s!default#2\endcsname\dimexpr\tempbodyfontsize\relax}}} - -\def\docheckbodyfontenvironment#1#2% class size (simplified version of definebodyfontenvironment) - {\@@beginfontdef - \edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}% - \addtocommalist\tempbodyfontsize\bodyfontenvironmentlist - \processcommacommand[\fontrelativesizelist]{\dodocheckbodyfontenvironment{#1}}% - \copyparameters % can inherit - [\??ft#1\tempbodyfontsize][\??ft\s!default] - [\c!interlinespace,\c!em]% - %\ifproductionrun - \ifcsname\??fontsize\tempbodyfontsize\endcsname \else - \letvalueempty{\??fontsize\tempbodyfontsize}% prevent loop - \pushmacro\fontclass - \edef\fontclass{#1}% - \normalexpanded{\defineunknownfont{\tempbodyfontsize}}% we can also inherit here - \popmacro\fontclass - \fi - %\fi - \setevalue{\??fontsize#1}{\noexpand\docompletefontswitch[#1]}% - \@@endfontdef} - -% this one already catches both define/setup - -\let\setupbodyfontenvironment\definebodyfontenvironment - -%D Just a couple of interface macros: - -% todo: -% -% \letvalueempty{\??ft\s!empty} -% -% \def\currentbodyfontvariable#1% -% {\csname\??ft -% \ifcsname\??ft\fontclass#1\endcsname\fontclass#1\else -% \ifcsname\??ft #1\endcsname #1\else \s!empty \fi -% \fi} - -\def\bodyfontvariable#1% - {\??ft\ifcsname\??ft\fontclass#1\endcsname\fontclass\fi#1} - -\def\bodyfontinterlinespecs - {\bodyfontvariable{\normalizedbodyfontsize\c!interlinespace}} - -\def\bodyfontinterlinespace - {\csname\bodyfontinterlinespecs\endcsname} - -%D We default all parameters to the main bodyfont size (begin -%D \type{#1}), so the next setup is valid too: -%D -%D \starttyping -%D \definebodyfontenvironment[24pt] -%D \stoptyping -%D -%D All parameters can be redefined when needed, so one does -%D not have to stick to the default ones. - -%D \macros -%D {definebodyfont} -%D -%D The next step in defining a bodyfont involves the actual font -%D files, which can be recognized by their extension -%D \type{tfm}. Installing those file is often beyond the -%D scope of the user and up to the system administrator. -%D -%D \showsetup{definebodyfont} -%D -%D This commands takes three arguments: a (series of) bodyfont -%D size(s), the style group to which the definitions belong, -%D and an alternative, as specified by the \TEX\ (math) families, -%D extended with~a, b~\unknown. -%D -%D We show two examples, that show all the alternative -%D scaling options. The \type{\tfa} alternatives can be -%D extended with \type{\bfa}, \type{\slb}, etc. or even -%D \type{e} and higher alternatives. The magic scaled -%D values are derived from plain \TEX's \type {\magstep}: -%D -%D \starttyping -%D \definebodyfont [12pt] [rm] -%D [tf=cmr12, -%D bf=cmbx12, -%D it=cmti12, -%D sl=cmsl12, -%D bi=cmbxti10 at 12pt, -%D bs=cmbxsl10 at 12pt, -%D tfa=cmr12 scaled 1.200, -%D tfb=cmr12 scaled 1.440, -%D tfc=cmr12 scaled 1.728, -%D tfd=cmr12 scaled 2.074, -%D sc=cmcsc10 at 12pt] -%D -%D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm] -%D [tf=lbr sa 1, -%D bf=lbd sa 1, -%D it=lbi sa 1, -%D sl=lbsl sa 1, -%D bi=lbdi sa 1, -%D bs=lbdi sa 1, -%D tfa=lbr sa 1.200, -%D tfb=lbr sa 1.440, -%D tfc=lbr sa 1.728, -%D tfd=lbr sa 2.074, -%D sc=lbr sa 0.833] -%D \stoptyping -%D -%D The second example shows that we can define more sizes at -%D once. The main difference between these examples is that the -%D Computer Modern Roman come in many design sizes. This means -%D that there we cannot define them in bulk using \type{sa}. -%D Instead of \type{rm} (roman) one can define \type{ss} (sans -%D serif), \type{tt} (teletype), \type{hw} (hand written), -%D \type{cg} (calygraphic) and whatever styles. -%D -%D The first argument may be a comma separated list. This, -%D combined with specifications using \type{sa} can save a lot -%D of typing. Although all arguments should be specified, we -%D treat the second argument as optional. -%D -%D Defining a bodyfont involves two actions: defining the -%D specific style related alternatives, like \type{\rma}, -%D \type{\bfa} and \type{\rmsla}, and storing the definitions -%D of their bodyfont size related fonts. The first step is -%D bodyfont independant but executed every time. This permits -%D user definitions like \type{\tfw} or \type{\bfq} for real -%D large alternatives. - -%D If we move design size info to the lfg file (after all only lm -%D has design sizes) we can get rid of much code .. 2012 or so. - -% todo: \s!parent - -\unexpanded\def\definebodyfont - {\doquadrupleempty\redefinebodyfont} - -\def\redefinebodyfont[#1][#2][#3][#4]% - {\iffourthargument - \processcommacommand[#1]{\reredefinebodyfont[#2][#3][#4]}% - \else - \dodefinebodyfont[#1][#2][#3]% - \fi} - -\def\reredefinebodyfont[#1][#2][#3]#4% - {\pushmacro\fontclass - \doifelse{#4}\s!default - {\let\fontclass\empty} - {\def\fontclass{#4}}% - \definebodyfont[#1][#2][#3]% - \popmacro\fontclass} - -\def\dodefinebodyfont[#1][#2][#3]% body|identifier style defs|identifier - {\ifthirdargument - \doifnumberelse{#1} - {\doifassignmentelse{#3} - {% [12pt] [style] [settings] - \ifcsname#2\endcsname\else\normalexpanded{\noexpand\definefontstyle[#2][#2]}\fi % new - \processcommalist[#1]{\dododefinebodyfont{#2}{#3}}} - {% [12pt] [style] [identifier] - \dodefinedefaultbodyfont[#1][#2][#3]}} % body style identifier - {% [identifier] [style] [settings] % see *** - \setvalue{\s!default#1#2}##1##2{\normalexpanded{\noexpand\xdodefinebodyfont[##1][##2][#3]}}}% - \else\ifsecondargument - \definebodyfont[#1][\c!rm][#2]% - \else - % Maybe there are default dependencies defined which we can use ([unknown]) and - % if not, then we have at least to make sure some basics are set up. - \ifcsname\??fontsize#1\endcsname \else - \defineunknownfont{#1}% - \fi - \ifcsname\??fontsize#1\endcsname \else - \definebodyfont[#1][\c!rm][]% - \fi - \fi\fi} - -\def\xdodefinebodyfont[#1][#2][#3]% body|identifier style defs|identifier - {\checkrelativefontsize{#2}% rather new, inherit from other defs - \ifcsname#2\endcsname\else\normalexpanded{\noexpand\definefontstyle[#2][#2]}\fi % new - \processcommalist[#1]{\dododefinebodyfont{#2}{#3}}% - \let\relativefontsize\defaultrelativefontsize} - -\def\dododefinebodyfont#1#2#3% style defs body - {\checkbodyfontenvironment[#3]% just to be sure; can probably be omited now - \processcommalist[#2]{\dodododefinebodyfont{#1}{#3}}} - -\def\dodododefinebodyfont#1#2#3% style body def - {\dododododefinebodyfont{#1}{#2}[#3]} - -\def\dododododefinebodyfont - {\ifx\fontclass\empty - \expandafter\dododododefinebodyfontnop - \else - \expandafter\dododododefinebodyfontyes - \fi} - -\def\dododododefinebodyfontyes#1% style body def - {\edef\askedbodyfontstyle{#1}% - \ifx\askedbodyfontstyle\c!mm - \expandafter\dodefinebodyfontyesmm - \else - \expandafter\dodefinebodyfontyesxx - \fi\askedbodyfontstyle} % we can get rid of #1 - -\def\dododododefinebodyfontnop#1% style body def - {\edef\askedbodyfontstyle{#1}% - \ifx\askedbodyfontstyle\c!mm - \expandafter\dodefinebodyfontnopmm - \else - \expandafter\dodefinebodyfontnopxx - \fi\askedbodyfontstyle} % we can get rid of #1 - -\def\dodefinebodyfontnopxx#1#2[#3#4#5=#6]% style body def - {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \@EA\let\csname*#2#1#3#4#5*\endcsname\undefined - \unexpanded\@EA\edef\csname#2#1#3#4#5\endcsname{\xxdododefinefont{#2#1#3#4#5}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}} - -\def\dodefinebodyfontyesxx#1#2[#3#4#5=#6]% style body def - {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \global\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined - \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#5\endcsname{\xxdododefinefont{#2#1#3#4#5}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}} - -\def\dodefinebodyfontnopmm#1#2[#3#4#5=#6]% style body def - {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \@EA\let\csname*#2#1#3#4#51*\endcsname\undefined - \@EA\let\csname*#2#1#3#4#52*\endcsname\undefined - \@EA\let\csname*#2#1#3#4#53*\endcsname\undefined - \unexpanded\@EA\edef\csname#2#1#3#4#51\endcsname{\xxdododefinefont{#2#1#3#4#51}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}% - \unexpanded\@EA\edef\csname#2#1#3#4#52\endcsname{\xxdododefinefont{#2#1#3#4#52}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}% - \unexpanded\@EA\edef\csname#2#1#3#4#53\endcsname{\xxdododefinefont{#2#1#3#4#53}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}} - -\def\dodefinebodyfontyesmm#1#2[#3#4#5=#6]% style body def - {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \global\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined - \global\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined - \global\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined - \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#51\endcsname{\xxdododefinefont{#2#1#3#4#51}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}% - \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#52\endcsname{\xxdododefinefont{#2#1#3#4#52}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}% - \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#53\endcsname{\xxdododefinefont{#2#1#3#4#53}{\number\relativefontsize}{#2}{\normalunexpanded{#6}}}} - -\def\checkbodyfont#1% tests for ttsl mmbf - {\edef\c!!mm{#1}% - \ifx\c!!mm\c!mm % prevents \max and alike (re)defs - \expandafter\checkmathbodyfont - \else - \expandafter\checktextbodyfont - \fi{#1}} % no \c!!mm, not expanded later on - -\def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) - {%\message{!m #1 #2 #3!}% #1 #2 #3 = signal - %setugvalue {#2}{\setcurrentfontalternative {#2}}% % \mr \mb - \setugvalue {#1}{\setcurrentfontstyle {#1}}} % \mm - -\def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) - {%\message{!t #1 #2 #3!}% % beware, some can be defined already - \setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}% % \rma - \setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}% % \sla - \setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% % \rmsla - \ifcsname\s!normal#1\endcsname % text/math check - \expandafter\let\csname#1\expandafter\endcsname\csname\s!normal#1\endcsname - \else - \setugvalue {#1}{\setcurrentfontstyle {#1}}% % \rm - \fi - \ifcsname\s!normal#2\endcsname % text/math check - \expandafter\let\csname#2\expandafter\endcsname\csname\s!normal#2\endcsname - \else - \setugvalue {#2}{\setcurrentfontalternative {#2}}% % \sl - \fi - \setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}% % \rmx - \setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}% % \rmxx - \setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}% % \slx - \setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}% % \slxx - \setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}} % \rmsl - -\def\dodefinedefaultbodyfont[#1][#2][#3]% sizes styles identifier - {\def\dododefinedefaultbodyfont##1% - {\def\dodododefinedefaultbodyfont####1% - {\def\dododododefinedefaultbodyfont########1% - {\ifcsname\s!default########1####1\endcsname - % [12pt] [style] [identifier] - \csname\s!default########1####1\endcsname{##1}{####1}% - \fi}% - \processcommalist[#3]\dododododefinedefaultbodyfont}% - \processcommalist[#2]\dodododefinedefaultbodyfont}% - \processcommalist[#1]\dododefinedefaultbodyfont} - -%D Unknown families are added to the family list! For the -%D moment we also set the direct calls here. Some day a better -%D solution will be implemented. The good news is that unknown -%D fonts are defined automatically. - -\newif\ifdefiningunknownfont - -\def\dodefineunknownfont#1#2% - {\ifcsname\??ft\s!default#2\endcsname - \donetrue - \edef\tempbodyfontsize{\thenormalizedbodyfontsize{\csname\??ft\s!default#2\endcsname\dimexpr#1\relax}}% - \letvalue{\??ft#1#2}\tempbodyfontsize - \fi} - -\def\dodefineunknownbodyfont#1#2% see *** - {\ifcsname\s!default\s!default#2\endcsname % somehow related to */* - \donetrue - \csname\s!default\s!default#2\endcsname{#1}{#2}% - \fi} - -\def\dodefineunknownsubfont#1#2% - {\ifcsname\??fontsize\csname\??ft#1#2\endcsname\endcsname - \else - \donetrue - \defineunknownfont{\csname\??ft#1#2\endcsname}% - \fi} - -\let\c!savedtext\c!text - -\unexpanded\def\defineunknownfont#1% - {\let\c!text\s!text - \donefalse - \processcommacommand[\fontrelativesizelist]{\dodefineunknownfont{#1}}% - \let\c!text\c!savedtext - \ifdone - \donefalse - \processcommacommand - [\fontstylelist] - {\dodefineunknownbodyfont{#1}}% - \ifdone - \donefalse - \setvalue{\??fontsize#1}{\docompletefontswitch[#1]}% - \ifdefiningunknownfont \else - \definingunknownfonttrue - \processcommacommand[\fontrelativesizelist]{\dodefineunknownsubfont{#1}}% - \definingunknownfontfalse - \fi - \fi - \ifdone - \showmessage\m!fonts{14}{#1}% - \fi - \fi} - -%D These macros show that quite some definitions take place. -%D Fonts are not loaded yet! This means that at format -%D generation time, no font files are preloaded. - -%D \macros -%D {everybodyfont,Everybodyfont,everyglobalbodyfont} -%D -%D Every change in bodyfont size has conseqences for the baseline -%D distance and skips between paragraphs. These are initialized -%D in other modules. Here we only provide the hooks that -%D garantees their handling. - -%D At the system level one can initialize thing like: -%D -%D \starttyping -%D \appendtoks \setupspacing \to \everybodyfont -%D \stoptyping -%D -%D While users can add their own non standard commands like: -%D -%D \starttyping -%D \EveryBodyFont{\message{changing to bodyfont \the\bodyfontsize}} -%D \stoptyping -%D -%D Personnaly I never felt the need for such extensions, but -%D at least its possible. - -%D \macros -%D {globalbodyfontsize,localbodyfontsize} -%D -%D Next we'll do the tough job of font switching. Here we -%D have to distinguish between the global (overal) bodyfont -%D size and the local (sometimes in the textflow) size. We -%D store these dimensions in two \DIMENSION\ registers. - -\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt -\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize - -%D \macros -%D {bodyfontsize} -%D -%D These two registers are not to be misused in calculations. -%D For this purpose we keep a copy: - -\newdimen\bodyfontsize \bodyfontsize=\globalbodyfontsize - -%D \macros -%D {bodyfontfactor,bodyfontpoints} -%D -%D For multiplication purposes we keep an auxiliary counter -%D and macro (here the expansion is not explicitly needed): - -\newcount\bodyfontpoints \dimensiontocount\bodyfontsize\bodyfontpoints - -\edef\bodyfontfactor{\withoutpt\the\bodyfontsize} - -%D When we assign for instance 12pt to a \DIMENSION\ register -%D the \type{\the}'d value comes out as 12.0pt, which is -%D often not the way users specify the bodyfont size. Therefore -%D we also store the normalized value. - -\setnewconstant\fontdigits\plustwo % was 1 - -\def\normalizebodyfontsize#1\to#2% - {\edef#2{\ctxcommand{nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}} - -\def\thenormalizedbodyfontsize#1% - {\ctxcommand{nbfs(\number\dimexpr#1\relax,\number\fontdigits)}} - -\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize} -\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} -\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} - -%D \macros -%D {fontstyle,fontalternative,fontsize} -%D -%D Within a bodyfont, fonts can come in different sizes. For -%D instance \type{\tf} is accompanied by \type{\tfa}, -%D \type{\tfb} etc. The first two characters denote the -%D alternative, while the third character in these sequences -%D represents the size. The actual size is saved in a macro -%D -%D The style, being roman (\type{\rm}), sans serif (\type{\ss}) -%D etc. is also available in a macro in \type{rm}, \type{ss} -%D etc. form: - -\let\defaultfontalternative = \c!tf -\let\defaultfontstyle = \empty -\let\defaultfontsize = \empty - -\let\fontalternative = \defaultfontalternative -\let\fontstyle = \defaultfontstyle -\let\fontsize = \defaultfontsize - -%D When \type {\loadfontfileoncetrue}, such files are -%D only loaded once! This permits redundant loading, but at -%D the same time forced grouping when we want continuously mix -%D all kind of font, which of course is a kind of -%D typographically sin. The \type{"} is made inactive if -%D needed to prevent problems with loading files that use this -%D character in numbers. - -% can be made faster (only used internally now) - -\def\doswitchpoints[#1]% - {\normalexpanded{\dodoswitchpoints{#1}}} - -\unexpanded\def\dodoswitchpoints#1% - {\ifcsname\??fontsize#1\endcsname \else - \defineunknownfont{#1}% - \fi% - %\defineunknownfontstyles{#1}% - \ifcsname\??fontsize#1\endcsname - \csname\??fontsize#1\endcsname - \localbodyfontsize#1\relax - % \edef\fontbody{\fontbody}% to be tested but we can clean up mkiv further - \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}% - \checkbodyfontenvironment[\normalizedbodyfontsize]% - \else - \showmessage\m!fonts4{#1}% - \fi} - -\unexpanded\def\doswitchstyle[#1]% - {\ifcsname\??fontstyle#1\endcsname - \csname\??fontstyle#1\endcsname - \edef\fontstyle{#1}% - \ifmmode\mr\fi % in order to be compatible with \rm in math mode - % \the\everybodyfont % cleaner, in setting size as well as style - \else - \showmessage\m!fonts5{#1}% - \fi} - -%D \TEX\ loads font metric files like \type{cmr10.tfm} and -%D \type{tir.tfm} only once. In \PLAIN\ \TEX\ some font files -%D are {\em preloaded}. This means that the font files are -%D loaded, but not accessible yet by name. This is accomplished -%D by saying: -%D -%D \starttyping -%D \font\preloaded=cmr10 at 11pt -%D \stoptyping -%D -%D and using the name \type{\preloaded} again and again, so -%D fonts are indeed loaded, but unnamed, and therefore -%D unaccessible. In \CONTEXT\ we don't preload fonts, not even -%D the \PLAIN\ \TEX\ ones, although users can access them. Now -%D why is this done? - -%D Defining fonts using \type{\definebodyfont} takes time, so we -%D prefer to predefine at least the Computer Modern Roman -%D fonts. However, loading all those fonts at definition time -%D would take both time and space. But even worse, once fonts -%D are loaded into memory, their encoding vector is fixed, -%D which is a handicap when we want to distribute the compact -%D \type{fmt} files. So what we want to do is defining fonts in -%D a way that postpones the loading. We accomplish this by only -%D loading the fonts when we switch to another bodyfont size. -%D Among the other alternatives, such as loading the font at -%D the moment of activation and redefining the activation -%D macro afterwards, this proved to be the most efficient -%D alternative. -%D -%D The next few macros take care of the one exeption on this -%D scheme. When at format generation time we load the default -%D font file, the one that defines the Computer Modern Fonts, -%D we don't want the fonts metrics to end up in the format -%D file, so we temporary prohibit loading. This means that at -%D runtime we have to load the default bodyfont size just before -%D we start typesetting. -%D -%D Therefore we have to signal the font switching macros that -%D we are preloading fonts. -%D -%D \macros -%D {preloadfonts} -%D -%D Preloading is only called for once, during the startup -%D sequence of a session. After the loading job is done, the -%D macro relaxes itself and reset the signal. - -\fontslantperpoint \nullfont 0\scaledpoint -\fontinterwordspace \nullfont 256377\scaledpoint -\fontinterwordstretch\nullfont 128188\scaledpoint -\fontinterwordshrink \nullfont 85459\scaledpoint -\fontexheight \nullfont 338952\scaledpoint -\fontemwidth \nullfont 786432\scaledpoint -\fontextraspace \nullfont 85459\scaledpoint - -\fetchruntimecommand \showfontparameters {\f!fontprefix\s!run} - -\def\resetnullfont % this is needed because some macro packages (tikz) misuse \nullfont - {\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as: - \ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous - \globallet\resetnullfont\relax} - -\def\preloaddefaultfonts - {\resetpreloadfonts - \setupbodyfont[modern,\fontstyle,\fontbody]% - \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}} - -\def\preloaddefaultfontsmm - {\writestatus\m!fonts{preloading latin modern fonts (math)}% - \definetypeface[\fontclass][\c!mm][\s!math][modern][\s!default]% - \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}} - -\def\preloaddefaultfontstt - {\writestatus\m!fonts{preloading latin modern fonts (mono)}% - \definetypeface[\fontclass][\c!tt][\s!mono][modern][\s!default]% - \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}} - -\def\resetpreloadfonts - {\glet\preloaddefaultfonts \relax - %\glet\preloaddefaultfontstt \relax - %\glet\preloaddefaultfontsmm \relax - \glet\zerostagepreloadfonts \relax - \glet\firststagepreloadfonts \relax - \glet\secondstagepreloadfonts\relax - %\glet\thirdstagepreloadfonts \relax - \glet\fourthstagepreloadfonts\relax - \global\everyhbox\emptytoks - \global\everyvbox\emptytoks - \resetnullfont} - -\def\resetcheckedfonts - {\glet\preloaddefaultfontstt \relax - \glet\preloaddefaultfontsmm \relax - \glet\thirdstagepreloadfonts \relax} - -\def\dozerostagepreloadfonts - {\definedfont[\s!file:lmmono10-regular sa 1]} - -\def\zerostagepreloadfonts - {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}% - \glet\zerostagepreloadfonts\dozerostagepreloadfonts - \zerostagepreloadfonts} - -\appendtoks - \everyhbox{\zerostagepreloadfonts} - \everyvbox{\zerostagepreloadfonts} -\to \everydump - -\def\firststagepreloadfonts % *nofonts -> *preloadfonts - {\doifmodeelse{*preloadfonts} - {\preloaddefaultfonts - \writestatus\m!fonts{preloading latin modern fonts (first stage)}} - {\writestatus\m!fonts{latin modern fonts are not preloaded}}} - -\def\secondstagepreloadfonts - {\writestatus\m!fonts{preloading latin modern fonts (second stage)}% - \preloaddefaultfonts} - -\def\thirdstagepreloadfonts % always - {\ifx\fontclass\empty - \writestatus\m!fonts{preloading latin modern fonts (third stage)}% - \preloaddefaultfonts - \else - \resetpreloadfonts - \pushmacro\fontstyle - \ifcsname\fontclass\c!mm\s!features\endcsname \else - \preloaddefaultfontsmm - \fi - \ifcsname\fontclass\c!tt\s!features\endcsname \else - \preloaddefaultfontstt - \fi - \popmacro\fontstyle - \resetcheckedfonts % reset third, mm and tt - \setupbodyfont[\fontstyle]% - \fi} - -\def\fourthstagepreloadfonts - {\begingroup - %ifzeropt\fontcharwd\font\number`!\relax - \setbox\scratchbox\hbox{context}% - \ifzeropt\wd\scratchbox - \writeline - \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}% - \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}% - \writeline - \fi - \resetpreloadfonts - \endgroup} - -%D Here comes the main font switching macros. These macros -%D handle changes in size as well as returning to the global -%D bodyfont size. - -\def\dosetfont#1#2% #1 = set/switch state - {\doifelse{#2}\v!global - {\restoreglobalbodyfont} - {\processcommacommand[#2]{\dodocheckfontsize}% - \processcommacommand[#2]{\dodosetfont{#1}}% - \ifproductionrun - \thirdstagepreloadfonts - \doswitchpoints[\normalizedbodyfontsize]% - \doswitchstyle[\fontstyle]% - \ifx\defaultfontclass\empty - \let\defaultfontclass\fontclass - \fi - \fi}% - \currentxfontsize\zerocount} - -\def\dodocheckfontsize#1% - {\doifnumberelse{#1}{\checkbodyfontenvironment[#1]}\donothing} - -\def\dodosetfont#1#2% #1 = set/switch state | check fo rempty, else space - {\doifsomething{#2}{\dododosetfont{#1}{#2}{\showmessage\m!fonts4{#2}}}} - -\def\dododosetfont#1#2#3% #1 = set/switch state - {\doifnumberelse{#2}\dodododosetfont\redododosetfont{#1}{#2}{#3}} - -\def\redododosetfont#1#2#3% #1 = set/switch state - {\edef\expandedfontthing{#2}% - \def\interfacedfontsize{\normalizedbodyfontsize\interfaced\expandedfontthing}% - \ifcsname\??ft\interfacedfontsize\endcsname - \edef\fontstep{\csname\bodyfontvariable\interfacedfontsize\endcsname}% - \normalexpanded{\noexpand\dodododosetfont{#1}{\fontstep}}{#3}% - \else\ifx\expandedfontthing\v!reset - \let\fontstyle\empty % new 31/7/2006 - \let\fontsize \empty - \else - \ifcsname\??fontstyle\expandedfontthing\endcsname - \let\fontstyle\expandedfontthing - \else - \setcurrentfontclass\expandedfontthing - \ifcase#1\relax - \let\globalfontclass\globalfontclass - \else - \let\globalfontclass\fontclass - \fi - \ifx\fontclass\empty - \let\fontstyle\c!rm - \else\ifcsname\??tf\fontclass\s!default\endcsname - \edef\fontstyle{\csname\??tf\fontclass\s!default\endcsname}% - \else - \let\fontstyle\c!rm - \fi\fi - \fi - \fi\fi} - -\def\dodododosetfont#1#2#3% #1 = set/switch state - {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#2}}% - \ifcsname\??fontsize\normalizedsetfont\endcsname \else - \defineunknownfont{#2}% - \fi - \ifcsname\??fontsize\normalizedsetfont\endcsname - \localbodyfontsize\normalizedsetfont - \let\normalizedbodyfontsize\normalizedsetfont - \else - #3\dosetsubstitutefont{#1}{#2}% - \fi} - -%D When users specify for instance a 13 point bodyfont while no -%D such bodyfont is defined, the system automatically tries to -%D find a best fit, that is the nearest smaller defined -%D bodyfontzize. A smaller one is definitely better than a larger -%D one, simply because otherwise a lot of overfull box messages -%D are more probable to occur. By taking a value slightly -%D smaller than half a point, we can use the next method. - -\def\dosetsubstitutefont#1#2% #1 = set/switch state - {\scratchdimen#2\relax - \advance\scratchdimen .499\points - \dimensiontocount\scratchdimen\scratchcounter - \advance\scratchcounter \minusone - \ifnum\scratchcounter>\plusthree - \dododosetfont{#1}{\the\scratchcounter\s!pt}{}% - \fi} - -% The following bunch of macros deals with the (run time) -% expansion of names onto the definitions made by \type -% {\definebodyfont}. - -% \let\fontbody \empty % ... 10pt 11pt 12pt ... -% \let\fontstyle \empty % rm ss tt mm hw cg ... -% \let\fontalternative\empty % tf bf sl it bs bi sc ... -% \let\fontsize \empty % xy-abcd ... - -\def\defaultfontbody{\normalizedbodyfontsize} - -\let\fontbody\defaultfontbody - -\let\fontclass\empty \let\globalfontclass\fontclass - -% we need to check the fontclass - -\def\registerfontclass#1% - {\letgvalue{\??fontclassyes#1}\v!yes} % global ? - -\def\setcurrentfontclass#1% - {\ifcsname\??fontclassyes#1\endcsname - \edef\fontclass{#1}% - \else\ifcsname\??fontclassnop#1\endcsname - % already tried - \else % too messy: \ifcase\currentgrouplevel % (unpredictable) - \trycurrentfontclass{#1}% - \fi\fi} % \fi} - -\def\savefontclassparameters#1#2#3#4#5#6% #1=rm|ss|.. rscale features fallbacks goodies direction - {\setxvalue{\fontclass#1\s!rscale }{#2}% - \setxvalue{\fontclass#1\s!features }{#3}% - \setxvalue{\fontclass#1\s!fallbacks}{#4}% - \setxvalue{\fontclass#1\s!goodies }{#5}% - \setxvalue{\fontclass#1\s!direction}{#6}} - -\settrue\autotypescripts - -\def\trycurrentfontclass#1% - {\ifconditional\autotypescripts - % try to load typescript #1 - \usetypescript[#1]% - \ifcsname\??fontclassyes#1\endcsname - \edef\fontclass{#1}% - \else - % try to load type-#1.mkiv - \usetypescriptfile[\f!typeprefix#1]% - % try to load typescript #1 - \usetypescript[#1]% - \ifcsname\??fontclassyes#1\endcsname - \edef\fontclass{#1}% - \else - % todo: message - \letvalueempty{\??fontclassnop#1}% - \fi - \fi - \else - % todo: message - \letvalueempty{\??fontclassnop#1}% - \fi} - -\let\defaultfontstyle \c!rm -\let\defaultfontalternative \c!tf -\let\defaultfontsize \empty - -%D \macros -%D {bigmath,nobigmath} -%D -%D We can inhibit this slow||downer with: - -% these can best be combined - -% 0=never 1=everymath 2=always - -\setnewconstant\synchronizebigmathflag\plusone - -\appendtoks - \ifcase\synchronizebigmathflag - % never - \or - \synchronizebigmath - \or - % always - \fi -\to \everymathematics - -\def\nobigmath {\synchronizebigmathflag\zerocount} -\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath} -\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath} - -\let\bigmathfontsize\empty - -\unexpanded\def\synchronizebigmath - {\ifx\bigmathfontsize\fontsize - % already in sync - \else - \let\bigmathfontsize\fontsize - \synchronizemath - \fi} - -\unexpanded\def\checkbigmathsynchronization - {\ifcase\synchronizebigmathflag - % never - \or - \ifmmode \synchronizebigmath \fi - \or - \synchronizebigmath - \fi} - -%D So far for synchronisation. (We can inline the following macros.) - -\unexpanded\def\dosetcurrentfontsize#1% - {\edef\fontsize{#1}% - \checkbigmathsynchronization} - -\unexpanded\def\dosetcurrentfontalternative#1% - {\edef\fontalternative{#1}} - -\unexpanded\def\setcurrentfont#1#2#3#4% - {%\message{[1 #1 #2 #3 #4]}% - \edef\fontbody {#1}% - \edef\fontstyle {#2}% - \edef\fontalternative{#3}% \dosetcurrentfontalternative - \edef\fontsize {#4}% - \checkbigmathsynchronization - \synchronizefont} - -\unexpanded\def\setcurrentfontbody#1% - {%\message{[2 #1]}% - \edef\fontbody{#1}% - \synchronizefont} - -% For Taco: optional fall backs: - -\ifdefined\checkfontclass \else \let\checkfontclass\gobbleoneargument \fi % implemented in type-ini - -\unexpanded\def\setcurrentfontstyle#1% - {%\message{[3 #1]}% - \edef\fontstyle{#1}% - \checkfontclass\fontstyle - \ifmmode\mr\fi % otherwise \rm not downward compatible - \synchronizefont} - -\unexpanded\def\setcurrentfontbodyalternative#1#2% - {%\message{[4 #1 #2]}% - \edef\fontbody {#1}% - \edef\fontalternative{#2}% - \synchronizefont} - -\unexpanded\def\setcurrentfontalternative#1% - {%\message{[5 #1]}% - \edef\fontalternative{#1}% - \synchronizefont} - -\unexpanded\def\setcurrentfontsize#1% - {%\message{[6 #1]}% - \edef\fontsize{#1}% - \checkbigmathsynchronization - \synchronizefont} - -\unexpanded\def\setcurrentfontstylealternative#1#2% \rmsl - {%\message{[7 #1 #2]}% - \edef\fontstyle {#1}% - \edef\fontalternative{#2}% - \synchronizefont} - -\unexpanded\def\setcurrentfontstylesize#1#2% \rmsla - {%\message{[8 #1 #2]}% - \edef\fontstyle{#1}% - \edef\fontsize {#2}% - \checkbigmathsynchronization - \synchronizefont} - -\unexpanded\def\setcurrentfontalternativesize#1#2% \sla - {%\message{[9 #1 #2]}% - \edef\fontalternative{#1}% - \edef\fontsize {#2}% - \checkbigmathsynchronization - \synchronizefont} - -\unexpanded\def\setcurrentfontstylealternativesize#1#2#3% \rmsla - {%\message{[10 #1 #2 #3]}% - \edef\fontstyle {#1}% - \edef\fontalternative{#2}% - \edef\fontsize {#3}% - \checkbigmathsynchronization - \synchronizefont} - -%D In principle one can assign alternative fallback routines. -%D Some day we will. - -\newtoks\fontstrategies -\newif\iftryingfont - -\let\fontstrategy\relax - -\unexpanded\def\synchronizefont % we can have dups i.e. no need to let fontstrategy - {\tryingfonttrue - \ifx\fontclass\empty - \applyfontstrategies - \else - \applyfontclassstrategies - \fi - \autofontsizefalse - \ifskipfontcharacteristics - \setfontcharacteristics - \the\everyfontswitch - \fi} - -\def\fontclassstrategiesa % --- --- --- --- % pt tt bf a - {\ifcsname\fontclass\fontbody \fontstyle \fontalternative \fontsize\endcsname - \autofontsizefalse - \csname\fontclass\fontbody \fontstyle \fontalternative \fontsize\endcsname - \else - \expandafter\fontclassstrategiesb - \fi} - -\def\fontclassstrategiesb % --- --- --- def % pt tt bf - {\ifcsname\fontclass\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\fontclass\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname - \else - \expandafter\fontclassstrategiesc - \fi} - -\def\fontclassstrategiesc % --- --- def --- % pt tt tf a - {\ifcsname\fontclass\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname - \autofontsizetrue - \csname\fontclass\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname - \else - \expandafter\fontclassstrategiesd - \fi} - -\def\fontclassstrategiesd % --- --- def def % pt tt tf - {\ifcsname\fontclass\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\fontclass\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname - \else - \expandafter\fontclassstrategiese - \fi} - -\def\fontclassstrategiese % --- def def def % pt rm tf - {\ifcsname\fontclass\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizefalse - \csname\fontclass\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \else - \expandafter\fontclassstrategiesf - \fi} - -\def\fontclassstrategiesf % def def def def % rm tf - {\ifcsname\fontclass\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\fontclass\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \else - \expandafter\fontstrategiesa - \fi} - -% no class - -\def\fontstrategiesa % --- --- --- --- % pt tt bf a - {\ifcsname\fontbody \fontstyle \fontalternative \fontsize\endcsname - \autofontsizefalse - \csname\fontbody \fontstyle \fontalternative \fontsize\endcsname - \else - \expandafter\fontstrategiesb - \fi} - -\def\fontstrategiesb % --- --- --- --- % pt tt bf a - {\ifcsname\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname - \else - \expandafter\fontstrategiesc - \fi} - -\def\fontstrategiesc % --- --- --- --- % pt tt bf a - {\ifcsname\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname - \autofontsizetrue - \csname\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname - \else - \expandafter\fontstrategiesd - \fi} - -\def\fontstrategiesd % --- --- --- --- % pt tt bf a - {\ifcsname\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname - \else - \expandafter\fontstrategiese - \fi} - -\def\fontstrategiese % --- --- --- --- % pt tt bf a - {\ifcsname\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizefalse - \csname\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \else - \expandafter\fontstrategiesf - \fi} - -\def\fontstrategiesf % --- --- --- --- % pt tt bf a - {\ifcsname\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \autofontsizetrue - \csname\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname - \fi} - -\let\applyfontstrategies \fontstrategiesa -\let\applyfontclassstrategies\fontclassstrategiesa - -%D Let's synchronize: - -\newif\ifsynchronizefonts \synchronizefontstrue - -\prependtoks - \ifsynchronizefonts - \synchronizemath - \synchronizefont % problem: syncs last font - \fi -\to \everybodyfont - -%D Setting the normal sizes as well as the x and xx smaller -%D sizes is accomplished by the next set of macros. When in -%D math mode, the commands \type{\tx} and \type{\txx} are -%D just a switch to the script and double script styles, but -%D in text mode the values defined by the bodyfontenvironment are -%D used. Here we also set \type{\currentxfontsize}. - -\def\dosetcurrentfontxxxalternative#1#2#3#4% - {\currentxfontsize#2\relax - \ifmmode - #4% - \else\ifcsname\bodyfontvariable{\normalizedbodyfontsize#3}\endcsname - \setcurrentfontbodyalternative{\csname\bodyfontvariable\normalizedbodyfontsize#3\endcsname}{#1}% - \fi\fi} - -\def\setcurrentfontxalternative#1% - {\dosetcurrentfontxxxalternative{#1}1\c!x\scriptstyle - \let\tx\txx} - -\def\setcurrentfontxxalternative#1% - {\dosetcurrentfontxxxalternative{#1}2\c!xx\scriptscriptstyle - \let\tx\empty - \let\txx\empty} - -\def\checknestedxfontsize % option - {\ifcase\currentxfontsize\else\ifx\fontsize\empty\else - \currentxfontsize\zerocount - \let\fontsize\empty - \let\tx\normaltx - \let\txx\normaltxx - \fi\fi} - -\def\setcurrentfontxalternative#1% - {\checknestedxfontsize - \dosetcurrentfontxxxalternative{#1}1\c!x\scriptstyle - \let\tx\txx} - -\def\setcurrentfontxxalternative#1% - {\checknestedxfontsize - \dosetcurrentfontxxxalternative{#1}2\c!xx\scriptscriptstyle - \let\tx\empty - \let\txx\empty} - -% This alterative is not really needed, but for old time's sake -% we keep it there. We can speed it up when needed. - -\def\setcurrentfontxstylealternative #1{\csname#1\endcsname\tx} -\def\setcurrentfontxxstylealternative#1{\csname#1\endcsname\txx} - -%D These macros also show us that when we call for \type{\tx}, -%D this macro is redefined to be \type{\txx}. Therefore calls -%D like: -%D -%D \startbuffer -%D {small \tx is \tx beautiful} -%D {small \tx is \txx beautiful} -%D {small \txx is \tx beautiful} -%D {small \txx is \txx beautiful} -%D \stopbuffer -%D -%D \typebuffer -%D -%D result in: -%D -%D \startlines -%D \getbuffer -%D \stoplines -%D -%D Setting the main size involves the style list and therefore -%D takes a bit more time. Keep in mind that the fontsize is -%D represented by a character or empty. - -\unexpanded\def\tx {\setcurrentfontxalternative \fontalternative} -\unexpanded\def\txx{\setcurrentfontxxalternative\fontalternative} - -\let\normaltx \tx -\let\normaltxx\txx - -%D \macros -%D {definefontstyle} -%D -%D When setting of switching the overall style we can use the -%D short identifier like rm and ss, but when defined we can -%D also use more verbose names like roman or sansserif. Such -%D names are defined by: -%D -%D \starttyping -%D \definefontstyle [serif,rm] [rm] -%D \definefontstyle [sansserif,ss] [ss] -%D \stoptyping - -\def\dododefinefontstyle#1#2% - {\setvalue{\??fontshortstyle#2}{#1}% - \setvalue{\??fontstyle #2}{\csname#1\endcsname}} - -\def\dodefinefontstyle[#1][#2]% - {\rawdoifinsetelse{#2}{\fontstylelist}{}{\addtocommalist{#2}\fontstylelist}% - \processcommalist[#1]{\dododefinefontstyle{#2}}} - -\unexpanded\def\definefontstyle - {\dodoubleargument\dodefinefontstyle} - -\def\setfontstyle#1#2% #1:name (roman, romaan) #2:style (rm) - {\edef\fontstyle{#1}% - \checkfontnamecombinations - \setcurrentfontstyle\normalizedbodyfontsize} - -%D When asking for a complete font switch, for instance from 10 -%D to 12~points, the next macro does the job. First we -%D normalize the size, next we define the current range of -%D text, script and scriptscript sizes, then we set the text -%D fonts and the math families and finally we activate the -%D default typeface and also set the font specific parameters -%D assigned to \type{\everybodyfont} - -\def\dosetbodyfontface#1#2% - {\edef#1{\csname\bodyfontvariable\normalizedbodyfontsize#2\endcsname}} - -\def\docompletefontswitch[#1]% - {\bodyfontsize#1\relax - \dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart - \edef\bodyfontfactor{\withoutpt\the\bodyfontsize}% - \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}% - \dosetbodyfontface \textface \s!text - \dosetbodyfontface \scriptface \s!script - \dosetbodyfontface \scriptscriptface \s!scriptscript} - -\docompletefontswitch[12pt] % init - -%D \macros -%D {setupbodyfont,switchtobodyfont} -%D -%D The next two macros are user ones. With \type{\setupbodyfont} -%D one can set the document bodyfont size, font family, style -%D and/or options defined in files, for example: -%D -%D \starttyping -%D \setupbodyfont[modern,12pt,roman] -%D \stoptyping -%D -%D This command affects the document as a whole: text, headers -%D and footers. The second macro however affects only the text: -%D -%D \starttyping -%D \switchtobodyfont[10pt] -%D \stoptyping -%D -%D So we've got: -%D -%D \showsetup{setupbodyfont} -%D \showsetup{switchtobodyfont} -%D -%D Both macros look alike. The second one also has to take -%D all kind of keywords into account. - -\ifx\saveinterlinespace \undefined \let\saveinterlinespace \relax \fi -\ifx\restoreinterlinespace\undefined \let\restoreinterlinespace\relax \fi - -% \newtoks \everysetupbodyfont -% \newtoks \everyswitchtobodyfont - -\definecomplexorsimple\setupbodyfont - -\def\simplesetupbodyfont - {\restoreglobalbodyfont - \saveinterlinespace} - -\def\complexsetupbodyfont[#1]% - {\doifsomething{#1} - {\dosetfont1{#1}% - \globalbodyfontsize\localbodyfontsize - \edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\globalbodyfontsize}% - \let\globalfontstyle\fontstyle - \ifproductionrun - \the\everybodyfont - \the\everyglobalbodyfont - \saveinterlinespace - \fi - \the\everysetupbodyfont}} - -\unexpanded\def\switchtobodyfont[#1]% - {\doifsomething{#1} - {\ifcsname\??ft\normalizedbodyfontsize\interfaced{#1}\endcsname - \setbodyfontstep{#1}% so we have a fast [small] switch - \else - \dosetfont0{#1}% - \fi - \the\everybodyfont - \the\everyswitchtobodyfont}} - -%D The following alternative is meant for math||to||text -%D switching and will be optimized. - -\def\fastswitchtobodyfont#1% - {\ifcsname\??ft\normalizedbodyfontsize#1\endcsname - \edef\futurebodyfontsize{\csname\??ft\normalizedbodyfontsize#1\endcsname}% - \ifcsname\??fontsize\futurebodyfontsize\endcsname - \csname\??fontsize\futurebodyfontsize\endcsname - \localbodyfontsize\futurebodyfontsize\relax - \fi - \fi - \csname\??fontstyle\fontstyle\endcsname - \the\everybodyfont} - -%D \starttyping -%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$ -%D \stoptyping - -\def\setfontcharacteristics - {\the\everyfont} - -%D Predefined: - -% \installfontfeature[otf][tlig] -% \installfontfeature[otf][trep] - -%D Todo: - -% \def\os{\groupedcommand{\setfontfeature{oldstyle}}{}} - -%D Experimental: - -\unexpanded\def\definefontfeature - {\dotripleargument\dodefinefontfeature} - -\def\dodefinefontfeature[#1][#2][#3]% - {\global\expandafter\chardef\csname\??fq=#1\endcsname % beware () needed as we get two values returned - \cldcontext{((fonts.specifiers.presetcontext("#1","#2","#3")))}\relax} - -\definefontfeature % experiment, this might move to the lua code - [always] - [mode=auto, - script=auto, - kern=yes, - mark=yes, - mkmk=yes, - curs=yes] - -\definefontfeature - [default] - [always] - [liga=yes, - tlig=yes, - trep=yes] % texligatures=yes,texquotes=yes - -\definefontfeature - [smallcaps] - [always] - [smcp=yes, - tlig=yes, - trep=yes] % texligatures=yes,texquotes=yes - -\definefontfeature - [oldstyle] - [always] - [onum=yes, - liga=yes, - tlig=yes, - trep=yes] % texligatures=yes,texquotes=yes - -\definefontfeature % == default unless redefined - [ligatures] - [always] - [liga=yes, - tlig=yes, - trep=yes] - -\definefontfeature % can be used for type1 fonts - [complete] - [always] - [compose=yes, - liga=yes, - tlig=yes, - trep=yes] - -\definefontfeature - [none] - [mode=none, - features=no] - -\definefontfeature % might move - [arabic] - [mode=node,language=dflt,script=arab,ccmp=yes, - init=yes,medi=yes,fina=yes,isol=yes, - liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes, - mark=yes,mkmk=yes,kern=yes,curs=yes] - -\definefontfeature % might move - [simplearabic] - [mode=node,language=dflt,script=arab, - init=yes,medi=yes,fina=yes,calt=yes, - rlig=yes,curs=yes,mark=yes,mkmk=yes] - -% symbols: - -\definefontfeature - [dingbats] - [mode=base, - goodies=dingbats, - unicoding=yes] - -% math: - -\definefontfeature - [mathematics] - [mode=base, - liga=yes, - kern=yes, - tlig=yes, - trep=yes, - mathalternates=yes, - mathitalics=yes, - % nomathitalics=yes, % don't pass to tex, might become default - language=dflt, - script=math] - -\definefontfeature - [mathematics-l2r] - [mathematics] - [] - -\definefontfeature - [mathematics-r2l] - [mathematics] - [language=ara, - rtlm=yes, - locl=yes] - -\definefontfeature[virtualmath] [mathematics] % downward compatibility -\definefontfeature[virtualmath-l2r] [mathematics-l2r] % downward compatibility -\definefontfeature[virtualmath-r2l] [mathematics-r2l] % downward compatibility - -\definefontfeature[math-text] [mathematics] [ssty=no] -\definefontfeature[math-script] [mathematics] [ssty=1,mathsize=yes] -\definefontfeature[math-scriptscript] [mathematics] [ssty=2,mathsize=yes] - -\definefontfeature[math-text-l2r] [mathematics-l2r] [ssty=no] -\definefontfeature[math-script-l2r] [mathematics-l2r] [ssty=1,mathsize=yes] -\definefontfeature[math-scriptscript-l2r] [mathematics-l2r] [ssty=2,mathsize=yes] - -\definefontfeature[math-text-r2l] [mathematics-r2l] [ssty=no] -\definefontfeature[math-script-r2l] [mathematics-r2l] [ssty=1,mathsize=yes] -\definefontfeature[math-scriptscript-r2l] [mathematics-r2l] [ssty=2,mathsize=yes] - -\definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] -\definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] -\definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] - -% \definefontfeature[mathtext] [math-text] -% \definefontfeature[mathscript] [math-script] -% \definefontfeature[mathscriptscript] [math-scriptscript] - -%D Also new, handy for manuals: - -\unexpanded\def\fontchar#1{\ctxcommand{fontchar("#1")}} - -%D: We cannot yet inherit because no colors are predefined. - -\definecolor[trace:0][s=.6] -\definecolor[trace:1][r=.6] -\definecolor[trace:2][g=.6] -\definecolor[trace:3][b=.6] -\definecolor[trace:4][r=.6,g=.6] -\definecolor[trace:5][r=.6,b=.6] -\definecolor[trace:6][g=.6,b=.6] -\definecolor[trace:7][r=.8,g=.4] -\definecolor[trace:8][r=.8,b=.4] -\definecolor[trace:9][g=.4,b=.8] - -\definecolor[font:init][r=.75] -\definecolor[font:medi][g=.75] -\definecolor[font:fina][b=.75] -\definecolor[font:isol][r=.75,g=.75] % [y=.75] -\definecolor[font:mark][r=.75,b=.75] % [m=.75] -\definecolor[font:rest][g=.75,b=.75] % [c=.75] - -%D Experimental! - -\def\installfontfeature - {\dodoubleargument\doinstallfontfeature} - -\def\doinstallfontfeature[#1][#2]% - {\writestatus\m!fonts{installing font features was experimental}} % \ctxlua{fonts.install_feature("#1","#2")}} - -%D Not yet in \MKII. - -\def\fontfeatureslist - {\dodoubleargument\dofontfeatureslist} - -\def\dofontfeatureslist[#1][#2]% todo: arg voor type - {\cldcontext{fonts.specifiers.contexttostring("#1","otf","\luaescapestring{#2}","yes","no",true,{"number"})}} - -\attribute\zerocount\zerocount % first in list, so fast match - -\let\currentfeature\empty - -% ! ! ! very experimental, some test code for idris advanced features ! ! ! -% -% \startbuffer -% \definefontfeature[smallcaps][smallcaps][script=latn] -% \definefontfeature[oldstyle] [oldstyle] [script=latn] -% -% \definedfont[name:cambria at 15pt] -% -% Hello there {\setff{smallcaps}capped 123 \setff{oldstyle}123!} \blank -% Hello there {\addff{smallcaps}capped 123 \addff{oldstyle}123!} \blank -% Hello there {\addff{smallcaps}capped \subff{smallcaps}normal} \blank -% \stopbuffer -% -% \typebuffer \getbuffer - -\unexpanded\def\featureattribute#1{\ctxcommand{featureattribute("#1")}} -\unexpanded\def\setfontfeature #1{\ctxcommand{setfontfeature("#1")}\edef\currentfeature{#1}} -\unexpanded\def\resetfontfeature#1{\ctxcommand{resetfontfeature()}\let\currentfeature\empty} % initial value -\unexpanded\def\resetfontfeature#1{\attribute\zerocount\zerocount\let\currentfeature\empty} % initial value - -\unexpanded\def\addfontfeaturetoset #1{\ctxcommand{addfs("#1")}} % merge -\unexpanded\def\subtractfontfeaturefromset #1{\ctxcommand{subfs("#1")}} % merge -\unexpanded\def\addfontfeaturetofont #1{\ctxcommand{addff("#1")}} % overload -\unexpanded\def\subtractfontfeaturefromfont#1{\ctxcommand{subff("#1")}} % overload - -\let\setff\setfontfeature -\let\addfs\addfontfeaturetoset -\let\subfs\subtractfontfeaturefromset -\let\addff\addfontfeaturetofont -\let\subff\subtractfontfeaturefromfont - -%D The next auxilliary macro is an alternative to \type -%D {\fontname}. - -\def\purefontname#1{\ctxlua{file.basename("\fontname#1"}} % will be function using id - -%D \macros -%D {switchstyleonly} -%D -%D For switching a style but keeping the alternative, there -%D is: -%D -%D \starttyping -%D {\bf text \switchstyleonly\ss text} -%D {\bf text \switchstyleonly[ss]text} -%D {\sl text \switchstyleonly[sansserif]text} -%D \stoptyping - -\definecomplexorsimple\switchstyleonly - -\def\simpleswitchstyleonly#1% stupid version - {\complexswitchstyleonly[\checkedstrippedcsname#1]} - -\def\complexswitchstyleonly[#1]% todo : check - {\setcurrentfontstyle{\csname\??fontshortstyle#1\endcsname}% - \the\everybodyfont} % needed ? - -%D \macros -%D {os} -%D -%D In good old \TEX, the old style numerals were often taken -%D from the math fonts. No longer. - -\definefontfeature - [just-os] - [mode=node,onum=yes] - -% \def\sc{\setfontfeature{smallcaps}} -\unexpanded\def\os{\setfontfeature{just-os}} - -%D Code for switching to fraktur and script has also been -%D changed. We now have an alphabet switcher. - -\ifx\mathtext\undefined \let\mathtext\hbox \fi - -%D \macros -%D {definebodyfontswitch} -%D -%D \PLAIN\ \TEX\ defines some macro's like \type{\tenpoint} -%D to switch to a specific bodyfontsize. Just for the sake of -%D compatibility we can define them like: -%D -%D \starttyping -%D \definebodyfontswitch [twelvepoint] [12pt] -%D \stoptyping -%D -%D We don't support language specific synonyms here, mainly -%D because \PLAIN\ \TEX\ is english anyway. - -\def\dodefinebodyfontswitch[#1][#2]% - {\def\dododefinebodyfontswitch##1{\setvalue{##1}{\switchtobodyfont[#2]}}% - \processcommalist[#1]\dododefinebodyfontswitch} - -\unexpanded\def\definebodyfontswitch - {\dodoubleargument\dodefinebodyfontswitch} - -%D \macros -%D {setsmallbodyfont,setmainbodyfont,setbigbodyfont} -%D -%D When we're typesetting at for instance 10pt, we can call for -%D the \type{small} as well as the \type{big} alternative, -%D related to this main size, using \type{\switchtobodyfont[small]}. -%D The three alternatives can be activated by the next three -%D system calls and are defined by the bodyfontenvironment. - -\let\fontstep\empty % we can use \fontstep for tracing purposes - -\def\setbodyfontstep#1% - {\edef\fontstep{\csname\bodyfontvariable\normalizedbodyfontsize\interfaced{#1}\endcsname}% - \doswitchpoints[\fontstep]% - \doswitchstyle[\fontstyle]} - -\unexpanded\def\setsmallbodyfont{\setbodyfontstep\v!small\the\everybodyfont} -\unexpanded\def\setbigbodyfont {\setbodyfontstep\v!big \the\everybodyfont} - -\unexpanded\def\setmainbodyfont - {\doswitchpoints[\normalizedbodyfontsize]% - \doswitchstyle[\fontstyle]% - \the\everybodyfont - \the\everyglobalbodyfont - \saveinterlinespace} - -%D \macros -%D {restoreglobalbodyfont} -%D -%D Users can set whatever font available while typesetting text. -%D Pagenumbers, footers, headers etc. however must be typeset -%D in the main bodyfont and style of the document. Returning to -%D the global state can be done with the next macro: - -\let\globalfontstyle\c!rm - -\def\fullrestoreglobalbodyfont - {\let\fontsize\defaultfontsize - \let\fontbody\defaultfontbody - \currentxfontsize\zerocount - \let\fontclass\globalfontclass - \doswitchpoints[\normalizedglobalbodyfontsize]% - \doswitchstyle[\globalfontstyle]% - \redoconvertfont % just in case a pagebreak occurs - \tf - \the\everybodyfont - \the\everyglobalbodyfont - \saveinterlinespace} - -\def\partialrestoreglobalbodyfont - {\let\fontsize\defaultfontsize - \let\fontbody\defaultfontbody - \currentxfontsize\zerocount - \redoconvertfont - \tf - \the\everybodyfont % indeed needed - \the\everyglobalbodyfont % indeed needed - \saveinterlinespace} - -\def\restoreglobalbodyfont % ook style etc - {\ifx\fontclass\globalfontclass - \ifx\fontstyle\globalfontstyle - \ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize - \partialrestoreglobalbodyfont - \else - \fullrestoreglobalbodyfont - \fi - \else - \fullrestoreglobalbodyfont - \fi - \else - \fullrestoreglobalbodyfont - \fi} - -% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont - -%D This macro has to be called when entering the pagebody -%D handling routine as well as the footnote insert routine. -%D Users can access this feature |<|for instance when one wants -%D to typeset tables and alike in the main bodyfont and style -%D while the running text is temporary set to a smaller one|>| -%D by saying \type{\switchtobodyfont[global]}. - -%D \macros -%D {rasterfont} -%D -%D There are (at the moment) two situations in which we want to -%D have fast access to a particular font. When we are using -%D \TEX\ to typeset rasters, we use small {\rasterfont.}'s -%D (a rather small period indeed), the same as \PICTEX\ uses -%D for drawing purposes. - -\definefont [rasterfont] [Serif at 5pt] % obsolete - -%D \macros -%D {infofont} -%D -%D The second situation occurs when we enable the info mode, -%D and put all kind of status information in the margin. We -%D don't want huge switches to the main bodyfont and style, so -%D here too we use a direct method. - -\let\infofont\relax % satisfy dep checker - -\definefont [infofont] [Mono at 6pt] % todo \the\everybodyfont - -%D \macros -%D {definealternativestyle} -%D -%D In the main modules we are going to implement lots of -%D parameterized commands and one of these parameters will -%D concern the font to use. To suit consistent use of fonts we -%D here implement a mechanism for defining the keywords that -%D present a particular style or alternative. -%D -%D \starttyping -%D \definealternativestyle [keywords] [\style] [\nostyle] -%D \stoptyping -%D -%D The first command is used in the normal textflow, while the -%D second command takes care of headings and alike. Consider -%D the next two definitions: -%D -%D \starttyping -%D \definealternativestyle [bold] [\bf] [] -%D \definealternativestyle [cap] [\cap] [\cap] -%D \stoptyping -%D -%D A change \type{\bf} in a heading which is to be set in -%D \type{\tfd} does not look that well, so therefore we leave -%D the second argument of \type{\definealternativestyle} empty. -%D When we capatalize characters using the pseudo small cap -%D command \type{\cap}, we want this to take effect in both -%D text and headings, which is accomplished by assigning both -%D arguments. - -\setnewconstant \currentalternativestyleindex \plusone - -\def\dododefinealternativestyle#1#2#3% - {\ifcsname#3\endcsname - % no redefinition - \else - \setuvalue{#3}{\groupedcommand{#1}{}}% - \fi - \setvalue{\??ft:as:#3}{\doapplyalternativestyle{#1}{#2}}}% - -\def\dodefinealternativestyle[#1][#2][#3]% - {\processcommalist[#1]{\dododefinealternativestyle{#2}{#3}}} % also gets {##1} - -\def\applyalternativestyle#1% - {\ifcsname\??ft:as:#1\endcsname\csname\??ft:as:#1\expandafter\endcsname\fi} - -\def\doapplyalternativestyle - {\ifcase\currentalternativestyleindex - \expandafter\gobbletwoarguments - \or - \expandafter\firstoftwoarguments - \or - \expandafter\secondoftwoarguments - \else - \expandafter\firstoftwoarguments - \fi} - -\unexpanded\def\definealternativestyle - {\dotripleempty\dodefinealternativestyle} - -\let\definestyle\definealternativestyle % later redefined - -%D Maybe too geneneric, but probably ok is the following. (Maybe one -%D day we will use a dedicated grouped command for styles.) - -\appendtoks - \let\groupedcommand\thirdofthreearguments -\to \simplifiedcommands - -%D This command also defines the keyword as command. This means -%D that the example definition of \type{bold} we gave before, -%D results in a command \type{\bold} which can be used as: -%D -%D \startbuffer -%D He's a \bold{bold} man with a {\bold head}. -%D \stopbuffer -%D -%D \typebuffer -%D -%D or -%D -%D \startexample -%D \definealternativestyle[bold][\bf][]\getbuffer -%D \stopexample -%D -%D Such definitions are of course unwanted for \type{\cap} -%D because this would result in an endless recursive call. -%D Therefore we check on the existance of both the command and -%D the substitution. The latter is needed because for instance -%D \type{\type} is an entirely diferent command. That command -%D handles verbatim, while the style command would just switch -%D to teletype font. This is just an example of a tricky -%D naming coincidence. - -%D \macros -%D {doconvertfont,noconvertfont, -%D dontconvertfont,redoconvertfont} -%D -%D After having defined such keywords, we can call for them by -%D using -%D -%D \starttyping -%D \doconvertfont{keyword}{text} -%D \stoptyping -%D -%D We deliberately pass an argument. This enables us to -%D assign converters that handle one argument, like -%D \type{\cap}. -%D -%D By default the first specification is used to set the style, -%D exept when we say \type{\dontconvertfont}, after which the -%D second specification is used. We can also directly call for -%D \type{\noconvertfont}. In nested calls, we can restore the -%D conversion by saying \type{\redoconvertfont}. - -%D These commands are not grouped! Grouping is most probably -%D done by the calling macro's and would lead to unnecessary -%D overhead. - -\unexpanded\def\doconvertfont#1% #2% we need the protection - {\edef\currentconvertfont{#1}% - \ifx\currentconvertfont\empty - %\expandafter\firstofoneargument - \else - \expandafter\dodoconvertfont - \fi} - -\def\dodoconvertfont - {\edef\dtcurrentconvertfont{\detokenize\@EA{\currentconvertfont}}% - \ifcsname\??ft:as:\dtcurrentconvertfont\endcsname - \csname\??ft:as:\dtcurrentconvertfont\expandafter\endcsname - \else\ifcsname\dtcurrentconvertfont\endcsname - \csname\dtcurrentconvertfont\expandafter\endcsname - \else - \doubleexpandafter\currentconvertfont - \fi\fi} - -%D Low level switches (downward compatible): - -\unexpanded\def\dontconvertfont{\currentalternativestyleindex\plustwo} -\unexpanded\def\redoconvertfont{\currentalternativestyleindex\plusone} - -%D The new one: - -\unexpanded\def\dousestyleparameter#1% - {\edef\currentstyleparameter{#1}% - \ifx\currentstyleparameter\empty\else - \expandafter\dousecurrentstyleparameter - \fi} - -\unexpanded\def\dousestylehashparameter#1#2% - {\ifcsname#1#2\endcsname - \expandafter\dousestyleparameter\csname#1#2\endcsname - \fi} - -\unexpanded\def\dousecurrentstyleparameter % empty check outside here - {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}% - \settrue\fontattributeisset % reset is done elsewhere - \ifcsname\??ft:as:\detokenizedstyleparameter\endcsname - \csname\??ft:as:\detokenizedstyleparameter\endcsname - \else\ifcsname\detokenizedstyleparameter\endcsname - \csname\detokenizedstyleparameter\endcsname - \else - \currentstyleparameter - \fi\fi} - -\let\dosetfontattribute\dousestylehashparameter % for a while - -%D \macros -%D {em,emphasistypeface,emphasisboldface} -%D -%D The next macro started as a copy of Donald Arseneau's -%D \type{\em} (\TUGNEWS\ Vol.~3, no.~1, 1994). His -%D implementation was a bit more sophisticated version of the -%D standard \LATEX\ one. We furter enhanced the macro, so now -%D it also adapts itself to boldface mode. Because we favor -%D {\sl slanted} type over {\it italic}, we made the emphasis -%D adaptable, for instance: -%D -%D \starttyping -%D \def\emphasistypeface {\it} -%D \def\emphasisboldface {\bi} -%D \stoptyping -%D -%D But we prefer: - -\def\emphasistypeface {\sl} -\def\emphasisboldface {\bs} - -%D or even better: - -\def\doemphasistypeface#1#2% - {\edef\emphasizedtypeface{\csname\??ft\fontclass\normalizedbodyfontsize\c!em\endcsname}% - \ifx\emphasizedtypeface\v!slanted - #1% - \else\ifx\emphasizedtypeface\v!italic - #2% - \else\ifx\emphasizedtypeface\v!empty - \edef\emphasizedtypeface{\csname\??ft\normalizedbodyfontsize\c!em\endcsname}% - \ifx\emphasizedtypeface\v!slanted - #1% - \else\ifx\emphasizedtypeface\v!italic - #2% - \else - \getvalue\emphasizedtypeface - \fi\fi - \else - \getvalue\emphasizedtypeface - \fi\fi\fi} - -\unexpanded\def\emphasistypeface{\doemphasistypeface\sl\it} -\unexpanded\def\emphasisboldface{\doemphasistypeface\bs\bi} - -\unexpanded\def\normalboldface - {\relax\ifx\fontalternative\c!it \bi - \else \ifx\fontalternative\c!sl \bs - \else \bf \fi\fi} - -\unexpanded\def\normaltypeface - {\relax - \ifx\fontalternative\c!bi \it \else - \ifx\fontalternative\c!bs \sl \else - \tf \fi\fi} - -\unexpanded\def\swaptypeface - {\relax - \ifx\fontalternative\c!it \tf \else - \ifx\fontalternative\c!sl \tf \else - \ifx\fontalternative\c!bf \emphasisboldface \else - \ifx\fontalternative\c!bs \bf \else - \ifx\fontalternative\c!bi \bf \else - \emphasistypeface \fi\fi\fi\fi\fi} - -\let\typeface\normaltypeface -\let\boldface\normalboldface -\let\swapface\swaptypeface - -%D To be set with the default body font environment: \type -%D {em} being \type {slanted} or \type {italic}. - -% maybe a \csname...\fontalternative\endcsname - -\newconditional\emneeded - -\newtoks\everyemphasized - -\unexpanded\def\em - {\relax - \ifdim\slantperpoint>\zeropoint - \settrue\emneeded - \else - \setfalse\emneeded - \fi - \setemphasisboldface % new - \ifx\fontalternative\c!it - \def\emphasistypeface{\it}\tf - \else\ifx\fontalternative\c!sl - \def\emphasistypeface{\sl}\tf - \else\ifx\fontalternative\c!bf - \emphasisboldface - \else\ifx\fontalternative\c!bs - \def\emphasisboldface{\bs}\bf - \else\ifx\fontalternative\c!bi - \def\emphasisboldface{\bi}\bf - \else - \emphasistypeface - \fi\fi\fi\fi\fi - \the\everyemphasized - \ifconditional\emneeded\else - \expandafter\aftergroup - \fi - \emphasiscorrection} - -% compare ... -% -% \appendtoks \red \to \everyemphasized -% \setupbodyfontenvironment [default] [em={\italic\color[red]}] - -%D The next feature was not present in previous versions. It -%D takes care of \type {\em \bf ...} situations. - -\def\setemphasisboldface - {\let\savedemphasisboldface\bf - \let\setemphasisboldface\relax - \let\bf\font_emphasis_bold_bold} - -\unexpanded\def\font_emphasis_bold_bold - {%\relax - \let\bf\relax % new - \ifx\fontalternative\c!it - \bi - \else\ifx\fontalternative\c!sl - \bs - \else - \savedemphasisboldface - \fi\fi - \let\bf\savedemphasisboldface} - -%D Donald's (adapted) macros take the next character into -%D account when placing italic correction. As a bonus we also -%D look for something that looks like a dash, in which case we -%D don't correct. - -\let\italiccorrection=\/ % tex primitive - -\def\emphasiscorrection % not in raw alignment groups, else omit problem - {\ifhmode\ifnum\currentgrouptype=\aligngroupcode\else - \expandafter\expandafter\expandafter\emphasislook - \fi\fi} - -\def\emphasislook - {\begingroup - \futurelet\next\emphasistest} - -\def\emphasistest - {\ifcat\noexpand\next,% still ok? - \expandafter\doemphasiscorrection - \else - \expandafter\dododoemphasiscorrection - \fi} - -\def\doemphasiscorrection - {\futurelet\next\dodoemphasiscorrection} - -\def\dodoemphasiscorrection - {\setbox\scratchbox\hbox{\next}% - \ifdim\ht\scratchbox=\zeropoint % probably a space - \expandafter\dododoemphasiscorrection - \else\ifdim\ht\scratchbox<.3ex - \expandafter\expandafter\expandafter\endgroup - \else - \expandafter\expandafter\expandafter\dododoemphasiscorrection - \fi\fi} - -\def\dododoemphasiscorrection - {\scratchskip\lastskip - \ifdim\scratchskip=\zeropoint\relax % == \ifzeropt\scratchskip - \italiccorrection\relax - \else - \unskip\italiccorrection\hskip\scratchskip - \fi - \endgroup} - -%D We end with some examples which show the behavior when -%D some punctuation is met. We also show how the mechanism -%D adapts itself to bold, italic and slanted typing. -%D -%D \startbuffer -%D test {test}test \par -%D test {\sl test}test \par -%D test {\em test}test \par -%D test {\em test}--test \par -%D -%D test {test}, test \par -%D test {\em test}, test \par -%D -%D test {\em test {\em test {\em test} test} test} test \par -%D test {\bf test {\em test {\em test} test} test} test \par -%D test {\sl test {\em test {\em test} test} test} test \par -%D test {\it test {\em test {\em test} test} test} test \par -%D \stopbuffer -%D -%D \typebuffer -%D -%D We get: -%D -%D \startpacked -%D \getbuffer -%D \stoppacked - -%D \macros -%D {emphbf,emphit,emphsl,emphtf} -%D -%D The next emphasis alternatives are for \THANH. They adapt -%D their style as good as possible. These macros are obsolete -%D in \MKIV. - -\unexpanded\def\emphbf{\groupedcommand{\bf\def\emphit{\bi}\def\emphsl{\bs}}{}} -\unexpanded\def\emphit{\groupedcommand{\it\def\emphbf{\bi}\def\emphsl{\sl}}{}} -\unexpanded\def\emphsl{\groupedcommand{\sl\def\emphbf{\bs}\def\emphit{\it}}{}} -\unexpanded\def\emphtf{\groupedcommand{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}{}} - -%D \startbuffer -%D TEXT {\emphbf text \emphit text \emphtf text \emphsl text} TEXT -%D TEXT \emphbf{text \emphit{text} \emphtf{text} \emphsl{text}} TEXT -%D \stopbuffer -%D -%D \typebuffer -%D \startlines -%D \getbuffer -%D \stoplines - -%D \macros -%D {setfont} -%D -%D Every now and then we want to define a font directly, for -%D instance when we typeset title pages. The next macro saves -%D some typing: - -\def\setfont% geen \dosetfont mogelijk - {\def\next{\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace - \afterassignment\next\font\nextfont=} - -%D One can call this macro as: -%D -%D \starttyping -%D \setfont cmr10 at 60pt -%D \stoptyping -%D -%D After which the font is active and the baselines and -%D struts are set. - -%D \macros -%D {showbodyfont} -%D -%D One can call for a rather simple overview of a bodyfont and the -%D relations between its alternative fonts. -%D -%D \showsetup{showbodyfont} -%D -%D The current bodyfont (here we omitted the argument) looks like: -%D -%D \showbodyfont -%D -%D The implementation is rather straightforward in using -%D \type{\halign}. - -\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run} - -%D \macros -%D {showfontstrip, testminimalbaseline, showminimalbaseline} -%D -%D The next command can come in handy when combining -%D different fonts into a collection (typeface) and -%D determining optimal baseline distances. -%D -%D \showfontstrip \blank \showminimalbaseline - -\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run} -\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run} -\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run} - -%D \macros -%D {showkerning} -%D -%D A goody is: -%D -%D \showkerning{Can you guess what kerning is?} - -\fetchruntimecommand \showkerning {\f!fontprefix\s!run} - -%D \macros -%D {showbodyfontenvironment} -%D -%D The current bodyfontenvironment is: -%D -%D \showbodyfontenvironment -%D -%D This overview is generated using: -%D -%D \showsetup{showbodyfontenvironment} - -\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run} - -%D \macros -%D {showfont,showfontstyle,showligatures} -%D -%D The following command generates a fontmap: -%D -%D \startbuffer -%D \showfont[SansBold at 12pt] -%D \stopbuffer -%D -%D \typebuffer -%D \getbuffer - -% to be internationalized - -\fetchruntimecommand \showfont {\f!fontprefix\s!run} -\fetchruntimecommand \showfontstyle {\f!fontprefix\s!run} -\fetchruntimecommand \showligature {\f!fontprefix\s!run} -\fetchruntimecommand \showligatures {\f!fontprefix\s!run} -\fetchruntimecommand \showcharratio {\f!fontprefix\s!run} - -%D \macros -%D {getglyph, symbolicfont} -%D -%D Individual glyphs can be accessed by using -%D -%D \starttyping -%D \getglyph{fontname}{character} -%D \stoptyping -%D -%D This macro is used in for instance the symbol modules and -%D as one can see, it does obey the small and even smaller -%D sizes. The \type {\symbolicfont} macro can be used to -%D switch to a font named \type {fontname} (see \type -%D {cont-log} and \type {symb-eur} for examples of symbolic -%D definitions. - -\def\fontstringA - {\ifx\fontstyle\c!rm \s!Serif \else - \ifx\fontstyle\c!ss \s!Sans \else - \ifx\fontstyle\c!tt \s!Mono \else - \s!Serif \fi\fi\fi} - -\def\fontstringB - {\ifx\fontstyle\c!rm \s!Regular \else - \ifx\fontstyle\c!ss \s!Support \else - \ifx\fontstyle\c!tt \s!Type \else - \s!Serif \fi\fi\fi} - -\def\fontstringC - {\ifx\fontalternative\c!bf \s!Bold \else - \ifx\fontalternative\c!sl \s!Slanted \else - \ifx\fontalternative\c!it \s!Italic \else - \ifx\fontalternative\c!bs \s!BoldSlanted \else - \ifx\fontalternative\c!bi \s!BoldItalic \fi\fi\fi\fi\fi} - -\def\fontstringD % default fontstyle - {\expandafter\ifx\csname\??tf\fontclass\s!default\endcsname\c!rm \s!Serif \else - \expandafter\ifx\csname\??tf\fontclass\s!default\endcsname\c!ss \s!Sans \else - \expandafter\ifx\csname\??tf\fontclass\s!default\endcsname\c!tt \s!Mono \else - \s!Serif \fi\fi\fi} - -% potential generalization: -% -% \letvalue{\??fontfile:t:\c!rm}\s!Serif -% \letvalue{\??fontfile:t:\c!ss}\s!Sans -% \letvalue{\??fontfile:t:\c!tt}\s!Mono -% -% \letvalue{\??fontfile:s:\c!bf}\s!Bold -% \letvalue{\??fontfile:s:\c!sl}\s!Slanted -% \letvalue{\??fontfile:s:\c!it}\s!Italic -% \letvalue{\??fontfile:s:\c!bs}\s!BoldSlanted -% \letvalue{\??fontfile:s:\c!bi}\s!BoldItalic -% -% \letvalue{\??fontfile:a:\c!rm}\s!Regular -% \letvalue{\??fontfile:a:\c!ss}\s!Support -% \letvalue{\??fontfile:a:\c!tt}\s!Type -% -% \def\fontstringA{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif} -% \def\fontstringB{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif} -% \def\fontstringC{\executeifdefined{\??fontfile:s:\fontstyle}\empty} -% \def\fontstringD{\executeifdefined{\??fontfile:t:\csname\??tf\fontclass\s!default\endcsname}\s!Serif} - -\def\glyphfontfile#1% - {#1% - \ifcsname\??fontfile#1\fontstringA\fontstringC\endcsname - \fontstringA\fontstringC - \else\ifcsname\??fontfile#1\fontstringB\fontstringC\endcsname - \fontstringB\fontstringC - \else\ifcsname\??fontfile#1\fontstringA\endcsname - \fontstringA - \else\ifcsname\??fontfile#1\fontstringB\endcsname - \fontstringB - \else\ifcsname\??fontfile#1\fontstringC\endcsname - \fontstringC - \fi\fi\fi\fi\fi} - -%D The next macro can be used to make decisions based on the shape: - -\def\doifitalicelse#1#2% - {\ifx\fontalternative\c!sl#1\else - \ifx\fontalternative\c!it#1\else - \ifx\fontalternative\c!bs#1\else - \ifx\fontalternative\c!bi#1\else#2\fi\fi\fi\fi} - -%D For an example of usage of the following command, -%D see \type {cont-log.tex}. -%D -%D \starttyping -%D \def\symbolicfont#1{\definedfont[\glyphfontfile{#1} sa *]} -%D \stoptyping -%D -%D Since we know what scaling it to be applied, we can -%D implement a much faster alternative: - -\installcorenamespace {symbolfont} - -\let\thedefinedfont\relax - -\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile - {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% - \ifcsname\??symbolfont\askedsymbolfont\endcsname - \csname\??symbolfont\askedsymbolfont\endcsname - \else - \dodefinesymbolicfont - \fi} - -\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile - {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% - \ifcsname\??symbolfont\askedsymbolfont\endcsname - \csname\??symbolfont\askedsymbolfont\endcsname - \else - \dodefinesymbolicfont - \fi} - -\def\setstyledsymbolicfont#1% quite a slowdown, glyphfontfile - {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#1}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% - \ifcsname\??symbolfont\askedsymbolfont\endcsname - \csname\??symbolfont\askedsymbolfont\endcsname - \else - \dodefinesymbolicfont - \fi} - -\def\setdirectsymbolicfont#1% - {\edef\askedsymbolfont{\truefontname{#1} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% - \ifcsname\??symbolfont\askedsymbolfont\endcsname - \csname\??symbolfont\askedsymbolfont\endcsname - \else - \dodefinesymbolicfont - \fi} - -\def\dodefinesymbolicfont - {\definefont[currentsymbolfont][\askedsymbolfont]% - \currentsymbolfont - \global\expandafter\let\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall} - -\unexpanded\def\getnamedglyphstyled#1#2{{\setstyledsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} -\unexpanded\def\getnamedglyphdirect#1#2{{\setdirectsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} -\unexpanded\def\getglyphstyled #1#2{{\setstyledsymbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} -\unexpanded\def\getglyphdirect #1#2{{\setdirectsymbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} -\unexpanded\def\getscaledglyph #1#2#3{{\setscaledstyledsymbolicfont\fontbody{#1}{#2}\doifnumberelse{#3}\char\donothing#3}} - -\let\getglyph \getglyphstyled % old -\let\getrawglyph \getglyphdirect % old -\let\symbolicsizedfont\setscaledstyledsymbolicfont % old -\let\symbolicfont \setstyledsymbolicfont % old - -\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody} -\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody} - -%D The last implementation of \type {\getglyph} permits -%D definitions like: -%D -%D \starttyping -%D \definefontsynonym [EuroSans] [eurose] -%D \definefontsynonym [EuroSansBold] [euroseb] -%D \definefontsynonym [EuroSansItalic] [eurosei] -%D \definefontsynonym [EuroSansSlanted] [eurosei] -%D \definefontsynonym [EuroSansBoldItalic] [eurosebi] -%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi] -%D -%D \definesymbol [euro] [\getglyph{Euro}{\char160}] -%D -%D \def\euro{\symbol[euro]} -%D \stoptyping -%D -%D These definitions guarantee that the next calls work okay: -%D -%D \starttyping -%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro -%D \stoptyping -%D -%D The shape as well as the size is adapted to the current -%D environment. - -%D \macros -%D {ss, SS, sz} -%D -%D We are going to redefine \type{\ss} but for those wo still -%D want to have access to the german \SS, we save it's value in -%D \type{\SS}. Ok, I should have used \type{\sf} instead of -%D \type{\ss} in the first place. - -\ifdefined\SS \else \let\SS=\ss \fi -\ifdefined\sz \else \let\sz=\ss \fi - -%D Personally I think that using \TEX\ macro packages is -%D complicated by the way fonts are handled. Apart from the -%D many encodings, we also deal with different naming schemes. -%D Confronted with this problem, I decided to change the -%D definitions into: -%D -%D \starttyping -%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt] -%D \stoptyping -%D -%D combined with for instance: -%D -%D \starttyping -%D \definefontsynonym [Times-Roman] [tir] -%D \stoptyping - -%D Now we're up to some definitions. - -\definebodyfontenvironment - [\s!default] - [ \s!text=1.0, - \s!script=0.7, - \s!scriptscript=0.5, - \c!a=1.200, - \c!b=1.440, - \c!c=1.728, - \c!d=2.074, - *=\currentfontscale, % wildcard - \c!x=0.8, - \c!xx=0.6, - \c!big=1.2, - \c!small=0.8, - \c!interlinespace=, - \c!em=\v!slanted] - -\definebodyfontenvironment - [20.7pt] - [ \s!text=20.7pt, - \s!script=\!!fourteenpointfour, - \s!scriptscript=\!!twelvepoint, - \c!x=17.3pt, - \c!xx=\!!fourteenpointfour, - \c!big=20.7pt, % !!!! - \c!small=17.3pt] - -\definebodyfontenvironment - [17.3pt] - [ \s!text=17.3pt, - \s!script=\!!twelvepoint, - \s!scriptscript=\!!tenpoint, - \c!x=\!!fourteenpointfour, - \c!xx=\!!twelvepoint, - \c!big=20.7pt, - \c!small=\!!fourteenpointfour] - -\definebodyfontenvironment - [\!!fourteenpointfour] - [ \s!text=\!!fourteenpointfour, - \s!script=\!!elevenpoint, - \s!scriptscript=\!!ninepoint, - \c!x=\!!twelvepoint, - \c!xx=\!!tenpoint, - \c!big=17.3pt, - \c!small=\!!twelvepoint] - -\definebodyfontenvironment - [\!!twelvepoint] - [ \s!text=\!!twelvepoint, - \s!script=\!!ninepoint, - \s!scriptscript=\!!sevenpoint, - \c!x=\!!tenpoint, - \c!xx=\!!eightpoint, - \c!big=\!!fourteenpointfour, - \c!small=\!!tenpoint] - -\definebodyfontenvironment - [\!!elevenpoint] - [ \s!text=\!!elevenpoint, - \s!script=\!!eightpoint, - \s!scriptscript=\!!sixpoint, - \c!x=\!!ninepoint, - \c!xx=\!!sevenpoint, - \c!big=\!!twelvepoint, - \c!small=\!!ninepoint] - -\definebodyfontenvironment - [\!!tenpoint] - [ \s!text=\!!tenpoint, - \s!script=\!!sevenpoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!eightpoint, - \c!xx=\!!sixpoint, - \c!big=\!!twelvepoint, - \c!small=\!!eightpoint] - -\definebodyfontenvironment - [\!!ninepoint] - [ \s!text=\!!ninepoint, - \s!script=\!!sevenpoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!sevenpoint, - \c!xx=\!!fivepoint, - \c!big=\!!elevenpoint, - \c!small=\!!sevenpoint] - -\definebodyfontenvironment - [\!!eightpoint] - [ \s!text=\!!eightpoint, - \s!script=\!!sixpoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!sixpoint, - \c!xx=\!!fivepoint, - \c!big=\!!tenpoint, - \c!small=\!!sixpoint] - -\definebodyfontenvironment - [\!!sevenpoint] - [ \s!text=\!!sevenpoint, - \s!script=\!!sixpoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!sixpoint, - \c!xx=\!!fivepoint, - \c!big=\!!ninepoint, - \c!small=\!!fivepoint] - -\definebodyfontenvironment - [\!!sixpoint] - [ \s!text=\!!sixpoint, - \s!script=\!!fivepoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!fivepoint, - \c!xx=\!!fivepoint, - \c!big=\!!eightpoint, - \c!small=\!!fivepoint] - -\definebodyfontenvironment - [\!!fivepoint] - [ \s!text=\!!fivepoint, - \s!script=\!!fivepoint, - \s!scriptscript=\!!fivepoint, - \c!x=\!!fivepoint, - \c!xx=\!!fivepoint, - \c!big=\!!sevenpoint, - \c!small=\!!fivepoint] - -\definebodyfontenvironment - [\!!fourpoint] - [ \s!text=\!!fourpoint, - \s!script=\!!fourpoint, - \s!scriptscript=\!!fourpoint, - \c!x=\!!fourpoint, - \c!xx=\!!fourpoint, - \c!big=\!!sixpoint, - \c!small=\!!fourpoint] - -\definebodyfontswitch [fourteenpointfour] [\!!fourteenpointfour] -\definebodyfontswitch [twelvepoint] [\!!twelvepoint] -\definebodyfontswitch [elevenpoint] [\!!elevenpoint] -\definebodyfontswitch [tenpoint] [\!!tenpoint] -\definebodyfontswitch [ninepoint] [\!!ninepoint] -\definebodyfontswitch [eightpoint] [\!!eightpoint] -\definebodyfontswitch [sevenpoint] [\!!sevenpoint] -\definebodyfontswitch [sixpoint] [\!!sixpoint] -\definebodyfontswitch [fivepoint] [\!!fivepoint] -\definebodyfontswitch [fourpoint] [\!!fourpoint] - -% \definebodyfontswitch [xii] [\!!twelvepoint] -% \definebodyfontswitch [xi] [\!!elevenpoint] -% \definebodyfontswitch [x] [\!!tenpoint] -% \definebodyfontswitch [ix] [\!!ninepoint] -% \definebodyfontswitch [viii] [\!!eightpoint] -% \definebodyfontswitch [vii] [\!!sevenpoint] -% \definebodyfontswitch [vi] [\!!sixpoint] - -%D So far. - -\definefontstyle [\c!mm] [\c!mm] -\definefontstyle [\c!rm,\v!roman,\v!serif,\v!regular] [\c!rm] -\definefontstyle [\c!ss,\v!sansserif,\v!sans,\v!support] [\c!ss] -\definefontstyle [\c!tt,\v!teletype,\v!type,\v!mono] [\c!tt] -\definefontstyle [\c!hw,\v!handwritten] [\c!hw] -\definefontstyle [\c!cg,\v!calligraphic] [\c!cg] - -\definefontalternative[\c!tf] -\definefontalternative[\c!bf] -\definefontalternative[\c!it] -\definefontalternative[\c!sl] -\definefontalternative[\c!bs] -\definefontalternative[\c!bi] -\definefontalternative[\c!sc] - -\definefontsize[\c!a] \definefontsize[\c!b] -\definefontsize[\c!c] \definefontsize[\c!d] - -\definealternativestyle [\v!mediaeval] [\os] [] -\definealternativestyle [\v!normal] [\tf] [] -\definealternativestyle [\v!bold] [\bf] [] -\definealternativestyle [\v!type] [\tt] [] -\definealternativestyle [\v!mono] [\tt] [] -\definealternativestyle [\v!slanted] [\sl] [] -\definealternativestyle [\v!italic] [\it] [] -\definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] [] -\definealternativestyle [\v!bolditalic,\v!italicbold] [\bi] [] - -\definealternativestyle [\v!small,\v!smallnormal] [\setsmallbodyfont\tf] [] -\definealternativestyle [\v!smallbold] [\setsmallbodyfont\bf] [] -\definealternativestyle [\v!smalltype] [\setsmallbodyfont\tt] [] -\definealternativestyle [\v!smallslanted] [\setsmallbodyfont\sl] [] -\definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\setsmallbodyfont\bs] [] -\definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\setsmallbodyfont\bi] [] - -\definealternativestyle [\v!bigger] [\setbigbodyfont \tf] [] -\definealternativestyle [\v!smaller] [\setsmallbodyfont\tf] [] - -\definealternativestyle [\v!sans,\v!sansserif] [\ss] [] -\definealternativestyle [\v!sansbold] [\ss\bf] [] - -% % maybe we need interface neutral as well (for use in cld): -% -% \letcscsname\mediaeval \csname\v!mediaeval \endcsname -% \letcscsname\normal \csname\v!normal \endcsname -% \letcscsname\bold \csname\v!bold \endcsname -% \letcscsname\mono \csname\v!mono \endcsname -% \letcscsname\slanted \csname\v!slanted \endcsname -% \letcscsname\italic \csname\v!italic \endcsname -% \letcscsname\boldslanted \csname\v!boldslanted \endcsname -% \letcscsname\slantedbold \csname\v!slantedbold \endcsname -% \letcscsname\bolditalic \csname\v!bolditalic \endcsname -% \letcscsname\italicbold \csname\v!italicbold \endcsname -% -% \letcscsname\small \csname\v!small \endcsname -% \letcscsname\smallnormal \csname\v!smallnormal \endcsname -% \letcscsname\smallbold \csname\v!smallbold \endcsname -% \letcscsname\smalltype \csname\v!smalltype \endcsname -% \letcscsname\smallslanted \csname\v!smallslanted \endcsname -% \letcscsname\smallboldslanted\csname\v!smallboldslanted\endcsname -% \letcscsname\smallslantedbold\csname\v!smallslantedbold\endcsname -% \letcscsname\smallbolditalic \csname\v!smallbolditalic \endcsname -% \letcscsname\smallitalicbold \csname\v!smallitalicbold \endcsname -% -% \letcscsname\bigger \csname\v!bigger \endcsname -% \letcscsname\smaller \csname\v!smaller \endcsname -% -% \letcscsname\sans \csname\v!sans \endcsname -% \letcscsname\sansserif \csname\v!sansserif \endcsname -% \letcscsname\sansbold \csname\v!sansbold \endcsname - -%D We can go on and on and on: -%D -%D \starttyping -%D \setupbodyfontenvironment[default][p=0.8,q=0.6] -%D \definefontsize[p] -%D \definefontsize[q] -%D \stoptyping - -%D Slow but handy: - -\definealternativestyle [\v!smallbodyfont] [\setsmallbodyfont] [] -\definealternativestyle [\v!bigbodyfont] [\setbigbodyfont] [] - -%D We treat {\sc Small Caps} and \cap {Pseudo Caps} a bit -%D different. We also provide an \WORD {uppercase} style. - -\definealternativestyle [\v!cap,\v!capital] [\smallcapped] [\smallcapped] -\definealternativestyle [\v!smallcaps] [\sc] [\sc] -\definealternativestyle [\v!WORD] [\WORD] [\WORD] - -%D \macros -%D {fontstylesuffix} -%D -%D The next macro is used to map non latin fontnames on -%D fonts. See \type {font-uni} for an example of its use. - -\def\fontstylesuffix% why the \s!Regular ? see \getglyph - {\ifx\fontalternative\c!tf \s!Regular \else - \ifx\fontalternative\c!bf \s!Bold \else - \ifx\fontalternative\c!sl \s!Slanted \else - \ifx\fontalternative\c!it \s!Italic \else - \ifx\fontalternative\c!bs \s!BoldSlanted \else - \ifx\fontalternative\c!bi \s!BoldItalic \else - \ifx\fontalternative\c!sc \s!Caps \else - \s!Regular \fi\fi\fi\fi\fi\fi\fi}% - -%D \macros -%D {definefontvariant,fontvariant,variant} -%D -%D This command is obsolete in \MKIV\ as we have features. It might -%D come back using the local features handlers. - -\unexpanded\def\definefontvariant{\dotripleargument\dodefinefontvariant} - -\def\dodefinefontvariant[#1][#2][#3]{} -\def\variant [#1]{} - -\ifdefined\Var\else \let\Var\variant \fi - -%D By default we load the Computer Modern Roman fonts (but -%D not yet at this moment) and activate the 12pt roman -%D bodyfont. Sans serif and teletype are also available and -%D can be called for by \type{\ss} and \type{\tt}. Loading -%D takes place elsewhere. -%D -%D For tracing purposes we define: - -\definefont[tinyfont][Mono at 1ex] - -% \tracinglostchars=1 - -% this needs some interfacing -% -% \setupfonts[check=...] - -\def\checkcharactersinfont {\ctxcommand{checkcharactersinfont }} -\def\removemissingcharacters{\ctxcommand{removemissingcharacters}} - -%D New commands (not yet interfaced): -%D -%D \startbuffer -%D \definestyle[one][style=bold,color=darkblue] -%D -%D test \one{test} test -%D test \style[one]{test} test -%D test \style[color=red]{test} test -%D test \style[Serif at 20pt]{test} test -%D \stopbuffer -%D -%D \typebuffer \startlines \getbuffer \stoplines - -% definitions .. no tagging here - -\installcorenamespace{style} -\installcorenamespace{stylecheck} - -\installcommandhandler \??style {style} \??style - -\appendtoks - \letvalue{\??stylecheck\currentstyle}\relax - \setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}% - \setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}% - \setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here -\to \everydefinestyle - -\unexpanded\def\font_styles_apply_start#1% - {\begingroup - \font_styles_use_defined{#1}} - -\unexpanded\def\font_styles_apply_stop - {\endgroup} - -\unexpanded\def\font_styles_apply_grouped#1% assumes that the next is { or \bgroup - {\bgroup - \def\g_style{\font_styles_use_defined{#1}}% - \afterassignment\g_style - \let\nexttoken} - -\unexpanded\def\font_styles_use_defined#1% - {\edef\currentstyle{#1}% - \usestylestyleandcolor\c!style\c!color} - -\unexpanded\def\font_styles_use_generic#1% - {\let\currentstyle\s!unknown % reasonable generic tag - \setupcurrentstyle[\c!style=,\c!color=,#1]% - \usestylestyleandcolor\c!style\c!color} - -% commands - -\installcorenamespace{styleargument} - -\unexpanded\def\style[#1]% as this is can be a switch we use groupedcommand - {\csname\??styleargument - \ifcsname#1\endcsname1\else\ifcsname\??stylecheck#1\endcsname2\else3\fi\fi - \endcsname{#1}} - -\setvalue{\??styleargument1}#1{\csname#1\endcsname} -\setvalue{\??styleargument2}#1{\groupedcommand{\font_styles_use_defined{#1}}{}} -\setvalue{\??styleargument3}#1{\doifassignmentelse{#1}\font_styles_assignment\font_styles_direct{#1}} - -\def\font_styles_assignment#1{\groupedcommand{\font_styles_use_generic{#1}}{}} -\def\font_styles_direct #1{\groupedcommand{\definedfont[#1]}{}} - -% environments - -\installcorenamespace{styleenvironment} - -\unexpanded\def\startstyle[#1]% - {\begingroup - \csname\??styleenvironment - \ifcsname#1\endcsname1\else\ifcsname\??stylecheck#1\endcsname2\else3\fi\fi - \endcsname{#1}} - -\unexpanded\def\stopstyle - {\endgroup - \autoinsertnextspace} % will be configurable, maybe also in \definestartstop - -\setvalue{\??styleenvironment1}#1{\csname#1\endcsname} -\setvalue{\??styleenvironment2}#1{\font_styles_use_defined{#1}} -\setvalue{\??styleenvironment3}#1{\doifassignmentelse{#1}\font_styles_start_assignment\font_styles_start_direct{#1}} - -\def\font_styles_start_assignment#1{\usegenericstyle{#1}} -\def\font_styles_start_direct #1{\definedfont[#1]\relax} - -%D Still experimental (might even go away). - -% \definestylecollection[mine] - -% \definestyleinstance[mine][default][sorry] -% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl] -% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl] -% \definestyleinstance[mine][bf][\sl] -% \definestyleinstance[mine][sl][\tt] - -% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}} - -\installcorenamespace{stylecollection} - -\unexpanded\def\definestylecollection - {\dosingleargument\font_styles_define_style_collection} - -\def\font_styles_define_style_collection[#1]% - {\iffirstargument - \setuvalue{#1}{\styleinstance[#1]}% - \def\font_styles_define_style_collection_do##1% - {\def\font_styles_define_style_collection_do_do####1{\letbeundefined{\??stylecollection#1:##1:####1}}% - \processcommacommand[\fontalternativelist,\s!default]\font_styles_define_style_collection_do_do}% - \processcommacommand[\fontstylelist,\s!default]\font_styles_define_style_collection_do - \fi} - -\unexpanded\def\definestyleinstance - {\doquadrupleargument\font_styles_define_style_instance} - -\def\font_styles_define_style_instance[#1][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever] - {\iffirstargument - \ifcsname#1\endcsname\else\font_styles_define_style_collection[#1]\fi - \fi - \iffourthargument - \setvalue{\??stylecollection#1:#2:#3}{#4}% - \else\ifthirdargument - \setvalue{\??stylecollection#1::#2}{#3}% - \else\ifsecondargument - \letvalueempty{\??stylecollection#1::#2}% - \fi\fi\fi} - -\unexpanded\def\styleinstance[#1]% will be made faster - {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup - \executeifdefined{\??stylecollection#1:\fontstyle:\fontalternative}% - {\executeifdefined{\??stylecollection#1:\fontstyle:\s!default}% - {\executeifdefined{\??stylecollection#1::\fontalternative} - {\getvalue {\??stylecollection#1::\s!default}}}}} - -% \unexpanded\def\styleinstance[#1]% -% {\csname\??stylecollection#1% -% \ifcsname:\fontstyle:\fontalternative\endcsname -% :\fontstyle:\fontalternative -% \else\ifcsname:\fontstyle:\s!default\endcsname -% :\fontstyle:\s!default -% \else\ifcsname::\fontalternative\endcsname -% ::\fontalternative -% \else\ifcsname::\s!default\endcsname -% ::\s!default -% \else -% % nothing, \relax -% \fi\fi\fi\fi -% \endcsname} - -%D goodies: - -\unexpanded\def\showchardata#1{\ctxcommand{showchardata("#1")}} -\unexpanded\def\showfontdata {\ctxcommand{showfontparameters()}} - -%D some low level helpers -%D -%D \starttyping -%D \def\TestLookup#1% -%D {\dolookupfontbyspec{#1} -%D pattern: #1, found: \dolookupnoffound -%D \blank -%D \dorecurse {\dolookupnoffound} {% -%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad -%D }% -%D \blank} -%D -%D \TestLookup{familyname=helveticaneue} -%D \TestLookup{familyname=helveticaneue,weight=bold} -%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic} -%D \stoptyping - -% we can also move the lookups to the fonts.namespace (of commands) - -\def\dolookupfontbyspec #1{\ctxcommand{fontlookupinitialize("#1")}} -\def\dolookupnoffound {\ctxcommand{fontlookupnoffound()}} -\def\dolookupgetkeyofindex#1#2{\ctxcommand{fontlookupgetkeyofindex("#1",#2)}} -\def\dolookupgetkey #1{\ctxcommand{fontlookupgetkey("#1")}} -\def\cleanfontname #1{\ctxcommand{cleanfontname("#1")}} - -% \doifelsecurrentfonthasfeature{smcp}{YES}{NO} -% \doifelsecurrentfonthasfeature{crap}{YES}{NO} -% \doifelsecurrentfonthasfeature{kern}{YES}{NO} - -\def\doifelsecurrentfonthasfeature#1% - {\ctxcommand{doifelsecurrentfonthasfeature("#1")}} - -% variant selectors -% -% \mathematics {\vsone{\utfchar{"2229}}} -% \mathematics {\utfchar{"2229}\vsone{}} - -\unexpanded\edef\vsone#1{#1\utfchar{"FE00}} % used -\unexpanded\edef\vstwo#1{#1\utfchar{"FE01}} % not used but handy for testing - -% new: - -\unexpanded\def\setfontofid#1{\ctxcommand{setfontofid(#1)}} - -\protect \endinput - diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi new file mode 100644 index 000000000..3e9660cf3 --- /dev/null +++ b/tex/context/base/font-ini.mkvi @@ -0,0 +1,4014 @@ +%D \module +%D [ file=font-ini, +%D version=1998.09.11, % (second) +%D version=2001.02.20, % (third) +%D title=\CONTEXT\ Font Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Watch out: as we define inside macros in sometimes special ways, +%D an occasional \type {\normaldef} is used in order to please the +%D \MKVI\ parser. + +%D The \type {type-ini} and \type {font-ini} modules come as a pair +%D and have mutual dependencies. + +%D Beware, we use s special set of parameters here: +%D +%D \starttabulate[|l|l|] +%D \NC system variable (fixed) \NC \type {\s!text} \NC \NR +%D \NC system variable (fixed) \NC \type {\s!script} \NC \NR +%D \NC system variable (fixed) \NC \type {\s!scriptscript} \NC \NR +%D \NC system variable (fixed) \NC \type {\s!x} \NC \NR +%D \NC system variable (fixed) \NC \type {\s!xx} \NC \NR +%D \NC variable (value) \NC \type {\v!big} \NC \NR +%D \NC variable (value) \NC \type {\v!small} \NC \NR +%D \NC constant (regular key) \NC \type {\c!interlinespace} \NC \NR +%D \NC constant (regular key) \NC \type {\c!em} \NC \NR +%D \stoptabulate +%D +%D The math related ones are similar to the ones used in \TEX\ itself, +%D the size related ones show up as keywords in the user interface +%D when switching sizes, and the two constants are used in key|/|value +%D situations. + +% a few more names need to be _'d but best first make all mkvi so +% that we can come up with more meaningful names + +% at some point fontclass will always have a value so that quite some +% code can go away + +% todo: reconsider design sizes ... kick 'm out which removes the size +% code and simplifies things considerably. After all, there will be no +% lm math in sizes. + +% \definefontfeature[smallcaps][smcp=yes,script=latn] +% \definefontfeature[smallcaps][SmallCapitals=yes,script=latn] +% \definefontfeature[smallcaps][Small Capitals=yes,script=latn] +% \definefontfeature[smallcaps][small capitals=yes,script=latn] +% \definefontfeature[smallcaps][smallcapitals=yes,script=latn] +% +% \definedfont[cambria*smallcaps] test + +% \starttext +% \definefontfeature[basekerned][default][mode=base] +% \definefontfeature[nodekerned][default][mode=node] +% \definefontfeature[nonekerned][default][mode=base,kern=no] +% \setupcolors[state=start] +% \startoverlay +% {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }} +% {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }} +% {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }} +% \stopoverlay +% \stoptext + +% \enabletrackers[otf.kerns] +% +% \definefontfeature[withkern][default][mode=node] +% \definefontfeature[nokern] [default][mode=node,kern=no] +% \definefontfeature[single] [default][mode=node,cpsp=yes] +% \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no] +% +% {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} + +% figure out why \fontbody is not expanded + +\writestatus{loading}{ConTeXt Font Macros / Initialization} + +\registerctxluafile{font-ini}{1.001} +\registerctxluafile{font-log}{1.001} +\registerctxluafile{font-con}{1.001} +\registerctxluafile{font-enc}{1.001} +%registerctxluafile{font-agl}{1.001} % loaded when needed, saves 100K in format +\registerctxluafile{font-cid}{1.001} % cid maps +\registerctxluafile{font-map}{1.001} +\registerctxluafile{font-syn}{1.001} + +\registerctxluafile{font-tfm}{1.001} + +\registerctxluafile{font-afm}{1.001} + +\registerctxluafile{font-oti}{1.001} % otf initialization +\registerctxluafile{font-ott}{1.001} % otf tables (first) +\registerctxluafile{font-otf}{1.001} % otf main +\registerctxluafile{font-otb}{1.001} % otf main base +\registerctxluafile{node-inj}{1.001} % we might split it off +\registerctxluafile{font-otn}{1.001} % otf main node +\registerctxluafile{font-otd}{1.001} % otf dynamics (does an overload) +\registerctxluafile{font-ota}{1.001} % otf analyzers (needs dynamics) +\registerctxluafile{font-otp}{1.001} % otf pack +\registerctxluafile{font-otc}{1.001} % otf context +\registerctxluafile{font-oth}{1.001} % otf helpers + +\registerctxluafile{font-pat}{1.001} % patchers + +\registerctxluafile{node-fnt}{1.001} % here + +\registerctxluafile{font-lua}{1.001} + +\registerctxluafile{font-vf} {1.001} +\registerctxluafile{font-enh}{1.001} + +\registerctxluafile{font-gds}{1.001} % currently only otf + +\registerctxluafile{font-def}{1.001} +\registerctxluafile{font-ctx}{1.001} % after def as it overloads + +\registerctxluafile{font-ext}{1.001} +\registerctxluafile{font-fbk}{1.001} +\registerctxluafile{font-chk}{1.001} + +\registerctxluafile{font-aux}{1.001} + +\unprotect + +% \def\fontrange#criteria% +% {\font_basics_fontrange{#criteria =\bodyfontsize}} +% +% \def\font_basics_fontrange#criteria% +% {\font_basics_fontrange_grab#criteria \relax}% \v_font_string_a +% +% \def\font_basics_fontrange_grab#specification #criterium % +% {\ifdim\bodyfontsize#criterium% +% #specification\expandafter\gobbleuntilrelax +% \else +% \expandafter\font_basics_fontrange_grab +% \fi} +% +% \definefont +% [crap] +% [\fontrange +% {Regular <10pt +% RegularBold <12pt +% RegularSlanted <15pt +% Regular} sa 1] +% +% may be better: +% +% \definefontrange +% [crap] +% [Regular <10pt +% RegularBold <12pt +% RegularSlanted <15pt] +% [Regular sa 1] +% +% +% \dostepwiserecurse{2}{15}{1} +% {{\switchtobodyfont[\recurselevel pt]\crap test}\endgraf} + +% adapted, else wrong interlinespace + +\unexpanded\def\setfontparameters + {\setfalse\c_font_synchronize + \the\everybodyfont + \settrue\c_font_synchronize} + +% handy + +\unexpanded\def\savefont + {\edef\savedfont{\the\font}% gives \csname + \pushmacro\savedfont} + +\unexpanded\def\restorefont + {\popmacro\savedfont + \savedfont} + +\unexpanded\def\pushcurrentfont + {\edef\popcurrentfont + {\def\noexpand\fontbody {\fontbody}% + \def\noexpand\fontstyle {\fontstyle}% + \def\noexpand\fontalternative{\fontalternative}% + \def\noexpand\fontsize {\fontsize}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font}} + +% \definetypeface[one][rm][serif][computer-roman][default] +% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9] +% +% {\one \bf test \two test} +% {\one \bf test \pushcurrentfont \two \popcurrentfont test} + +%D \macros +%D {definedfont,startfont,doiffontcharelse} +%D +%D A couple of relatively new macros: + +% \newtoks \everydefinedfont % not ot be confused with \everydefinefont + +\let\thedefinedfont\relax + +\unexpanded\def\definedfont + {\doifnextoptionalelse\font_basics_defined_font_yes\font_basics_defined_font_nop} + +\def\font_basics_defined_font_yes[#specification]% + {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly + %\definefont[thedefinedfont][#specification]% + \font_basics_define_font_without_parameters{thedefinedfont}{#specification}% + \thedefinedfont + \the\everydefinedfont} + +\def\font_basics_defined_font_nop + {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly + \thedefinedfont + \the\everydefinedfont} + +\unexpanded\def\startfont + {\begingroup\definedfont} + +\unexpanded\def\stopfont + {\endgroup} + +\unexpanded\def\doiffontcharelse#specification#unicode% this could be a direct lua call + {\begingroup + %\definedfont[#specification]% + \font_basics_define_font_without_parameters{thedefinedfont}{#specification}% + \iffontchar\font#unicode\relax + \endgroup\expandafter\firstoftwoarguments + \else + \endgroup\expandafter\secondoftwoarguments + \fi} + +%D For more detailed (and historic information) we refer to the file +%D \type {font-ini.mkii}. Here we have a much simplified lower level +%D implementation due to a different approach to math. Also the chapter +%D on fonts in the reference manual explains a lot. + +%D \macros +%D {rm,ss,tt,hw,cg} +%D +%D Fonts are defined in separate files. When we define a font, +%D we distinguish between several styles. In most cases we will +%D use: +%D +%D \startlinecorrection +%D \starttable[|l||] +%D \HL +%D \NC roman regular serif \NC \type{\rm} \NC\FR +%D \NC sansserif sans support \NC \type{\ss} \NC\MR +%D \NC type teletype mono \NC \type{\tt} \NC\LR +%D \HL +%D \stoptable +%D \stoplinecorrection +%D +%D The number of styles is not limited to these three. When +%D using Lucida Bright we can for instance also define: +%D +%D \startlinecorrection +%D \starttable[|l||] +%D \HL +%D \NC handwritten \NC \type{\hw} \NC\FR +%D \NC calligraphic \NC \type{\cg} \NC\LR +%D \HL +%D \stoptable +%D \stoplinecorrection +%D +%D Within such a font set (\type{cmr}) and style (\type{\rm}) +%D we can define a number of text font alternatives: +%D +%D \startlinecorrection +%D \starttable[|l||] +%D \HL +%D \NC typeface \NC \type{\tf} \NC\FR +%D \NC boldface \NC \type{\bf} \NC\MR +%D \NC slanted \NC \type{\sl} \NC\MR +%D \NC italic \NC \type{\it} \NC\MR +%D \NC boldslanted \NC \type{\bs} \NC\MR +%D \NC bolditalic \NC \type{\bi} \NC\MR +%D \NC smallcaps \NC \type{\sc} \NC\LR +%D \HL +%D \stoptable +%D \stoplinecorrection +%D +%D Internally fonts are stored as combination of size, style +%D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. +%D Users are not confronted with sizes, but use the style or +%D style+alternative to activate them. +%D +%D During the definition of a bodyfont one can also declare the +%D available larger alternatives: +%D +%D \starttyping +%D \tf \tfa \tfb \tfc ... +%D \bf \bfa \bfb \bfc ... +%D \sl \sla \slb \slc ... +%D \stoptyping +%D +%D The smaller ones are automatically supplied and derived from +%D the the bodyfont environment. +%D +%D \starttyping +%D \tfx \tfxx +%D \bfx \bfxx +%D \slx \slxx +%D \stoptyping +%D +%D There are only two smaller alternatives per style. The +%D larger alternatives on the other hand have no limitations. +%D +%D These larger alternatives are mostly used in chapter and +%D section titles or on title pages. When one switches to a +%D larger alternative, the bold an other ones automatically +%D adapt themselves: +%D +%D \startbuffer +%D \tfd Hi \bf there\sl, here \tfb I \bf am +%D \stopbuffer +%D +%S \startnarrower +%D \typebuffer +%S \stopnarrower +%D +%D therefore becomes: +%D +%D \startexample +%D \getbuffer +%D \stopexample +%D +%D Maybe this mechanism isn't always as logic, but as said +%D before, we tried to make it as intuitive as possible. +%D +%D So a specific kind of glyph can be characterized by: +%D +%D \startnarrower +%D family (cmr) + bodyfont (12pt) + style (rm) + alternative (bf) + size (a) +%D \stopnarrower +%D +%D The last component (the size) is optional. +%D +%D We introduced \type{\tf} as command to call for the current +%D normally sized typeface. This commands results in roman, +%D sans serif, teletype or whatever style is in charge. Such +%D rather massive switches of style sometimes take more +%D processing time than comfortable. Of course there is a +%D workaround for this: we can call fonts directly by means of +%D commands like: +%D +%D \starttyping +%D \rmtf \sssl \tttf \rmbsa +%D \stoptyping +%D +%D One should realize that this fast calls have limitations, +%D they lack for instance automatic super- and subscript +%D support. +%D +%D This leaves us two more commands: \type{\tx} and +%D \type{\txx}. These activate a smaller and even more smaller +%D font than the current one and adapt themselves to the +%D current alternative, so when \type{\bf} is active, +%D \type{\tx} gives a smaller boldface, which in turn can be +%D called directly by \type{\bfx}. +%D +%D These two smaller alternatives are specified by the bodyfont +%D environment and therefore not necessarily have similar sizes +%D as \type{\scriptsize} and \type{\scriptscriptsize}. The main +%D reason for this incompatibility (which can easily be undone) +%D lays in the fact that we often want a bit bigger characters +%D than in math mode. In \CONTEXT\ for instance the \type{\tx} +%D and \type{\txx} commands are used for surrogate +%D \cap{smallcaps} which support both nesting and alternatives, +%D like in {\bf\cap{a \cap{small} world}}, which was typeset by +%D +%D \starttyping +%D \bf\cap{a \cap{small} world} +%D \stoptyping +%D +%D And compare $\rm \scriptstyle THIS$ with the slightly larger +%D \cap{THIS}: \ruledhbox{$\rm \scriptstyle scriptstyle: THIS$} +%D or \ruledhbox{\cap{x style: THIS}} makes a big difference. +%D +%D The \type{x..d} sizes should be used grouped. If you +%D don't group them, i.e. call them in a row, \CONTEXT\ will +%D not be able to sort out your intention (\type {x} inside +%D \type {d} inside \type {x}. etc.). The following table +%D demonstrates this: +%D +%D \def\FontState{\setstrut\ruledhbox{\strut Hello}} +%D +%D \starttabulate[|||||] +%D \HL +%D \NC \rlap{\quad\bf grouped} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR +%D \HL +%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR +%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR +%D \NC \type{\tf} \NC \tf \FontState \NC \tf \tx \FontState \NC \tf \txx \FontState \NC \NR +%D \NC \type{\tfa} \NC \tfa \FontState \NC \tfa \tx \FontState \NC \tfa \txx \FontState \NC \NR +%D \NC \type{\tfb} \NC \tfb \FontState \NC \tfb \tx \FontState \NC \tfb \txx \FontState \NC \NR +%D \NC \type{\tfc} \NC \tfc \FontState \NC \tfc \tx \FontState \NC \tfc \txx \FontState \NC \NR +%D \NC \type{\tfd} \NC \tfd \FontState \NC \tfd \tx \FontState \NC \tfd \txx \FontState \NC \NR +%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR +%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR +%D \HL +%D \stoptabulate +%D +%D \blank +%D +%D \starttabulate[|||||] +%D \HL +%D \NC \rlap{\quad\bf stacked} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR +%D \HL +%D \NC \type{\tfx} +%D \NC \tfx \FontState +%D \NC \tfx \tx \FontState +%D \NC \tfx \txx \FontState +%D \NC \NR +%D \NC \type{\tfxx} +%D \NC \tfx\tfxx \FontState +%D \NC \tfx\tfxx \tx \FontState +%D \NC \tfx\tfxx \txx \FontState +%D \NC \NR +%D \NC \type{\tf} +%D \NC \tfx\tfxx\tf \FontState +%D \NC \tfx\tfxx\tf \tx \FontState +%D \NC \tfx\tfxx\tf \txx \FontState +%D \NC \NR +%D \NC \type{\tfa} +%D \NC \tfx\tfxx\tf\tfa \FontState +%D \NC \tfx\tfxx\tf\tfa \tx \FontState +%D \NC \tfx\tfxx\tf\tfa \txx \FontState +%D \NC \NR +%D \NC \type{\tfb} +%D \NC \tfx\tfxx\tf\tfa\tfb \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb \tx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb \txx \FontState +%D \NC \NR +%D \NC \type{\tfc} +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \tx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \txx \FontState +%D \NC \NR +%D \NC \type{\tfd} +%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \tx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \txx \FontState +%D \NC \NR +%D \NC \type{\tfx} +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \tx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \txx \FontState +%D \NC \NR +%D \NC \type{\tfxx} +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \tx \FontState +%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \txx \FontState +%D \NC \NR +%D \HL +%D \stoptabulate +%D +%D Remark: math support has changed a bit. + +\installcorenamespace {fontfile} % file synonyms +\installcorenamespace {fontsize} % bodyfont size prefix (12pt etc) +\installcorenamespace {fontstyle} % full style prefix (roman etc) +\installcorenamespace {fontshortstyle} % short style prefix (rm etc) +\installcorenamespace {fontclassyes} % fontclass +\installcorenamespace {fontclassnop} % nofontclass + +%D \macros +%D {fontclass, defaultfontclass} +%D +%D The fontclass model was introduced a while after we implement +%D the basic font model and at that time we still defaulted to +%D no model at all. Nowadays we default to the \type {modern} +%D fontclass. + +\let\fontclass \empty +\let\defaultfontclass\empty + +\def\fontclassname#class#name% + {\ifcsname\??fontfile#class#name\endcsname + \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}% + \else\ifcsname\??fontfile#name\endcsname + \fontclassname{#class}{\csname\??fontfile#name\endcsname}% + \else + #2% + \fi\fi} + +%D \macros +%D {textonly} +%D +%D Traditionally math has a big impact on font definitions, mainly +%D because we need to define alphabet variants using families and +%D fonts. This means that one can easily get 10 fonts loaded per +%D math size. In \MKIV\ we use a different approach: one family +%D which has either a virtual font made of traditional fonts, or +%D an \OPENTYPE\ font that has it all. +%D +%D We currently use only one math family but in the future we +%D might consider using a second one for bold math. For the +%D moment we keep the \MKII\ method of using a token register +%D for definitions but we already dropped the text and symbols +%D ones since they now live in the same family. + +\newtoks \t_font_math_strategies +\newconditional\c_font_synchronize_math_fonts \settrue\c_font_synchronize_math_fonts + +\unexpanded\def\font_helpers_synchronize_math % math stuff in mmode + {\ifconditional\c_font_synchronize_math_fonts\the\t_font_math_strategies\fi} + +\unexpanded\def\textonly{\setfalse\c_font_synchronize_math_fonts} % document this + +%D The main math font definer. We have removed some optimized +%D code simply because we now always have a fontclass. We could +%D check for fontclass being default or empty and save a few +%D tests but it does not help us when no math is defined. + +%D Because we want to keep mr=.. and mb=... settings (read: not +%D break downward compatibility by enforcing mrlr etc) we need a +%D bit more code that optimal. + +% todo: \c_font_fam_mr + +\let\c_font_fam_mr \zerocount % math regular +\let\c_font_fam_mr_lr\plusone % math regular l2r +\let\c_font_fam_mr_rl\plustwo % math regular r2l + +\let\c_font_fam_mb \plusthree % math bold +\let\c_font_fam_mb_lr\plusfour % math bold l2r +\let\c_font_fam_mb_rl\plusfive % math bold r2l + +\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 + +\def\mathtextsuffix {-text} +\def\mathscriptsuffix {-script} +\def\mathscriptscriptsuffix{-scriptscript} + +\let\currentmathsize\empty + +\def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi} + +% Beware: truefontname also does a fallback on defaultfontclass so there +% can be some interference here, which is why we use a different method +% for bold. + +\def\font_helpers_set_math_family_a + {\ifcsname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size + \csname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size + \csname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else + \font_helpers_set_math_family_b + \fi\fi} + +\def\font_helpers_set_math_family_b + {\ifcsname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size + \csname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size + \csname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \else + \font_helpers_set_math_family_c + \fi\fi} + +\def\font_helpers_set_math_family_c + {\ifcsname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size + \csname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size + \csname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else + \nullfont \settrue\font_auto_font_size + \fi\fi} + +\def\font_helpers_set_math_family_indeed#mrtag#family% \currentmathsize etc are also used later on + {\let\savedfontbody\fontbody + \let\fontfamily#family% + \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_a\scriptscriptfont#mrtag\font + \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_a\scriptfont #mrtag\font + \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_a\textfont #mrtag\font + \let\currentmathsize\empty + \let\fontbody\savedfontbody + \setfalse\font_auto_font_size} + +\def\font_helpers_set_math_family_bold_a#font#mbfam#mrfam% + {\ifcsname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size + \csname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname #font#mbfam\font \else + \ifcsname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size + \csname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname #font#mbfam\font \else + #font#mbfam#font#mrfam% + \fi\fi} + +\def\font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr + {\let\savedfontclass\defaultfontclass + \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one + \let\savedfontbody\fontbody + \let\fontfamily#familytag% + \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam% + \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam% + \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% + \let\currentmathsize\empty + \let\fontbody\savedfontbody + \let\defaultfontclass\savedfontclass + \setfalse\font_auto_font_size} + +% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0)) +% +% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know +% all sizes so we postpone the optimization to the first starttext +% +% pitfall: we should reset 'm when a fontclass name is reused + +\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions + +\def\font_helpers_set_math_family#mrfam#familytag% + {\ifconditional\optimizemathfontdefinitions + \ifcsname*\fontclass\textface\s!mm#familytag1\fontsize1*\endcsname + \font_helpers_preset_math_family_indeed#mrfam#familytag% + \else + \font_helpers_set_math_family_indeed#mrfam#familytag% + \fi + \else + \font_helpers_set_math_family_indeed#mrfam#familytag% + \fi} + +\def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam% + {\ifconditional\optimizemathfontdefinitions + \ifcsname*\fontclass\textface\s!mm#familytag1\fontsize1*\endcsname + \font_helpers_preset_math_family_indeed#mbfam#familytag% + \else + \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% + \fi + \else + \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% + \fi} + +\def\font_helpers_preset_math_family_indeed#fam#familytag% + {\scriptscriptfont#fam\csname*\fontclass\scriptscriptface\s!mm#familytag3\fontsize3*\endcsname + \scriptfont #fam\csname*\fontclass\scriptface \s!mm#familytag2\fontsize2*\endcsname + \textfont #fam\csname*\fontclass\textface \s!mm#familytag1\fontsize1*\endcsname} + +\let\font_helpers_reset_fontclass_math_families\gobbleoneargument + +% It would be nice if characters could be defined in a neutral way (say fam 255) and +% be mapped to a real family during noad list construction. However, this changes +% tex in critical places so for the moment we simulate this using manipulation. + +% \appendtoks +% \font_helpers_check_bodyfont_environment[\scriptscriptface]% pretty slow when many switches +% \font_helpers_check_bodyfont_environment[\scriptface]% +% \font_helpers_check_bodyfont_environment[\textface]% +% \to \t_font_math_strategies + +% For tracing purposes we use three families but in l2r mode 1 and 2 are copies of 0 +% while in rl mode 0 is a copy of 1. There is no real overhead involved in this. This +% also permits different font definitions for normal and mixed. + +\let\m_font_class_direction\empty +\let\m_font_class_features \empty +\let\m_font_class_fallbacks\empty +\let\m_font_class_goodies \empty + +\let\m_font_direction\empty +\let\m_font_features \empty +\let\m_font_fallbacks\empty +\let\m_font_goodies \empty + +\appendtoks % can be analyzed once + % why here .. + \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 + \else + \setfalse\c_font_bidirectional_math_strategy + \fi +\to \t_font_math_strategies + +\def\font_helpers_bidirectional_mathstrategy_yes + {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr + \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl + \textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr + \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr + \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr} + +\def\font_helpers_bidirectional_mathstrategy_nop + {\font_helpers_set_math_family\c_font_fam_mr\s!mr + \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr + \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr + \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr + \textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr + \scriptfont \c_font_fam_mr_lr\scriptfont \c_font_fam_mr + \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr} + +\appendtoks + \ifconditional\c_font_bidirectional_math_strategy + \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 + {\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 + \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 + {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr + \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 + \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb + \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 + {\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 + \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mr_rl + \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mr_rl + \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mr_rl + \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mr_lr + \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 + \else + \font_helpers_complete_bold_math_strategy_yes + \fi + \else + \font_helpers_complete_bold_math_strategynop + \fi} + +\appendtoks + \font_helpers_apply_complete_bold_math_strategy +\to \t_font_math_strategies + +\ifdefined\defaultmathfamily \else + \setnewconstant\defaultmathfamily\zerocount +\fi + +\appendtoks + \fam\defaultmathfamily % all characters and symbols are in this family +\to \everymathematics + +\unexpanded\def\font_helpers_synchronize_math_family_mr + {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy + \ifconditional\c_math_right_to_left + \plustwo + \else + \plusone + \fi + \else + \zerocount + \fi} + +\unexpanded\def\font_helpers_synchronize_math_family_mb + {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy + \ifconditional\c_math_right_to_left + \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi + \else + \ifconditional\c_font_pseudo_bold_math_state\plusseven\else\plusfour\fi + \fi + \else + \ifconditional\c_font_pseudo_bold_math_state\plussix\else\plusthree\fi + \fi} + +\installcorenamespace{fontmathsynchronizer} +\installcorenamespace{fontmathstoredstrategy} + +\letvalue{\??fontmathsynchronizer\s!tf }\font_helpers_synchronize_math_family_mr +\letvalue{\??fontmathsynchronizer\s!sl }\font_helpers_synchronize_math_family_mr +\letvalue{\??fontmathsynchronizer\s!it }\font_helpers_synchronize_math_family_mr +\letvalue{\??fontmathsynchronizer\s!bf }\font_helpers_synchronize_math_family_mb +\letvalue{\??fontmathsynchronizer\s!bs }\font_helpers_synchronize_math_family_mb +\letvalue{\??fontmathsynchronizer\s!bi }\font_helpers_synchronize_math_family_mb +\letvalue{\??fontmathsynchronizer\empty}\font_helpers_synchronize_math_family_mr + +\def\font_helpers_synchronize_math_family + {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname} + +\ifdefined \fontid % we need to keep this test for a while + \appendtoks + \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree + \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy + \else + \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy + \fi + \to \t_font_math_strategies +\else + \appendtoks + \edef\currentmathfontmr{\fontname\textfont\zerocount}% + \edef\currentmathfontmb{\fontname\textfont\plusthree}% + \ifx\currentmathfontmr\currentmathfontmb + \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy + \else + \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy + \fi + \to \t_font_math_strategies +\fi + +\def\font_helpers_synchronize_math_bold_strategy{\csname\??fontmathstoredstrategy\fontclass\endcsname} + +\newconditional\c_font_pseudo_bold_math_state + +\def\font_helpers_set_math_partial_bold_strategy{\settrue \c_font_pseudo_bold_math_state} +\def\font_helpers_set_math_full_bold_strategy {\setfalse\c_font_pseudo_bold_math_state} + +\appendtoks + \font_helpers_synchronize_math_bold_strategy +\to \everymathematics + +% Bold is somewhat special as we might want both full-bold-math mixed +% regular-math, as well as automatic adaption to outer bold (in titles +% and inline text bold) so we will need explicit switches as well as +% an automatic one. (We will use lucida as an example.) + +\unexpanded\def\mr + {\ifmmode + \font_helpers_synchronize_math_family_mr + \else + \font_helpers_set_current_font_alternative\s!mr + \fi} + +\unexpanded\def\mb + {\ifmmode + \font_helpers_synchronize_math_family_mb + \else + \font_helpers_set_current_font_alternative\s!mb + \fi} + +\appendtoks + \font_helpers_synchronize_math_family % auto bold +\to \everymathematics + +%D All used styles, like rm, ss and tt, are saved in a comma +%D separated list. Appart from practical limitations one can +%D define as many styles as needed. + +\def\font_helpers_process_relative_size_list#command% + {#command\s!text + #command\s!script + #command\s!scriptscript + #command\s!x + #command\s!xx + #command\v!big + #command\v!small} + +%D There are several ways to specify a font. Three of them are +%D pure \TeX\ ones, the fourth one is new: +%D +%D \starttyping +%D \font\name=cmr12 +%D \font\name=cmr12 at 10pt +%D \font\name=cmr12 scaled 2 +%D \font\name=cmr12 sa 1.440 +%D \stoptyping +%D +%D The non||\TEX\ alternative \type{sa} stands for {\em scaled +%D at}. This means as much as: scale the bodyfontsize with this +%D factor. The scaled option is not that useful as one needs to +%D know the design size. +%D +%D Because \type {sa} (scaled at) and \type {mo} (mapped on) +%D are not low level \TEX\ supported alternatives, we have to +%D test for it ourselves. In doing so, we need an auxiliary +%D \DIMENSION. We cannot use \type{\scratchdimen} because font +%D loading can happen at any moment due to postponed loading. +%D We could instead have used dirty grouping tricks, but this +%D one works too. + +% \enableexperiments[fonts.autorscale] +% +% \starttypescript[mscore] +% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default] +% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860] +% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065] +% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020] +% \stoptypescript +% +% \starttext +% \setupbodyfont[mscore,12pt] +% \startTEXpage +% test \ss test \tt test +% \stopTEXpage +% \stoptext + +\let\v_font_size_relative \plusone +\def\v_font_size_absolute {\fontbody} + +\let\v_font_rscale_default\plusone +\let\p_font_rscale \v_font_rscale_default + +\def\font_helpers_check_relative_font_id % can be plugged in later + {\let\p_font_rscale\minusone + \let\p_font_rscale\v_font_rscale_default} + +\def\font_helpers_check_relative_font_size#scale% + {\edef\p_font_rscale + {\ifcsname\??fontclass\fontclass#scale\s!rscale\endcsname + \csname\??fontclass\fontclass#scale\s!rscale\endcsname + \else\ifcsname\??fontclass\defaultfontclass#scale\s!rscale\endcsname + \csname\??fontclass\defaultfontclass#scale\s!rscale\endcsname + \else + \v_font_rscale_default + \fi\fi}% + \ifx\p_font_rscale\v!auto + \let\p_font_rscale\plusone + \font_helpers_check_relative_font_id + \else + \let\relativefontid\minusone + \fi} + +%D Scaling macros: +%D +%D This system is somewhat complicated by two (possible conflicting) +%D demands: +%D +%D \startitemize +%D \item We support wildcards like \type {sa *} which will adapt +%D to the current size. This is also the default specification. +%D \item We support named scales like \type {sa d}; beware: \type +%D {x} and \type {xx} are valid scales but they are not alway +%D the same as the ones used in for instance \type {\bfx} because +%D there the sized come from the bodyfont environment. In the +%D future there maybe a switch that also honors the environment +%D in named scales. +%D \stopitemize + +%D Keep in mind that the smaller sizes are just for text super and +%D subscripts while larger sizes can be used in titles where for +%D instance math follows the size. + +% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par +% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par +% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par +% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par +% +% *:x{\definedfont[Serif sa *]x}\par +% 1:x{\definedfont[Serif sa 1]x}\par +% 2:x{\definedfont[Serif sa 2]x}\par +% 3:x{\definedfont[Serif sa 3]x}\par +% 4:x{\definedfont[Serif sa 4]x}\par +% 5:x{\definedfont[Serif sa 5]x}\par +% +% {\definedfont[cmbx10 at 10pt]x\definedfont[cmbx8 at 10pt]x} + +\installcorenamespace{fonts} + +\def\safontscale{\number\dimexpr\v_font_size_absolute\relax} +\def\mofontscale{\number\dimexpr\font_basics_set_mapped_fontsize\v_font_size_absolute\relax} + +\let\somefontname\s!unknown +\let\somefontspec\s!unknown +\let\somefontsize\zerocount + +\newcount\scaledfontmode % also used at the lua end +\newcount\lastfontid % also used at the lua end / tex end +\newtoks \everydefinefont + +\def\currentfontbodysize + {\ifcsname\??fonts\s!default\somefontsize\endcsname + \csname\??fonts\s!default\somefontsize\endcsname + \else + \somefontsize + \fi} + +\let\relativefontid\empty + +% 0 = none +% 1 = fontonly +% 2 = classonly +% 3 = fontfirst +% 4 = classfirst + +\let\c_font_feature_inheritance_fontnone \zerocount +\let\c_font_feature_inheritance_fontonly \plusone +\let\c_font_feature_inheritance_classonly \plustwo +\let\c_font_feature_inheritance_fontfirst \plusthree +\let\c_font_feature_inheritance_classfirst\plusfour + +\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst + +\setnewconstant\c_font_feature_inheritance_mode \c_font_feature_inheritance_default + +\newdimen\d_font_scaled_text_face +\newdimen\d_font_scaled_font_size + +\unexpanded\def\font_helpers_low_level_define#specification#csname% + {% we can now set more at the lua end + \ctxcommand{definefont_one(\!!bs\luaescapestring{#specification}\!!es)}% the escapestring catches at \somedimen + % sets \scaledfontmode and \somefontname and \somefontsize + \ifcase\scaledfontmode\relax + % none, avoid the designsize if possible + \d_font_scaled_font_size-\plusthousand\scaledpoint + \or + % at + \d_font_scaled_font_size\somefontsize + \or + % sa + \d_font_scaled_font_size\v_font_size_absolute\relax + \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size + \or + % mo + \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute + \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size + \or + % scaled, don't use this one as it's unpredictable + \d_font_scaled_font_size-\somefontsize\scaledpoint + \fi + \relax + \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size + \ifconditional\font_auto_font_size + \d_font_scaled_font_size\currentfontbodyscale\d_font_scaled_font_size + \d_font_scaled_text_face\currentfontbodyscale\dimexpr\textface\relax + \else + \d_font_scaled_text_face\textface + \fi + \edef\somefontspec{at \number\d_font_scaled_font_size sp}% + \edef\somefontfile{\truefontname\somefontname}% + \ifx\somefontfile\s!unknown + \edef\somefontfile{\defaultfontfile}% + \fi + \ifx\somefontfile\s!unknown + \edef\somefontfile{\defaultfontfile}% + \fi + \font_helpers_update_font_parameters + \font_helpers_update_font_class_parameters + \ctxcommand{definefont_two( + \ifx\fontclass\empty false\else true\fi, + "#csname", + \!!bs\somefontfile\!!es, + \number\d_font_scaled_font_size, + \number\c_font_feature_inheritance_mode, + "\m_font_class_features", + "\m_font_features", + "\m_font_class_fallbacks", + "\m_font_fallbacks", + 0\currentmathsize, + \number\d_font_scaled_text_face, + "\relativefontid", % experiment + "\m_font_class_goodies", % experiment (not yet used) + "\m_font_goodies" % experiment + )}% + \edef\somefontspec{at \number\d_font_scaled_font_size sp}% we need the resolved designsize (for fallbacks) + \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname + \the\everydefinefont + \c_font_feature_inheritance_mode\c_font_feature_inheritance_default} + +% Why these expanded and rscale not ... maybe not worth the trouble (delayed +% expansion actually would be better i.e. macros in feature specs). Test +% without pre-expansion. + +\def\font_helpers_update_font_class_parameters + {\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\fontstyle\s!direction\endcsname\csname\??fontclass\fontclass\fontstyle\s!direction\endcsname\fi}% + \edef\m_font_class_features {\ifcsname\??fontclass\fontclass\fontstyle\s!features \endcsname\csname\??fontclass\fontclass\fontstyle\s!features \endcsname\fi}% + \edef\m_font_class_fallbacks{\ifcsname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\csname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\fi}% + \edef\m_font_class_goodies {\ifcsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\csname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\fi}} + +% resolve + +\def\font_helpers_set_features_yes#name% + {\ifcsname\??fontfile\fontclass#name\s!features \endcsname\expandafter\let\expandafter\m_font_features + \csname\??fontfile\fontclass#name\s!features \endcsname\else + \ifcsname\??fontfile #name\s!features \endcsname\expandafter\let\expandafter\m_font_features + \csname\??fontfile #name\s!features \endcsname\else + \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_features_yes + \csname\??fontfile\fontclass #name\endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_yes + \csname\??fontfile #name\endcsname\else + \let\m_font_features\empty\fi\fi\fi\fi} + +\def\font_helpers_set_fallbacks_yes#name% + {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks + \csname\??fontfile\fontclass#name\s!fallbacks\endcsname\else + \ifcsname\??fontfile #name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks + \csname\??fontfile #name\s!fallbacks\endcsname\else + \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_fallbacks_yes + \csname\??fontfile\fontclass #name\endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_yes + \csname\??fontfile #name\endcsname\else + \let\m_font_fallbacks\empty\fi\fi\fi\fi} + +\def\font_helpers_set_goodies_yes#name% + {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies + \csname\??fontfile\fontclass#name\s!goodies \endcsname\else + \ifcsname\??fontfile #name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies + \csname\??fontfile #name\s!goodies \endcsname\else + \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_goodies_yes + \csname\??fontfile\fontclass #name\endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_yes + \csname\??fontfile #name\endcsname\else + \let\m_font_goodies\empty\fi\fi\fi\fi} + +\def\font_helpers_set_features_nop#name% + {\ifcsname\??fontfile#name\s!features \endcsname\expandafter\let\expandafter\m_font_features + \csname\??fontfile#name\s!features \endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_nop + \csname\??fontfile #name\endcsname\else + \let\m_font_features\empty\fi\fi} + +\def\font_helpers_set_fallbacks_nop#name% + {\ifcsname\??fontfile#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks + \csname\??fontfile#name\s!fallbacks\endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_nop + \csname\??fontfile #name\endcsname\else + \let\m_font_fallbacks\empty\fi\fi} + +\def\font_helpers_set_goodies_nop#name% + {\ifcsname\??fontfile#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies + \csname\??fontfile#name\s!goodies \endcsname\else + \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_nop + \csname\??fontfile #name\endcsname\else + \let\m_font_goodies\empty\fi\fi} + +\def\font_helpers_update_font_parameters_yes + {\font_helpers_set_features_yes \somefontname + \font_helpers_set_fallbacks_yes\somefontname + \font_helpers_set_goodies_yes \somefontname} + +\def\font_helpers_update_font_parameters_nop + {\font_helpers_set_features_nop \somefontname + \font_helpers_set_fallbacks_nop\somefontname + \font_helpers_set_goodies_nop \somefontname} + +\def\font_helpers_update_font_parameters + {\ifx\fontclass\empty\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi} + +\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue + +%D When fontclasses are used, we define the font global, +%D since namespaces are used. Otherwise we parse the specs +%D each time. + +\let\fontfile\s!unknown + +% \definefontfeature[slanted] [default][slant=.25] +% \definefontfeature[stretched][default][stretch=2] +% +% \start \definedfont[SerifBold*slanted at 20pt] \ruledhbox{Test!} \stop +% \start \definedfont[SerifBold*stretched at 20pt] \ruledhbox{Test!} \stop + +% \definefontfeature[default] [liga=yes,texligatures=yes,texquotes=yes] +% \definefontfeature[default-caps][liga=yes,texligatures=yes,texquotes=yes,smcp=yes,script=latn] +% +% \starttypescript [serif] [palatino-nova-regular] [name] +% \definefontsynonym[Serif] [palatinonova-regular][features=default] +% \definefontsynonym[SerifCaps][palatinonova-regular][features=default-caps] % also sets Serif +% \stoptypescript +% +% \starttypescript [serif] [palatino-nova-regular] [name] +% \definefontsynonym[Serif] [palatinonova-regular*default] +% \definefontsynonym[SerifCaps] [palatinonova-regular*default-caps] +% \stoptypescript + +% \definetypeface[mainface][rm][serif][palatino-nova-regular][default] \setupbodyfont[mainface] +% +% \starttext +% ``Test'' -- --- ff fi fl \sc ``Test'' -- --- ff fi fl +% \stoptext + +% \starttext +% \definefont +% [blabla] +% [name:Latin Modern Something] +% \definefont +% [blabla] +% [file:texnansi-lmr10] +% \blabla test +% \definefont +% [blabla] +% [texnansi-lmtt10] +% \blabla test +% \stoptext + +% \starttext +% +% \setupcolors[state=start] +% +% \definefontfeature +% [default-base] +% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes] +% \definefontfeature +% [default-node] +% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes,mode=node] +% \definefontfeature +% [default-none] +% [script=latn,language=dflt,liga=yes,kern=no, tlig=yes,trep=yes] +% +% \startoverlay +% {\vtop{\color[red] {\font\test=name:lmroman12regular*default-node \test \input ward \input zapf \input linden }}} +% {\vtop{\color[green]{\font\test=name:lmroman12regular*default-base \test \input ward \input zapf \input linden }}} +% {\vtop{\color[blue] {\font\test=name:lmroman12regular*default-none \test \input ward \input zapf \input linden }}} +% \stopoverlay +% +% \blank +% +% \startoverlay +% {\vtop{\color[red] {\font\test=name:texgyrepagella*default-node \test \input ward \input zapf \input linden }}} +% {\vtop{\color[green]{\font\test=name:texgyrepagella*default-base \test \input ward \input zapf \input linden }}} +% {\vtop{\color[blue] {\font\test=name:texgyrepagella*default-none \test \input ward \input zapf \input linden }}} +% \stopoverlay +% +% \blank +% +% \startoverlay +% {\vtop{\color[red] {\font\test=name:palatinonovaregular*default-node \test \input ward \input zapf \input linden }}} +% {\vtop{\color[green]{\font\test=name:palatinonovaregular*default-base \test \input ward \input zapf \input linden }}} +% {\vtop{\color[blue] {\font\test=name:palatinonovaregular*default-none \test \input ward \input zapf \input linden }}} +% \stopoverlay +% +% \startoverlay +% {\vtop{\color[red] {\font\test=name:OfficinaSerifBookITC*default-node \test \input ward \input zapf \input linden }}} +% {\vtop{\color[green]{\font\test=name:OfficinaSerifBookITC*default-base \test \input ward \input zapf \input linden }}} +% {\vtop{\color[blue] {\font\test=name:OfficinaSerifBookITC*default-none \test \input ward \input zapf \input linden }}} +% \stopoverlay +% +% \definefontfeature[superdefault][default][compose=yes] +% +% {\font\oeps=name:lmroman10regular*default at 30pt \oeps test \char7683} +% {\font\oeps=name:lmroman10regular*superdefault at 30pt \oeps test \char7683} +% +% \stoptext + +\def \defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone +\edef\nullfontname {\fontname\nullfont} + +%D \macros +%D {everyfont,everyfontswitch} +%D +%D For special purposes, we provide a hook. + +% \newevery \everyfont \relax +% \newevery \everyfontswitch \relax + +%D We also accept \type{sa a}||\type{sa d} as specification. + +%D \macros +%D {definefontsynonym, doifelsefontsynonym, +%D expandfontsynonym, truefontname, truefontdata} +%D +%D While looking for fonts, fontsynonyms are used for accessing +%D the files! +%D +%D \starttyping +%D \definefontsynonym[Serif][Lucida-Bright] +%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi] +%D \stoptyping + +\def\classfont#class#name{#class#name} % \definefont[whatever][\classfont{xx}{yy} at 10pt] + +% We need to move the feature into the filename else it may be +% overloaded by another reference. For instance the definition of +% a regular and caps variant can use the same font. + +% We could use an indirect method ... store in 'array' and refer to +% slot. +% +% or nicer .. use parent chain + +\let\m_font_name\empty +\let\m_font_file\empty + +\unexpanded\def\definefontsynonym[#name]#crap[#file]% + {\edef\m_font_name{#name}% + \edef\m_font_file{#file}% + \ifx\fontclass\empty + \expandafter\font_basics_define_font_synonym_nop + \else + \expandafter\font_basics_define_font_synonym_yes + \fi} + +\def\font_basics_define_font_synonym_nop + {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file + \doifnextoptionalelse\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil} + +\def\font_basics_define_font_synonym_yes + {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file + \doifnextoptionalelse\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil} + +\def\font_basics_define_font_synonym_nop_opt[#specification]% + {\let\p_features \undefined + \let\p_fallbacks\undefined + \let\p_goodies \undefined + \expandafter\font_basics_get_font_parameter_nop#specification,]=,} + +\def\font_basics_define_font_synonym_yes_opt[#specification]% + {\let\p_features \undefined + \let\p_fallbacks\undefined + \let\p_goodies \undefined + \expandafter\font_basics_get_font_parameter_yes#specification,]=,} + +\def\font_basics_get_font_parameter_nop#key=#value,% + {\if]#key% + \font_basics_get_font_parameter_nop_finish + \else + \expandafter\normaldef\csname p_#key\endcsname{#value}% + \expandafter\font_basics_get_font_parameter_nop + \fi} + +\def\font_basics_get_font_parameter_yes#key=#value,% + {\if]#key% + \font_basics_get_font_parameter_yes_finish + \else + \expandafter\normaldef\csname p_#key\endcsname{#value}% + \expandafter\font_basics_get_font_parameter_yes + \fi} + +% helpers, some day these will be toks and counts + +% \def\fntsetdefname {\global\let\somefontname\defaultfontfile} +% \def\fntsetsomename{\gdef\somefontname} % takes argument +% \def\fntsetnopsize {\let\somefontsize\empty} +% \def\fntsetsomesize{\def\somefontsize} % takes argument + +% happens later, else mkvi parsing gets into troubles + +% end of helpers + +% we could collect them in one macro (but no expansion) + +\def\font_basics_define_font_synonym_nop_nil + {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\undefined + \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\undefined + \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\undefined} + +\def\font_basics_define_font_synonym_yes_nil + {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined + \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\undefined + \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined} + +\def\font_basics_get_font_parameter_nop_finish + {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\p_features + \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\p_fallbacks + \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies} + +\def\font_basics_get_font_parameter_yes_finish + {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features + \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\p_fallbacks + \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies} + +%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] +% +%\defineclassfontsynonym [KopFont] [officina] [SerifBold] + +\unexpanded\def\defineclassfontsynonym + {\dotripleargument\font_basics_define_class_font_synonym} + +%\definefontsynonym[#tag][\fontclassname{#class}{#fileortag}]} + +\def\font_basics_define_class_font_synonym[#tag][#class][#fileortag]% needs testing + {\expandafter\normaldef\csname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}% + \font_basics_define_font_synonym_yes_nil} + +\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater + +\unexpanded\def\setupfontsynonym + {\dodoubleempty\dosetupfontsynonym} + +\def\dosetupfontsynonym[#name][#settings]% not yet supported, will do when needed + {} + +% todo: replace * by ... less messy with features + +\def\truefontname#name% + {\expandafter\font_helpers_true_fontname#name*\empty*\relax} + +\def\font_helpers_true_fontname#name*#first#rest*#crap\relax + {\ifcsname\??fontfile\fontclass#name\endcsname + \ifx#first\empty + \expandafter\truefontname\csname\??fontfile\fontclass#name\endcsname + \else + \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname*#first#rest% + \fi + \else\ifcsname\??fontfile\defaultfontclass#name\endcsname + \ifx#first\empty + \expandafter\truefontname\csname\??fontfile\defaultfontclass#name\endcsname + \else + \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname*#first#rest% + \fi + \else\ifcsname\??fontfile#name\endcsname + \ifx#first\empty + \expandafter\truefontname\csname\??fontfile#name\endcsname + \else + \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname*#first#rest% + \fi + \else + #name\ifx#first\empty\else*#first#rest\fi + \fi\fi\fi} + +\def\font_helpers_true_fontname_check#name% + {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax} + +\def\font_helpers_true_fontname_check_indeed#name*#crap\relax + {\ifcsname\??fontfile\fontclass#name\endcsname + \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname + \else\ifcsname\??fontfile\defaultfontclass#name\endcsname + \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname + \else\ifcsname\??fontfile#name\endcsname + \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname + \else + #name% + \fi\fi\fi} + +\def\expandfontsynonym#command#name% one level expansion + {\ifcsname\??fontfile\fontclass#name\endcsname + \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\fontclass#name\endcsname}% + \else\ifcsname\??fontfile\defaultfontclass#2\endcsname + \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\defaultfontclass#name\endcsname}% + \fi\fi} + +\def\doifelsefontsynonym#name% + {\ifcsname\??fontfile\fontclass#name\endcsname + \singleexpandafter\firstoftwoarguments + \else\ifcsname\??fontfile\defaultfontclass#name\endcsname + \doubleexpandafter\firstoftwoarguments + \else + \doubleexpandafter\secondoftwoarguments + \fi\fi} + +% \definetypeface[palatino][rm][serif][palatino,allbold][default] +% +% \startfontclass[palatino] +% \definefontsynonym [Serif] [SerifBold] +% \definefontsynonym [SerifItalic] [SerifBoldItalic] +% \definefontsynonym [SerifSlanted] [SerifBoldSlanted] +% \definefontsynonym [SerifCaps] [SerifBold] +% \stopfontclass +% +% \setupbodyfont[palatino] + +\unexpanded\def\startfontclass + {\dosingleempty\font_basics_start_font_class} + +\def\font_basics_start_font_class[#class]% + {\pushmacro\fontclass + \doifelse{#class}\v!each + {\let\fontclass\empty} + {\doifsomething{#class}{\def\fontclass{#class}}}} + +\unexpanded\def\stopfontclass + {\popmacro\fontclass} + +%D \macros +%D {tracedfontname} +%D +%D A goody: + +\def\tracedfontname#name% + {#name\ifcsname\??fontfile\fontclass#name\endcsname + \expandafter\tracedfontname\csname\??fontfile\fontclass#name\endcsname + \else\ifcsname\??fontfile#name\endcsname + \expandafter\tracedfontname\csname\??fontfile#name\endcsname + \fi\fi} + +%D \macros +%D {definefont} +%D +%D Before we implement the main definition macro, we first show +%D one for local use: +%D +%D \starttyping +%D \definefont[Some][LucidaBright at 100pt] \Some some +%D \definefont[More][LucidaBright scaled 3000] \More more +%D \definefont[Nice][LucidaBright mo 2] \Nice nice +%D \definefont[Text][LucidaBright sa 5.4] \Text last +%D \stoptyping +%D +%D The implementation looks as follows: + +% \unexpanded\def\definefont +% {\dotripleempty\font_basics_define_font} +% +% \def\font_basics_define_font[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id] +% {\ifthirdargument +% \setuvalue{#name}{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}% +% \else +% \setuvalue{#name}{\font_basics_define_font_without_parameters{#name}{#specification}}% +% \fi} +% +% \def\font_basics_define_font_with_parameters#name#specification#settings% +% {\font_basics_define_font_without_parameters{#name}{#specification}% +% \doifsetupselse{#settings} +% {\setups[#settings]} % don't forget to document this ! +% {\setuplocalinterlinespace[#settings]% +% \setupspacing}} % needed ? + +\unexpanded\def\definefont % [name][spec][1.6 | line=10pt | setup_id] + {\dotripleempty\font_basics_define_font} + +\def\font_basics_define_font + {\ifthirdargument + \expandafter\font_basics_define_font_a + \else + \expandafter\font_basics_define_font_b + \fi} + +\def\font_basics_define_font_a[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id] + {\doifsetupselse{#settings}% + {\setuvalue{#name}{\font_basics_define_font_with_setups {#name}{#specification}{#settings}}} + {\setuvalue{#name}{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}}} + +\def\font_basics_define_font_b[#name][#specification][#dummy]% + {\setuvalue{#name}{\font_basics_define_font_without_parameters{#name}{#specification}}} + +\def\font_basics_define_font_with_parameters#name#specification#settings% + {\font_basics_define_font_without_parameters{#name}{#specification}% + \setuplocalinterlinespace[#settings]% + \setupspacing\relax} % is this really needed ? + +\def\font_basics_define_font_with_setups#name#specification#settings% + {\font_basics_define_font_without_parameters{#name}{#specification}% + \setups[#settings]} + +% Beware, currently no settings are supported ... might happen some day + +\unexpanded\def\definefrozenfont + {\dotripleempty\font_basics_define_frozen_font} + +\def\font_basics_define_frozen_font[#name][#specification][#settings]% + {\begingroup + \font_basics_define_font[#name][#specification][#settings]% + \csname#name\endcsname + \expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall} + +%D The \type {*} makes the switch local, so that we can redefine a +%D logical name and/or change the size in between. + +% todo: now mathsize twice in name (so it can go here) +% todo: check when mathsize is needed + +\installcorenamespace {fontsbasic} +\installcorenamespace {fontsclass} + +\newconditional\font_auto_font_size \settrue\font_auto_font_size + +\let\lastfontidentifier\empty + +\def\v_font_identifier_basic{\??fontsbasic \lastfontidentifier\fontsize\currentmathsize} +\def\v_font_identifier_class{\??fontsclass\fontclass\lastfontidentifier\fontsize\currentmathsize} + +\def\v_font_identifier_basic{\??fontsbasic \lastfontidentifier\fontsize\currentmathsize} +\def\v_font_identifier_class{\??fontsclass\fontclass\lastfontidentifier\fontsize\currentmathsize} + +\let\v_font_identifier_basic_saved\v_font_identifier_basic +\let\v_font_identifier_class_saved\v_font_identifier_class + +% \def\v_font_identifier_class{*\fontclass\lastfontidentifier\fontstyle\fontsize*} % no \currentmathsize + +\def\font_basics_define_font_without_parameters#identifier#2% + {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly + \edef\lastfontidentifier{#identifier}% + \let\v_font_size_relative\v_font_rscale_default + \let\v_font_size_absolute\fontbody + \font_helpers_low_level_define{#2}\v_font_identifier_basic + \csname\v_font_identifier_basic\endcsname + \setfalse\font_auto_font_size + \setfontcharacteristics + \the\everyfontswitch + \let\v_font_identifier_basic\v_font_identifier_basic_saved} + +\unexpanded\def\font_helpers_trigger#identifier% + {\edef\lastfontidentifier{#identifier}% + \ifcsname\v_font_identifier_class\endcsname + \expandafter\font_helpers_trigger_reuse + \else + \expandafter\font_helpers_trigger_define + \fi} + +\def\font_helpers_trigger_define#relative#absolute#specification% + {\def\v_font_size_relative{#relative}% + \def\v_font_size_absolute{#absolute}% + \font_helpers_low_level_define{#specification}\v_font_identifier_class + \csname\v_font_identifier_class\endcsname + \setfalse\font_auto_font_size + \ifskipfontcharacteristics \else + \setfontcharacteristics + \the\everyfontswitch + \fi + \let\v_font_identifier_class\v_font_identifier_class_saved} + +\def\font_helpers_trigger_reuse#relative#absolute#specification% + {\csname\v_font_identifier_class\endcsname + \setfalse\font_auto_font_size + \ifskipfontcharacteristics \else + \setfontcharacteristics + \the\everyfontswitch + \fi + \let\v_font_identifier_class\v_font_identifier_class_saved} + +%D \macros +%D {mapfontsize} +%D +%D For special purposes, like in math, you may want to use +%D slightly different sizes than the ones given. This happens +%D for instance with the Math Times fonts. Mapped font sizes +%D can be specified by using the \type {mo} key instead of +%D \type {sa} in font definitions. +%D +%D \startbuffer +%D \mapfontsize[10pt][11pt] +%D \mapfontsize[11pt][12pt] +%D \mapfontsize[12pt][13pt] +%D +%D \definefont[test][Serif]\test TEST \par +%D \definefont[test][Serif sa 5]\test TEST \par +%D \definefont[test][Serif mo 5]\test TEST \par +%D \definefont[test][Serif sa d]\test TEST \par +%D \definefont[test][Serif at 60pt]\test TEST \par +%D \definefont[test][Serif scaled 6000]\test TEST \par +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startpacked +%D \getbuffer +%D \stoppacked + +\installcorenamespace{mappedfontsize} + +\unexpanded\def\mapfontsize + {\dodoubleargument\font_basics_map_fontsize} + +\def\font_basics_map_fontsize[#from][#to]% + {\setvalue{\??mappedfontsize\the\dimexpr#from\relax}{#to}} + +\def\font_basics_set_mapped_fontsize#from% + {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname + \csname\??mappedfontsize\the\dimexpr#from\relax\endcsname\else#from% + \fi} + +%D To be documented. + +\let\fontsizelist \empty +\let\fontalternativelist\empty +\let\fontstylelist \empty + +% if we really need it we can make a toks + +\def\font_helpers_check_fontname_combinations_indeed#size% + {\def\font_helpers_check_fontname_combinations_indeed_a#alternative% + {\def\font_helpers_check_fontname_combinations_indeed_b#style{\font_basics_check_bodyfont{#style}{#alternative}{#size}}% + \processcommacommand[\fontstylelist]\font_helpers_check_fontname_combinations_indeed_b}% + \processcommacommand[\fontalternativelist]\font_helpers_check_fontname_combinations_indeed_a} + +\unexpanded\def\font_helpers_check_fontname_combinations % we need to split math and text here ... todo (math only has mr and mb) + {\processcommacommand[\fontsizelist]\font_helpers_check_fontname_combinations_indeed} + +\unexpanded\def\definefontsize[#size]% sneller met toks + {\addtocommalist{#size}\fontsizelist + \font_helpers_check_fontname_combinations} + +\unexpanded\def\definefontalternative[#alternative]% + {\addtocommalist{#alternative}\fontalternativelist + \font_helpers_check_fontname_combinations} + +%D \macros +%D {currentfontscale,currentfontbodyscale} +%D +%D Sometimes we need to have access to the font scale +%D including the \type{a}||\type{d} sizes. The next macro +%D returns the current scaling factor. Take a look at +%D \type {cont-log.tex} for an example of its use. + +\def\currentfontscale + {\csname\??fonts\s!default + \ifcsname\??fonts\s!default\xfontsize\endcsname \xfontsize \else + \ifcsname\??fonts\s!default\s!text \endcsname \s!text \fi\fi + \endcsname} + +\def\currentfontbodyscale + {\csname\??fonts\s!default + \ifcsname\??fonts\s!default\fontsize\endcsname \fontsize \else + \ifcsname\??fonts\s!default\s!text \endcsname \s!text \fi\fi + \endcsname} + +\setvalue{\??fonts\s!default}{1} + +%D Both alternatives use \type {\xfontsize}, a macro that +%D expands to the current size in terms of \type {a} \unknown +%D \type {d}, nothing, or \type {x} \unknown \type {xx}. + +%D In the following macros we use \type{\currentxfontsize} to +%D hold the current x||size of the font. This enables us to +%D support for instance \type{\sl} inside a \type{\tx} switch. + +\newconstant\currentxfontsize + +\def\xfontsize{\ifcase\currentxfontsize\fontsize\or\s!x\else\s!xx\fi} + +%D A typical use of this command is in commands that switch +%D to another font bypassing the font mechanism: +%D +%D \starttyping +%D \font\myfont=\truefontname{MyFont} at \the\dimexpr\currentfontscale\bodyfontsize\relax +%D \stoptyping + +%D Now we enter the area of font switching. The switching +%D mechanism has to take care of several situations, like: +%D +%D \startitemize[packed] +%D \item changing the overal document fonts (including margins, +%D headers and footers) +%D \item changing local fonts (only the running text) +%D \item smaller and even more smaller alternatives (super- +%D and subscripts) +%D \stopitemize +%D +%D \TEX\ offers a powerfull family mechanism for super- and +%D subscripts in math mode. In text mode however, we don't use +%D families for the smaller alternatives, and therefore have +%D to take care of it otherwise. + +%D \macros +%D {definebodyfontenvironment,setupbodyfontenvironment} +%D +%D The relationship between the several sizes of a font, is +%D defined by: +%D +%D \showsetup{definebodyfontenvironment} +%D +%D Later on we will see how these parameters are used, so for +%D the moment we stick with an example: +%D +%D \starttyping +%D \definebodyfontenvironment +%D [12pt] +%D [ text=12pt, +%D script=9pt, +%D scriptscript=7pt, +%D x=10pt, +%D xx=8pt, +%D big=12pt, +%D small=10pt] +%D \stoptyping +%D +%D The first argument specifies the bodyfont size to which the +%D settings apply. All second parameters are specified in +%D dimensions and tell us more about related sizes. +%D +%D Afterwards, one can change values with +%D +%D \showsetup{setupbodyfontenvironment} +%D +%D When instead of a size the keyword \type{unknown} is +%D passed, fractions (relations) are used instead of fixed +%D sizes. + +%D {\bf Remark:} We need to cover the following cases, otherwise users can +%D get confused: +%D +%D \starttyping +%D \setupbodyfont[23pt] +%D +%D \definebodyfontenvironment[23pt] +%D \setupbodyfont[23pt] +%D +%D \definebodyfontenvironment[23pt] +%D \definebodyfont[23pt][rm,ss,tt][default] +%D \setupbodyfont[23pt] +%D \stoptyping +%D +%D Beware: while some font defs can be global, the bodyfont +%D environment checks local. This means that multiple local +%D checks resulting in definitions are not that efficient. +%D So, apart from an occasional switch, one should define an +%D environment at the outer level. + +\letvalue\??fonts\empty % so we default to empty + +\def\bodyfontvariable#parameter% + {\csname\??fonts + \ifcsname\??fonts\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\else + \ifcsname\??fonts\fontclass #parameter\endcsname\fontclass #parameter\else + \ifcsname\??fonts \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\else + \ifcsname\??fonts\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi + \endcsname} + +\def\bodyfontsizevariable#size#parameter% + {\csname\??fonts + \ifcsname\??fonts\fontclass#size#parameter\endcsname\fontclass#size#parameter\else + \ifcsname\??fonts\fontclass #parameter\endcsname\fontclass #parameter\else + \ifcsname\??fonts #size#parameter\endcsname #size#parameter\else + \ifcsname\??fonts\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi + \endcsname} + +\def\bodyfontinterlinespace{\bodyfontvariable\c!interlinespace} % used elsewhere + +\def\bodyfontdimension#class#size#parameter#body% + {\the\dimexpr + \ifcsname\??fonts#class #size#parameter\endcsname + \csname\??fonts#class #size#parameter\endcsname \else + \ifcsname\??fonts#class\s!default#parameter\endcsname + \csname\??fonts#class\s!default#parameter\endcsname\dimexpr#body\relax \else % factor + \ifcsname\??fonts #size#parameter\endcsname + \csname\??fonts #size#parameter\endcsname \else + \csname\??fonts \s!default#parameter\endcsname\dimexpr#body\relax \fi\fi\fi % factor + \relax} + +\let\bodyfontenvironmentlist\empty % used in font-run + +\unexpanded\def\definebodyfontenvironment + {\dotripleempty\font_basics_define_body_font_environment} + +\let\setupbodyfontenvironment\definebodyfontenvironment + +% the lookup order is: +% +% [class] [dimension] [parameters] +% [class] [default] [parameters] % factors +% [dimension] [parameters] +% [default] [parameters] % factors +% +% with defaults providing factors + +% todo: class:size +% todo: make assignments global + +\installcorenamespace{fontsteps} % fast cache + +\let\m_font_body \empty +\let\m_font_body_normalized\empty + +\def\font_basics_define_body_font_environment + {\ifthirdargument + \singleexpandafter\font_basics_define_body_font_environment_class + \else\ifsecondargument + \doubleexpandafter\font_basics_define_body_font_environment_empty + \fi\fi} + +% First we handle the class specific case. Beware: you can change values before +% a bodyfont is loaded but changing them afterwards can be sort of tricky as +% values are not consulted afterwards. + +\def\font_basics_define_body_font_environment_class[#class][#body][#settings]% + {\edef\m_font_body{#body}% + \ifx\m_font_body\s!default + % these are the last resort within a class + \getrawparameters[\??fonts#class\s!default][#settings]% + \else + \edef\m_font_body_normalized{\thenormalizedbodyfontsize\m_font_body}% + \addtocommalist\m_font_body_normalized\bodyfontenvironmentlist + \font_basics_define_body_font_environment_size[#class][\m_font_body_normalized][#settings]% + \letvalue{\??fonts#class#body\s!check}\empty % a signal that we have defined this one + \fi} + +\def\font_basics_define_body_font_environment_size[#class][#body][#settings]% normalized body + {\getrawparameters[\??fonts#class#body][#settings]% + % don't check too soon as we can refer to later definitions + % \font_helpers_process_relative_size_list{\font_basics_define_body_font_environment_size_step{#class}{#body}{#body}}% + \ifproductionrun + \ifcsname\??fontsize#body\endcsname + % only once + \else + % \empty prevents loop + \letvalueempty{\??fontsize#body}% + \pushmacro\fontclass + \edef\fontclass{#class}% + \font_helpers_define_unknown_font{#body}% + \popmacro\fontclass + \fi + \fi + % so far + \setevalue{\??fontsize#body}{\font_basics_complete_switch[#body]}} + +\def\font_basics_define_body_font_environment_size_step_normal#class#size#body#step% + {\expandafter\normaledef\csname\??fontsteps#class#size#step\endcsname + {\thenormalizedbodyfontsize{\bodyfontdimension{#class}{#size}{#step}{#body}}}} + +\def\font_basics_define_body_font_environment_size_step_traced#class#size#body#step% + {\font_basics_define_body_font_environment_size_step_normal{#class}{#size}{#body}{#step}% + \writestatus{size mapping}{#class #size #step => \csname\??fontsteps#class#size#step\endcsname}} + +\let\font_basics_define_body_font_environment_size_step\font_basics_define_body_font_environment_size_step_normal + +\unexpanded\def\tracefontsizemapping % todo, \enabletextracker + {\let\font_basics_define_body_font_environment_size_step\font_basics_define_body_font_environment_size_step_traced} + +% \tracefontsizemapping + +% The empty case uses the same code but needs to ignore the current class +% settings (just to be sure, as it's not really needed). + +\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]% + {\pushmacro\fontclass + \let\fontclass\empty + \font_basics_define_body_font_environment_class[][#body][#settings]% + \popmacro\fontclass} + +% Checking + +\def\font_helpers_check_bodyfont_environment[#size]% + {\ifcsname\??fonts\fontclass#size\s!check\endcsname \else + \font_helpers_check_bodyfont_environment_indeed{#size}% + \fi} + +\def\font_helpers_check_bodyfont_environment_indeed#size% class size (simplified version of definebodyfontenvironment) + {\edef\m_font_body_normalized{\thenormalizedbodyfontsize{#size}}% + \addtocommalist\m_font_body_normalized\bodyfontenvironmentlist + \font_helpers_process_relative_size_list{\font_basics_define_body_font_environment_size_step\fontclass\m_font_body_normalized\fontbody}% + \letvalue{\??fonts\fontclass#size\s!check}\empty + \ifcsname\??fontsize\m_font_body_normalized\endcsname \else + \letvalue{\??fontsize\m_font_body_normalized}\empty % prevent loop + \normalexpanded{\font_helpers_define_unknown_font{\m_font_body_normalized}}% we can also inherit here + \fi + \setevalue{\??fontsize\fontclass}{\font_basics_complete_switch[\fontclass]}} + +%D We default all parameters to the main bodyfont size, so the +%D next setup is valid too: +%D +%D \starttyping +%D \definebodyfontenvironment[24pt] +%D \stoptyping +%D +%D All parameters can be redefined when needed, so one does +%D not have to stick to the default ones. + +%D \macros +%D {definebodyfont} +%D +%D The next step in defining a bodyfont involves the actual font +%D files, which can be recognized by their extension +%D \type{tfm}. Installing those file is often beyond the +%D scope of the user and up to the system administrator. +%D +%D \showsetup{definebodyfont} +%D +%D This commands takes three arguments: a (series of) bodyfont +%D size(s), the style group to which the definitions belong, +%D and an alternative, as specified by the \TEX\ (math) families, +%D extended with~a, b~\unknown. +%D +%D We show two examples, that show all the alternative +%D scaling options. The \type{\tfa} alternatives can be +%D extended with \type{\bfa}, \type{\slb}, etc. or even +%D \type{e} and higher alternatives. The magic scaled +%D values are derived from plain \TEX's \type {\magstep}: +%D +%D \starttyping +%D \definebodyfont [12pt] [rm] +%D [tf=cmr12, +%D bf=cmbx12, +%D it=cmti12, +%D sl=cmsl12, +%D bi=cmbxti10 at 12pt, +%D bs=cmbxsl10 at 12pt, +%D tfa=cmr12 scaled 1.200, +%D tfb=cmr12 scaled 1.440, +%D tfc=cmr12 scaled 1.728, +%D tfd=cmr12 scaled 2.074, +%D sc=cmcsc10 at 12pt] +%D +%D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm] +%D [tf=lbr sa 1, +%D bf=lbd sa 1, +%D it=lbi sa 1, +%D sl=lbsl sa 1, +%D bi=lbdi sa 1, +%D bs=lbdi sa 1, +%D tfa=lbr sa 1.200, +%D tfb=lbr sa 1.440, +%D tfc=lbr sa 1.728, +%D tfd=lbr sa 2.074, +%D sc=lbr sa 0.833] +%D \stoptyping +%D +%D The second example shows that we can define more sizes at +%D once. The main difference between these examples is that the +%D Computer Modern Roman come in many design sizes. This means +%D that there we cannot define them in bulk using \type{sa}. +%D Instead of \type{rm} (roman) one can define \type{ss} (sans +%D serif), \type{tt} (teletype), \type{hw} (hand written), +%D \type{cg} (calygraphic) and whatever styles. +%D +%D The first argument may be a comma separated list. This, +%D combined with specifications using \type{sa} can save a lot +%D of typing. Although all arguments should be specified, we +%D treat the second argument as optional. +%D +%D Defining a bodyfont involves two actions: defining the +%D specific style related alternatives, like \type{\rma}, +%D \type{\bfa} and \type{\rmsla}, and storing the definitions +%D of their bodyfont size related fonts. The first step is +%D bodyfont independant but executed every time. This permits +%D user definitions like \type{\tfw} or \type{\bfq} for real +%D large alternatives. + +%D If we move design size info to the lfg file (after all only lm +%D has design sizes) we can get rid of much code .. 2012 or so. + +\installcorenamespace{fontdefaults} + +\unexpanded\def\definebodyfont + {\doquadrupleempty\font_basics_define_body_font} + +\def\font_basics_define_body_font[#1][#2][#3][#4]% + {\iffourthargument + \processcommacommand[#1]{\font_basics_define_body_font_by_class[#2][#3][#4]}% + \else + \font_basics_define_body_font_indeed[#1][#2][#3]% + \fi} + +\def\font_basics_define_body_font_by_class[#1][#2][#3]#4% + {\pushmacro\fontclass + \doifelse{#4}\s!default + {\let\fontclass\empty} + {\def\fontclass{#4}}% + \definebodyfont[#1][#2][#3]% + \popmacro\fontclass} + +\def\font_basics_define_body_font_indeed + {\ifthirdargument + \singleexpandafter\font_basics_define_body_font_indeed_a + \else\ifsecondargument + \doubleexpandafter\font_basics_define_body_font_indeed_b + \else + \doubleexpandafter\font_basics_define_body_font_indeed_c + \fi\fi} + +\def\font_basics_define_body_font_indeed_a[#body][#style][#specification]% body|identifier style defs|identifier + {\doifnumberelse{#body} + {\doifassignmentelse{#specification} + {% [12pt] [style] [settings] + \ifcsname#style\endcsname\else\normalexpanded{\definefontstyle[#style][#style]}\fi % new + \processcommalist[#1]{\font_basics_define_body_font_styles{#style}{#specification}}} + {% [12pt] [style] [identifier] + \font_basics_define_default_bodyfont[#body][#style][#specification]}} % body style identifier + {% [identifier] [style] [settings] % see *** ... normalexpanded + \setevalue{\??fontdefaults#body#style}{\font_basics_define_body_font_default{#specification}}}} % takes two extra arguments + +\def\font_basics_define_body_font_indeed_b[#body][#specification][#dummy]% body|identifier defs|identifier + {\font_basics_define_body_font_indeed_a[#body][\s!rm][#specification]} + +\def\font_basics_define_body_font_indeed_c[#body][#dummya][#dummyb]% body|identifier + {% Maybe there are default dependencies defined which we can use ([unknown]) and + % if not, then we have at least to make sure some basics are set up. + \ifcsname\??fontsize#1\endcsname \else + \font_helpers_define_unknown_font{#body}% + \fi + \ifcsname\??fontsize#1\endcsname \else + \font_basics_define_body_font_indeed_a[#body][\s!rm][]% + \fi} + +\unexpanded\def\font_basics_define_body_font_default#specification#body#style% + {\font_helpers_check_relative_font_size{#style}% rather new, inherit from other defs + \ifcsname#style\endcsname\else\normalexpanded{\definefontstyle[#style][#style]}\fi % new + \processcommalist[#body]{\font_basics_define_body_font_styles{#style}{#specification}}% + \let\p_font_rscale\v_font_rscale_default} + +\def\font_basics_define_body_font_styles#1#2#3% style defs body + {\font_helpers_check_bodyfont_environment[#3]% just to be sure; can probably be omited now + \processcommalist[#2]{\font_basics_define_body_font_defs{#1}{#3}}} + +\def\font_basics_define_body_font_defs#1#2#3% style body def + {\font_basics_define_body_font_defs_indeed{#1}{#2}[#3]} + +\def\font_basics_define_body_font_defs_indeed + {\ifx\fontclass\empty + \expandafter\font_basics_define_body_font_defs_nop + \else + \expandafter\font_basics_define_body_font_defs_yes + \fi} + +\def\font_basics_define_body_font_defs_yes#style% style body def + {\edef\askedbodyfontstyle{#style}% + \ifx\askedbodyfontstyle\s!mm + \expandafter\font_basics_define_body_font_yes_mm + \else + \expandafter\font_basics_define_body_font_yes_xx + \fi\askedbodyfontstyle} + +\def\font_basics_define_body_font_defs_nop#style% style body def + {\edef\askedbodyfontstyle{#style}% + \ifx\askedbodyfontstyle\s!mm + \expandafter\font_basics_define_body_font_nop_mm + \else + \expandafter\font_basics_define_body_font_nop_xx + \fi\askedbodyfontstyle} + +% we split into two characters (first part of spec) and the rest + +\def\font_basics_define_body_font_nop_xx#style#body[#one#two#rest=#value]% + {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi + \expandafter\let\csname*#body#style#one#two#rest*\endcsname\undefined + \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest\endcsname{\font_helpers_trigger{#body#style#one#two#rest}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}} + +\def\font_basics_define_body_font_yes_xx#style#body[#one#two#rest=#value]% + {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi + \global\expandafter\let\csname*\fontclass#body#style#one#two#rest*\endcsname\undefined + \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest\endcsname{\font_helpers_trigger{#body#style#one#two#rest}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}} + +\def\font_basics_define_body_font_nop_mm#style#body[#one#two#rest=#value]% + {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi + \expandafter\let\csname*#body#style#one#two#rest1*\endcsname\undefined + \expandafter\let\csname*#body#style#one#two#rest2*\endcsname\undefined + \expandafter\let\csname*#body#style#one#two#rest3*\endcsname\undefined + \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest1\endcsname{\font_helpers_trigger{#body#style#one#two#rest1}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}% + \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest2\endcsname{\font_helpers_trigger{#body#style#one#two#rest2}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}% + \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest3\endcsname{\font_helpers_trigger{#body#style#one#two#rest3}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}} + +\def\font_basics_define_body_font_yes_mm#style#body[#one#two#rest=#value]% + {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi + \global\expandafter\let\csname*\fontclass#body#style#one#two#rest1*\endcsname\undefined + \global\expandafter\let\csname*\fontclass#body#style#one#two#rest2*\endcsname\undefined + \global\expandafter\let\csname*\fontclass#body#style#one#two#rest3*\endcsname\undefined + \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest1\endcsname{\font_helpers_trigger{#body#style#one#two#rest1}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}% + \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest2\endcsname{\font_helpers_trigger{#body#style#one#two#rest2}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}% + \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest3\endcsname{\font_helpers_trigger{#body#style#one#two#rest3}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}} + +\let\m_font_mm\empty + +\def\font_basics_check_bodyfont#style% tests for ttsl mmbf + {\edef\m_font_mm{#style}% + \ifx\m_font_mm\s!mm % prevents \max and alike (re)defs + \expandafter\font_basics_check_math_bodyfont + \else + \expandafter\font_basics_check_text_bodyfont + \fi{#style}} % no \m_font_mm, not expanded later on + +% nb: We define the commands globally in the next two macros. After +% all they are part of the formal font interface once defined. +% +% The size can be empty (so checking is needed as \bf is already +% defined) + +\def\font_basics_check_math_bodyfont#style#alternative#size% + {%setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \mr \mb + \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}}% \mm + +\def\font_basics_check_text_bodyfont#style#alternative#size% nb: gdef % size can be empty (checking needed as \bf is already defined) + {\setugvalue{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}% \rma + \setugvalue{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}% \sla + \setugvalue{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}% \rmsla + \ifcsname\s!normal#style\endcsname % text/math check + \expandafter\let\csname#style\expandafter\endcsname\csname\s!normal#style\endcsname + \else + \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}% \rm + \fi + \ifcsname\s!normal#alternative\endcsname % text/math check + \expandafter\let\csname#alternative\expandafter\endcsname\csname\s!normal#alternative\endcsname + \else + \setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \sl + \fi + \setugvalue{#style\s!x}{\font_helpers_set_current_font_x_style_alternative{#style}}% \rmx + \setugvalue{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}% \rmxx + \setugvalue{#alternative\s!x}{\font_helpers_set_current_font_x_alternative{#alternative}}% \slx + \setugvalue{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}% \slxx + \setugvalue{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}% \rmsl + +\def\font_basics_define_default_bodyfont[#sizes][#styles][#specification]% + {\def\font_basics_define_default_bodyfont_a#size% + {\def\font_basics_define_default_bodyfont_b#style% + {\def\font_basics_define_default_bodyfont_c#spec% + {\ifcsname\??fontdefaults#spec#style\endcsname + % [12pt] [style] [identifier] + \csname\??fontdefaults#spec#style\endcsname{#size}{#style}% + \fi}% + \processcommalist[#specification]\font_basics_define_default_bodyfont_c}% + \processcommalist[#styles]\font_basics_define_default_bodyfont_b}% + \processcommalist[#sizes]\font_basics_define_default_bodyfont_a} + +\newconditional\c_font_defining_unknown +\newconditional\c_font_defining_state + +\def\font_helpers_define_unknown_font_indeed#body#relativesize% + {\ifcsname\??fonts\s!default#relativesize\endcsname + \settrue\c_font_defining_state + \edef\m_font_body_normalized{\thenormalizedbodyfontsize{\csname\??fonts\s!default#relativesize\endcsname\dimexpr#body\relax}}% + \letvalue{\??fonts#body#relativesize}\m_font_body_normalized + \fi} + +\def\font_helpers_define_unknown_bodyfont_indeed#body#style% see *** + {\ifcsname\??fontdefaults\s!default#style\endcsname % somehow related to */* + \settrue\c_font_defining_state + \csname\??fontdefaults\s!default#style\endcsname{#body}{#style}% + \fi} + +\def\font_helpers_define_unknown_sub_font#body#relativesize% + {\ifcsname\??fontsize\csname\??fonts#body#relativesize\endcsname\endcsname \else + \settrue\c_font_defining_state + \font_helpers_define_unknown_font{\csname\??fonts#body#relativesize\endcsname}% + \fi} + +\unexpanded\def\font_helpers_define_unknown_font#body% + {\setfalse\c_font_defining_state + \font_helpers_process_relative_size_list{\font_helpers_define_unknown_font_indeed{#body}}% + \ifconditional\c_font_defining_state + \setfalse\c_font_defining_state + \processcommacommand + [\fontstylelist] + {\font_helpers_define_unknown_bodyfont_indeed{#body}}% + \ifconditional\c_font_defining_state + \setfalse\c_font_defining_state + \setevalue{\??fontsize#body}{\font_basics_complete_switch[#body]}% + \ifconditional\c_font_defining_unknown \else + \settrue\c_font_defining_unknown + \font_helpers_process_relative_size_list{\font_helpers_define_unknown_sub_font{#body}}% + \setfalse\c_font_defining_unknown + \fi + \fi + \ifconditional\c_font_defining_state + \showmessage\m!fonts{14}{#body}% + \fi + \fi} + +%D These macros show that quite some definitions take place. +%D Fonts are not loaded yet! This means that at format +%D generation time, no font files are preloaded. + +%D \macros +%D {everybodyfont,Everybodyfont,everyglobalbodyfont} +%D +%D Every change in bodyfont size has conseqences for the baseline +%D distance and skips between paragraphs. These are initialized +%D in other modules. Here we only provide the hooks that +%D garantees their handling. + +%D At the system level one can initialize thing like: +%D +%D \starttyping +%D \appendtoks \setupspacing \to \everybodyfont +%D \stoptyping +%D +%D While users can add their own non standard commands like: +%D +%D \starttyping +%D \EveryBodyFont{\message{changing to bodyfont \the\bodyfontsize}} +%D \stoptyping +%D +%D Personnaly I never felt the need for such extensions, but +%D at least its possible. + +%D \macros +%D {globalbodyfontsize,localbodyfontsize} +%D +%D Next we'll do the tough job of font switching. Here we +%D have to distinguish between the global (overal) bodyfont +%D size and the local (sometimes in the textflow) size. We +%D store these dimensions in two \DIMENSION\ registers. + +\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt +\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize + +%D \macros +%D {bodyfontsize} +%D +%D These two registers are not to be misused in calculations. +%D For this purpose we keep a copy: + +\newdimen\bodyfontsize \bodyfontsize=\globalbodyfontsize + +%D \macros +%D {bodyfontfactor,bodyfontpoints} +%D +%D For multiplication purposes we keep an auxiliary counter +%D and macro (here the expansion is not explicitly needed): + +\newcount\bodyfontpoints \dimensiontocount\bodyfontsize\bodyfontpoints + +\edef\bodyfontfactor{\withoutpt\the\bodyfontsize} + +%D When we assign for instance 12pt to a \DIMENSION\ register +%D the \type{\the}'d value comes out as 12.0pt, which is +%D often not the way users specify the bodyfont size. Therefore +%D we also store the normalized value. + +\setnewconstant\fontdigits\plustwo % was 1 + +\def\normalizebodyfontsize#body\to#macro% + {\edef#macro{\ctxcommand{nbfs(\number\dimexpr#body\relax,\number\fontdigits)}}} + +\def\thenormalizedbodyfontsize#body% + {\ctxcommand{nbfs(\number\dimexpr#body\relax,\number\fontdigits)}} + +\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize} +\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} +\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} + +%D \macros +%D {fontstyle,fontalternative,fontsize} +%D +%D Within a bodyfont, fonts can come in different sizes. For +%D instance \type{\tf} is accompanied by \type{\tfa}, +%D \type{\tfb} etc. The first two characters denote the +%D alternative, while the third character in these sequences +%D represents the size. The actual size is saved in a macro +%D +%D The style, being roman (\type{\rm}), sans serif (\type{\ss}) +%D etc. is also available in a macro in \type{rm}, \type{ss} +%D etc. form: + +\let\defaultfontalternative = \s!tf +\let\defaultfontstyle = \empty +\let\defaultfontsize = \empty + +\let\fontalternative = \defaultfontalternative +\let\fontstyle = \defaultfontstyle +\let\fontsize = \defaultfontsize + +%D When \type {\loadfontfileoncetrue}, such files are +%D only loaded once! This permits redundant loading, but at +%D the same time forced grouping when we want continuously mix +%D all kind of font, which of course is a kind of +%D typographically sin. The \type{"} is made inactive if +%D needed to prevent problems with loading files that use this +%D character in numbers. + +% can be made faster (only used internally now) + +% \def\font_basics_switch_points#body% +% {\normalexpanded{\font_basics_switch_points_indeed{#body}}} +% +% \unexpanded\def\font_basics_switch_points_indeed#body% +% +% is expanded still handy here? + +\unexpanded\def\font_basics_switch_points#body% + {\ifcsname\??fontsize#body\endcsname \else + \font_helpers_define_unknown_font{#body}% + \fi% + \ifcsname\??fontsize#body\endcsname + \csname\??fontsize#body\endcsname + \localbodyfontsize#body\relax + \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}% + \font_helpers_check_bodyfont_environment[\normalizedbodyfontsize]% + \else + \showmessage\m!fonts4{#body}% + \fi} + +\unexpanded\def\font_basics_switch_style#style% + {\ifcsname\??fontstyle#style\endcsname + \csname\??fontstyle#style\endcsname + \edef\fontstyle{#style}% + \ifmmode\mr\fi % in order to be compatible with \rm in math mode + % \the\everybodyfont % cleaner, in setting size as well as style + \else + \showmessage\m!fonts5{#style}% + \fi} + +%D Defining fonts using \type{\definebodyfont} takes time, so we +%D prefer to predefine at least the Computer Modern Roman +%D fonts. However, loading all those fonts at definition time +%D would take both time and space. But even worse, once fonts +%D are loaded into memory, their encoding vector is fixed, +%D which is a handicap when we want to distribute the compact +%D \type{fmt} files. So what we want to do is defining fonts in +%D a way that postpones the loading. We accomplish this by only +%D loading the fonts when we switch to another bodyfont size. +%D Among the other alternatives, such as loading the font at +%D the moment of activation and redefining the activation +%D macro afterwards, this proved to be the most efficient +%D alternative. +%D +%D The next few macros take care of the one exeption on this +%D scheme. When at format generation time we load the default +%D font file, the one that defines the Computer Modern Fonts, +%D we don't want the fonts metrics to end up in the format +%D file, so we temporary prohibit loading. This means that at +%D runtime we have to load the default bodyfont size just before +%D we start typesetting. +%D +%D Therefore we have to signal the font switching macros that +%D we are preloading fonts. +%D +%D \macros +%D {preloadfonts} +%D +%D Preloading is only called for once, during the startup +%D sequence of a session. After the loading job is done, the +%D macro relaxes itself and reset the signal. + +\fontslantperpoint \nullfont 0\scaledpoint +\fontinterwordspace \nullfont 256377\scaledpoint +\fontinterwordstretch\nullfont 128188\scaledpoint +\fontinterwordshrink \nullfont 85459\scaledpoint +\fontexheight \nullfont 338952\scaledpoint +\fontemwidth \nullfont 786432\scaledpoint +\fontextraspace \nullfont 85459\scaledpoint + +\fetchruntimecommand \showfontparameters {\f!fontprefix\s!run} + +\def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont + {%\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as: + \ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous + \globallet\font_preloads_reset_nullfont\relax} + +\def\font_preload_default_fonts + {\font_preloads_reset + \setupbodyfont[modern,\fontstyle,\fontbody]% + \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}} + +\def\font_preload_default_fonts_mm + {\writestatus\m!fonts{preloading latin modern fonts (math)}% + \definetypeface[\fontclass][\s!mm][\s!math][modern][\s!default]% + \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}} + +\def\font_preload_default_fonts_tt + {\writestatus\m!fonts{preloading latin modern fonts (mono)}% + \definetypeface[\fontclass][\s!tt][\s!mono][modern][\s!default]% + \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}} + +\def\font_preloads_reset + {\glet\font_preload_default_fonts \relax + %\glet\font_preload_default_fonts_tt\relax + %\glet\font_preload_default_fonts_mm\relax + \glet\font_preloads_zero_stage \relax + \glet\font_preloads_first_stage \relax + \glet\font_preloads_second_stage \relax + %\glet\font_preloads_third_stage \relax + \glet\fourthstagepreloadfonts \relax + \global\everyhbox\emptytoks + \global\everyvbox\emptytoks + \font_preloads_reset_nullfont} + +\def\font_preloads_reset_checked + {\glet\font_preload_default_fonts_tt\relax + \glet\font_preload_default_fonts_mm\relax + \glet\font_preloads_third_stage \relax} + +\def\font_preloads_zero_stage_indeed + {\definedfont[\s!file:lmmono10-regular sa 1]} + +\unexpanded\def\font_preloads_zero_stage + {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}% + \glet\font_preloads_zero_stage\font_preloads_zero_stage_indeed + \font_preloads_zero_stage} + +\unexpanded\def\font_preloads_first_stage % % *nofonts -> *preloadfonts + {\doifmodeelse{*preloadfonts} + {\font_preload_default_fonts + \writestatus\m!fonts{preloading latin modern fonts (first stage)}} + {\writestatus\m!fonts{latin modern fonts are not preloaded}}} + +\unexpanded\def\font_preloads_second_stage + {\writestatus\m!fonts{preloading latin modern fonts (second stage)}% + \font_preload_default_fonts} + +\unexpanded\def\font_preloads_third_stage % always + {\ifx\fontclass\empty + \writestatus\m!fonts{preloading latin modern fonts (third stage)}% + \font_preload_default_fonts + \else + \font_preloads_reset + \pushmacro\fontstyle + \ifcsname\??fontclass\fontclass\s!mm\s!features\endcsname \else + \font_preload_default_fonts_mm + \fi + \ifcsname\??fontclass\fontclass\s!tt\s!features\endcsname \else + \font_preload_default_fonts_tt + \fi + \popmacro\fontstyle + \font_preloads_reset_checked % reset third, mm and tt + \setupbodyfont[\fontstyle]% + \fi} + +\unexpanded\def\font_preloads_fourth_stage + {\begingroup + %ifzeropt\fontcharwd\font\number`!\relax + \setbox\scratchbox\hbox{context}% + \ifzeropt\wd\scratchbox + \writeline + \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}% + \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}% + \writeline + \fi + \font_preloads_reset + \endgroup} + +\appendtoks + \everyhbox{\font_preloads_zero_stage} + \everyvbox{\font_preloads_zero_stage} +\to \everydump + +\def\font_preloads_at_every_job {\font_preloads_first_stage } +\def\font_preloads_at_start_text{\font_preloads_second_stage} +\def\font_preloads_at_stop_text {\font_preloads_fourth_stage} + +%D Here comes the main font switching macros. These macros +%D handle changes in size as well as returning to the global +%D bodyfont size. + +\def\font_helpers_set_font#method#specification% + {\doifelse{#specification}\v!global + {\restoreglobalbodyfont} + {\processcommacommand[#specification]{\font_helpers_set_font_check_size}% + \processcommacommand[#specification]{\font_helpers_set_font_set_font{#method}}% + \ifproductionrun + \font_preloads_third_stage + \font_basics_switch_points\normalizedbodyfontsize + \font_basics_switch_style\fontstyle + \ifx\defaultfontclass\empty + \let\defaultfontclass\fontclass + \fi + \fi}% + \currentxfontsize\zerocount} + +\def\font_helpers_set_font_check_size#option% + {\doifnumberelse{#option}{\font_helpers_check_bodyfont_environment[#option]}\donothing} + +\def\font_helpers_set_font_set_font#method#option% method=1: set, method=2: switch + {\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}} + +\def\font_helpers_set_font_set_font_option#method#option% + {\doifnumberelse{#option}% + \font_helpers_set_font_set_font_option_body + \font_helpers_set_font_set_font_option_keyword + {#method}{#option}{#option}} + +\let\m_font_keyword\empty + +\unexpanded\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message% + {\edef\m_font_keyword{#keyword}% + \ifcsname\??fonts\normalizedbodyfontsize\m_font_keyword\endcsname + \edef\m_font_step{\bodyfontvariable\m_font_keyword}% + \normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}% + \else\ifx\m_font_keyword\v!reset + \let\fontstyle\empty % new 31/7/2006 + \let\fontsize \empty + \else\ifcsname\??fontstyle\m_font_keyword\endcsname + \let\fontstyle\m_font_keyword + \else + \setcurrentfontclass\m_font_keyword + \ifcase#method\relax + \let\globalfontclass\globalfontclass + \else + \let\globalfontclass\fontclass + \fi + \font_helpers_set_fontstyle_of_fontclass + \fi\fi\fi} + +% \unexpanded\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message% +% {\edef\m_font_keyword{#keyword}% +% \ifx\m_font_keyword\v!reset +% \let\fontstyle\empty % new 31/7/2006 +% \let\fontsize \empty +% \else\ifcsname\??fontstyle\m_font_keyword\endcsname +% \let\fontstyle\m_font_keyword +% \else +% \edef\m_font_step{\bodyfontvariable\m_font_keyword}% +% \ifx\m_font_step\empty +% \setcurrentfontclass\m_font_keyword +% \ifcase#method\relax +% \let\globalfontclass\globalfontclass +% \else +% \let\globalfontclass\fontclass +% \fi +% \font_helpers_set_fontstyle_of_fontclass +% \else +% \normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}% we can have a simple one for this +% \fi +% \fi\fi} + +\def\font_helpers_set_fontstyle_of_fontclass % will be overloaded later + {\let\fontstyle\s!rm} + +\unexpanded\def\font_helpers_set_font_set_font_option_body#method#body#message% + {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#body}}% redundant for some calls + \ifcsname\??fontsize\normalizedsetfont\endcsname \else + \font_helpers_define_unknown_font{#body}% + \fi + \ifcsname\??fontsize\normalizedsetfont\endcsname + \localbodyfontsize\normalizedsetfont + \let\normalizedbodyfontsize\normalizedsetfont + \else + \showmessage\m!fonts4{#message}% + \font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}% + \fi} + +%D When users specify for instance a 13 point bodyfont while no +%D such bodyfont is defined, the system automatically tries to +%D find a best fit, that is the nearest smaller defined +%D bodyfontzize. A smaller one is definitely better than a larger +%D one, simply because otherwise a lot of overfull box messages +%D are more probable to occur. By taking a value slightly +%D smaller than half a point, we can use the next method. + +\def\font_helpers_set_font_set_font_option_body_fallbacks#method#body% + {\scratchdimen#body\relax + \advance\scratchdimen .499\points + \dimensiontocount\scratchdimen\scratchcounter + \advance\scratchcounter \minusone + \ifnum\scratchcounter>\plusthree + %\font_helpers_set_font_set_font_option{#method}{\the\scratchcounter\s!pt}% + \font_helpers_set_font_set_font_option_body{#method}{\the\scratchcounter\s!pt}\empty + \fi} + +% The following bunch of macros deals with the (run time) +% expansion of names onto the definitions made by \type +% {\definebodyfont}. + +% \let\fontbody \empty % ... 10pt 11pt 12pt ... +% \let\fontstyle \empty % rm ss tt mm hw cg ... +% \let\fontalternative\empty % tf bf sl it bs bi sc ... +% \let\fontsize \empty % xy-abcd ... + +\def\defaultfontbody{\normalizedbodyfontsize} + +\let\fontbody\defaultfontbody + +\let\fontclass\empty \let\globalfontclass\fontclass + +% we need to check the fontclass + +\def\registerfontclass#class% + {\letgvalue{\??fontclassyes#class}\v!yes} % global ? + +\def\setcurrentfontclass#class% + {\ifcsname\??fontclassyes#class\endcsname + \edef\fontclass{#class}% + \else\ifcsname\??fontclassnop#class\endcsname + % already tried + \else % too messy: \ifcase\currentgrouplevel % (unpredictable) + \trycurrentfontclass{#class}% + \fi\fi} % \fi} + +% no prefix ? + +\installcorenamespace{fontclass} + +\unexpanded\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#direction% + {\setxvalue{\??fontclass\fontclass#style\s!rscale }{#rscale}% + \setxvalue{\??fontclass\fontclass#style\s!features }{#features}% + \setxvalue{\??fontclass\fontclass#style\s!fallbacks}{#fallbacks}% + \setxvalue{\??fontclass\fontclass#style\s!goodies }{#goodies}% + \setxvalue{\??fontclass\fontclass#style\s!direction}{#direction}} + +\settrue\autotypescripts + +\unexpanded\def\trycurrentfontclass#typeface% + {\ifconditional\autotypescripts + \usetypescript[#typeface]% + \ifcsname\??fontclassyes#typeface\endcsname + \edef\fontclass{#typeface}% + \else + \usetypescriptfile[\f!typeprefix#typeface]% + \usetypescript[#typeface]% + \ifcsname\??fontclassyes#typeface\endcsname + \edef\fontclass{#typeface}% + \else + % todo: message + \letvalueempty{\??fontclassnop#typeface}% + \fi + \fi + \else + % todo: message + \letvalueempty{\??fontclassnop#typeface}% + \fi} + +\let\defaultfontstyle \s!rm +\let\defaultfontalternative\s!tf +\let\defaultfontsize \empty + +%D \macros +%D {bigmath,nobigmath} +%D +%D We can inhibit this slow||downer with: + +% these can best be combined + +% 0=never 1=everymath 2=always + +\setnewconstant\synchronizebigmathflag\plusone + +\appendtoks + \ifcase\synchronizebigmathflag + % never + \or + \synchronizebigmath + \or + % always + \fi +\to \everymathematics + +\unexpanded\def\nobigmath {\synchronizebigmathflag\zerocount} +\unexpanded\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath} +\unexpanded\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath} + +\let\bigmathfontsize\empty + +\unexpanded\def\synchronizebigmath + {\ifx\bigmathfontsize\fontsize + % already in sync + \else + \let\bigmathfontsize\fontsize + \font_helpers_synchronize_math + \fi} + +\unexpanded\def\font_helpers_check_big_math_synchronization + {\ifcase\synchronizebigmathflag + % never + \or + \ifmmode \synchronizebigmath \fi + \or + \synchronizebigmath + \fi} + +%D So far for synchronisation. (We can inline the following macros.) + +\unexpanded\def\setcurrentfont#body#style#alternative#size% + {\edef\fontbody {#body}% + \edef\fontstyle {#style}% + \edef\fontalternative{#alternative}% + \edef\fontsize {#size}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font} + +\unexpanded\def\setcurrentfontbody#body% + {\edef\fontbody{#body}% + \font_helpers_synchronize_font} + +% For Taco: optional fall backs: + +\ifdefined\font_typescripts_inherit_check \else + \let\font_typescripts_inherit_check\gobbleoneargument % implemented in type-ini +\fi + +\unexpanded\def\font_helpers_set_current_font_style#style% + {\edef\fontstyle{#style}% + \font_typescripts_inherit_check\fontstyle + \ifmmode\mr\fi % otherwise \rm not downward compatible ... not adapted yet + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_fontbody_alternative#body#alternative% + {\edef\fontbody {#body}% + \edef\fontalternative{#alternative}% + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_alternative#alternative% + {\edef\fontalternative{#alternative}% + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_size#size% + {\edef\fontsize{#size}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_style_alternative#style#alternative% \rmsl + {\edef\fontstyle {#style}% + \edef\fontalternative{#alternative}% + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_style_size#style#size% \rma + {\edef\fontstyle{#style}% + \edef\fontsize {#size}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_alternative_size#alternative#size% \sla + {\edef\fontalternative{#alternative}% + \edef\fontsize {#size}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_set_current_font_style_alternative_size#style#alternative#size% \rmsla + {\edef\fontstyle {#style}% + \edef\fontalternative{#alternative}% + \edef\fontsize {#size}% + \font_helpers_check_big_math_synchronization + \font_helpers_synchronize_font} + +\unexpanded\def\font_helpers_synchronize_font % we can have dups i.e. no need to let fontstrategy + {\ifx\fontclass\empty + \applyfontstrategies + \else + \applyfontclassstrategies + \fi + \setfalse\font_auto_font_size + \ifskipfontcharacteristics + \setfontcharacteristics + \the\everyfontswitch + \fi} + +\def\font_helpers_check_strategy_class_a % --- --- --- --- % pt tt bf a + {\ifcsname\fontclass\fontbody \fontstyle \fontalternative \fontsize\endcsname + \setfalse\font_auto_font_size + \csname\fontclass\fontbody \fontstyle \fontalternative \fontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_class_b + \fi} + +\def\font_helpers_check_strategy_class_b % --- --- --- def % pt tt bf + {\ifcsname\fontclass\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\fontclass\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_class_c + \fi} + +\def\font_helpers_check_strategy_class_c % --- --- def --- % pt tt tf a + {\ifcsname\fontclass\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname + \settrue\font_auto_font_size + \csname\fontclass\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_class_d + \fi} + +\def\font_helpers_check_strategy_class_d % --- --- def def % pt tt tf + {\ifcsname\fontclass\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\fontclass\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_class_e + \fi} + +\def\font_helpers_check_strategy_class_e % --- def def def % pt rm tf + {\ifcsname\fontclass\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \setfalse\font_auto_font_size + \csname\fontclass\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_class_f + \fi} + +\def\font_helpers_check_strategy_class_f % def def def def % rm tf + {\ifcsname\fontclass\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\fontclass\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_a + \fi} + +% no class + +\def\font_helpers_check_strategy_a % --- --- --- --- % pt tt bf a + {\ifcsname\fontbody \fontstyle \fontalternative \fontsize\endcsname + \setfalse\font_auto_font_size + \csname\fontbody \fontstyle \fontalternative \fontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_b + \fi} + +\def\font_helpers_check_strategy_b % --- --- --- --- % pt tt bf a + {\ifcsname\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\fontbody \fontstyle \fontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_c + \fi} + +\def\font_helpers_check_strategy_c % --- --- --- --- % pt tt bf a + {\ifcsname\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname + \settrue\font_auto_font_size + \csname\fontbody \fontstyle \defaultfontalternative \fontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_d + \fi} + +\def\font_helpers_check_strategy_d % --- --- --- --- % pt tt bf a + {\ifcsname\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\fontbody \fontstyle \defaultfontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_e + \fi} + +\def\font_helpers_check_strategy_e % --- --- --- --- % pt tt bf a + {\ifcsname\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \setfalse\font_auto_font_size + \csname\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \else + \expandafter\font_helpers_check_strategy_f + \fi} + +\def\font_helpers_check_strategy_f % --- --- --- --- % pt tt bf a + {\ifcsname\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \settrue\font_auto_font_size + \csname\defaultfontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname + \fi} + +\let\applyfontstrategies \font_helpers_check_strategy_a +\let\applyfontclassstrategies\font_helpers_check_strategy_class_a + +%D Let's synchronize: + +\newconditional\c_font_synchronize \settrue\c_font_synchronize + +\prependtoks + \ifconditional\c_font_synchronize + \font_helpers_synchronize_math + \font_helpers_synchronize_font % problem: syncs last font + \fi +\to \everybodyfont + +%D Setting the normal sizes as well as the x and xx smaller +%D sizes is accomplished by the next set of macros. When in +%D math mode, the commands \type{\tx} and \type{\txx} are +%D just a switch to the script and double script styles, but +%D in text mode the values defined by the bodyfontenvironment are +%D used. Here we also set \type{\currentxfontsize}. + +\def\font_helpers_set_current_font_xxx_alternative#alternative#size#xsize#scriptstyle% + {\currentxfontsize#size\relax + \ifmmode + #scriptstyle% + \else\ifcsname\??fontsteps\fontclass\fontbody#xsize\endcsname + \expandafter\font_helpers_set_current_fontbody_alternative\csname\??fontsteps\fontclass\fontbody#xsize\endcsname{#alternative}% + \else + % some error: check is not done correctly + \fi\fi} + +\def\font_helpers_set_current_font_x_alternative#alternative% + {\font_helpers_set_current_font_xxx_alternative{#alternative}1\s!x\scriptstyle + \let\tx\txx} + +\def\font_helpers_set_current_font_xx_alternative#alternative% + {\font_helpers_set_current_font_xxx_alternative{#alternative}2\s!xx\scriptscriptstyle + \let\tx\empty + \let\txx\empty} + +\def\font_helpers_check_nested_x_fontsize % option + {\ifcase\currentxfontsize\else\ifx\fontsize\empty\else + \currentxfontsize\zerocount + \let\fontsize\empty + \let\tx\normaltx + \let\txx\normaltxx + \fi\fi} + +\def\font_helpers_set_current_font_x_alternative#alternative% + {\font_helpers_check_nested_x_fontsize + \font_helpers_set_current_font_xxx_alternative{#alternative}1\s!x\scriptstyle + \let\tx\txx} + +\def\font_helpers_set_current_font_xx_alternative#alternative% + {\font_helpers_check_nested_x_fontsize + \font_helpers_set_current_font_xxx_alternative{#alternative}2\s!xx\scriptscriptstyle + \let\tx\empty + \let\txx\empty} + +% This alterative is not really needed, but for old time's sake +% we keep it there. We can speed it up when needed. + +\def\font_helpers_set_current_font_x_style_alternative #alternative{\csname#alternative\endcsname\tx} +\def\font_helpers_set_current_font_xx_style_alternative#alternative{\csname#alternative\endcsname\txx} + +%D These macros also show us that when we call for \type{\tx}, +%D this macro is redefined to be \type{\txx}. Therefore calls +%D like: +%D +%D \startbuffer +%D {small \tx is \tx beautiful} +%D {small \tx is \txx beautiful} +%D {small \txx is \tx beautiful} +%D {small \txx is \txx beautiful} +%D \stopbuffer +%D +%D \typebuffer +%D +%D result in: +%D +%D \startlines +%D \getbuffer +%D \stoplines +%D +%D Setting the main size involves the style list and therefore +%D takes a bit more time. Keep in mind that the fontsize is +%D represented by a character or empty. + +\unexpanded\def\tx {\font_helpers_set_current_font_x_alternative \fontalternative} +\unexpanded\def\txx{\font_helpers_set_current_font_xx_alternative\fontalternative} + +\let\normaltx \tx +\let\normaltxx\txx + +%D \macros +%D {definefontstyle} +%D +%D When setting of switching the overall style we can use the +%D short identifier like rm and ss, but when defined we can +%D also use more verbose names like roman or sansserif. Such +%D names are defined by: +%D +%D \starttyping +%D \definefontstyle [serif,rm] [rm] +%D \definefontstyle [sansserif,ss] [ss] +%D \stoptyping + +\unexpanded\def\definefontstyle + {\dodoubleargument\font_basics_define_fontstyle} + +\def\font_basics_define_fontstyle[#commands][#style]% + {\rawdoifinsetelse{#style}{\fontstylelist}{}{\addtocommalist{#style}\fontstylelist}% + \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}} + +\def\font_basics_define_fontstyle_indeed#style#command% + {\setvalue{\??fontshortstyle#command}{#style}% + \setvalue{\??fontstyle #command}{\csname#style\endcsname}} + +%D When asking for a complete font switch, for instance from 10 +%D to 12~points, the next macro does the job. First we +%D normalize the size, next we define the current range of +%D text, script and scriptscript sizes, then we set the text +%D fonts and the math families and finally we activate the +%D default typeface and also set the font specific parameters +%D assigned to \type{\everybodyfont} + +\unexpanded\def\font_basics_complete_switch[#size]% + {\bodyfontsize#size\relax + \dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart + \edef\bodyfontfactor{\withoutpt\the\bodyfontsize}% + \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}% + \edef\textface {\bodyfontvariable\s!text }% + \edef\scriptface {\bodyfontvariable\s!script }% + \edef\scriptscriptface{\bodyfontvariable\s!scriptscript}} + +% \font_basics_complete_switch[12pt] % init + +%D \macros +%D {setupbodyfont,switchtobodyfont} +%D +%D The next two macros are user ones. With \type{\setupbodyfont} +%D one can set the document bodyfont size, font family, style +%D and/or options defined in files, for example: +%D +%D \starttyping +%D \setupbodyfont[modern,12pt,roman] +%D \stoptyping +%D +%D This command affects the document as a whole: text, headers +%D and footers. The second macro however affects only the text: +%D +%D \starttyping +%D \switchtobodyfont[10pt] +%D \stoptyping +%D +%D So we've got: +%D +%D \showsetup{setupbodyfont} +%D \showsetup{switchtobodyfont} +%D +%D Both macros look alike. The second one also has to take +%D all kind of keywords into account. + +\ifx\saveinterlinespace \undefined \let\saveinterlinespace \relax \fi +\ifx\restoreinterlinespace\undefined \let\restoreinterlinespace\relax \fi + +% \newtoks \everysetupbodyfont +% \newtoks \everyswitchtobodyfont + +\unexpanded\def\setupbodyfont + {\doifnextoptionalelse\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop} + +\def\font_basics_setupbodyfont_nop + {\restoreglobalbodyfont + \saveinterlinespace} + +\def\font_basics_setupbodyfont_yes[#specification]% + {\doifsomething{#specification} + {\font_helpers_set_font\plusone{#specification}% + \globalbodyfontsize\localbodyfontsize + \edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\globalbodyfontsize}% + \let\globalfontstyle\fontstyle + \ifproductionrun + \the\everybodyfont + \the\everyglobalbodyfont + \saveinterlinespace + \fi + \the\everysetupbodyfont}} + +% \unexpanded\def\switchtobodyfont[#specification]% +% {\doifsomething{#specification} +% {\ifcsname\??fonts\normalizedbodyfontsize#specification\endcsname +% \font_helpers_set_bodyfont_step{#specification}% so we have a fast [small] switch +% \else +% \font_helpers_set_font\zerocount{#specification}% +% \fi +% \the\everybodyfont +% \the\everyswitchtobodyfont}} + +\unexpanded\def\switchtobodyfont[#specification]% + {\doifsomething{#specification} + {\edef\m_font_step{\bodyfontvariable{#specification}}% + \ifx\m_font_step\empty + \font_helpers_set_font\zerocount{#specification}% + \else + \font_helpers_switch_bodyfont_step % so we have a fast [small] switch + \fi + \the\everybodyfont + \the\everyswitchtobodyfont}} + +\def\font_helpers_switch_bodyfont_step + {\font_basics_switch_points\m_font_step + \font_basics_switch_style \fontstyle} + +%D The following alternative is meant for math||to||text +%D switching and will be optimized. + +\unexpanded\def\fastswitchtobodyfont#name% + {\ifcsname\??fonts\normalizedbodyfontsize#name\endcsname + \edef\futurebodyfontsize{\csname\??fonts\normalizedbodyfontsize#name\endcsname}% + \ifcsname\??fontsize\futurebodyfontsize\endcsname + \csname\??fontsize\futurebodyfontsize\endcsname + \localbodyfontsize\futurebodyfontsize\relax + \fi + \fi + \csname\??fontstyle\fontstyle\endcsname + \the\everybodyfont} + +%D \starttyping +%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$ +%D \stoptyping + +\def\setfontcharacteristics + {\the\everyfont} + +%D Handy for manuals: + +\unexpanded\def\fontchar#character% + {\ctxcommand{fontchar("#character")}} + +%D Feature management. + +\unexpanded\def\definefontfeature + {\dotripleargument\font_basics_define_font_feature} + +\def\font_basics_define_font_feature[#featureset][#parent][#settings]% + {\ctxcommand{definefontfeature("#featureset","#parent","#settings")}} + +\unexpanded\def\fontfeatureslist + {\dodoubleargument\font_basics_features_list} + +\def\font_basics_features_list[#name][#separator]% todo: arg voor type + {\cldcommand{featurelist("#name","otf","\luaescapestring{#separator}","yes","no",true,{"number"})}} + +\attribute\zerocount\zerocount % first in list, so fast match + +\let\currentfeature\empty + +% ! ! ! very experimental, some test code for idris advanced features ! ! ! +% +% \startbuffer +% \definefontfeature[smallcaps][smallcaps][script=latn] +% \definefontfeature[oldstyle] [oldstyle] [script=latn] +% +% \definedfont[name:cambria at 15pt] +% +% Hello there {\setff{smallcaps}capped 123 \setff{oldstyle}123!} \blank +% Hello there {\addff{smallcaps}capped 123 \addff{oldstyle}123!} \blank +% Hello there {\addff{smallcaps}capped \subff{smallcaps}normal} \blank +% \stopbuffer +% +% \typebuffer \getbuffer + +\unexpanded\def\featureattribute#feature{\ctxcommand{featureattribute("#feature")}} +\unexpanded\def\setfontfeature #feature{\ctxcommand{setfontfeature("#feature")}\edef\currentfeature{#feature}} +%unexpanded\def\resetfontfeature {\ctxcommand{resetfontfeature()}\let\currentfeature\empty} % initial value +\unexpanded\def\resetfontfeature {\attribute\zerocount\zerocount \let\currentfeature\empty} % initial value + +\unexpanded\def\addfontfeaturetoset #feature{\ctxcommand{addfs("#feature")}} % merge +\unexpanded\def\subtractfontfeaturefromset #feature{\ctxcommand{subfs("#feature")}} % merge +\unexpanded\def\addfontfeaturetofont #feature{\ctxcommand{addff("#feature")}} % overload +\unexpanded\def\subtractfontfeaturefromfont#feature{\ctxcommand{subff("#feature")}} % overload + +\let\setff\setfontfeature +\let\addfs\addfontfeaturetoset +\let\subfs\subtractfontfeaturefromset +\let\addff\addfontfeaturetofont +\let\subff\subtractfontfeaturefromfont + +%D The next auxilliary macro is an alternative to \type +%D {\fontname}. + +\def\purefontname#font{\ctxlua{file.basename("\fontname#font"}} % will be function using id + +%D \macros +%D {switchstyleonly} +%D +%D For switching a style but keeping the alternative, there +%D is: +%D +%D \starttyping +%D {\bf text \switchstyleonly\ss text} +%D {\bf text \switchstyleonly[ss]text} +%D {\sl text \switchstyleonly[sansserif]text} +%D \stoptyping + +\unexpanded\def\switchstyleonly + {\doifnextoptionalelse\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg} + +\def\font_basics_switch_style_only_arg#name% stupid version + {\font_helpers_set_current_font_style{\csname\??fontshortstyle\checkedstrippedcsname#name\endcsname}% + \the\everybodyfont} % needed ? + +\def\font_basics_switch_style_only_opt[#name]% todo : check + {\font_helpers_set_current_font_style{\csname\??fontshortstyle#name\endcsname}% + \the\everybodyfont} % needed ? + +%D \macros +%D {os} +%D +%D In good old \TEX, the old style numerals were often taken +%D from the math fonts. No longer. + +\definefontfeature + [just-os] + [mode=node,onum=yes] + +%unexpanded\def\sc{\setfontfeature{smallcaps}} +\unexpanded\def\os{\setfontfeature{just-os}} + +%D \macros +%D {definebodyfontswitch} +%D +%D \PLAIN\ \TEX\ defines some macro's like \type{\tenpoint} +%D to switch to a specific bodyfontsize. Just for the sake of +%D compatibility we can define them like: +%D +%D \starttyping +%D \definebodyfontswitch [twelvepoint] [12pt] +%D \stoptyping +%D +%D We don't support language specific synonyms here, mainly +%D because \PLAIN\ \TEX\ is english anyway. + +\unexpanded\def\definebodyfontswitch + {\dodoubleargument\font_basics_define_bodyfont_switch} + +\def\font_basics_define_bodyfont_switch[#command][#specification]% no longer a commalist (not useful) + {\setvalue{#command}{\switchtobodyfont[#specification]}}% + +%D \macros +%D {setsmallbodyfont,setmainbodyfont,setbigbodyfont} +%D +%D When we're typesetting at for instance 10pt, we can call for +%D the \type{small} as well as the \type{big} alternative, +%D related to this main size, using \type{\switchtobodyfont[small]}. +%D The three alternatives can be activated by the next three +%D system calls and are defined by the bodyfontenvironment. + +\let\m_font_step\empty + +\def\font_helpers_set_bodyfont_step#step% + {\edef\m_font_step{\bodyfontvariable{#step}}% not always \cs + \font_basics_switch_points\m_font_step + \font_basics_switch_style \fontstyle} + +\unexpanded\def\setsmallbodyfont{\font_helpers_set_bodyfont_step\v!small\the\everybodyfont} +\unexpanded\def\setbigbodyfont {\font_helpers_set_bodyfont_step\v!big \the\everybodyfont} + +\unexpanded\def\setmainbodyfont + {\font_basics_switch_points\normalizedbodyfontsize + \font_basics_switch_style\fontstyle + \the\everybodyfont + \the\everyglobalbodyfont + \saveinterlinespace} + +%D \macros +%D {restoreglobalbodyfont} +%D +%D Users can set whatever font available while typesetting text. +%D Pagenumbers, footers, headers etc. however must be typeset +%D in the main bodyfont and style of the document. Returning to +%D the global state can be done with the next macro: + +\let\globalfontstyle\s!rm + +\def\fullrestoreglobalbodyfont + {\let\fontsize\defaultfontsize + \let\fontbody\defaultfontbody + \currentxfontsize\zerocount + \let\fontclass\globalfontclass + \font_basics_switch_points\normalizedglobalbodyfontsize + \font_basics_switch_style\globalfontstyle + \redoconvertfont % just in case a pagebreak occurs + \tf + \the\everybodyfont + \the\everyglobalbodyfont + \saveinterlinespace} + +\def\partialrestoreglobalbodyfont + {\let\fontsize\defaultfontsize + \let\fontbody\defaultfontbody + \currentxfontsize\zerocount + \redoconvertfont + \tf + \the\everybodyfont % indeed needed + \the\everyglobalbodyfont % indeed needed + \saveinterlinespace} + +\def\restoreglobalbodyfont % ook style etc + {\ifx\fontclass\globalfontclass + \ifx\fontstyle\globalfontstyle + \ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize + \partialrestoreglobalbodyfont + \else + \fullrestoreglobalbodyfont + \fi + \else + \fullrestoreglobalbodyfont + \fi + \else + \fullrestoreglobalbodyfont + \fi} + +% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont + +%D This macro has to be called when entering the pagebody +%D handling routine as well as the footnote insert routine. +%D Users can access this feature |<|for instance when one wants +%D to typeset tables and alike in the main bodyfont and style +%D while the running text is temporary set to a smaller one|>| +%D by saying \type{\switchtobodyfont[global]}. + +%D \macros +%D {definealternativestyle} +%D +%D In the main modules we are going to implement lots of +%D parameterized commands and one of these parameters will +%D concern the font to use. To suit consistent use of fonts we +%D here implement a mechanism for defining the keywords that +%D present a particular style or alternative. +%D +%D \starttyping +%D \definealternativestyle [keywords] [\style] [\nostyle] +%D \stoptyping +%D +%D The first command is used in the normal textflow, while the +%D second command takes care of headings and alike. Consider +%D the next two definitions: +%D +%D \starttyping +%D \definealternativestyle [bold] [\bf] [] +%D \definealternativestyle [cap] [\cap] [\cap] +%D \stoptyping +%D +%D A change \type{\bf} in a heading which is to be set in +%D \type{\tfd} does not look that well, so therefore we leave +%D the second argument of \type{\definealternativestyle} empty. +%D When we capatalize characters using the pseudo small cap +%D command \type{\cap}, we want this to take effect in both +%D text and headings, which is accomplished by assigning both +%D arguments. + +\installcorenamespace{alternativestyles} + +\setnewconstant \c_font_current_alternative_style_index \plusone + +\unexpanded\def\definealternativestyle + {\dotripleempty\font_basics_define_alternative_style} + +\def\font_basics_define_alternative_style[#commands][#variantone][#varianttwo]% + {\processcommalist[#commands]{\font_basics_define_alternative_style_indeed{#variantone}{#varianttwo}}} + +\let\definestyle\definealternativestyle % later redefined + +\def\font_basics_define_alternative_style_indeed#variantone#varianttwo#command% + {\ifcsname#command\endcsname + % no redefinition + \else + \setuvalue{#command}{\groupedcommand{#variantone}{}}% + \fi + \setvalue{\??alternativestyles#command}{\font_helpers_apply_alternative_style{#variantone}{#varianttwo}}}% + +\def\font_helpers_apply_alternative_style + {\ifcase\c_font_current_alternative_style_index + \expandafter\gobbletwoarguments + \or + \expandafter\firstoftwoarguments + \or + \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments + \fi} + +\def\applyalternativestyle#name% public + {\ifcsname\??alternativestyles#name\endcsname\csname\??alternativestyles#name\expandafter\endcsname\fi} + +%D Maybe too geneneric, but probably ok is the following. (Maybe one +%D day we will use a dedicated grouped command for styles.) + +% \appendtoks +% \let\groupedcommand\thirdofthreearguments +% \to \simplifiedcommands + +%D This command also defines the keyword as command. This means +%D that the example definition of \type{bold} we gave before, +%D results in a command \type{\bold} which can be used as: +%D +%D \startbuffer +%D He's a \bold{bold} man with a {\bold head}. +%D \stopbuffer +%D +%D \typebuffer +%D +%D or +%D +%D \startexample +%D \definealternativestyle[bold][\bf][]\getbuffer +%D \stopexample +%D +%D Such definitions are of course unwanted for \type{\cap} +%D because this would result in an endless recursive call. +%D Therefore we check on the existance of both the command and +%D the substitution. The latter is needed because for instance +%D \type{\type} is an entirely diferent command. That command +%D handles verbatim, while the style command would just switch +%D to teletype font. This is just an example of a tricky +%D naming coincidence. + +%D \macros +%D {doconvertfont,noconvertfont, +%D dontconvertfont,redoconvertfont} +%D +%D After having defined such keywords, we can call for them by +%D using +%D +%D \starttyping +%D \doconvertfont{keyword}{text} +%D \stoptyping +%D +%D We deliberately pass an argument. This enables us to +%D assign converters that handle one argument, like +%D \type{\cap}. +%D +%D By default the first specification is used to set the style, +%D exept when we say \type{\dontconvertfont}, after which the +%D second specification is used. We can also directly call for +%D \type{\noconvertfont}. In nested calls, we can restore the +%D conversion by saying \type{\redoconvertfont}. + +%D These commands are not grouped! Grouping is most probably +%D done by the calling macro's and would lead to unnecessary +%D overhead. + +\let\m_current_convert_font \empty +\let\m_current_convert_font_dt\empty + +\unexpanded\def\doconvertfont#specification% takes second argument / this command is obsolete + {\edef\m_current_convert_font{#specification}% + \ifx\m_current_convert_font\empty + %\expandafter\firstofoneargument + \else + \expandafter\font_helpers_do_convert_font + \fi} + +\def\font_helpers_do_convert_font + {\edef\m_current_convert_font_dt{\detokenize\expandafter{\m_current_convert_font}}% + \ifcsname\??alternativestyles\m_current_convert_font_dt\endcsname + \csname\??alternativestyles\m_current_convert_font_dt\expandafter\endcsname + \else\ifcsname\m_current_convert_font_dt\endcsname + \csname\m_current_convert_font_dt\expandafter\endcsname + \else + \doubleexpandafter\m_current_convert_font + \fi\fi} + +%D Low level switches (downward compatible): + +\unexpanded\def\dontconvertfont{\c_font_current_alternative_style_index\plustwo} % needs checking in usage +\unexpanded\def\redoconvertfont{\c_font_current_alternative_style_index\plusone} % needs checking in usage + +%D The new one: + +\unexpanded\def\dousestyleparameter#value% + {\edef\currentstyleparameter{#value}% + \ifx\currentstyleparameter\empty\else + \expandafter\dousecurrentstyleparameter + \fi} + +\unexpanded\def\dousestylehashparameter#hash#parameter% + {\ifcsname#hash#parameter\endcsname + \expandafter\dousestyleparameter\csname#hash#parameter\endcsname + \fi} + +\unexpanded\def\dousecurrentstyleparameter % empty check outside here + {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}% + \settrue\fontattributeisset % reset is done elsewhere + \ifcsname\??alternativestyles\detokenizedstyleparameter\endcsname + \csname\??alternativestyles\detokenizedstyleparameter\endcsname + \else\ifcsname\detokenizedstyleparameter\endcsname + \csname\detokenizedstyleparameter\endcsname + \else + \currentstyleparameter + \fi\fi} + +\let\dosetfontattribute\dousestylehashparameter % for a while + +%D \macros +%D {setfont} +%D +%D Every now and then we want to define a font directly, for +%D instance when we typeset title pages. The next macro saves +%D some typing: + +\unexpanded\def\setfont% geen \font_helpers_set_font mogelijk + {\afterassignment\font_basics_set_font\font\nextfont=} + +\def\font_basics_set_font + {\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace + +%D One can call this macro as: +%D +%D \starttyping +%D \setfont cmr10 at 60pt +%D \stoptyping +%D +%D After which the font is active and the baselines and +%D struts are set. + +%D \macros +%D {showbodyfont} +%D +%D One can call for a rather simple overview of a bodyfont and the +%D relations between its alternative fonts. +%D +%D \showsetup{showbodyfont} +%D +%D The current bodyfont (here we omitted the argument) looks like: +%D +%D \showbodyfont +%D +%D The implementation is rather straightforward in using +%D \type{\halign}. + +\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run} + +%D \macros +%D {showfontstrip, testminimalbaseline, showminimalbaseline} +%D +%D The next command can come in handy when combining +%D different fonts into a collection (typeface) and +%D determining optimal baseline distances. +%D +%D \showfontstrip \blank \showminimalbaseline + +\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run} +\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run} +\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run} + +%D \macros +%D {showkerning} +%D +%D A goody is: +%D +%D \showkerning{Can you guess what kerning is?} + +\fetchruntimecommand \showkerning {\f!fontprefix\s!run} + +%D \macros +%D {showbodyfontenvironment} +%D +%D The current bodyfontenvironment is: +%D +%D \showbodyfontenvironment +%D +%D This overview is generated using: +%D +%D \showsetup{showbodyfontenvironment} + +\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run} + +%D \macros +%D {showfont,showfontstyle,showligatures} +%D +%D The following command generates a fontmap: +%D +%D \startbuffer +%D \showfont[SansBold at 12pt] +%D \stopbuffer +%D +%D \typebuffer +%D \getbuffer + +% to be internationalized + +\fetchruntimecommand \showfont {\f!fontprefix\s!run} +\fetchruntimecommand \showfontstyle {\f!fontprefix\s!run} +\fetchruntimecommand \showligature {\f!fontprefix\s!run} +\fetchruntimecommand \showligatures {\f!fontprefix\s!run} +\fetchruntimecommand \showcharratio {\f!fontprefix\s!run} + +%D \macros +%D {getglyph, symbolicfont} +%D +%D Individual glyphs can be accessed by using +%D +%D \starttyping +%D \getglyph{fontname}{character} +%D \stoptyping +%D +%D This macro is used in for instance the symbol modules and +%D as one can see, it does obey the small and even smaller +%D sizes. The \type {\symbolicfont} macro can be used to +%D switch to a font named \type {fontname} (see \type +%D {cont-log} and \type {symb-eur} for examples of symbolic +%D definitions. + +\def\v_font_string_a + {\ifx\fontstyle\s!rm \s!Serif \else + \ifx\fontstyle\s!ss \s!Sans \else + \ifx\fontstyle\s!tt \s!Mono \else + \s!Serif \fi\fi\fi} + +\def\v_font_string_b + {\ifx\fontstyle\s!rm \s!Regular \else + \ifx\fontstyle\s!ss \s!Support \else + \ifx\fontstyle\s!tt \s!Type \else + \s!Serif \fi\fi\fi} + +\def\v_font_string_c + {\ifx\fontalternative\s!bf \s!Bold \else + \ifx\fontalternative\s!sl \s!Slanted \else + \ifx\fontalternative\s!it \s!Italic \else + \ifx\fontalternative\s!bs \s!BoldSlanted \else + \ifx\fontalternative\s!bi \s!BoldItalic \fi\fi\fi\fi\fi} + +\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini) + +% potential generalization: +% +% \letvalue{\??fontfile:t:\s!rm}\s!Serif +% \letvalue{\??fontfile:t:\s!ss}\s!Sans +% \letvalue{\??fontfile:t:\s!tt}\s!Mono +% +% \letvalue{\??fontfile:a:\s!rm}\s!Regular +% \letvalue{\??fontfile:a:\s!ss}\s!Support +% \letvalue{\??fontfile:a:\s!tt}\s!Type +% +% \letvalue{\??fontfile:s:\s!bf}\s!Bold +% \letvalue{\??fontfile:s:\s!sl}\s!Slanted +% \letvalue{\??fontfile:s:\s!it}\s!Italic +% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted +% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic +% +% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif} +% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif} +% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif} +% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty} +% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif} + +%D \macros +%D {fontstylesuffix} +%D +%D The next macro is used to map non latin fontnames on fonts. See \type +%D {font-uni} for an example of its use. + +\def\fontstylesuffix% why the \s!Regular ? see \getglyph + {\ifx\fontalternative\s!tf \s!Regular \else + \ifx\fontalternative\s!bf \s!Bold \else + \ifx\fontalternative\s!sl \s!Slanted \else + \ifx\fontalternative\s!it \s!Italic \else + \ifx\fontalternative\s!bs \s!BoldSlanted \else + \ifx\fontalternative\s!bi \s!BoldItalic \else + \ifx\fontalternative\s!sc \s!Caps \else + \s!Regular \fi\fi\fi\fi\fi\fi\fi}% + +\def\glyphfontfile#base% appends + {#base% + \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname + \v_font_string_a\v_font_string_c + \else\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname + \v_font_string_b\v_font_string_c + \else\ifcsname\??fontfile#base\v_font_string_a\endcsname + \v_font_string_a + \else\ifcsname\??fontfile#base\v_font_string_b\endcsname + \v_font_string_b + \else\ifcsname\??fontfile#base\v_font_string_c\endcsname + \v_font_string_c + \fi\fi\fi\fi\fi} + +%D The next macro can be used to make decisions based on the shape: + +\def\doifitalicelse#yes#nop% + {\ifx\fontalternative\s!sl#yes\else + \ifx\fontalternative\s!it#yes\else + \ifx\fontalternative\s!bs#yes\else + \ifx\fontalternative\s!bi#yes\else#nop\fi\fi\fi\fi} + +%D For an example of usage of the following command, +%D see \type {cont-log.tex}. +%D +%D \starttyping +%D \def\symbolicfont#specification{\definedfont[\glyphfontfile{#specification} sa *]} +%D \stoptyping +%D +%D Since we know what scaling it to be applied, we can +%D implement a much faster alternative: + +\installcorenamespace {symbolfont} + +\let\thedefinedfont\relax + +\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname + \else + \font_basics_define_symbolic_font + \fi} + +\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname + \else + \font_basics_define_symbolic_font + \fi} + +\def\setstyledsymbolicfont#fontname% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname + \else + \font_basics_define_symbolic_font + \fi} + +\def\setdirectsymbolicfont#fontname% + {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname + \else + \font_basics_define_symbolic_font + \fi} + +\def\font_basics_define_symbolic_font + {\definefont[currentsymbolfont][\askedsymbolfont]% + \currentsymbolfont + \global\expandafter\let\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall} + +\unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}} +\unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}} +\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}} +\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}} + +% this one is wrong: + +\unexpanded\def\getscaledglyph#scale#name#content% + {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifnumberelse{#content}\char\donothing#content}} + +\let\getglyph \getglyphstyled % old +\let\getrawglyph \getglyphdirect % old +\let\symbolicsizedfont\setscaledstyledsymbolicfont % old +\let\symbolicfont \setstyledsymbolicfont % old + +\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody} +\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody} + +%D The last implementation of \type {\getglyph} permits +%D definitions like: +%D +%D \starttyping +%D \definefontsynonym [EuroSans] [eurose] +%D \definefontsynonym [EuroSansBold] [euroseb] +%D \definefontsynonym [EuroSansItalic] [eurosei] +%D \definefontsynonym [EuroSansSlanted] [eurosei] +%D \definefontsynonym [EuroSansBoldItalic] [eurosebi] +%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi] +%D +%D \definesymbol [euro] [\getglyph{Euro}{\char160}] +%D +%D \def\euro{\symbol[euro]} +%D \stoptyping +%D +%D These definitions guarantee that the next calls work okay: +%D +%D \starttyping +%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro +%D \stoptyping +%D +%D The shape as well as the size is adapted to the current +%D environment. + +%D Personally I think that using \TEX\ macro packages is +%D complicated by the way fonts are handled. Apart from the +%D many encodings, we also deal with different naming schemes. +%D Confronted with this problem, I decided to change the +%D definitions into: +%D +%D \starttyping +%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt] +%D \stoptyping +%D +%D combined with for instance: +%D +%D \starttyping +%D \definefontsynonym [Times-Roman] [tir] +%D \stoptyping + +% this needs some interfacing +% +% \setupfonts[check=...] + +\unexpanded\def\checkcharactersinfont {\ctxcommand{checkcharactersinfont }} +\unexpanded\def\removemissingcharacters{\ctxcommand{removemissingcharacters}} + +%D New commands (not yet interfaced): +%D +%D \startbuffer +%D \definestyle[one][style=bold,color=darkblue] +%D +%D test \one{test} test +%D test \style[one]{test} test +%D test \style[color=red]{test} test +%D test \style[Serif at 20pt]{test} test +%D \stopbuffer +%D +%D \typebuffer \startlines \getbuffer \stoplines + +% definitions .. no tagging here + +\installcorenamespace{style} +\installcorenamespace{stylecheck} + +\installcommandhandler \??style {style} \??style + +\appendtoks + \letvalue{\??stylecheck\currentstyle}\relax + \setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}% + \setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}% + \setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here +\to \everydefinestyle + +\unexpanded\def\font_styles_apply_start#name% + {\begingroup + \font_styles_use_defined{#name}} + +\unexpanded\def\font_styles_apply_stop + {\endgroup} + +\unexpanded\def\font_styles_apply_grouped#name% assumes that the next is { or \bgroup + {\bgroup + \def\g_style{\font_styles_use_defined{#name}}% + \afterassignment\g_style + \let\nexttoken} + +\unexpanded\def\font_styles_use_defined#name% + {\edef\currentstyle{#name}% + \usestylestyleandcolor\c!style\c!color} + +\unexpanded\def\font_styles_use_generic#specification% + {\let\currentstyle\s!unknown % reasonable generic tag + \setupcurrentstyle[\c!style=,\c!color=,#specification]% + \usestylestyleandcolor\c!style\c!color} + +% commands + +\installcorenamespace{styleargument} + +\unexpanded\def\style[#name]% as this is can be a switch we use groupedcommand + {\csname\??styleargument + \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi + \endcsname{#name}} + +\setvalue{\??styleargument1}#name% + {\csname#name\endcsname} + +\setvalue{\??styleargument2}#name% + {\groupedcommand{\font_styles_use_defined{#name}}{}} + +\setvalue{\??styleargument3}#specification% + {\doifassignmentelse{#specification}\font_styles_assignment\font_styles_direct{#specification}} + +\def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}} +\def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}} + +% environments + +\installcorenamespace{styleenvironment} + +\unexpanded\def\startstyle[#name]% + {\begingroup + \csname\??styleenvironment + \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi + \endcsname{#name}} + +\unexpanded\def\stopstyle + {\endgroup + \autoinsertnextspace} % will be configurable, maybe also in \definestartstop + +\setvalue{\??styleenvironment1}#name% + {\csname#name\endcsname} + +\setvalue{\??styleenvironment2}#name% + {\font_styles_use_defined{#name}} + +\setvalue{\??styleenvironment3}#specification% + {\doifassignmentelse{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}} + +\def\font_styles_start_assignment#specification{\usegenericstyle{#specification}} +\def\font_styles_start_direct #specification{\definedfont[#specification]\relax} + +%D Still experimental (might even go away). + +% \definestylecollection[mine] + +% \definestyleinstance[mine][default][sorry] +% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl] +% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl] +% \definestyleinstance[mine][bf][\sl] +% \definestyleinstance[mine][sl][\tt] + +% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}} + +\installcorenamespace{stylecollection} + +\unexpanded\def\definestylecollection + {\dosingleargument\font_styles_define_style_collection} + +\def\font_styles_define_style_collection[#name]% + {\iffirstargument + \setuvalue{#name}{\styleinstance[#name]}% + \def\font_styles_define_style_collection_a#style% + {\def\font_styles_define_style_collection_b#alternative{\letbeundefined{\??stylecollection#name:#style:#alternative}}% + \processcommacommand[\fontalternativelist,\s!default]\font_styles_define_style_collection_b}% + \processcommacommand[\fontstylelist,\s!default]\font_styles_define_style_collection_a + \fi} + +\unexpanded\def\definestyleinstance + {\doquadrupleargument\font_styles_define_style_instance} + +\def\font_styles_define_style_instance[#instance][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever] + {\iffirstargument + \ifcsname#1\endcsname\else\font_styles_define_style_collection[#instance]\fi + \fi + \iffourthargument + \setvalue{\??stylecollection#instance:#2:#3}{#4}% + \else\ifthirdargument + \setvalue{\??stylecollection#instance::#2}{#3}% + \else\ifsecondargument + \letvalueempty{\??stylecollection#instance::#2}% + \fi\fi\fi} + +\unexpanded\def\styleinstance[#instance]% will be made faster + {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup + \executeifdefined{\??stylecollection#instance:\fontstyle:\fontalternative}% + {\executeifdefined{\??stylecollection#instance:\fontstyle:\s!default}% + {\executeifdefined{\??stylecollection#instance::\fontalternative} + {\getvalue {\??stylecollection#instance::\s!default}}}}} + +% \unexpanded\def\styleinstance[#instance]% +% {\csname\??stylecollection#instance% +% \ifcsname\??stylecollection#instance:\fontstyle:\fontalternative\endcsname +% :\fontstyle:\fontalternative +% \else\ifcsname\??stylecollection#instance:\fontstyle:\s!default\endcsname +% :\fontstyle:\s!default +% \else\ifcsname\??stylecollection#instance::\fontalternative\endcsname +% ::\fontalternative +% \else % \ifcsname\??stylecollection#instance::\s!default\endcsname +% ::\s!default +% % \else +% % % nothing, \relax +% \fi\fi\fi % \fi +% \endcsname} + +%D goodies: + +\unexpanded\def\showchardata#character{\ctxcommand{showchardata("#character")}} +\unexpanded\def\showfontdata {\ctxcommand{showfontparameters()}} + +%D some low level helpers +%D +%D \starttyping +%D \def\TestLookup#specification% +%D {\dolookupfontbyspec{#specification} +%D pattern: #specification, found: \dolookupnoffound +%D \blank +%D \dorecurse {\dolookupnoffound} {% +%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad +%D }% +%D \blank} +%D +%D \TestLookup{familyname=helveticaneue} +%D \TestLookup{familyname=helveticaneue,weight=bold} +%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic} +%D \stoptyping + +% we can also move the lookups to the fonts.namespace (of commands) + +% these will be renamed but it needs synchronization with WS + +\def\dolookupfontbyspec #1{\ctxcommand{fontlookupinitialize("#1")}} +\def\dolookupnoffound {\ctxcommand{fontlookupnoffound()}} +\def\dolookupgetkeyofindex#1#2{\ctxcommand{fontlookupgetkeyofindex("#1",#2)}} +\def\dolookupgetkey #1{\ctxcommand{fontlookupgetkey("#1")}} +\def\cleanfontname #1{\ctxcommand{cleanfontname("#1")}} + +% \doifelsecurrentfonthasfeature{smcp}{YES}{NO} +% \doifelsecurrentfonthasfeature{crap}{YES}{NO} +% \doifelsecurrentfonthasfeature{kern}{YES}{NO} + +\def\doifelsecurrentfonthasfeature#feature% + {\ctxcommand{doifelsecurrentfonthasfeature("#feature")}} + +%D variant selectors +%D +%D \starttyping +%D \mathematics {\vsone{\utfchar{"2229}}} +%D \mathematics {\utfchar{"2229}\vsone{}} +%D \stoptyping + +\unexpanded\edef\vsone#character{#character\utfchar{"FE00}} % used +\unexpanded\edef\vstwo#character{#character\utfchar{"FE01}} % not used but handy for testing + +% new: + +\unexpanded\def\setfontofid#1{\ctxcommand{setfontofid(#1)}} + +%D Watch the \type {\normal} hackery: this makes the mkvi parser happy. + +\normaldef\fntsetdefname {\global\let\somefontname\defaultfontfile} +\normaldef\fntsetsomename{\normalgdef\somefontname} % takes argument +\normaldef\fntsetnopsize {\let\somefontsize\empty} +\normaldef\fntsetsomesize{\normaldef\somefontsize} % takes argument + +\protect \endinput + diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv new file mode 100644 index 000000000..a7769dffb --- /dev/null +++ b/tex/context/base/font-pre.mkiv @@ -0,0 +1,466 @@ +%D \module +%D [ file=font-pre, +%D version=2012.01.04, % moved from font-ini +%D title=\CONTEXT\ Font Macros, +%D subtitle=Predefined, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Predefined} + +\unprotect + +%D A basic set of features is defined here. + +\definefontfeature + [always] + [mode=auto, + script=auto, + kern=yes, + mark=yes, + mkmk=yes, + curs=yes] + +\definefontfeature + [default] + [always] + [liga=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes + +\definefontfeature + [smallcaps] + [always] + [smcp=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes + +\definefontfeature + [oldstyle] + [always] + [onum=yes, + liga=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes + +\definefontfeature % == default unless redefined + [ligatures] + [always] + [liga=yes, + tlig=yes, + trep=yes] + +\definefontfeature % can be used for type1 fonts + [complete] + [always] + [compose=yes, + liga=yes, + tlig=yes, + trep=yes] + +\definefontfeature + [none] + [mode=none, + features=no] + +\definefontfeature % might move + [arabic] + [mode=node,language=dflt,script=arab,ccmp=yes, + init=yes,medi=yes,fina=yes,isol=yes, + liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes, + mark=yes,mkmk=yes,kern=yes,curs=yes] + +\definefontfeature % might move + [simplearabic] + [mode=node,language=dflt,script=arab, + init=yes,medi=yes,fina=yes,calt=yes, + rlig=yes,curs=yes,mark=yes,mkmk=yes] + +% symbols: + +\definefontfeature + [dingbats] + [mode=base, + goodies=dingbats, + unicoding=yes] + +% math: + +\definefontfeature + [mathematics] + [mode=base, + liga=yes, + kern=yes, + tlig=yes, + trep=yes, + mathalternates=yes, + mathitalics=yes, + % nomathitalics=yes, % don't pass to tex, might become default + language=dflt, + script=math] + +\definefontfeature + [mathematics-l2r] + [mathematics] + [] + +\definefontfeature + [mathematics-r2l] + [mathematics] + [language=ara, + rtlm=yes, + locl=yes] + +\definefontfeature[virtualmath] [mathematics] % downward compatibility +\definefontfeature[virtualmath-l2r] [mathematics-l2r] % downward compatibility +\definefontfeature[virtualmath-r2l] [mathematics-r2l] % downward compatibility + +\definefontfeature[math-text] [mathematics] [ssty=no] +\definefontfeature[math-script] [mathematics] [ssty=1,mathsize=yes] +\definefontfeature[math-scriptscript] [mathematics] [ssty=2,mathsize=yes] + +\definefontfeature[math-text-l2r] [mathematics-l2r] [ssty=no] +\definefontfeature[math-script-l2r] [mathematics-l2r] [ssty=1,mathsize=yes] +\definefontfeature[math-scriptscript-l2r] [mathematics-l2r] [ssty=2,mathsize=yes] + +\definefontfeature[math-text-r2l] [mathematics-r2l] [ssty=no] +\definefontfeature[math-script-r2l] [mathematics-r2l] [ssty=1,mathsize=yes] +\definefontfeature[math-scriptscript-r2l] [mathematics-r2l] [ssty=2,mathsize=yes] + +\definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] +\definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] +\definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] + +% \definefontfeature[mathtext] [math-text] +% \definefontfeature[mathscript] [math-script] +% \definefontfeature[mathscriptscript] [math-scriptscript] + +%D We define some colors that are used in tracing (for instance \OPENTYPE\ +%D features). We cannot yet inherit because no colors are predefined. + +\definecolor[trace:0][s=.6] +\definecolor[trace:1][r=.6] +\definecolor[trace:2][g=.6] +\definecolor[trace:3][b=.6] +\definecolor[trace:4][r=.6,g=.6] +\definecolor[trace:5][r=.6,b=.6] +\definecolor[trace:6][g=.6,b=.6] +\definecolor[trace:7][r=.8,g=.4] +\definecolor[trace:8][r=.8,b=.4] +\definecolor[trace:9][g=.4,b=.8] + +\definecolor[font:init][r=.75] +\definecolor[font:medi][g=.75] +\definecolor[font:fina][b=.75] +\definecolor[font:isol][r=.75,g=.75] % [y=.75] +\definecolor[font:mark][r=.75,b=.75] % [m=.75] +\definecolor[font:rest][g=.75,b=.75] % [c=.75] + +%D Now we're up to some definitions. + +\definebodyfontenvironment + [\s!default] + [ \s!text=1.0, + \s!script=0.7, + \s!scriptscript=0.5, + \s!a=1.200, + \s!b=1.440, + \s!c=1.728, + \s!d=2.074, + *=\currentfontscale, % wildcard + \s!x=0.8, + \s!xx=0.6, + \v!big=1.2, + \v!small=0.8, + \c!interlinespace=, + \s!em=\v!slanted] + +\definebodyfontenvironment + [20.7pt] + [ \s!text=20.7pt, + \s!script=\!!fourteenpointfour, + \s!scriptscript=\!!twelvepoint, + \s!x=17.3pt, + \s!xx=\!!fourteenpointfour, + \v!big=20.7pt, % !!!! + \v!small=17.3pt] + +\definebodyfontenvironment + [17.3pt] + [ \s!text=17.3pt, + \s!script=\!!twelvepoint, + \s!scriptscript=\!!tenpoint, + \s!x=\!!fourteenpointfour, + \s!xx=\!!twelvepoint, + \v!big=20.7pt, + \v!small=\!!fourteenpointfour] + +\definebodyfontenvironment + [\!!fourteenpointfour] + [ \s!text=\!!fourteenpointfour, + \s!script=\!!elevenpoint, + \s!scriptscript=\!!ninepoint, + \s!x=\!!twelvepoint, + \s!xx=\!!tenpoint, + \v!big=17.3pt, + \v!small=\!!twelvepoint] + +\definebodyfontenvironment + [\!!twelvepoint] + [ \s!text=\!!twelvepoint, + \s!script=\!!ninepoint, + \s!scriptscript=\!!sevenpoint, + \s!x=\!!tenpoint, + \s!xx=\!!eightpoint, + \v!big=\!!fourteenpointfour, + \v!small=\!!tenpoint] + +\definebodyfontenvironment + [\!!elevenpoint] + [ \s!text=\!!elevenpoint, + \s!script=\!!eightpoint, + \s!scriptscript=\!!sixpoint, + \s!x=\!!ninepoint, + \s!xx=\!!sevenpoint, + \v!big=\!!twelvepoint, + \v!small=\!!ninepoint] + +\definebodyfontenvironment + [\!!tenpoint] + [ \s!text=\!!tenpoint, + \s!script=\!!sevenpoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!eightpoint, + \s!xx=\!!sixpoint, + \v!big=\!!twelvepoint, + \v!small=\!!eightpoint] + +\definebodyfontenvironment + [\!!ninepoint] + [ \s!text=\!!ninepoint, + \s!script=\!!sevenpoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!sevenpoint, + \s!xx=\!!fivepoint, + \v!big=\!!elevenpoint, + \v!small=\!!sevenpoint] + +\definebodyfontenvironment + [\!!eightpoint] + [ \s!text=\!!eightpoint, + \s!script=\!!sixpoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!sixpoint, + \s!xx=\!!fivepoint, + \v!big=\!!tenpoint, + \v!small=\!!sixpoint] + +\definebodyfontenvironment + [\!!sevenpoint] + [ \s!text=\!!sevenpoint, + \s!script=\!!sixpoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!sixpoint, + \s!xx=\!!fivepoint, + \v!big=\!!ninepoint, + \v!small=\!!fivepoint] + +\definebodyfontenvironment + [\!!sixpoint] + [ \s!text=\!!sixpoint, + \s!script=\!!fivepoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!fivepoint, + \s!xx=\!!fivepoint, + \v!big=\!!eightpoint, + \v!small=\!!fivepoint] + +\definebodyfontenvironment + [\!!fivepoint] + [ \s!text=\!!fivepoint, + \s!script=\!!fivepoint, + \s!scriptscript=\!!fivepoint, + \s!x=\!!fivepoint, + \s!xx=\!!fivepoint, + \v!big=\!!sevenpoint, + \v!small=\!!fivepoint] + +\definebodyfontenvironment + [\!!fourpoint] + [ \s!text=\!!fourpoint, + \s!script=\!!fourpoint, + \s!scriptscript=\!!fourpoint, + \s!x=\!!fourpoint, + \s!xx=\!!fourpoint, + \v!big=\!!sixpoint, + \v!small=\!!fourpoint] + +\definebodyfontswitch [fourteenpointfour] [\!!fourteenpointfour] +\definebodyfontswitch [twelvepoint] [\!!twelvepoint] +\definebodyfontswitch [elevenpoint] [\!!elevenpoint] +\definebodyfontswitch [tenpoint] [\!!tenpoint] +\definebodyfontswitch [ninepoint] [\!!ninepoint] +\definebodyfontswitch [eightpoint] [\!!eightpoint] +\definebodyfontswitch [sevenpoint] [\!!sevenpoint] +\definebodyfontswitch [sixpoint] [\!!sixpoint] +\definebodyfontswitch [fivepoint] [\!!fivepoint] +\definebodyfontswitch [fourpoint] [\!!fourpoint] + +%D So far. + +\definefontstyle [\s!mm] [\s!mm] +\definefontstyle [\s!rm,\v!roman,\v!serif,\v!regular] [\s!rm] +\definefontstyle [\s!ss,\v!sansserif,\v!sans,\v!support] [\s!ss] +\definefontstyle [\s!tt,\v!teletype,\v!type,\v!mono] [\s!tt] +\definefontstyle [\s!hw,\v!handwritten] [\s!hw] +\definefontstyle [\s!cg,\v!calligraphic] [\s!cg] + +\definefontalternative[\s!tf] +\definefontalternative[\s!bf] +\definefontalternative[\s!it] +\definefontalternative[\s!sl] +\definefontalternative[\s!bs] +\definefontalternative[\s!bi] +\definefontalternative[\s!sc] + +\definefontsize[\s!a] \definefontsize[\s!b] +\definefontsize[\s!c] \definefontsize[\s!d] + +\definealternativestyle [\v!mediaeval] [\os] [] +\definealternativestyle [\v!normal] [\tf] [] +\definealternativestyle [\v!bold] [\bf] [] +\definealternativestyle [\v!type] [\tt] [] +\definealternativestyle [\v!mono] [\tt] [] +\definealternativestyle [\v!slanted] [\sl] [] +\definealternativestyle [\v!italic] [\it] [] +\definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] [] +\definealternativestyle [\v!bolditalic,\v!italicbold] [\bi] [] + +\definealternativestyle [\v!small,\v!smallnormal] [\setsmallbodyfont\tf] [] +\definealternativestyle [\v!smallbold] [\setsmallbodyfont\bf] [] +\definealternativestyle [\v!smalltype] [\setsmallbodyfont\tt] [] +\definealternativestyle [\v!smallslanted] [\setsmallbodyfont\sl] [] +\definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\setsmallbodyfont\bs] [] +\definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\setsmallbodyfont\bi] [] + +\definealternativestyle [\v!bigger] [\setbigbodyfont \tf] [] +\definealternativestyle [\v!smaller] [\setsmallbodyfont\tf] [] + +\definealternativestyle [\v!sans,\v!sansserif] [\ss] [] +\definealternativestyle [\v!sansbold] [\ss\bf] [] + +% % maybe we need interface neutral as well (for use in cld): +% +% \letcscsname\mediaeval \csname\v!mediaeval \endcsname +% \letcscsname\normal \csname\v!normal \endcsname +% \letcscsname\bold \csname\v!bold \endcsname +% \letcscsname\mono \csname\v!mono \endcsname +% \letcscsname\slanted \csname\v!slanted \endcsname +% \letcscsname\italic \csname\v!italic \endcsname +% \letcscsname\boldslanted \csname\v!boldslanted \endcsname +% \letcscsname\slantedbold \csname\v!slantedbold \endcsname +% \letcscsname\bolditalic \csname\v!bolditalic \endcsname +% \letcscsname\italicbold \csname\v!italicbold \endcsname +% +% \letcscsname\small \csname\v!small \endcsname +% \letcscsname\smallnormal \csname\v!smallnormal \endcsname +% \letcscsname\smallbold \csname\v!smallbold \endcsname +% \letcscsname\smalltype \csname\v!smalltype \endcsname +% \letcscsname\smallslanted \csname\v!smallslanted \endcsname +% \letcscsname\smallboldslanted\csname\v!smallboldslanted\endcsname +% \letcscsname\smallslantedbold\csname\v!smallslantedbold\endcsname +% \letcscsname\smallbolditalic \csname\v!smallbolditalic \endcsname +% \letcscsname\smallitalicbold \csname\v!smallitalicbold \endcsname +% +% \letcscsname\bigger \csname\v!bigger \endcsname +% \letcscsname\smaller \csname\v!smaller \endcsname +% +% \letcscsname\sans \csname\v!sans \endcsname +% \letcscsname\sansserif \csname\v!sansserif \endcsname +% \letcscsname\sansbold \csname\v!sansbold \endcsname + +%D We can go on and on and on: +%D +%D \starttyping +%D \setupbodyfontenvironment[default][p=0.8,q=0.6] +%D \definefontsize[p] +%D \definefontsize[q] +%D \stoptyping + +%D Slow but handy: + +\definealternativestyle [\v!smallbodyfont] [\setsmallbodyfont] [] +\definealternativestyle [\v!bigbodyfont] [\setbigbodyfont] [] + +%D We treat {\sc Small Caps} and \cap {Pseudo Caps} a bit +%D different. We also provide an \WORD {uppercase} style. + +\definealternativestyle [\v!cap,\v!capital] [\smallcapped] [\smallcapped] +\definealternativestyle [\v!smallcaps] [\sc] [\sc] +\definealternativestyle [\v!WORD] [\WORD] [\WORD] + +%D \macros +%D {tinyfont} +%D +%D By default we load the Computer Modern Roman fonts (but +%D not yet at this moment) and activate the 12pt roman +%D bodyfont. Sans serif and teletype are also available and +%D can be called for by \type{\ss} and \type{\tt}. Loading +%D takes place elsewhere. +%D +%D For tracing purposes we define: + +\definefont[tinyfont][Mono at 1ex] + +%D \macros +%D {infofont} +%D +%D The second situation occurs when we enable the info mode, +%D and put all kind of status information in the margin. We +%D don't want huge switches to the main bodyfont and style, so +%D here too we use a direct method. + +\let\infofont\relax % satisfy dep checker + +\definefont [infofont] [Mono at 6pt] % todo \the\everybodyfont + +\protect \endinput + +% LM math vs CM math (analysis by Taco): +% +% Computer Modern Roman : Donald Knuth +% Latin Modern : LM Font Revision Team +% +% lmex10.tfm % identical +% lmmi5.tfm % identical +% lmmi6.tfm % identical +% lmmi7.tfm % identical +% lmmi8.tfm % identical +% lmmi9.tfm % identical +% lmmi10.tfm % identical +% lmmi12.tfm % identical +% lmmib10.tfm % identical +% lmsy5.tfm % extra chars: 254,255 (octal) +% lmsy6.tfm % extra chars: 254,255 (octal) +% lmsy7.tfm % extra chars: 254,255 (octal) +% lmsy8.tfm % extra chars: 254,255 (octal) +% lmsy9.tfm % extra chars: 254,255 (octal) +% lmsy10.tfm % extra chars: 254,255 (octal) +% lmbsy10.tfm % extra chars: 254,255 (octal) +% +% From the 'AMS' set: +% +% lmmib5.tfm % identical +% lmmib7.tfm % identical +% lmbsy5.tfm % extra chars: 254,255 (octal) +% lmbsy7.tfm % extra chars: 254,255 (octal) +% +% The two extra characters are: +% +% /lessorequalslant +% /greaterorequalslant diff --git a/tex/context/base/font-run.mkiv b/tex/context/base/font-run.mkiv index 537272085..cc72b1b31 100644 --- a/tex/context/base/font-run.mkiv +++ b/tex/context/base/font-run.mkiv @@ -77,14 +77,15 @@ \vbox {\dosetshowfonttitle{#1}% \def\next##1% - {&&\getvalue{\bodyfontvariable{##1\s!text}}% - &&\getvalue{\bodyfontvariable{##1\s!script}}% - &&\getvalue{\bodyfontvariable{##1\s!scriptscript}}% - &&\getvalue{\bodyfontvariable{##1\c!x}}% - &&\getvalue{\bodyfontvariable{##1\c!xx}}% - &&\getvalue{\bodyfontvariable{##1\interfaced\v!small}}% - &&\getvalue{\bodyfontvariable{##1\interfaced\v!big}}% - &&\edef\next{\getvalue{\bodyfontvariable{##1\c!interlinespace}}}\ifx\next\empty not set\else\next\fi&\cr + {&&\bodyfontsizevariable{##1}\s!text + &&\bodyfontsizevariable{##1}\s!script + &&\bodyfontsizevariable{##1}\s!scriptscript + &&\bodyfontsizevariable{##1}\s!x + &&\bodyfontsizevariable{##1}\s!xx + &&\bodyfontsizevariable{##1}\v!small + &&\bodyfontsizevariable{##1}\v!big + &&\bodyfontsizevariable{##1}\c!interlinespace + &\cr \noalign{\hrule}} \halign to \localhsize {##&\vrule##\strut @@ -97,7 +98,7 @@ &\multispan{17}{\vrule\hfil\tttf\strut\title\hfil}\vrule\cr \noalign{\hrule} &&\tttf\tx\s!text&&\tttf\tx\s!script&&\tttf\tx\s!scriptscript - &&\tttf\tx\c!x&&\tttf\tx\c!xx&&\tttf\tx\v!small&&\tttf\tx\v!big + &&\tttf\tx\s!x&&\tttf\tx\s!xx&&\tttf\tx\v!small&&\tttf\tx\v!big &&\tttf\tx\c!interlinespace&\cr \noalign{\hrule} \@EA\globalprocesscommalist\@EA[\bodyfontenvironmentlist]\next}} @@ -211,9 +212,9 @@ \gdef\dodoshowfontstyle[#1][#2]% {\doifelse{#2}\v!all - {\dodoshowfontstyle[#1][\c!rm,\c!ss,\c!tt,\c!mm]} + {\dodoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]} {\doifelsenothing{#2} - {\redoshowfontstyle[#1][\c!rm,\c!ss,\c!tt,\c!mm]} + {\redoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]} {\redoshowfontstyle[#1][#2]}}} \gdef\dododoshowfontstyle[#1][#2][#3]% diff --git a/tex/context/base/font-unk.mkiv b/tex/context/base/font-unk.mkiv index 601f0449f..5bb89b6be 100644 --- a/tex/context/base/font-unk.mkiv +++ b/tex/context/base/font-unk.mkiv @@ -56,13 +56,13 @@ %D style (so, Bold may expand to SansBold or SerifBold, depending %D on the default style in the typeface). -\definefontsynonym[\s!Normal] [\noexpand\fontstringD] -\definefontsynonym[\s!Bold] [\noexpand\fontstringD\noexpand\s!Bold] -\definefontsynonym[\s!Italic] [\noexpand\fontstringD\noexpand\s!Italic] -\definefontsynonym[\s!Slanted] [\noexpand\fontstringD\noexpand\s!Slanted] -\definefontsynonym[\s!BoldItalic] [\noexpand\fontstringD\noexpand\s!BoldItalic] -\definefontsynonym[\s!BoldSlanted][\noexpand\fontstringD\noexpand\s!BoldSlanted] -\definefontsynonym[\s!Caps] [\noexpand\fontstringD\noexpand\s!Caps] +\definefontsynonym[\s!Normal] [\noexpand\v_font_string_d] +\definefontsynonym[\s!Bold] [\noexpand\v_font_string_d\noexpand\s!Bold] +\definefontsynonym[\s!Italic] [\noexpand\v_font_string_d\noexpand\s!Italic] +\definefontsynonym[\s!Slanted] [\noexpand\v_font_string_d\noexpand\s!Slanted] +\definefontsynonym[\s!BoldItalic] [\noexpand\v_font_string_d\noexpand\s!BoldItalic] +\definefontsynonym[\s!BoldSlanted][\noexpand\v_font_string_d\noexpand\s!BoldSlanted] +\definefontsynonym[\s!Caps] [\noexpand\v_font_string_d\noexpand\s!Caps] %D Also handy: diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index acf809ef2..c33949361 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -33,13 +33,17 @@ \setfalse\externalfigurelevel \settrue \externalfigureflush +\installcorenamespace{externalfigures} + \def\doplaceexternalfigure[#1][#2][#3][#4][#5]% {\doifsomething{#2}% catches \defineexternalfigure dummies - {\doifundefinedelse{\??ef\??ef#2} - {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} - {\doifelse{#1}{#2} - {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} - {\getvalue{\??ef\??ef#2}[#5]}}}} + {\ifcsname\??externalfigures#2\endcsname + \doifelse{#1}{#2} + {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} + {\getvalue{\??externalfigures#2}[#5]}% + \else + \dodoplaceexternalfigure[#1][#2][#3][#4][#5]% + \fi}} \ifdefined\dotagfigure \else \let\dotagfigure\relax \fi @@ -96,7 +100,7 @@ {\dodoubleargument\dodefineexternalfigure} \def\dodefineexternalfigure[#1][#2]% - {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][][][#2]}} + {\setvalue{\??externalfigures#1}{\doplaceexternalfigure[#1][][][#2]}} % \useexternalfigure[alpha][koe] % \useexternalfigure[beta] [koe] [breedte=1cm] @@ -147,7 +151,7 @@ {\dodouseexternalfigure{#1}{#2}{#3}{#4}}}}} \def\dodouseexternalfigure#1#2#3#4% - {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][#2][#3][#4]}% + {\setvalue{\??externalfigures#1}{\doplaceexternalfigure[#1][#2][#3][#4]}% \doanalyzeexternalfigurecollection[#2][#4]} \newconditional\inexternalfigurecollection @@ -215,49 +219,67 @@ \def\dosetefparameters#1#2#3% parent_id use_settings current_settings {\doifelsenothing{#1} % inherit from parent {\getparameters[\??ef][#2,#3]} - {\doifdefinedelse{\??ef\??ef#1} - {\pushmacro\doplaceexternalfigure - \def\doplaceexternalfigure[##1][##2][##3][##4]{\getparameters[\??ef][##4,#2,#3]}% - \getvalue{\??ef\??ef#1}% - \popmacro\doplaceexternalfigure} - {\getparameters[\??ef][#2,#3]}}} + {\ifcsname\??externalfigures#1\endcsname + \pushmacro\doplaceexternalfigure + \def\doplaceexternalfigure[##1][##2][##3][##4]{\getparameters[\??ef][##4,#2,#3]}% + \getvalue{\??externalfigures#1}% + \popmacro\doplaceexternalfigure + \else + \getparameters[\??ef][#2,#3]% + \fi}} \unexpanded\def\externalfigure {\dotripleempty\doexternalfigure} +% \def\doexternalfigure[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings] +% {\bgroup +% \doifelsenothing{#1} +% {\framed[\c!width=\defaultfigurewidth,\c!height=\defaultfigureheight]{external\\figure\\no name}} +% {\ifcsname\??externalfigures#1\endcsname +% \doifassignmentelse{#2} +% {\getvalue{\??externalfigures#1}[#2]}% +% {\getvalue{\??externalfigures#1}[#3]}% +% \else +% \useexternalfigure[\s!dummy][#1][#2][#3]% +% \getvalue{\??externalfigures\s!dummy}[]% [] is dummy arg 5 +% \fi}% +% \globallet\currentresourcecomment\empty +% \egroup} + \def\doexternalfigure[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings] - {\bgroup - \doifelsenothing{#1} - {\framed[\c!width=\defaultfigurewidth,\c!height=\defaultfigureheight]{external\\figure\\no name}} - {\doifundefinedelse{\??ef\??ef#1} - {\useexternalfigure[\s!dummy][#1][#2][#3]% - \getvalue{\??ef\??ef\s!dummy}[]} % [] is dummy arg 5 - {\doifassignmentelse{#2} - {\getvalue{\??ef\??ef#1}[#2]}% - {\getvalue{\??ef\??ef#1}[#3]}}}% + {\bgroup % also catched #1 == empty ... scales nicer now + \ifcsname\??externalfigures#1\endcsname + \doifassignmentelse{#2} + {\getvalue{\??externalfigures#1}[#2]}% + {\getvalue{\??externalfigures#1}[#3]}% + \else + \useexternalfigure[\s!dummy][#1][#2][#3]% + \getvalue{\??externalfigures\s!dummy}[]% [] is dummy arg 5 + \fi \globallet\currentresourcecomment\empty \egroup} -\long\def\resourcecomment#1% - {\long\gdef\currentresourcecomment{#1}} +\def\resourcecomment#1% + {\gdef\currentresourcecomment{#1}} -\long\unexpanded\def\startresourcecomment#1\stopresourcecomment - {\long\gdef\currentresourcecomment{#1}} +\unexpanded\def\startresourcecomment#1\stopresourcecomment + {\gdef\currentresourcecomment{#1}} \let\currentresourcecomment\empty -\def\showexternalfigures % maybe run time command is better, but no core-run, unless figs-run ... +\unexpanded\def\showexternalfigures % maybe run time command is better, but no core-run, unless figs-run ... {%\writestatus\m!system{for \string\showexternalfigures\space see \truefilename{x-res-20}.tex} - \usemodule[res-20]\showexternalfigures} % so for the moment we do it this way + \usemodule[res-20]% + \showexternalfigures} % so for the moment we do it this way -\def\overlayfigure#1% +\unexpanded\def\overlayfigure#1% {\externalfigure[#1][\c!width=\overlaywidth,\c!height=\overlayheight]} %D Whatever \newbox\colorbarbox -\def\makecolorbar[#1]% +\unexpanded\def\makecolorbar[#1]% {\def\docommand##1% {\color[##1] {\blackrule @@ -307,7 +329,7 @@ {\teststartfigure[#1][#2][#3]#4\teststopfigure \let\@@exframes\v!on} {\let\@@exframes\v!off}% - \setvalue{\??ef\??ef#1}% + \setvalue{\??externalfigures#1}% {\dosingleempty{\placestartfigure[#1][#2][#3]#4\placestopfigure}}% }% no longer \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}} @@ -376,7 +398,7 @@ {\teststartfigure[#1][#2][#3]#4\teststopfigure \let\@@exframe\v!on} {\let\@@exframe\v!off}% - \setvalue{\??ef\??ef#1}% + \setvalue{\??externalfigures#1}% {\def\next{\placestartfigure[#1][#2][#3]#4\placestopfigure}% \dosingleempty\next}% }% no longer: \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}} diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index c5a41152c..58d1e2b62 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -257,7 +257,7 @@ % \externalfigure[demo.svg] % \externalfigure[demo.svg][conversion=png] -\def\calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \cmd label filename parent_id preset current +\unexpanded\def\calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \cmd label filename parent_id preset current {\dontcomplain \restorecatcodes \forgetall diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv index 0b603f1ba..b3392a9b7 100644 --- a/tex/context/base/grph-trf.mkiv +++ b/tex/context/base/grph-trf.mkiv @@ -152,7 +152,6 @@ \global\let\finalscaleboxyfactor\!!hundred % \forgetall - \dontshowcomposition \dontcomplain % \setfalse\c_grph_scale_done @@ -687,8 +686,7 @@ \dowithnextboxcs\grph_mirror_finish\hbox} \def\grph_mirror_finish - {\dontshowcomposition - \scratchdimen\wd\nextbox + {\scratchdimen\wd\nextbox % better use an hbox (if no \forgetall, leftskip etc may creep in) %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\wd\nextbox\box\nextbox\dostopmirroring}% \setbox\nextbox\hbox{\dostartmirroring\hskip-\wd\nextbox\box\nextbox\dostopmirroring}% @@ -836,9 +834,9 @@ {\bgroup \hbox\bgroup % compatibility hack \edef\p_rotation_rotation{#1}% - \dowithnextboxcs\grph_rotate_finish} + \dowithnextboxcs\grph_rotate_finish_box} -\def\grph_rotate_finish +\def\grph_rotate_finish_box {\getvalue{\??rotatelocation\v!broad}% \grph_rotate_finish_indeed \egroup @@ -878,7 +876,6 @@ \ifcsname\??rotatepreset\p_rotation_rotation\endcsname\p_rotation_rotation\else\v!default\fi \endcsname \setbox\nextbox\vbox{\box\nextbox}% not really needed - \dontshowcomposition \dontcomplain \ifconditional\c_grph_rotate_center \d_grph_rotate_saved_width \wd\nextbox diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua index 0769296c8..1777f26de 100644 --- a/tex/context/base/lpdf-ano.lua +++ b/tex/context/base/lpdf-ano.lua @@ -11,6 +11,7 @@ if not modules then modules = { } end modules ['lpdf-ano'] = { local next, tostring = next, tostring local rep, format = string.rep, string.format local texcount = tex.count +local lpegmatch = lpeg.match local backends, lpdf = backends, lpdf @@ -501,7 +502,7 @@ function specials.order(var,actions) -- references.specials ! local operation = var.operation if operation then local kind, name, n = lpegmatch(splitter,operation) - local order = lists.ordered[kind] + local order = structures.lists.ordered[kind] order = order and order[name] local v = order[tonumber(n)] local r = v and v.references.realpage diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua index d0543250c..f7ab63045 100644 --- a/tex/context/base/luat-mac.lua +++ b/tex/context/base/luat-mac.lua @@ -6,6 +6,14 @@ if not modules then modules = { } end modules ['luat-mac'] = { license = "see context related readme files" } +-- Sometimes we run into situations like: +-- +-- \def\foo#1{\expandafter\def\csname#1\endcsname} +-- +-- As this confuses the parser, the following should be used instead: +-- +-- \def\foo#1{\expandafter\normaldef\csname#1\endcsname} + local P, V, S, R, C, Cs, Cmt, Carg = lpeg.P, lpeg.V, lpeg.S, lpeg.R, lpeg.C, lpeg.Cs, lpeg.Cmt, lpeg.Carg local lpegmatch, patterns = lpeg.match, lpeg.patterns @@ -28,7 +36,7 @@ local function set(s) local ns = #stack local h = hashes[ns] if not h then - h = rep("#",ns) + h = rep("#",2^(ns-1)) hashes[ns] = h end m = h .. n @@ -84,8 +92,8 @@ local csname = (R("AZ","az") + S("@?!_"))^1 local longname = (longleft/"") * (nolong^1) * (longright/"") local variable = P("#") * Cs(name + longname) local escapedname = escape * csname -local definer = escape * (P("def") + P("egx") * P("def")) -- tex -local setter = escape * P("set") * (P("u")^-1 * P("egx")^-1) * P("value") -- context specific +local definer = escape * (P("def") + S("egx") * P("def")) -- tex +local setter = escape * P("set") * (P("u")^-1 * S("egx")^-1) * P("value") -- context specific --- + escape * P("install") * (1-P("handler"))^1 * P("handler") -- context specific local startcode = P("\\starttexdefinition") -- context specific local stopcode = P("\\stoptexdefinition") -- context specific diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index eb708782b..22f989805 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -405,7 +405,7 @@ function lxml.convert(id,data,entities,compress) end function lxml.load(id,filename,compress,entities) - filename = commands.preparedfile(filename) + filename = commands.preparedfile(filename) -- not commands! if trace_loading then report_lxml("loading file '%s' as '%s'",filename,id) end @@ -1275,8 +1275,9 @@ function finalizers.tag(collected,n) if collected then local nc = #collected if nc > 0 then + n = tonumber(n) or 0 local c - if n == 0 or not n then + if n == 0 then c = collected[1] elseif n > 1 then c = collected[n] diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 561b50a95..581881a9c 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -119,16 +119,16 @@ \let\mathalternate\setmathalternate % obsolete -\unexpanded\def\mr {\setmathattribute\s!regular\c!tf\setmathstylealterternate\s!tf} +\unexpanded\def\mr {\setmathattribute\s!regular\s!tf\setmathstylealterternate\s!tf} -\unexpanded\def\mathdefault {\setmathattribute\s!regular\c!it\setmathstylealterternate\s!it} +\unexpanded\def\mathdefault {\setmathattribute\s!regular\s!it\setmathstylealterternate\s!it} \unexpanded\def\mathscript {\setmathalphabet \s!script \setmathstylealterternate\s!script} \unexpanded\def\mathfraktur {\setmathalphabet \s!fraktur \setmathstylealterternate\s!fraktur} \unexpanded\def\mathblackboard{\setmathalphabet \s!blackboard \setmathstylealterternate\s!blackboard} -\unexpanded\def\mathrm {\setmathattribute\s!rm\c!tf \setmathstylealterternate\s!tf} -\unexpanded\def\mathss {\setmathattribute\s!ss\c!tf \setmathstylealterternate\s!tf} -\unexpanded\def\mathtt {\setmathattribute\s!tt\c!tf \setmathstylealterternate\s!tf} +\unexpanded\def\mathrm {\setmathattribute\s!rm\s!tf \setmathstylealterternate\s!tf} +\unexpanded\def\mathss {\setmathattribute\s!ss\s!tf \setmathstylealterternate\s!tf} +\unexpanded\def\mathtt {\setmathattribute\s!tt\s!tf \setmathstylealterternate\s!tf} \unexpanded\def\mathtf {\setmathstyle\s!tf \setmathstylealterternate\s!tf} \unexpanded\def\mathsl {\setmathstyle\s!it \setmathstylealterternate\s!it} % no sl @@ -136,7 +136,7 @@ \unexpanded\def\mathbf {\setmathstyle\s!bf \setmathstylealterternate\s!bf} \unexpanded\def\mathbs {\setmathstyle\s!bi \setmathstylealterternate\s!bi} % no sl -\unexpanded\def\mathbi {\setmathstyle\s!bi \setmathstylealterternate\c!bi} +\unexpanded\def\mathbi {\setmathstyle\s!bi \setmathstylealterternate\s!bi} \let\tfmath\mathtf % maybe a grouped command \let\slmath\mathsl diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 16c56789e..69b717cfe 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -837,6 +837,16 @@ %D In order to communicate conveniently with the \TEX\ %D engine, we introduce some typesetting variables. +% \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch + +% A temporary hack so that I can test an alternative in cont-loc. See ** in +% colo-ini.lua (mpcolor). + +\def\m_meta_colo_initializations{% + OverlayLineColor:=\MPcolor{\overlaylinecolor}; + OverlayColor:=\MPcolor{\overlaycolor}; +} + \startMPextensions color OverlayColor,OverlayLineColor; \stopMPextensions @@ -846,9 +856,13 @@ OverlayWidth:=\overlaywidth; OverlayHeight:=\overlayheight; OverlayDepth:=\overlayheight; - OverlayColor:=\MPcolor{\overlaycolor}; OverlayLineWidth:=\overlaylinewidth; - OverlayLineColor:=\MPcolor{\overlaylinecolor}; + % + \m_meta_colo_initializations +% OverlayLineColor:=\MPcolor{\overlaylinecolor}; +% OverlayColor:=\MPcolor{\overlaycolor}; +% vardef OverlayLineColor=\MPcolor{\overlaylinecolor} enddef; +% vardef OverlayColor=\MPcolor{\overlaycolor} enddef; % BaseLineSkip:=\the\baselineskip; LineHeight:=\the\baselineskip; diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index 8118b476e..366d69d97 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -183,7 +183,7 @@ % \hbox{#1}% % \fi} -\def\globalregisterMPtextarea{\normalexpanded{\global\MPtextareadata{\the\MPtextareadata +\unexpanded\def\globalregisterMPtextarea{\normalexpanded{\global\MPtextareadata{\the\MPtextareadata RegisterTextArea(% \MPx\currentMPtextarea,% \MPy\currentMPtextarea,% @@ -192,7 +192,7 @@ \MPd\currentMPtextarea% );}}} -\def\localregisterMPtextarea{\normalexpanded{\global\MPlocaltextareadata{% +\unexpanded\def\localregisterMPtextarea{\normalexpanded{\global\MPlocaltextareadata{% RegisterLocalTextArea(% \MPx\currentMPtextarea,% \MPy\currentMPtextarea,% @@ -201,7 +201,7 @@ \MPd\currentMPtextarea% );}}} -\def\registerMPtextareaindeed#1#2% +\unexpanded\def\registerMPtextareaindeed#1#2% {\ifpositioning \begingroup \global\advance\currentMPtextareadata\plusone @@ -216,7 +216,7 @@ \unexpanded\def\registerMPtextarea {\registerMPtextareaindeed\globalregisterMPtextarea} \unexpanded\def\registerMPlocaltextarea{\registerMPtextareaindeed\localregisterMPtextarea } -\expanded\def\resetMPlocaltextarea +\unexpanded\def\resetMPlocaltextarea {\global\MPlocaltextareadata\emptytoks} \startMPextensions diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv index b273c58a5..4defd260c 100644 --- a/tex/context/base/meta-tex.mkiv +++ b/tex/context/base/meta-tex.mkiv @@ -68,17 +68,16 @@ \unexpanded\def\definetextext[#1]% {\def\currenttextext{#1}% - \doifnextoptionalelse\meta_define_textext_one\meta_define_textext_zero} + \doifnextoptionalelse\meta_textext_define_one\meta_textext_define_zero} -\def\meta_define_textext_one {\setvalue{\??graphictexarguments1:\currenttextext}} -\def\meta_define_textext_zero{\setvalue{\??graphictexarguments0:\currenttextext}} +\def\meta_textext_define_one {\setvalue{\??graphictexarguments1:\currenttextext}} +\def\meta_textext_define_zero{\setvalue{\??graphictexarguments0:\currenttextext}} \def\sometxt#1#{\meta_some_txt{#1}} \def\meta_some_txt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered {textext.drt("\mpsometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")} - \unexpanded\def\mpsometxt % no _ catcode {\doifnextoptionalelse\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop} diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 66d7add8b..e50a7470c 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -138,8 +138,8 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname #2parameter\endcsname - \expandafter\noexpand\csname do#2parameter\endcsname - \expandafter\noexpand\csname do#2parentparameter\endcsname + \expandafter\noexpand\csname do#2parameter\endcsname % or : #2_parameter_hash + \expandafter\noexpand\csname do#2parentparameter\endcsname % or : #2_parent_parameter_hash \expandafter\noexpand\csname named#2parameter\endcsname \expandafter\noexpand\csname detokenized#2parameter\endcsname \expandafter\noexpand\csname strict#2parameter\endcsname % checked @@ -173,8 +173,8 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname #2parameterhash\endcsname - \expandafter\noexpand\csname do#2parameterhash\endcsname - \expandafter\noexpand\csname do#2parentparameterhash\endcsname + \expandafter\noexpand\csname do#2parameterhash\endcsname % or : #2_parameter_hash + \expandafter\noexpand\csname do#2parentparameterhash\endcsname % or : #2_parent_parameter_hash \expandafter\noexpand\csname current#2hash\endcsname \expandafter\noexpand\csname named#2hash\endcsname \expandafter\noexpand\csname check#2parent\endcsname @@ -276,7 +276,7 @@ \expandafter\noexpand\csname define#2\endcsname {\noexpand#3}% root \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname d@define#2\endcsname % sort of public + \expandafter\noexpand\csname define_#2\endcsname % semi-public \expandafter\noexpand\csname everypreset#2\endcsname \expandafter\noexpand\csname everydefine#2\endcsname \expandafter\noexpand\csname current#2parent\endcsname}} @@ -290,12 +290,12 @@ \def#4[##1][##2]% maybe helper {\let\savedsetupwhatever#3% \ifsecondargument - \def\docommand####1% we will have a simple one as well + \def\mult_interfaces_with_comma_list_element####1% we will have a simple one as well {\edef#3{####1}% % \getparameters[#1#3:][##2]% \mult_interfaces_get_parameters{#1#3:}[##2]% \the#5}% - \processcommalist[##1]\docommand + \processcommalist[##1]\mult_interfaces_with_comma_list_element \else \let#3\empty % \getparameters[#1:][##1]% @@ -310,7 +310,7 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname d@setup#2\endcsname % sort of public + \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname setupcurrent#2\endcsname}} @@ -349,7 +349,7 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname d@setup#2\endcsname + \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname setupcurrent#2\endcsname}} @@ -362,20 +362,20 @@ \def#4[##1][##2][##3]% {\let\savedsetupwhatever#3% \ifthirdargument - \def\docommand####1% + \def\mult_interfaces_with_comma_list_element####1% {\edef#3{####1}% % \getparameters[#1#3:][\s!parent=#1##2,##3]% \mult_interfaces_get_parameters{#1#3:}[\s!parent=#1##2,##3]% always sets parent \the#5}% - \processcommalist[##1]\docommand + \processcommalist[##1]\mult_interfaces_with_comma_list_element \else\ifsecondargument - \def\docommand####1% + \def\mult_interfaces_with_comma_list_element####1% {\edef#3{####1}% #7% checks parent and sets if needed % \getparameters[#1#3:][##2]% \mult_interfaces_get_parameters{#1#3:}[##2]% \the#5}% - \processcommalist[##1]\docommand + \processcommalist[##1]\mult_interfaces_with_comma_list_element \else \let#3\empty % \getparameters[#1:][##1]% @@ -390,7 +390,7 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname d@setup#2\endcsname % sort of public + \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname setupcurrent#2\endcsname \expandafter\noexpand\csname check#2parent\endcsname}} @@ -464,7 +464,7 @@ {\mult_interfaces_install_direct_setup_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname - \expandafter\noexpand\csname d@setup#2\endcsname + \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname}} \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% diff --git a/tex/context/base/mult-ini.mkiv b/tex/context/base/mult-ini.mkiv index 09f047063..21727f564 100644 --- a/tex/context/base/mult-ini.mkiv +++ b/tex/context/base/mult-ini.mkiv @@ -42,7 +42,6 @@ %D \NC \type{\c!prefix!} \NC c! \NC constant (direct) \NC\FR %D \NC \type{\e!prefix!} \NC e! \NC element \NC\MR %D \NC \type{\f!prefix!} \NC f! \NC file \NC\MR -%D \NC \type{\k!prefix!} \NC k! \NC constant (indirect) \NC\MR %D \NC \type{\m!prefix!} \NC m! \NC age \NC\MR %D \NC \type{\s!prefix!} \NC s! \NC system \NC\MR %D \NC \type{\v!prefix!} \NC v! \NC variable \NC\MR @@ -57,7 +56,6 @@ \def\c!prefix!{c!} \def\e!prefix!{e!} \def\f!prefix!{f!} % for the moment we keep this one -\def\k!prefix!{k!} \def\m!prefix!{m!} \def\s!prefix!{s!} \def\v!prefix!{v!} @@ -760,28 +758,6 @@ \def\do@siele#1#2{\expandafter\gdef\csname\e!prefix!#1\endcsname{#2}} \def\do@sicom#1#2{\expandafter\gdef\csname#2\expandafter\endcsname\expandafter{\csname#1\endcsname}} -%D \macros -%D {interfaced} -%D -%D The setup commands translate the constants automatically. -%D When we want to translate 'by hand' we can use the simple -%D but effective command: -%D -%D \starttyping -%D \interfaced {something} -%D \stoptyping -%D -%D Giving \type{\interfaced{breedte}} results in \type{width} -%D or, when not defined, in \type{breedte} itself. This -%D macro is used in the font switching mechanism. - -\def\interfaced#1% - {\ifcsname\k!prefix!#1\endcsname - \csname\k!prefix!#1\endcsname - \else - #1% - \fi} - %D So much for the basic multi||lingual interface commands. The %D macro's can be enhanced with more testing facilities, but %D for the moment they suffice. diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index ec865e793..f059faad0 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -37,6 +37,8 @@ return { "bgroup", "egroup", "endline", -- + "conditionaltrue", "conditionalfalse", + -- "attributeunsetvalue", -- "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", @@ -74,7 +76,12 @@ return { "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", - -- + -- + "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", + "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", + "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", + "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", + -- -- maybe a different class -- "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", @@ -100,6 +107,8 @@ return { "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", -- not used -- + "then", + -- "htdp", "unvoidbox", "vfilll", diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 2d7ad1eed..9f322a960 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -170,6 +170,38 @@ \definesystemconstant {rm} \definesystemconstant {ss} \definesystemconstant {tt} +\definesystemconstant {hw} +\definesystemconstant {cg} +\definesystemconstant {mm} + +\definesystemconstant {x} +\definesystemconstant {xx} +\definesystemconstant {em} + +\definesystemconstant {a} +\definesystemconstant {b} +\definesystemconstant {c} +\definesystemconstant {d} +\definesystemconstant {e} +\definesystemconstant {f} + +\definesystemconstant {mr} +\definesystemconstant {mb} +\definesystemconstant {mrlr} +\definesystemconstant {mrrl} +\definesystemconstant {mblr} +\definesystemconstant {mbrl} + +\definesystemconstant {tf} +\definesystemconstant {bf} +\definesystemconstant {bs} +\definesystemconstant {bi} +\definesystemconstant {sl} +\definesystemconstant {it} +\definesystemconstant {sc} + +\definesystemconstant {small} +\definesystemconstant {big} %D Net come some \CONTEXT\ constants, used in the definition %D of private commands: @@ -304,6 +336,7 @@ \definesystemconstant {gray} \definesystemconstant {spot} \definesystemconstant {all} +\definesystemconstant {dtp} \definesystemconstant {none} \definesystemconstant {map} @@ -431,9 +464,7 @@ \definesystemvariable {fc} % FramedContent \definesystemvariable {fi} % FIle Once \definesystemvariable {fo} % xml FO (xtag) -\definesystemvariable {fq} % Features \definesystemvariable {fr} % Division -\definesystemvariable {ft} % FonTs \definesystemvariable {fu} % FontSolution \definesystemvariable {fw} % simpleFonts by Wolfgang \definesystemvariable {fx} % FoXet @@ -516,12 +547,9 @@ \definesystemvariable {ta} % TAb \definesystemvariable {tb} % TekstBlokken \definesystemvariable {te} % TEmplate -\definesystemvariable {tf} % TypeFace \definesystemvariable {ti} % TabelInstellingen \definesystemvariable {tl} % TekstLijnen -\definesystemvariable {tm} % TypesynonyM \definesystemvariable {to} % TOlerance -\definesystemvariable {ts} % TypeScript \definesystemvariable {tt} % TabulaTe \definesystemvariable {tx} % TeXtflow \definesystemvariable {ur} % URl @@ -644,52 +672,21 @@ %definefileconstant {beforeprefix} {b-} %definefileconstant {afterprefix} {a-} -%D \CONTEXT\ follows different strategies for finding files. -%D The macros that are responsible for this 'clever' searching -%D make use of two (very important) path specifiers. - -%definefileconstant {pathseparator} {/} -%definefileconstant {currentpath} {.} -%definefileconstant {parentpath} {..} - -%D The way fonts are defined and called upon is language -%D independant. We follow the scheme laid down by Knuth in -%D Plain \TEX. We'll explain their meaning later. - -\defineinterfaceconstant {tf} {tf} -\defineinterfaceconstant {bf} {bf} -\defineinterfaceconstant {bs} {bs} -\defineinterfaceconstant {bi} {bi} -\defineinterfaceconstant {sl} {sl} -\defineinterfaceconstant {it} {it} -\defineinterfaceconstant {sc} {sc} - -\defineinterfaceconstant {rm} {rm} -\defineinterfaceconstant {ss} {ss} -\defineinterfaceconstant {tt} {tt} -\defineinterfaceconstant {hw} {hw} -\defineinterfaceconstant {cg} {cg} -\defineinterfaceconstant {mm} {mm} - -%defineinterfaceconstant {os} {os} -\defineinterfaceconstant {i} {i} % still used ? -%defineinterfaceconstant {nn} {nn} - -\defineinterfaceconstant {x} {x} -\defineinterfaceconstant {xx} {xx} - -\defineinterfaceconstant {em} {em} - -\defineinterfaceconstant {mr} {mr} -\defineinterfaceconstant {mb} {mb} +% for old times sake: -\defineinterfaceconstant {mrlr} {mrlr} -\defineinterfaceconstant {mrrl} {mrrl} +% \defineinterfaceconstant {x} {x} +% \defineinterfaceconstant {xx} {xx} +% \defineinterfaceconstant {em} {em} % will go -\defineinterfaceconstant {mblr} {mblr} -\defineinterfaceconstant {mbrl} {mbrl} +% \defineinterfaceconstant {tf} {tf} +% \defineinterfaceconstant {bf} {bf} +% \defineinterfaceconstant {bs} {bs} +% \defineinterfaceconstant {bi} {bi} +% \defineinterfaceconstant {sl} {sl} +% \defineinterfaceconstant {it} {it} +% \defineinterfaceconstant {sc} {sc} % keep, used elsewhere (or define in mult-def) -%D For figure inclusion we need: +%D For figure inclusion we need(ed): %defineinterfaceconstant {tif} {tif} %defineinterfaceconstant {eps} {eps} diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index daf2bb48e..89eb017a3 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -553,7 +553,7 @@ % page=yes, % correct for topskip % location=lt] % {\externalfigure[koe][bleed][frame=on]}} - + % \setlayerframed[layer id][layer settings][framed setting]{data} % \setlayerframed[layer id][combined settings]{data} @@ -565,7 +565,7 @@ \def\pack_layers_set_framed {\ifthirdargument - \expandafter \pack_layers_set_framed_t + \singleexpandafter\pack_layers_set_framed_t \else\ifsecondargument \doubleexpandafter\pack_layers_set_framed_d \else diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv index 46209d50c..f3f3d11d9 100644 --- a/tex/context/base/pack-mrl.mkiv +++ b/tex/context/base/pack-mrl.mkiv @@ -599,8 +599,8 @@ {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}% \hbox spread 2\dimexpr\@@tldistance\relax {\hss - \dousestyleparameter\@tlstyle - \dousecolorparameter\@tlcolor + \dousestyleparameter\@@tlstyle + \dousecolorparameter\@@tlcolor \strut#1% \hss}}}% \color[\@@tlrulecolor] diff --git a/tex/context/base/pack-obj.mkiv b/tex/context/base/pack-obj.mkiv index c2bc0587a..6c9848a01 100644 --- a/tex/context/base/pack-obj.mkiv +++ b/tex/context/base/pack-obj.mkiv @@ -269,7 +269,6 @@ \def\dododosetobject#1#2#3% {\begingroup - \dontshowcomposition % rather fuzzy in \setxvalue ... \hbox \scratchdimen\objectoffset \@EA\xdef\csname\??ob:#2::#3\endcsname {\noexpand\dohandleobject{#2}{#3}% @@ -299,7 +298,6 @@ \def\dogetobject#1#2#3#4#5#6#7% don't change this, should work for dvi & pdf {% \initializepaper \forgetall - \dontshowcomposition % todo: if no attr then faster \setbox\scratchbox\vbox attr \viewerlayerattribute \attribute\viewerlayerattribute {\doinsertobject{#1}{#2}}% diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index adef6aa8a..8248ba67a 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -364,8 +364,8 @@ \pack_framed_background_box_gray_indeed \fi} -\def\pack_framed_background_box_gray_indeed - {\raster[\p_framed_backgroundscreen]{\pack_framed_filled_box}} % can be more direct but who cares +\def\pack_framed_background_box_gray_indeed % can be more direct but who cares, just compatibility + {\colored[s=\p_framed_backgroundscreen]{\pack_framed_filled_box}} %D It won't be a surprise that we not only provide gray boxes, %D but also colored ones. Here it is: @@ -1291,8 +1291,7 @@ \fi} \unexpanded\def\pack_framed_finish - {\dontshowcomposition - \pack_framed_stop_orientation % hm, wrong place ! should rotate the result (after reshape) + {\pack_framed_stop_orientation % hm, wrong place ! should rotate the result (after reshape) \pack_framed_locator_before\p_framed_location \ifconditional\c_framed_has_format \ifx\p_framed_autowidth\v!force diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv index 1804f9f95..f38033b36 100644 --- a/tex/context/base/page-imp.mkiv +++ b/tex/context/base/page-imp.mkiv @@ -89,8 +89,7 @@ {\page_shipouts_ignore} \def\page_boxes_shipout#1% or: \page_shipouts_apply - {\dontshowcomposition % redundant - \dontcomplain % redundant + {\dontcomplain % redundant \the\everybeforeshipout \ifcase\shipoutfinalizemethod \page_shipouts_handle{#1}% diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index ab6633992..e7a4f49d2 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -1274,7 +1274,7 @@ \c!lines=0, \c!paper=, % for foxet \c!page=, % for foxet - \c!columns=1, + \c!columns=\plusone, \c!columndistance=\zeropoint] %D First we define a whole range of (DIN) papersizes, diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv index 2806586b8..df8d38ee6 100644 --- a/tex/context/base/page-mul.mkiv +++ b/tex/context/base/page-mul.mkiv @@ -405,7 +405,6 @@ \leftskip\zeropoint \rightskip\zeropoint % - \dontshowcomposition %\setcolumntextwidth\relax %\setcolumntextheight\relax \widowpenalty\zerocount % is gewoon beter @@ -445,9 +444,8 @@ \let\sethsize\setcolumnhsize \let\setvsize\setcolumnvsize \sethsize - \setvsize - \showcomposition} - + \setvsize} + %D When we leave the multi||column mode, we have to process the %D not yet shipped out part of the columns. When we don't %D balance, we simply force a continuous output, but a balanced @@ -474,7 +472,6 @@ \vskip\lineheight \vskip-\lineheight % take footnotes into account \fi - \dontshowcomposition \doflushcolumnfloat % added recently %\doflushcolumnfloats % no, since it results in wrong top floats \flushnotes % before start of columns @@ -585,14 +582,13 @@ \fi \forgetall \setmulticolumnsout - \showcomposition \setmaxcolumndimensions \dohandleallcolumns {\mkprocesscolumncontents\currentcolumnbox}% \dohandleallcolumns {\page_marks_synchronize_column\plusone\nofcolumns\mofcolumns\currentcolumnbox}% \postprocesscolumns - \dohandleallcolumns % \hbox i.v.m. \showcomposition + \dohandleallcolumns {\global\setbox\currentcolumnbox\hbox to \localcolumnwidth {\box\currentcolumnbox}% \wd\currentcolumnbox\localcolumnwidth @@ -944,7 +940,6 @@ {\bgroup \forgetall \setmulticolumnsout - \dontshowcomposition % \dimen0=\columntextheight % \advance\dimen0 -\precolumnboxheight % \settotalinsertionheight @@ -1016,7 +1011,6 @@ \def\balancedmulticolumnsout {\bgroup \setmulticolumnsout - \dontshowcomposition \widowpenalty\zerocount \setbox0\vbox{\unvbox\normalpagebox}% \ifdim\ht0>\openlineheight % at least one line diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index 8d2d9c1d3..d2d996dea 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -95,7 +95,7 @@ \to \everysetuplayoutelement \def\page_layouts_reset_element_status#vertical% - {\expandafter\gdef\csname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}} + {\expandafter\normalgdef\csname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}} \def\page_layouts_set_element_status_normal#vertical% {\global\expandafter\let\csname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal @@ -111,10 +111,10 @@ \fi} \def\page_layouts_synchronize_element_indeed#vertical% - {\ifx\currenttextstate \v!high \calculatevsizes\recalculatebackgrounds \else - \ifx\previoustextstate\v!high \calculatevsizes\recalculatebackgrounds \else - \ifx\currenttextstate \v!none \calculatevsizes\recalculatebackgrounds \else - \ifx\previoustextstate\v!none \calculatevsizes\recalculatebackgrounds \fi\fi\fi\fi + {\ifx\currenttextstate \v!high \calculatevsizes\page_backgrounds_recalculate \else + \ifx\previoustextstate\v!high \calculatevsizes\page_backgrounds_recalculate \else + \ifx\currenttextstate \v!none \calculatevsizes\page_backgrounds_recalculate \else + \ifx\previoustextstate\v!none \calculatevsizes\page_backgrounds_recalculate \fi\fi\fi\fi \letgvalue{\??layouttextssynchronize#vertical}\currenttextstate} \unexpanded\def\setuptop {\dotripleempty\page_layouts_setup_text[\v!top ]} @@ -756,7 +756,7 @@ \def\page_layouts_place_page_number_left % historic {\begingroup - \setbox\scratchbox\normalhbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% + \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% \ifzeropt\wd\scratchbox\else \doifelsenothing\@@nmwidth {\box\scratchbox\tfskip} @@ -766,7 +766,7 @@ \def\page_layouts_place_page_number_right % historic {\begingroup - \setbox\scratchbox\normalhbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% + \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% \ifzeropt\wd\scratchbox\else \doifelsenothing\@@nmwidth {\tfskip\box\scratchbox} diff --git a/tex/context/base/prop-ini.mkiv b/tex/context/base/prop-ini.mkiv index de259bc59..d8d2ea2f4 100644 --- a/tex/context/base/prop-ini.mkiv +++ b/tex/context/base/prop-ini.mkiv @@ -20,41 +20,45 @@ \unprotect -\def\propertyobsoletemessage +\installcorenamespace{propertytypes} +\installcorenamespace{propertydefiners} +\installcorenamespace{propertystarters} + +\def\properties_obsolete_message {\writestatus\m!system{properties are obsolete, use dedicated commands}% - \glet\propertyobsoletemessage\donothing} + \glet\properties_obsolete_message\donothing} -\setvalue{\??py:d:\v!layer }[#1][#2][#3]{\defineviewerlayer[#1][#3]} -\setvalue{\??py:d:\s!effect }[#1][#2][#3]{\defineeffect [#1][#3]} -\setvalue{\??py:d:\v!negative}[#1][#2][#3]{} +\setvalue{\??propertydefiners\v!layer }[#1][#2][#3]{\defineviewerlayer[#1][#3]} +\setvalue{\??propertydefiners\s!effect }[#1][#2][#3]{\defineeffect [#1][#3]} +\setvalue{\??propertydefiners\v!negative}[#1][#2][#3]{} \unexpanded\def\defineproperty - {\dotripleempty\dodefineproperty} + {\dotripleempty\properties_define} -\def\dodefineproperty[#1][#2][#3]% - {\propertyobsoletemessage - \setevalue{\??py#1\c!type}{#2}% - \getvalue{\??py:d:#2}[#1][#2][#3]} +\def\properties_define[#1][#2][#3]% + {\properties_obsolete_message + \setevalue{\??propertytypes#1e}{#2}% + \getvalue{\??propertydefiners#2}[#1][#2][#3]} -\setvalue{\??py:s:\v!layer }#1{\let\dostopproperty\stopviewerlayer\startviewerlayer[#1]} -\setvalue{\??py:s:\s!effect }#1{\let\dostopproperty\stopeffect \starteffect [#1]} -\setvalue{\??py:s:\v!negative}#1{\let\dostopproperty\stopnegative \startnegative } +\setvalue{\??propertystarters\v!layer }#1{\let\properties_stop\stopviewerlayer\startviewerlayer[#1]} +\setvalue{\??propertystarters\s!effect }#1{\let\properties_stop\stopeffect \starteffect [#1]} +\setvalue{\??propertystarters\v!negative}#1{\let\properties_stop\stopnegative \startnegative } \unexpanded\def\property[#1]% - {\groupedcommand{\dostartproperty{#1}}\dostopproperty} + {\groupedcommand{\properties_start{#1}}\properties_stop} \unexpanded\def\startproperty[#1]% - {\dostartproperty{#1}} + {\properties_start{#1}} \unexpanded\def\stopproperty - {\dostopproperty} + {\properties_stop} -\unexpanded\def\dostartproperty#1% - {\pushmacro\dostopproperty - \getvalue{\??py:s:\getvalue{\??py#1\c!type}}{#1}} +\unexpanded\def\properties_start#1% + {\pushmacro\properties_stop + \getvalue{\??propertystarters\getvalue{\??propertytypes#1}}{#1}} -\unexpanded\def\dostopproperty - {\dostopproperty - \popmacro\dostopproperty} +\unexpanded\def\properties_stop + {\properties_stop + \popmacro\properties_stop} \protect \endinput diff --git a/tex/context/base/scrn-fld.lua b/tex/context/base/scrn-fld.lua index 439de13b3..6f45b30d3 100644 --- a/tex/context/base/scrn-fld.lua +++ b/tex/context/base/scrn-fld.lua @@ -40,7 +40,7 @@ commands.definefieldset = defineset commands.clonefield = clone function commands.insertfield(name,specification) - tex.box["scrn_field_box_body"] = insert(name,specification) + tex.box["b_scrn_field_body"] = insert(name,specification) end -- (for the monent) only tex interface diff --git a/tex/context/base/scrp-ini.mkiv b/tex/context/base/scrp-ini.mkiv index 1c2b1dbaf..b9112a61f 100644 --- a/tex/context/base/scrp-ini.mkiv +++ b/tex/context/base/scrp-ini.mkiv @@ -36,12 +36,12 @@ \setuevalue\currentscript{\setscript[\currentscript]}% \to \everydefinescript -\unexpanded\def\dosetscript +\unexpanded\def\scripts_basics_set {\ctxlua{scripts.set("\currentscript","\scriptparameter\c!method","\scriptparameter\c!preset")}} \unexpanded\def\setscript[#1]% {\edef\currentscript{#1}% - \dosetscript} + \scripts_basics_set} \unexpanded\def\resetscript {\ctxlua{scripts.reset()}} @@ -49,18 +49,18 @@ \unexpanded\def\startscript[#1]% {\begingroup \edef\currentscript{#1}% - \dosetscript} + \scripts_basics_set} \unexpanded\def\stopscript {\endgroup} % \setscript[hangul] \hangul \startscript[hangul] -\definescript[hangul] [\c!method=hangul] -\definescript[hanzi] [\c!method=hanzi] +\definescript[hangul] [\c!method=hangul] +\definescript[hanzi] [\c!method=hanzi] -\definescript[ethiopic] [\c!method=ethiopic] +\definescript[ethiopic][\c!method=ethiopic] -\definescript[latin] [\c!method=] % resets the attribute (also currentscript) +\definescript[latin] [\c!method=] % resets the attribute (also currentscript) \protect \endinput diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 943de1617..01bd565c0 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -728,13 +728,11 @@ \relax}% \dontleavehmode \begingroup - \dontshowcomposition \inleftmargin{\vsmash{\infofont\framed[\c!align=\v!right]{\thepardata}}}% \endgroup} \unexpanded\def\startshowpardata {\begingroup - \showcomposition % all this tracing can go ... if we want it back it will be done in lua \showstruts\tracepositionstrue \tracingparagraphs\maxdimen \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv index cdc45d80e..ae08f4d6e 100644 --- a/tex/context/base/spac-def.mkiv +++ b/tex/context/base/spac-def.mkiv @@ -27,7 +27,7 @@ \def\forgetparindent {\forgeteverypar - \indentfirstparagraphtrue % recently added + \settrue\c_spac_indentation_indent_first % recently added \ctxparindent\zeropoint \parindent\zeropoint \let\currentindentation\v!none} @@ -42,36 +42,41 @@ \rightskip\zeropoint \relax} -\def\forgetspacing +\def\forgethorizontalstretch {\emergencystretch\zeropoint} +\def\forgetverticalstretch + {\spacing\plusone} + \newif\ifforgotten % rather good signal for inner -\appendtoks \forgottentrue \to \everyforgetall -\appendtoks \forgetragged \to \everyforgetall -\appendtoks \forgetparskip \to \everyforgetall -\appendtoks \forgetparindent \to \everyforgetall -\appendtoks \forgetbothskips \to \everyforgetall -\appendtoks \forgetspacing \to \everyforgetall % i.v.m. funny spacing in pagebody -\appendtoks \spacing\plusone \to \everyforgetall % new per 10/08/2004, else problems in otr / !! needed -\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! +% This will become better: several resetters that do all in once as currently there is +% redundant code. +\appendtoks \forgottentrue \to \everyforgetall +\appendtoks \forgetragged \to \everyforgetall +\appendtoks \forgetparskip \to \everyforgetall +\appendtoks \forgetparindent \to \everyforgetall +\appendtoks \forgetbothskips \to \everyforgetall +\appendtoks \forgethorizontalstretch \to \everyforgetall % needed in pagebody +\appendtoks \forgetverticalstretch \to \everyforgetall % needed in otr +\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! -\appendtoks \spacing\plusone \to \everybodyfont +\appendtoks \forgetverticalstretch \to \everybodyfont \appendtoks \presetnormallineheight \to \everybodyfont -\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant -\appendtoks \setstrut \to \everybodyfont % check if redundant -\appendtoks \settopskip \to \everybodyfont -\appendtoks \setmaxdepth \to \everybodyfont -\appendtoks \simplesetupindenting \to \everybodyfont +\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant (\forgetverticalstretch does it too) +\appendtoks \setstrut \to \everybodyfont % check if redundant (\forgetverticalstretch does it too) +\appendtoks \settopskip \to \everybodyfont % factors set in \forgetverticalstretch +\appendtoks \setmaxdepth \to \everybodyfont % factors set in \forgetverticalstretch +\appendtoks \synchronizeindenting \to \everybodyfont \appendtoks \simplesetupblank \to \everybodyfont \appendtoks \simplesetupwhitespace \to \everybodyfont -\appendtoks \simplesetupspacing \to \everybodyfont % nieuw +\appendtoks \synchronizespacecodes \to \everybodyfont % not needed, frozen factors \appendtoks \setrelativeinterlinespace \to \everybodyfont -\appendtoks \updateraggedskips \to \everyfontswitch % under test -\prependtoks \let\par\endgraf \to \everybeforepagebody % see \fillinline -\appendtoks \simplesetupspacing \to \everydefinedfont +\appendtoks \updateraggedskips \to \everyfontswitch % under test +\prependtoks \let\par\normalpar \to \everybeforepagebody % see \fillinline (was endgraf) +\appendtoks \synchronizespacecodes \to \everydefinedfont % not needed, frozen factors \setupwhitespace [\v!none] @@ -82,7 +87,7 @@ \setupindenting [\v!none] -\setupvspacing +\setupvspacing % == \setupblank [\v!standard, \v!big] @@ -92,22 +97,22 @@ \definevspacing[\v!after] [\v!before] \setupinterlinespace - [\c!minheight=0pt, % only special purpose - \c!mindepth=0pt, % only special purpose + [\c!minheight=\zeropoint, % only special purpose + \c!mindepth=\zeropoint, % only special purpose \c!height=.72, \c!depth=.28, \c!top=1.0, \c!bottom=0.4, - \c!distance=1pt, - \c!line=2.8ex, - \c!stretch=0] + \c!distance=\onepoint, + \c!line=2.8\exheight, + \c!stretch=\zerocount] \setupnarrower [\c!before=\endgraf, \c!after=\endgraf, - \c!left=1.5em, - \c!right=1.5em, - \c!middle=1.5em] + \c!left=1.5\emwidth, + \c!right=1.5\emwidth, + \c!middle=1.5\emwidth] \setuptolerance [\v!horizontal,\v!verystrict] diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv index 3001b79bd..4ef39b67a 100644 --- a/tex/context/base/spac-hor.mkiv +++ b/tex/context/base/spac-hor.mkiv @@ -23,68 +23,64 @@ \newdimen \ctxparindent \parindent\ctxparindent % for the show -\newif\ifindentfirstparagraph \indentfirstparagraphtrue - -\newconstant\indentingtogglestate +\newconditional\c_spac_indentation_indent_first \settrue\c_spac_indentation_indent_first +\newconstant \c_spac_indentation_toggle_state %D After a blank or comparable situation (left side floats) we %D need to check if the next paragraph has to be indented. \def\presetindentation - {\doifoutervmode{\ifindentfirstparagraph\else\spac_indentation_variant_no\fi}} - -% we need a better everypar model: for each option a switch, which we -% set to false with \forgetall and can enable when needed (context 4); -% that way we can control the order of execution of options + {\doifoutervmode{\ifconditional\c_spac_indentation_indent_first\else\spac_indentation_variant_no\fi}} -\def\checkeverypar % currently a hack - {\ifzeropt\parindent\else - \doifsometokselse\everypar\donothing\docheckupcomingindentation - \fi} +\unexpanded\def\setupindenting + {\doifnextoptionalelse\spac_indentation_setup_options\spac_indentation_setup_size} -\def\docheckupcomingindentation % brr - {\appendtoks\checkindentation\to\everypar} +\def\spac_indentation_setup_size + {\assigndimension\currentindentation\ctxparindent{1\emwidth}{1.5\emwidth}{2\emwidth}} -\definecomplexorsimple\setupindenting +\let\synchronizeindenting\spac_indentation_setup_size -\unexpanded\def\complexsetupindenting[#1]% - {\edef\currentindenting{#1}% +\def\spac_indentation_setup_options[#1]% + {\edef\currentindenting{#1}% comma separated list \ifx\currentindenting\empty \else - \doapplycurrentindenting + \spac_indentation_setup_indeed \fi} -\def\doapplycurrentindenting - {% not here: \indentfirstparagraphtrue - % not here: \parindent\ctxparindent - % not here: \indentingtogglestate\zerocount - % we use commacommand in order to catch #1 being a command (expanded parameter) - \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc - \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest - \checkeverypar % only when non-empty #1 - \ifindentfirstparagraph\else\spac_indentation_variant_no\fi - \spac_indentation_check_toggle} - -\def\docomplexsetupindentingA#1% +\def\spac_indentation_setup_indeed + {% not here: \settrue\c_spac_indentation_indent_first + % not here: \parindent\ctxparindent + % not here: \c_spac_indentation_toggle_state\zerocount + \processcommacommand[\currentindenting]\spac_indentation_apply_step_one % catch small, medium, etc + \processcommacommand[\currentindenting]\spac_indentation_apply_step_two % catch rest + \ifzeropt\parindent\else + \doifemptytoks\everypar\spac_indentation_set_everypar + \fi + \ifconditional\c_spac_indentation_indent_first\else + \spac_indentation_variant_no + \fi + \spac_indentation_check_toggle} + +\def\spac_indentation_set_everypar + {\everypar{\checkindentation}} + +\def\spac_indentation_apply_step_one#1% {\ifcsname\??indenting#1\endcsname - % case b + % case two \else - \edef\currentindentation{#1}% + \edef\currentindentation{#1}% single entry in list \let\normalindentation\currentindentation - \simplesetupindenting + \spac_indentation_setup_size \fi} -\def\docomplexsetupindentingB#1% +\def\spac_indentation_apply_step_two#1% {\ifcsname\??indenting#1\endcsname \csname\??indenting#1\endcsname \else - % case a + % case one \fi} -\def\simplesetupindenting % empty case, a it strange, needed this way? - {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} - \unexpanded\def\indenting % kind of obsolete - {\dosingleargument\complexsetupindenting} + {\doifnextoptionalelse\spac_indentation_setup_options\relax} % use \noindentation to suppress next indentation @@ -96,26 +92,26 @@ \defineindentingmethod [\v!no] {\parindent\zeropoint}% was: \ctxparindent\noindent} \defineindentingmethod [\v!not] {\parindent\zeropoint}% was: \ctxparindent\noindent} -\defineindentingmethod [\v!first] {\indentfirstparagraphtrue} -\defineindentingmethod [\v!next] {\indentfirstparagraphfalse} +\defineindentingmethod [\v!first] {\settrue\c_spac_indentation_indent_first} +\defineindentingmethod [\v!next] {\setfalse\c_spac_indentation_indent_first} \defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! \defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! \defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! - \indentingtogglestate\zerocount} + \c_spac_indentation_toggle_state\zerocount} -\defineindentingmethod [\v!odd] {\indentingtogglestate\plusone} -\defineindentingmethod [\v!even] {\indentingtogglestate\plustwo} +\defineindentingmethod [\v!odd] {\c_spac_indentation_toggle_state\plusone} +\defineindentingmethod [\v!even] {\c_spac_indentation_toggle_state\plustwo} \defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else \let\currentindentation\normalindentation \simplesetupindenting \fi} -\defineindentingmethod [\v!reset] {\indentfirstparagraphtrue +\defineindentingmethod [\v!reset] {\settrue\c_spac_indentation_indent_first \parindent\zeropoint - \indentingtogglestate\zerocount} + \c_spac_indentation_toggle_state\zerocount} \defineindentingmethod [\v!toggle] {\parindent\ifdim\parindent=\zeropoint \ctxparindent @@ -162,7 +158,7 @@ {\global\let\checkindentation\spac_indentation_no_toggle_indeed} \def\spac_indentation_check_toggle - {\ifcase\indentingtogglestate + {\ifcase\c_spac_indentation_toggle_state % nothing \or \spac_indentation_no_toggle @@ -239,10 +235,10 @@ \csname\??indentnext\ifcsname\??indentnext\p_indentnext\endcsname\p_indentnext\fi\endcsname \fi} -\letvalue{\??indentnext }\donothing -\letvalue{\??indentnext\v!yes }\spac_indentation_variant_yes -\letvalue{\??indentnext\v!no }\spac_indentation_variant_no -\letvalue{\??indentnext\v!auto }\spac_indentation_variant_auto +\letvalue{\??indentnext }\donothing +\letvalue{\??indentnext\v!yes }\spac_indentation_variant_yes +\letvalue{\??indentnext\v!no }\spac_indentation_variant_no +\letvalue{\??indentnext\v!auto}\spac_indentation_variant_auto %D An example of usage: %D @@ -293,42 +289,46 @@ %D Hm ... todo: -\sfcode`\)=0 -\sfcode`\'=0 -\sfcode`\]=0 +\installcorenamespace{spacecodemethods} -\unexpanded\def\setfrenchspacing#1% - {\sfcode`\.#1 \sfcode`\,#1\relax - \sfcode`\?#1 \sfcode`\!#1\relax - \sfcode`\:#1 \sfcode`\;#1\relax} +\sfcode`\)=\zerocount +\sfcode`\'=\zerocount +\sfcode`\]=\zerocount -\unexpanded\def\frenchspacing - {\setfrenchspacing{1000}} +\def\spac_spacecodes_set_fixed#1% + {\sfcode`\.#1\relax \sfcode`\,#1\relax + \sfcode`\?#1\relax \sfcode`\!#1\relax + \sfcode`\:#1\relax \sfcode`\;#1\relax} -\unexpanded\def\resetfrenchspacing +\def\spac_spacecodes_set_stretch {\sfcode`\.3000 \sfcode`\,1250 \sfcode`\?3000 \sfcode`\!3000 \sfcode`\:2000 \sfcode`\;1500 } -\unexpanded\def\frenchspacing {\setfrenchspacing{1000}} -\unexpanded\def\newfrenchspacing{\setfrenchspacing{1050}} -\unexpanded\def\nonfrenchspacing{\resetfrenchspacing} +\unexpanded\def\frenchspacing {\spac_spacecodes_set_fixed\plusthousand} +\unexpanded\def\newfrenchspacing{\spac_spacecodes_set_fixed{1050}} +\unexpanded\def\nonfrenchspacing{\spac_spacecodes_set_stretch} + +\unexpanded\def\definespacingmethod[#1]#2{\setvalue{\??spacecodemethods#1}{#2}} -\installcorenamespace{spacingmethods} +\definespacingmethod[\empty] {} % keep values +\definespacingmethod[\v!fixed] {\frenchspacing } % equal spaces everywhere +\definespacingmethod[\v!packed]{\newfrenchspacing} % slighly more after punctuation +\definespacingmethod[\v!broad ]{\nonfrenchspacing} % more depending on what punctuation -\unexpanded\def\definespacingmethod[#1]#2{\setvalue{\??spacingmethods#1}{#2}} +\unexpanded\def\setupspacing + {\doifnextoptionalelse\spac_spacecodes_setup_yes\spac_spacecodes_setup_nop} -\definespacingmethod[\v!packed]{\newfrenchspacing} -\definespacingmethod[\v!broad ]{\nonfrenchspacing} +\def\spac_spacecodes_setup_yes[#1]% + {\csname\??spacecodemethods#1\endcsname + \updateraggedskips} % not needed, as sf codes are static -\def\complexsetupspacing[#1]% - {\executeifdefined{\??spacingmethods#1}\relax - \updateraggedskips} +\def\spac_spacecodes_setup_nop + {\updateraggedskips} % not needed, as sf codes are static -\def\simplesetupspacing - {\updateraggedskips} +% This is not needed, as \updateraggedskips is taking care of it: -\definecomplexorsimple\setupspacing +\let\synchronizespacecodes\spac_spacecodes_setup_nop % \relax % \dorecurse{100}{\recurselevel\spacefactor 800 \space} \par % \dorecurse{100}{\recurselevel\spacefactor1200 \space} \par @@ -386,7 +386,7 @@ % but, since not all fonts have .5em digits: \unexpanded\def\fixedspace - {\setbox\scratchbox\normalhbox{\mathortext{0}{0}}% + {\setbox\scratchbox\hbox{\mathortext{0}{0}}% \hskip\wd\scratchbox\relax} \def\fixedspaces @@ -723,7 +723,7 @@ %D {\relax\ifmmode %D \copy\strutbox %D \else -%D \bgroup\setbox\strutbox=\normalhbox{\box\strutbox}\unhcopy\strutbox\egroup +%D \bgroup\setbox\strutbox=\hbox{\box\strutbox}\unhcopy\strutbox\egroup %D \fi} %D \stoptyping %D diff --git a/tex/context/base/spac-lin.mkiv b/tex/context/base/spac-lin.mkiv new file mode 100644 index 000000000..094e18e0b --- /dev/null +++ b/tex/context/base/spac-lin.mkiv @@ -0,0 +1,148 @@ +%D \module +%D [ file=spac-lin, +%D version=2012.01.08, % 2009.10.16 (core-ver) 1997.03.31 (core-spa) +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Vertical, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Lines} + +\unprotect + +%D When spacing is active we need to handle commands in +%D a special way: +%D +%D \starttyping +%D \setuplines[space=on] +%D +%D \startlines +%D Let's talk about this{\ttsl\gobbleoneargument or}that. +%D \stoplines +%D +%D \startlines +%D Let's talk about this{\getvalue{ttsl}or}that. +%D \stoplines +%D \stoptyping +%D +%D One can indent in several ways: +%D +%D \starttyping +%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even +%D +%D \startlines +%D first +%D second +%D third +%D fourth +%D \stoplines +%D \stoptyping + +%D Contrary to \MKII\ we can now define classes of lines (generalized by +%D Wolfgang). I will probably rewrite bits in \LUA. + +\installcorenamespace{lines} + +\installcommandhandler \??lines {lines} \??lines + +\setuplines + [\c!option=, + \c!command=, + \c!before=\blank, + \c!after=\blank, + \c!inbetween=\blank, + \c!indenting=\v!no, + \c!space=\v!default] + +\appendtoks + \setuevalue{\e!start\currentlines}{\spac_lines_start[\currentlines]}% + \setuevalue{\e!stop \currentlines}{\spac_lines_stop}% +\to \everydefinelines + +\unexpanded\def\spac_lines_start[#1]% + {\bgroup + \edef\currentlines{#1}% + \obeylines + \dosingleempty\spac_lines_start_indeed} + +\let\p_lines_option\empty + +\let\spac_lines_break \relax +\let\spac_after_first_obeyed_line\relax + +\def\spac_lines_start_indeed[#1]% new: optional second argument (WS) + {\iffirstargument + \setupcurrentlines[#1]% + \fi + \edef\p_lines_option{\linesparameter\c!option}% + \ifx\p_lines_option\v!packed + \let\spac_lines_break\nobreak + \else + \let\spac_lines_break\relax + \fi + \linesparameter\c!before + \pushmacro\checkindentation + \whitespace + \dostarttagged\t!lines\currentlines + \begingroup + \uselinesstyleandcolor\c!style\c!color + \setupindenting[\linesparameter\c!indenting]% + \setupalign[\linesparameter\c!align]% + \typesettinglinestrue + \setupwhitespace[\v!none]% + %\obeylines % move upwards to keep spaces in the first line due to optional argument + \ignorespaces + \glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_a + \let\obeyedline\spac_lines_obeyed_line + \activatespacehandler{\linesparameter\c!space}% + \dostarttagged\t!line\empty + \GotoPar} % this will become a nice lowercased helper + +% we could have states instead and handle option in there + +\def\spac_lines_after_first_obeyed_line_a % tzt two pass, like itemize + {\linesparameter\c!command + \glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_b} + +\def\spac_lines_after_first_obeyed_line_b + {\spac_lines_break + \linesparameter\c!command} + +\def\spac_lines_obeyed_line + {\dostoptagged + \par + \dostarttagged\t!line\empty + \futurelet\next\spac_lines_between} + +\unexpanded\def\spac_lines_stop + {\dostoptagged + \endgroup + \dostoptagged + \popmacro\checkindentation + \linesparameter\c!after + \egroup} + +\def\spac_lines_between + {\doifmeaningelse\next\obeyedline % brrr + {\linesparameter\c!inbetween} + {\spac_after_first_obeyed_line}} + +\definelines[\v!lines] + +\unexpanded\def\emptylines + {\dosingleempty\spac_lines_empty} + +\def\spac_lines_empty[#1]% + {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} + +\ifdefined\startlines \else + \expandafter\let\expandafter\startlines\csname\e!start\v!lines\endcsname + \expandafter\let\expandafter\stoplines \csname\e!stop \v!lines\endcsname +\fi + +\protect \endinput diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index a84b49a18..ee770656f 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -17,6 +17,9 @@ \registerctxluafile{spac-ver}{1.001} +% Isn't it about time to get rid of topskip i.e. make it equivalent to +% \openstrutheight so that we can remove delta code. + %D There are two ways to influence the interline spacing. The %D most general and often most consistent way is using %D @@ -46,6 +49,9 @@ %D arguments) to set the interline space according to the %D current font, e.g. a \type{\bfa}. +% will be cleaned up but it will stay messy because we accept so +% many variants + \newif\iflocalinterlinespace \newskip\s_spac_vspacing_temp \s_spac_vspacing_temp\bigskipamount @@ -61,56 +67,21 @@ \fi \fi \relax} -\ifx\bodyfontinterlinespecs\undefined - - \let\bodyfontinterlinespecs\empty +\ifdefined\bodyfontinterlinespace \else \let\bodyfontinterlinespace\empty - \fi \unexpanded\def\presetnormallineheight % each bodyfont {\edef\normallineheight{\interlinespaceparameter\c!line}% - %done elsewhere : \spacing\!!plusone % new per 10/08/2004, else problems in otr / !! needed \iflocalinterlinespace \else - \doifdefined\bodyfontinterlinespecs - {\doifsomething\bodyfontinterlinespace - {\edef\normallineheight{\bodyfontinterlinespace}}}% + \edef\m_spac_normallineheight{\bodyfontinterlinespace}% + \ifx\m_spac_normallineheight\empty \else + \let\normallineheight\m_spac_normallineheight + \fi \fi} -% check and test: -% -% \let\m_spac_linespacing_asked\empty -% -% \unexpanded\def\presetnormallineheight % each bodyfont -% {\iflocalinterlinespace -% \spac_linespacing_set_lineheight_regular -% \else -% \spac_linespacing_set_lineheight_checked -% \fi} -% -% \def\spac_linespacing_set_lineheight_regular -% {\edef\normallineheight{\interlinespaceparameter\c!line}} -% -% \def\spac_linespacing_set_lineheight_checked -% {\edef\m_spac_linespacing_asked{\bodyfontvariable{\normalizedbodyfontsize\c!interlinespace}}% -% \ifcsname\m_spac_linespacing_asked\endcsname -% \spac_linespacing_set_lineheight_specific -% \else -% \spac_linespacing_set_lineheight_regular -% \fi} -% -% \def\spac_linespacing_set_lineheight_specific -% {\edef\m_spac_linespacing_asked{\csname\bodyfontinterlinespecs\endcsname}% -% \ifx\m_spac_linespacing_asked\empty -% \spac_linespacing_set_lineheight_regular -% \else -% \let\normallineheight\m_spac_linespacing_asked -% \fi} - -\let\currentrelativeinterlinespace\empty - \unexpanded\def\setupspecifiedinterlinespace[#1]% - {\getparameters[\??it\currentinterlinespace][#1]% + {\setupcurrentinterlinespace[#1]% \spac_linespacing_setup_specified_interline_space} \def\spac_linespacing_setup_specified_interline_space @@ -132,7 +103,8 @@ \installcorenamespace{interlinespacerelative} -\let\setrelativeinterlinespace\relax % used elsewhere +\let\setrelativeinterlinespace \relax % used elsewhere +\let\currentrelativeinterlinespace\empty \setvalue{\??interlinespacerelative\v!on }{\oninterlineskip} \setvalue{\??interlinespacerelative\v!off }{\offinterlineskip} @@ -162,49 +134,40 @@ \spacing\currentrelativeinterlinespace \fi} -% todo: use command handler here - \newtoks\everysetupglobalinterlinespace \newtoks\everysetuplocalinterlinespace -\def\interlinespaceparameter #1{\csname\dointerlinespaceparameter{\??it\currentinterlinespace}#1\endcsname} -\def\dointerlinespaceparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dointerlinespaceparentparameter\csname#1\s!parent\endcsname#2\fi} -\def\dointerlinespaceparentparameter#1#2{\ifx#1\relax\s!empty\else\dointerlinespaceparameter#1#2\fi} % \s!empty ? - \newconditional\interlinespaceisset -\let\currentinterlinespace\empty - -\unexpanded\def\defineinterlinespace - {\dodoubleempty\dodefineinterlinespace} +\installcorenamespace{interlinespace} -\def\dodefineinterlinespace[#1][#2]% - {\getparameters[\??it#1][\s!parent=\??it,#2]} +\installcommandhandler \??interlinespace {interlinespace} \??interlinespace \unexpanded\def\setupinterlinespace - {\dodoubleempty\dosetupinterlinespace} + {\dodoubleempty\spac_linespacing_setup} -\def\dosetupinterlinespace[#1][#2]% +\def\spac_linespacing_setup[#1][#2]% {\settrue\interlinespaceisset % reset has to be done when needed \ifsecondargument - \getparameters[\??it#1][#2]% + \setup_interlinespace[#1][#2]% \else\iffirstargument - \edef\currentinterlinespace{\ifcsname\??it#1\s!parent\endcsname#1\fi}% - \ifx\currentinterlinespace\empty - \complexsetupinterlinespace[#1]% + \ifcsname\namedinterlinespacehash{#1}\s!parent\endcsname + \edef\currentinterlinespace{#1}% + \spac_linespacing_setup_specified_interline_space + %\dosetupspecifiedinterlinespaceindeed \else - \dosetupspecifiedinterlinespaceindeed + \space_linespacing_setup_specified_or_relative[#1]% \fi \else \let\currentinterlinespace\empty - \simplesetupinterlinespace + \space_linespacing_synchronize_local \fi\fi} -\def\complexsetupinterlinespace[#1]% \commalistelement ipv #1 +\def\space_linespacing_setup_specified_or_relative[#1]% {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]% \the\iflocalinterlinespace\everysetuplocalinterlinespace\else\everysetupglobalinterlinespace\fi} -\def\simplesetupinterlinespace % adapts to the font +\def\space_linespacing_synchronize_local % adapts to the font {\localinterlinespacetrue \setfontparameters \updateraggedskips % funny one here @@ -214,11 +177,11 @@ \def\dosetupcheckedinterlinespace#1% often a chain {\edef\askedinterlinespace{#1}% \ifx\askedinterlinespace\empty - \simplesetupinterlinespace - \else\ifcsname\??it\askedinterlinespace\s!parent\endcsname + \space_linespacing_synchronize_local + \else\ifcsname\namedinterlinespacehash\askedinterlinespace\s!parent\endcsname % we could have a \s!check \pushmacro\currentinterlinespace \let\currentinterlinespace\askedinterlinespace - \dosetupspecifiedinterlinespaceindeed + \spac_linespacing_setup_specified_interline_space % \dosetupspecifiedinterlinespaceindeed \iflocalinterlinespace \the\everysetuplocalinterlinespace \else @@ -229,8 +192,7 @@ \popmacro\currentinterlinespace \else \normalexpanded{\noexpand\doifassignmentelse{\askedinterlinespace}% - \noexpand\setupspecifiedinterlinespace - \noexpand\setuprelativeinterlinespace[\askedinterlinespace]}% + \setupspecifiedinterlinespace\setuprelativeinterlinespace[\askedinterlinespace]}% \iflocalinterlinespace \the\everysetuplocalinterlinespace \else @@ -249,7 +211,7 @@ \let\switchtointerlinespace\setuplocalinterlinespace -\definecomplexorsimple\setupinterlinespace +% \definecomplexorsimple\setupinterlinespace %D Helpers @@ -411,6 +373,8 @@ \fi \fi} +% this will become \installwhitespacemethod{}{} + \unexpanded\def\definewhitespacemethod[#1]#2{\setvalue{\??whitespacemethod#1}{#2}} \definewhitespacemethod [\v!fix] {} @@ -512,8 +476,8 @@ \flushnextbox \stopbaselinecorrection} -\unexpanded\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}} -\unexpanded\def\horizontalstrut{\normalhbox {\strut}} +\unexpanded\def\verticalstrut {\vbox{\hsize\zeropoint\forgetall\strut}} +\unexpanded\def\horizontalstrut{\hbox {\strut}} % Hieronder volgen enkele instellingen en macro's ten behoeve % van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en @@ -664,7 +628,7 @@ \normallineskiplimit\zeropoint\relax \normalbaselines} -\unexpanded\def\spacing#1% +\unexpanded\def\spacing#1% vertical {\ifgridsnapping \let\spacingfactor\plusone \else @@ -705,7 +669,7 @@ \newbox\strutbox -\setbox\strutbox\normalhbox{\vrule\!!height8.5pt\!!depth3.5pt\!!width\zeropoint} % just a start +\setbox\strutbox\hbox{\vrule\!!height8.5pt\!!depth3.5pt\!!width\zeropoint} % just a start \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} @@ -755,7 +719,7 @@ \dosetstrut} \unexpanded\def\setcharstrut#1% - {\setbox\strutbox\normalhbox{#1}% + {\setbox\strutbox\hbox{#1}% \strutht\ht\strutbox \strutdp\dp\strutbox \dosetstrut} @@ -804,15 +768,15 @@ \fi} \def\spac_struts_set_hide - {\setbox\strutbox\normalhbox + {\setbox\strutbox\hbox {\vrule \!!width \zeropoint \!!height\strutht \!!depth \strutdp}} \def\spac_struts_set_vide - {\setbox\strutbox\normalhbox - {\normalhbox to \zeropoint + {\setbox\strutbox\hbox + {\hbox to \zeropoint {% \hss % new, will be option \vrule \!!width \strutwidth @@ -924,14 +888,14 @@ \def\spac_struts_beg_signal {\noindent\horizontalstrut - \normalpenalty\plustenthousand - \normalhskip-\strutsignal - \normalhskip\strutsignal} + \penalty\plustenthousand + \hskip-\strutsignal + \hskip\strutsignal} \def\spac_struts_beg_normal {\strut - \normalpenalty\plustenthousand - \normalhskip\zeropoint} + \penalty\plustenthousand + \hskip\zeropoint} \unexpanded\def\endstrut {\relax\ifhmode @@ -956,15 +920,15 @@ \unpenalty \setbox\scratchbox\lastbox \else - \normalpenalty\plustenthousand - \normalhskip\zeropoint + \penalty\plustenthousand + \hskip\zeropoint \strut \fi} \def\spac_struts_end_normal {\removeunwantedspaces - \normalpenalty\plustenthousand - \normalhskip\zeropoint + \penalty\plustenthousand + \hskip\zeropoint \strut} % unsave: @@ -1729,116 +1693,4 @@ \relax \fi} -%D When spacing is active we need to handle commands in -%D a special way: -%D -%D \starttyping -%D \setuplines[space=on] -%D -%D \startlines -%D Let's talk about this{\ttsl\gobbleoneargument or}that. -%D \stoplines -%D -%D \startlines -%D Let's talk about this{\getvalue{ttsl}or}that. -%D \stoplines -%D \stoptyping -%D -%D One can indent in several ways: -%D -%D \starttyping -%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even -%D -%D \startlines -%D first -%D second -%D third -%D fourth -%D \stoplines -%D \stoptyping - -%D Contrary to \MKII\ we can now define classes of lines (generalized by -%D Wolfgang). I will probably rewrite bits in \LUA. - -\installcorenamespace{lines} - -\installcommandhandler \??lines {lines} \??lines - -\setuplines - [\c!option=, - \c!command=, - \c!before=\blank, - \c!after=\blank, - \c!inbetween=\blank, - \c!indenting=\v!no, - \c!space=\v!default] - -\appendtoks - \setuevalue{\e!start\currentlines}{\dostartlines[\currentlines]}% - \setuevalue{\e!stop \currentlines}{\dostoplines}% -\to \everydefinelines - -\unexpanded\def\dostartlines[#1]% - {\bgroup - \edef\currentlines{#1}% - \obeylines - \dosingleempty\dodostartlines} - -\def\dodostartlines[#1]% new: optional second argument (WS) - {\iffirstargument - \setupcurrentlines[#1]% - \fi - \edef\linesoption{\linesparameter\c!option}% - \linesparameter\c!before - \pushmacro\checkindentation - \whitespace - \dostarttagged\t!lines\currentlines - \begingroup - \uselinesstyleandcolor\c!style\c!color - \setupindenting[\linesparameter\c!indenting]% - \setupalign[\linesparameter\c!align]% - \typesettinglinestrue - \setupwhitespace[\v!none]% - %\obeylines % move upwards to keep spaces in the first line due to optional argument - \ignorespaces - \gdef\afterfirstobeyedline % tzt two pass, net als opsomming - {\linesparameter\c!command - \gdef\afterfirstobeyedline - {\ifx\linesoption\v!packed\nobreak\fi - \linesparameter\c!command}}% - \def\obeyedline - {\dostoptagged - \par - \dostarttagged\t!line\empty - \futurelet\next\dobetweenthelines}% - \activatespacehandler{\linesparameter\c!space}% - \dostarttagged\t!line\empty - \GotoPar} - -\unexpanded\def\dostoplines - {\dostoptagged - \endgroup - \dostoptagged - \popmacro\checkindentation - \linesparameter\c!after - \egroup} - -\def\dobetweenthelines - {\doifmeaningelse\next\obeyedline - {\linesparameter\c!inbetween} - {\afterfirstobeyedline}} - -\definelines[\v!lines] - -\def\emptylines - {\dosingleempty\doemptylines} - -\def\doemptylines[#1]% - {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} - -\ifdefined\startlines \else - \expandafter\let\expandafter\startlines\csname\e!start\v!lines\endcsname - \expandafter\let\expandafter\stoplines \csname\e!stop \v!lines\endcsname -\fi - \protect \endinput diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 2450c93b4..f248eb5ac 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 5c297c1ff..1a5956dcc 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 27e65c475..d742d8736 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -281,11 +281,13 @@ return { filename = "supp-vis", marktype = "mkiv", status = "unknown", + comment = "will become a module (and part will stay in the core)", }, { filename = "supp-fun", marktype = "mkiv", status = "unknown", + comment = "will be integrated elsewhere", }, { filename = "supp-ran", @@ -578,6 +580,12 @@ return { comment = "update lua code (communicate via register)" }, { + filename = "spac-lin", + marktype = "mkiv", + status = "unknown", + comment = "could be improved if needed" + }, + { filename = "spac-pag", marktype = "mkiv", status = "okay", @@ -782,11 +790,6 @@ return { status = "unknown", }, { - filename = "file-job", - marktype = "mkvi", - status = "unknown", - }, - { filename = "buff-ini", marktype = "mkiv", status = "okay", @@ -946,8 +949,14 @@ return { }, { filename = "font-ini", + marktype = "mkvi", + status = "okay", + comment = "needs occasional checking and upgrading", + }, + { + filename = "font-pre", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "font-unk", @@ -968,8 +977,8 @@ return { }, { filename = "font-col", - marktype = "mkiv", - status = "unknown", + marktype = "mkvi", + status = "okay", }, { filename = "font-gds", @@ -1050,38 +1059,29 @@ return { }, { filename = "type-ini", - marktype = "mkiv", - status = "unknown", + marktype = "mkvi", + status = "okay", }, { filename = "type-set", marktype = "mkiv", - status = "unknown", - }, - { - filename = "type-def", - marktype = "mkiv", - status = "unknown", - }, - { - filename = "type-lua", - marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "scrp-ini", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "prop-ini", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "this module is obsolete", }, { filename = "mlib-ctx", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "meta-ini", @@ -1091,12 +1091,13 @@ return { { filename = "meta-tex", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "meta-fun", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "maybe this one will be merged" }, { filename = "meta-pag", @@ -1216,7 +1217,7 @@ return { { filename = "phys-dim", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "strc-mat", @@ -1339,7 +1340,7 @@ return { { filename = "cldf-ver", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "cldf-com", diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex index 4c764e4f7..4127b35de 100644 --- a/tex/context/base/status-mkiv.tex +++ b/tex/context/base/status-mkiv.tex @@ -58,7 +58,10 @@ if preloaded then - for i=1,#preloaded do + local nofunknown = 0 + local nofloaded = #preloaded + + for i=1,nofloaded do preloaded[i].order = i end @@ -71,18 +74,27 @@ context.NC() context.bold("status") context.NC() context.bold("comment") context.NC() context.NR() - for i=1,#preloaded do + for i=1,nofloaded do local module = preloaded[i] local status = module.status context.NC() context(module.order) context.NC() context(module.filename) context.NC() context(module.marktype) - context.NC() if status == "unknown" then context.bold(status) else context(status) end + if status == "unknown" then + context.NC() context.bold(status) + nofunknown = nofunknown + 1 + else + context.NC() context(status) + end context.NC() context(module.comment) context.NC() context.NR() end context.stoptabulate() + context.blank() + + context("Of the %s core modules (so far) in this list %s have the status unknown",nofloaded,nofunknown) + end end diff --git a/tex/context/base/strc-des.mkiv b/tex/context/base/strc-des.mkiv index 48102655a..9f84c493d 100644 --- a/tex/context/base/strc-des.mkiv +++ b/tex/context/base/strc-des.mkiv @@ -195,8 +195,7 @@ \@@makedescriptionhangbox\raggedright{\advance\rightskip \descriptionsheaddistance}% \noindent \llap - {\dontshowcomposition - \vtop to \zeropoint{\box\descriptionheadbox}}% + {\vtop to \zeropoint{\box\descriptionheadbox}}% \@@dodescription} \def\@@descriptionrighthang @@ -208,7 +207,6 @@ \noindent \rlap {\dontcomplain - \dontshowcomposition \hbox to \dimexpr\hsize-\leftskip-\rightskip\relax % can be a macro {\hss\vtop to \zeropoint{\box\descriptionheadbox}}}% \@@dodescription} @@ -337,7 +335,6 @@ {\descriptionparameter\c!before \begingroup \doadaptleftskip{\descriptionparameter\c!margin}% - \showcomposition \setlocalhsize % so we can use \localhsize in width assignments \descriptionsheaddistance\descriptionlocationparameter\c!distance\relax \ifdim\descriptionsheaddistance=\zeropoint\relax diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi index 2ef345e4b..6d04f27ed 100644 --- a/tex/context/base/strc-itm.mkvi +++ b/tex/context/base/strc-itm.mkvi @@ -697,70 +697,25 @@ \else \edef\itemgroupoptions{\itemgroupoptions,\itemgroupextraoptions}% \fi\fi - \redostartitemgroup{#settings}} - -\let\startcollectitems\relax -\let\stopcollectitems \relax - -\ifdefined\startcolumns \else \unexpanded\def\startcolumns[#settings]{} \fi -\ifdefined\stopcolumns \else \unexpanded\def\stopcolumns {} \fi - -\letvalue{\??itemgroupalign\v!flushleft }\relax -\letvalue{\??itemgroupalign\v!right }\relax -\letvalue{\??itemgroupalign\v!flushright}\hfill -\letvalue{\??itemgroupalign\v!left }\hfill -\letvalue{\??itemgroupalign\v!middle }\hfil -\letvalue{\??itemgroupalign\v!center }\hfil - -\def\strc_itemgroups_left_sym_filler - {\csname\??itemgroupalign\itemgroupparameter\c!symalign\endcsname} - -% symbols + states - -\def\strc_itemgroups_store_global_symbol#symbol% - {\letgvalue{\??itemgroupglobal\currentitemlevel}#symbol} - -\def\strc_itemgroups_store_local_symbol#symbol% - {\letgvalue{\??itemgrouplocal\currentitemlevel}#symbol} - -\def\strc_itemgroups_fetch_global_symbol - {\getvalue{\??itemgroupglobal\currentitemlevel}} - -\def\strc_itemgroups_fetch_local_symbol - {\getvalue{\??itemgrouplocal\currentitemlevel}} - -\def\strc_itemgroups_setup_symbol_default - {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}% - \strc_itemgroups_store_global_symbol\empty} - -\def\strc_itemgroups_setup_symbol_continue - {\ifcsname\??itemgroupglobal\currentitemlevel\endcsname - \let\strc_itemgroups_asked_symbol\strc_itemgroups_fetch_global_symbol - \else - \let\strc_itemgroups_asked_symbol\currentitemlevel - \fi} - -\def\strc_itemgroups_setup_symbol_asked - {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}} - -\unexpanded\def\redostartitemgroup#settings% k/v - {\begingroup % (2) + \begingroup % (2) \the\itemgroupcommands \let\c_strc_itemgroups_text_saved\c_strc_itemgroups_text \strc_itemgroups_initialize_local \strc_itemgroups_preset_stage_one\itemgroupoptions - \ifhmode - \ifconditional\c_strc_itemgroups_auto_concat - \ifdim\lastskip=\d_strc_itemgroups_signal - \settrue\c_strc_itemgroups_concat - \fi - \fi - \ifconditional\c_strc_itemgroups_text_saved \else - \ifconditional\c_strc_itemgroups_text \else - \par - \fi - \fi - \fi +% +% \ifhmode +% \ifconditional\c_strc_itemgroups_auto_concat +% \ifdim\lastskip=\d_strc_itemgroups_signal +% \settrue\c_strc_itemgroups_concat +% \fi +% \fi +% \ifconditional\c_strc_itemgroups_text_saved \else +% \ifconditional\c_strc_itemgroups_text \else +% \par +% \fi +% \fi +% \fi +% \iftrialtypesetting \savestructurecounter[\v_strc_itemgroups_counter]% \fi @@ -782,6 +737,20 @@ \strc_itemgroups_store_continue_state\itemgroupoptions{#settings}% \fi \fi + % + \ifhmode + \ifconditional\c_strc_itemgroups_auto_concat + \ifdim\lastskip=\d_strc_itemgroups_signal + \settrue\c_strc_itemgroups_concat + \fi + \fi + \ifconditional\c_strc_itemgroups_text_saved \else + \ifconditional\c_strc_itemgroups_text \else + \par + \fi + \fi + \fi + % \ifnum\c_strc_itemgroups_nesting=\plusone % NIEUW \doadaptleftskip {\itemgroupparameter\c!margin}% \doadaptleftskip {\itemgroupparameter\c!leftmargin}% @@ -842,6 +811,50 @@ \d_strc_itemgroups_asked_width\itemgroupparameter\c!width\relax \startcollectitems} +\let\startcollectitems\relax +\let\stopcollectitems \relax + +\ifdefined\startcolumns \else \unexpanded\def\startcolumns[#settings]{} \fi +\ifdefined\stopcolumns \else \unexpanded\def\stopcolumns {} \fi + +\letvalue{\??itemgroupalign\v!flushleft }\relax +\letvalue{\??itemgroupalign\v!right }\relax +\letvalue{\??itemgroupalign\v!flushright}\hfill +\letvalue{\??itemgroupalign\v!left }\hfill +\letvalue{\??itemgroupalign\v!middle }\hfil +\letvalue{\??itemgroupalign\v!center }\hfil + +\def\strc_itemgroups_left_sym_filler + {\csname\??itemgroupalign\itemgroupparameter\c!symalign\endcsname} + +% symbols + states + +\def\strc_itemgroups_store_global_symbol#symbol% + {\letgvalue{\??itemgroupglobal\currentitemlevel}#symbol} + +\def\strc_itemgroups_store_local_symbol#symbol% + {\letgvalue{\??itemgrouplocal\currentitemlevel}#symbol} + +\def\strc_itemgroups_fetch_global_symbol + {\getvalue{\??itemgroupglobal\currentitemlevel}} + +\def\strc_itemgroups_fetch_local_symbol + {\getvalue{\??itemgrouplocal\currentitemlevel}} + +\def\strc_itemgroups_setup_symbol_default + {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}% + \strc_itemgroups_store_global_symbol\empty} + +\def\strc_itemgroups_setup_symbol_continue + {\ifcsname\??itemgroupglobal\currentitemlevel\endcsname + \let\strc_itemgroups_asked_symbol\strc_itemgroups_fetch_global_symbol + \else + \let\strc_itemgroups_asked_symbol\currentitemlevel + \fi} + +\def\strc_itemgroups_setup_symbol_asked + {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}} + \def\strc_itemgroups_start_columns {\startcolumns [\c!n=\itemgroupparameter\c!n, @@ -896,11 +909,14 @@ \fi \global\advance\c_strc_itemgroups_nesting\minusone \xdef\currentitemlevel{\number\c_strc_itemgroups_nesting}% - \endgroup % (2) - \endgroup % (1) - \ifconditional\c_strc_itemgroups_text \else - \par % hm, already done - \fi + %\ifconditional\c_strc_itemgroups_text + \endgroup % (2) + \endgroup % (1) + %\else + % \endgroup % (2) + % \endgroup % (1) + % \par % hm, already done, and dangerous as \c_strc_itemgroups_text is already forgotten + %\fi \dorechecknextindentation} % The items. @@ -989,7 +1005,7 @@ \let\strc_itemgroups_margin_symbol\relax \dostarttagged\t!itemcontent\empty \strut - \nobreak % else problems with intext items + \nobreak % else problems with intext items \hskip\d_strc_itemgroups_signal % concat \itemgroupparameter\c!command} @@ -1235,7 +1251,7 @@ {\setfalse\c_strc_itemgroups_indented_first \ifx\m_strc_itemgroups_indenting\empty \else \normalexpanded{\setupindenting[\v!reset,\v!yes,\m_strc_itemgroups_indenting]}% - \ifindentfirstparagraph + \ifconditional\c_spac_indentation_indent_first % better is to have a mode \doifnot{\itemgroupparameter\c!alignsymbol}\v!yes {\settrue\c_strc_itemgroups_indented_first}% \fi @@ -1252,10 +1268,10 @@ \fi} \def\strc_itemgroups_insert_item - {\ifconditional\c_strc_itemgroups_text + {\ifconditional\c_strc_itemgroups_text % again? % begin of item \else - \par + \par % done twice? \fi \advance\c_strc_itemgroups_n_of_items\plusone \optimizelistitemsbreak @@ -1310,15 +1326,21 @@ \strc_itemgroups_check_for_repeated \ignorespaces} -\setvalue{\??itemgroupdistance\c!textdistance:\v!none}% +\setvalue{\??itemgroupdistance\v!none}% + {\let\m_strc_itemgroups_text_distance\zeropoint} + +\setvalue{\??itemgroupdistance\v!space}% + {\def\m_strc_itemgroups_text_distance{\interwordspace\!!plus\interwordstretch\!!minus\interwordshrink}} + +\setvalue\??itemgroupdistance % catches empty value {\let\m_strc_itemgroups_text_distance\zeropoint} \unexpanded\def\strc_itemgroups_set_text_item_distance {\edef\m_strc_itemgroups_text_distance{\itemgroupparameter\c!textdistance}% \ifx\m_strc_itemgroups_text_distance\empty % - \else\ifcsname\??itemgroupdistance\c!textdistance:\m_strc_itemgroups_text_distance\endcsname - \csname\??itemgroupdistance\c!textdistance:\m_strc_itemgroups_text_distance\endcsname + \else\ifcsname\??itemgroupdistance\m_strc_itemgroups_text_distance\endcsname + \csname\??itemgroupdistance\m_strc_itemgroups_text_distance\endcsname \else \strc_itemgroups_set_text_item_distance_indeed \fi\fi} @@ -1509,7 +1531,7 @@ \c!start=1, \c!criterium=\v!all, % permits 0 and negative numbers %\c!option=, - \c!textdistance=\v!big, + \c!textdistance=\v!space, % none big medium small <dimension> \c!command=\strc_itemgroups_default_command, \c!indenting=\v!next, %\c!alignsymbol=v!no, diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index 043d23bb5..d80217a32 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -83,28 +83,10 @@ \c!interaction=\v!sectionnumber, \c!label=\v!no, \c!distance=\!!zeropoint, - %\c!sectionseparatorset=, - %\c!sectionconversionset=, - %\c!sectionstarter=, - %\c!sectionstopper=, - %\c!sectionset=, - %\c!sectionsegments=, - %\c!prefix=\v!no, - %\c!prefixseparatorset=, - %\c!prefixconversionset=, - %\c!prefixstarter=., - %\c!prefixstopper=., - %\c!prefixset=, - %\c!prefixsegments=, - %\c!pageseparatorset=, - %\c!pageconversionset=, - %\c!pagestarter=, - %\c!pagestopper=, + %\c!number*= + %\c!prefix*=, + %\c!pageprefix*=, %\c!expansion=, - %\c!prefixconnector=., % maybe inherit from setupheads - %\c!pageprefix=\v!no, % is unset, inherits - %\c!pageprefixconnector=\listparameter\c!prefixconnector, - %\c!pagesegments=2:2, \c!limittext=\languageparameter\c!limittext] % not used currently % Whatever: diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 93a915bb6..f093e1275 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -12,6 +12,8 @@ if not modules then modules = { } end modules ['strc-ref'] = { -- the useddata and pagedata names might change -- todo: pack exported data +-- todo: autoload components when ::: + local format, find, gmatch, match, concat = string.format, string.find, string.gmatch, string.match, table.concat local texcount, texsetcount = tex.count, tex.setcount local rawget, tonumber = rawget, tonumber @@ -697,6 +699,7 @@ local function loadexternalreferences(name,utilitydata) local external = struc.references.collected -- direct references local lists = struc.lists.collected -- indirect references (derived) local pages = struc.pages.collected -- pagenumber data + -- a bit weird one, as we don't have the externals in the collected for prefix, set in next, external do for reference, data in next, set do if trace_importing then @@ -934,7 +937,7 @@ function structures.references.loadpresets(product,component) -- we can consider local utilitydata = job.loadother(fullname) if utilitydata then if trace_importing then - report_importing("loading presets for component %s from product %s",component,product) + report_importing("loading references for component %s of product %s from %s",component,product,fullname) end loadproductvariables (product,component,utilitydata) loadproductreferences(product,component,utilitydata) @@ -956,8 +959,8 @@ if useproduct then if texconditionals.autocrossfilereferences then local component = justacomponent() if component then - if trace_referencing then - report_references("loading presets for component '%s' from product '%s'",component,product) + if trace_referencing or trace_importing then + report_references("loading presets for component '%s' of product '%s'",component,product) end structures.references.loadpresets(product,component) end diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index ff9ecbaf7..b1268170b 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -802,8 +802,13 @@ % 2 = before % 3 = after +% \def\strc_references_by_reference_page_state#unknown#before#current#after% +% {\ifcase\referencepagestate\relax#unknown\or#current\or#before\or#after\fi} +% +% this fails in an expansion as the \relax stays, so we need: + \def\strc_references_by_reference_page_state#unknown#before#current#after% - {\ifcase\referencepagestate\relax#unknown\or#current\or#before\or#after\fi} + {\ifcase\referencepagestate\space#unknown\or#current\or#before\or#after\fi} \unexpanded\def\somewhere#backward#foreward#dummy[#label]% #dummy gobbles space around #foreward {\doifreferencefoundelse{#label}% usage needs checking (useless) diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv index 0e3f95492..0c78994ea 100644 --- a/tex/context/base/supp-box.mkiv +++ b/tex/context/base/supp-box.mkiv @@ -142,10 +142,10 @@ %D and smashed alternatives. The later ones reduce all %D dimensions to zero. -\unexpanded\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\normalhbox} -\unexpanded\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\normalvbox} -\unexpanded\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \normalhbox} -\unexpanded\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \normalvbox} +\unexpanded\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\hbox} +\unexpanded\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\vbox} +\unexpanded\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \hbox} +\unexpanded\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \vbox} \unexpanded\def\syst_boxes_hsmashed_nextbox {\wd\nextbox\zeropoint @@ -175,8 +175,8 @@ %D \smashedvbox to ... {...} %D \stoptyping -\unexpanded\def\smashedhbox{\normalhbox\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\normalhbox} -\unexpanded\def\smashedvbox{\normalvbox\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\normalvbox} +\unexpanded\def\smashedhbox{\hbox\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\hbox} +\unexpanded\def\smashedvbox{\vbox\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\vbox} %D First we define a helper. We use a \LUATEX\ feature in order to avoid %D mathpalettes. @@ -185,7 +185,7 @@ \unexpanded\def\syst_boxes_math_set_nextbox#1% {\c_boxes_math_style\mathstyle - \setbox\nextbox\normalhbox{$\mathsurround\zeropoint\triggermathstyle\c_boxes_math_style{#1}$}} + \setbox\nextbox\hbox{$\mathsurround\zeropoint\triggermathstyle\c_boxes_math_style{#1}$}} %D \macros %D {smash} @@ -228,10 +228,10 @@ \syst_boxes_smash_process} \def\syst_boxes_smash_hbox - {\dowithnextboxcs\syst_boxes_smash_process\normalhbox} + {\dowithnextboxcs\syst_boxes_smash_process\hbox} \def\syst_boxes_smash_text#1% - {\setbox\nextbox\normalhbox{#1}% + {\setbox\nextbox\hbox{#1}% \syst_boxes_smash_process} \def\syst_boxes_smash_process @@ -277,13 +277,13 @@ \def\syst_boxes_phantom_math_v#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_v} \def\syst_boxes_phantom_math_h#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_h} -\def\syst_boxes_phantom_hbox {\dowithnextboxcs\syst_boxes_phantom_make \normalhbox} % always hbox -\def\syst_boxes_phantom_hbox_v{\dowithnextboxcs\syst_boxes_phantom_make_v\normalhbox} % always hbox -\def\syst_boxes_phantom_hbox_h{\dowithnextboxcs\syst_boxes_phantom_make_h\normalhbox} % always hbox +\def\syst_boxes_phantom_hbox {\dowithnextboxcs\syst_boxes_phantom_make \hbox} % always hbox +\def\syst_boxes_phantom_hbox_v{\dowithnextboxcs\syst_boxes_phantom_make_v\hbox} % always hbox +\def\syst_boxes_phantom_hbox_h{\dowithnextboxcs\syst_boxes_phantom_make_h\hbox} % always hbox -\def\syst_boxes_phantom_text #1{\setbox\nextbox\normalhbox{#1}\syst_boxes_phantom_make } % always hbox -\def\syst_boxes_phantom_text_v#1{\setbox\nextbox\normalhbox{#1}\syst_boxes_phantom_make_v} % always hbox -\def\syst_boxes_phantom_text_h#1{\setbox\nextbox\normalhbox{#1}\syst_boxes_phantom_make_h} % always hbox +\def\syst_boxes_phantom_text #1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make } % always hbox +\def\syst_boxes_phantom_text_v#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_v} % always hbox +\def\syst_boxes_phantom_text_h#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_h} % always hbox \def\syst_boxes_phantom_indeed {\ifmmode @@ -538,7 +538,7 @@ \unexpanded\def\doiftextelse#1% {\begingroup - \setbox\scratchbox\normalhbox + \setbox\scratchbox\hbox {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox @@ -549,7 +549,7 @@ \unexpanded\def\doiftext#1% {\begingroup - \setbox\scratchbox\normalhbox + \setbox\scratchbox\hbox {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox @@ -582,7 +582,7 @@ %D \starttyping %D \def\getfloat% %D {\def\handlefloat{...\box\nextbox...} -%D \dowithnextboxcs\handlefloat\normalvbox} +%D \dowithnextboxcs\handlefloat\vbox} %D \stoptyping %D %D instead of: @@ -626,9 +626,9 @@ %D \starttyping %D \long\def\dowithnextbox#1#2% %D {\long\def\syst_boxes_with_next_box{#1}% -%D \ifx#2\normalhbox +%D \ifx#2\hbox %D \afterassignment\syst_boxes_with_next_box_indeed -%D \else\ifx#2\normalvbox +%D \else\ifx#2\vbox %D \afterassignment\syst_boxes_with_next_box_indeed %D \else\ifx#2\normalvtop %D \afterassignment\syst_boxes_with_next_box_indeed @@ -690,13 +690,13 @@ %D Some well known friends, but we implement them our own %D way. We want the macros to work in both math and text mode. -\def\dodorlap{\normalhbox to \zeropoint{\box\nextbox\normalhss}\endgroup} -\def\dodollap{\normalhbox to \zeropoint{\normalhss\box\nextbox}\endgroup} -\def\dodoclap{\normalhbox to \zeropoint{\normalhss\box\nextbox\normalhss}\endgroup} +\def\dodorlap{\hbox to \zeropoint{\box\nextbox\normalhss}\endgroup} +\def\dodollap{\hbox to \zeropoint{\normalhss\box\nextbox}\endgroup} +\def\dodoclap{\hbox to \zeropoint{\normalhss\box\nextbox\normalhss}\endgroup} -\def\dorlap{\begingroup\dowithnextboxcs\dodorlap\normalhbox} -\def\dollap{\begingroup\dowithnextboxcs\dodollap\normalhbox} -\def\doclap{\begingroup\dowithnextboxcs\dodoclap\normalhbox} +\def\dorlap{\begingroup\dowithnextboxcs\dodorlap\hbox} +\def\dollap{\begingroup\dowithnextboxcs\dodollap\hbox} +\def\doclap{\begingroup\dowithnextboxcs\dodoclap\hbox} \def\domathclap{\mathpalette\dodomathclap} \def\dodomathclap#1#2{\doclap{$\mathsurround\zeropoint#1#2$}} \def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{$\mathsurround\zeropoint#1#2$}} @@ -706,11 +706,11 @@ \unexpanded\def\llap{\mathortext\domathllap\dollap} \unexpanded\def\clap{\mathortext\domathclap\doclap} -\def\dodotlap{\normalvbox to \zeropoint{\normalvss\box\nextbox}\endgroup} -\def\dodoblap{\normalvbox to \zeropoint{\box\nextbox\normalvss}\endgroup} +\def\dodotlap{\vbox to \zeropoint{\normalvss\box\nextbox}\endgroup} +\def\dodoblap{\vbox to \zeropoint{\box\nextbox\normalvss}\endgroup} -\unexpanded\def\tlap{\begingroup\dowithnextboxcs\dodotlap\normalvbox} -\unexpanded\def\blap{\begingroup\dowithnextboxcs\dodoblap\normalvbox} +\unexpanded\def\tlap{\begingroup\dowithnextboxcs\dodotlap\vbox} +\unexpanded\def\blap{\begingroup\dowithnextboxcs\dodoblap\vbox} %D \macros %D {beginofshapebox, @@ -757,7 +757,7 @@ %D %D \reshapebox %D {\doglobal\increment\LineNumber -%D \normalhbox{\llap{\LineNumber\hskip2em}\box\shapebox}} +%D \hbox{\llap{\LineNumber\hskip2em}\box\shapebox}} %D %D \flushshapebox %D \stopbuffer @@ -779,7 +779,7 @@ %D %D \reshapebox %D {\doglobal\increment\LineNumber -%D \normalhbox +%D \hbox %D {\llap{\LineNumber\ (\NumberOfLines)\hskip2em}% %D \box\shapebox}% %D \doglobal\decrement\NumberOfLines} @@ -802,7 +802,7 @@ %D %D \reshapebox %D {\doglobal\increment\LineNumber -%D \normalhbox{\llap{$\star$\hskip1em}\box\shapebox}% +%D \hbox{\llap{$\star$\hskip1em}\box\shapebox}% %D \doglobal\decrement\NumberOfLines} %D %D \flushshapebox @@ -866,7 +866,7 @@ \ifzeropt\ht\oldshapebox % \ifdim\ht\oldshapebox=\zeropoint \setbox\newshapebox\emptyvbox \else - \setbox\newshapebox\normalvbox + \setbox\newshapebox\vbox {\unvcopy\oldshapebox \setbox\newshapebox\emptybox \shapecounter\zerocount @@ -879,7 +879,7 @@ % We will turn this into a \MKIV\ variant. \unexpanded\def\insertshapesignal - {\normalhbox to \shapesignal{\strut\hss}% plus \strut + {\hbox to \shapesignal{\strut\hss}% plus \strut \prevdepth\strutdp} % never \nointerlineskip \unexpanded\def\restoreshapebox % compensates for the signal @@ -888,15 +888,15 @@ \def\dodoreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip {\ifnum\lastnodetype=\gluenodecode \shapeskip\lastskip - \global\setbox\tmpshapebox\normalvbox{#4\unvbox\tmpshapebox}% + \global\setbox\tmpshapebox\vbox{#4\unvbox\tmpshapebox}% \unskip \else\ifnum\lastnodetype=\kernnodecode \shapekern\lastkern - \global\setbox\tmpshapebox\normalvbox{#3\unvbox\tmpshapebox}% + \global\setbox\tmpshapebox\vbox{#3\unvbox\tmpshapebox}% \unkern \else\ifnum\lastnodetype=\penaltynodecode \shapepenalty\lastpenalty - \global\setbox\tmpshapebox\normalvbox{#2\unvbox\tmpshapebox}% + \global\setbox\tmpshapebox\vbox{#2\unvbox\tmpshapebox}% \unpenalty \else\ifnum\lastnodetype<\zeropoint \exitloop @@ -907,7 +907,7 @@ \exitloop \else \shapecounter\zerocount - \global\setbox\tmpshapebox\normalvbox{#1\unvbox\tmpshapebox}% + \global\setbox\tmpshapebox\vbox{#1\unvbox\tmpshapebox}% \fi\fi \fi\fi\fi\fi \ifnum\shapecounter>100 % can be less @@ -920,7 +920,7 @@ \fi} \unexpanded\def\beginofshapebox - {\setbox\oldshapebox\normalvbox + {\setbox\oldshapebox\vbox \bgroup \reshapingboxtrue \the\everyshapebox @@ -1006,7 +1006,7 @@ %D %D When constructing a new box, using the content of \type %D {\shapebox}, one can best use \type {\shapedhbox} instead -%D of \type {\normalhbox}, since it manages the height and depth of +%D of \type {\hbox}, since it manages the height and depth of %D the line. \unexpanded\def\shapedhbox % lines with non strutted dimensions have @@ -1014,7 +1014,7 @@ {\dp\nextbox\the\ht\shapebox % spacing, we need to preserve the original \dp\nextbox\the\dp\shapebox % height and depth which is definitely \box\nextbox}} % needed if we apply struts to the 'new' - \normalhbox} % box or do something that changed ist size + \hbox} % box or do something that changed ist size %D \macros %D {hyphenatedword, @@ -1136,16 +1136,16 @@ %D complex macro than needed at first sight. \def\dodoboundtext#1% - {\setbox0\normalhbox{#1}% + {\setbox0\hbox{#1}% \advance\scratchdimen -\wd0 \ifdim\scratchdimen>\zeropoint\relax#1\fi}% \def\doboundtext#1#2#3% still used? - {\normalhbox - {\setbox\scratchbox\normalhbox{#1}% + {\hbox + {\setbox\scratchbox\hbox{#1}% \scratchdimen#2\relax \ifdim\wd\scratchbox>\scratchdimen - \setbox\scratchbox\normalhbox{#3}% + \setbox\scratchbox\hbox{#3}% \advance\scratchdimen -\wd\scratchbox \handletokens#1\with\dodoboundtext \fi @@ -1175,7 +1175,7 @@ \forgetall % otherwise indentation and so \let\limitatetext\firstofthreearguments \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! - \dowithnextboxcs\syst_boxes_limitate_text\normalhbox} + \dowithnextboxcs\syst_boxes_limitate_text\hbox} \def\syst_boxes_limitate_text#1% #2 {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}} % {#2} @@ -1194,10 +1194,10 @@ \donetrue \fi \ifdim\wd\nextbox>\scratchdimen - \setbox\scratchbox\normalhbox{\ifdone\space#2\else#2\space\fi}% + \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}% \advance\scratchdimen -\wd\scratchbox \setbox0\box\nextbox - \setbox\nextbox\normalvbox + \setbox\nextbox\vbox {\hsize\scratchdimen \hfuzz\maxdimen \veryraggedright @@ -1209,7 +1209,7 @@ \fi \unhcopy0}% \ifdim\ht\nextbox>\strutht - \setbox\nextbox\normalvbox % if omitted: missing brace reported + \setbox\nextbox\vbox % if omitted: missing brace reported {\splittopskip\openstrutheight \ifdone \setbox\nextbox\vsplit\nextbox to \strutht @@ -1220,7 +1220,7 @@ \fi \unvbox\nextbox \setbox\nextbox\lastbox - \global\setbox1\normalhbox + \global\setbox1\hbox {\ifdone \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox \else @@ -1257,11 +1257,11 @@ {%\dontleavehmode \bgroup \let\speciallimitatetext\firstoffourarguments - \setbox0\normalhbox + \setbox0\hbox {\nohyphens \normallimitatetext{#1}{+#2}{}#4% \normallimitatetext{#1}{-#3}{}}% - \setbox2\normalhbox + \setbox2\hbox {#1}% \ifdim\wd2<\wd0 #1\else\unhbox0\fi \egroup} @@ -1314,10 +1314,10 @@ %D \startbuffer %D \processisolatedchars{some more words} \ruledhbox \par %D \processisolatedchars{and some $x + y = z$ math} \ruledhbox \par -%D \processisolatedchars{and a \normalhbox{$x + y = z$}} \ruledhbox \par +%D \processisolatedchars{and a \hbox{$x + y = z$}} \ruledhbox \par %D \processisolatedwords{some more words} \ruledhbox \par %D \processisolatedwords{and some $x + y = z$ math} \ruledhbox \par -%D \processisolatedwords{and a \normalhbox{$x + y = z$}} \ruledhbox \par +%D \processisolatedwords{and a \hbox{$x + y = z$}} \ruledhbox \par %D \stopbuffer %D %D \typebuffer \blank \getbuffer \blank @@ -1327,16 +1327,16 @@ \unexpanded\def\processisolatedchars#1#2% {\dontleavehmode \begingroup - \setbox\scratchbox\normalhbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% - \setbox\scratchbox\normalhbox{\restorecurrentattributes{pic}#1}% + \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% + \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}% \ctxcommand{applytochars(\number\scratchbox,"\strippedcsname#2",true)}% \endgroup} \unexpanded\def\processisolatedwords#1#2% {\dontleavehmode \begingroup - \setbox\scratchbox\normalhbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% - \setbox\scratchbox\normalhbox{\restorecurrentattributes{pic}#1}% + \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% + \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}% \ctxcommand{applytowords(\number\scratchbox,"\strippedcsname#2",true)}% \endgroup} @@ -1350,12 +1350,12 @@ \unexpanded\def\applytocharacters#1% {\dontleavehmode \dowithnextbox{\ctxcommand{applytochars(\number\nextbox,"\strippedcsname#1",true)}}% - \normalhbox} + \hbox} \unexpanded\def\applytowords#1% {\dontleavehmode \dowithnextbox{\ctxcommand{applytowords(\number\nextbox,"\strippedcsname#1",true)}}% - \normalhbox} + \hbox} %D \macros %D {sbox} @@ -1385,11 +1385,11 @@ %D and footers and|/|or margin material. \unexpanded\def\sbox - {\normalvbox\bgroup - \dowithnextboxcs\syst_boxes_sbox_finish\normalvbox} + {\vbox\bgroup + \dowithnextboxcs\syst_boxes_sbox_finish\vbox} \unexpanded\def\syst_boxes_sbox_finish - {\setbox\nextbox\normalhbox + {\setbox\nextbox\hbox {\strut \dp\nextbox\zeropoint \lower\strutdepth\box\nextbox}% @@ -1405,8 +1405,8 @@ %D a strut. \unexpanded\def\struttedbox - {\normalhbox\bgroup - \dowithnextboxcs\syst_boxes_struttedbox_finish\normalhbox} + {\hbox\bgroup + \dowithnextboxcs\syst_boxes_struttedbox_finish\hbox} \def\syst_boxes_struttedbox_finish {\ht\nextbox\strutdepth @@ -1422,11 +1422,11 @@ %D equals strutdepth. \unexpanded\def\topskippedbox - {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_topskippedbox_finish\normalhbox} + {\hbox\bgroup\dowithnextboxcs\syst_boxes_topskippedbox_finish\hbox} \def\syst_boxes_topskippedbox_finish {\edef\m_boxes_tmp{\ifdim\strutdepth=\dp\nextbox\dp\nextbox\the\dp\nextbox\fi}% - \lower\topskip\normalhbox{\raise\strutheight\box\nextbox}% + \lower\topskip\hbox{\raise\strutheight\box\nextbox}% \m_boxes_tmp \egroup} @@ -1478,19 +1478,19 @@ \unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen {\bgroup - \setbox0\normalvbox to \vsize + \setbox0\vbox to \vsize \bgroup \dontcomplain \forgetall - \setbox0\normalhbox{\vrule\!!width \zeropoint#1}% - \setbox2\normalvbox{\hrule\!!height\zeropoint#1}% + \setbox0\hbox{\vrule\!!width \zeropoint#1}% + \setbox2\vbox{\hrule\!!height\zeropoint#1}% \advance\vsize \ht2 \advance\hsize \wd0 - \normalvbox to \vsize + \vbox to \vsize \bgroup \vskip-\ht2 \vss - \normalhbox to \hsize + \hbox to \hsize \bgroup \dowithnextbox {\hskip-\wd0 @@ -1505,7 +1505,7 @@ \ht0\vsize \box0 \egroup} - \normalhbox} + \hbox} %D For those who don't want to deal with \type {\hsize} %D and \type {\vsize}, we have: @@ -1524,7 +1524,7 @@ \vsize\ht\nextbox \centeredbox#1{\box\nextbox}% \egroup} - \normalhbox} + \hbox} %D \macros %D {centerbox} @@ -1542,13 +1542,13 @@ {\bgroup \dowithnextbox {\setlocalhsize - \setbox\scratchbox\normalhbox{\vrule\!!width \zeropoint#1}% + \setbox\scratchbox\hbox{\vrule\!!width \zeropoint#1}% \ifzeropt\wd\scratchbox\else\hsize\wd\scratchbox\fi - \setbox\scratchbox\normalvbox{\hrule\!!height\zeropoint#1}% + \setbox\scratchbox\vbox{\hrule\!!height\zeropoint#1}% \ifzeropt\ht\scratchbox\else\vsize\ht\scratchbox\fi - \normalvbox to \vsize{\vss\normalhbox to \hsize{\hss\box\nextbox\hss}\vss}% + \vbox to \vsize{\vss\hbox to \hsize{\hss\box\nextbox\hss}\vss}% \egroup}% - \normalhbox} + \hbox} %D \macros %D {setrigidcolumnhsize,rigidcolumnbalance,rigidcolumnlines} @@ -1599,11 +1599,11 @@ {\ifnum\rigidcolumns=1 % tzt ook h/d correctie \ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi#1\relax \else - \normalvbox + \vbox {\forgetall \nopenalties \dontcomplain - \setbox\rigidcolumnbox\normalvbox + \setbox\rigidcolumnbox\vbox {\line{}\goodbreak\unvbox#1\removebottomthings}% \splittopskip\openstrutheight \setbox\scratchbox\vsplit\rigidcolumnbox to \zeropoint @@ -1632,7 +1632,7 @@ \setbox0=\box\rigidcolumnbox \doloop {\setbox\rigidcolumnbox=\copy0 - \setbox\scratchbox\normalhbox to \savedrigidhsize + \setbox\scratchbox\hbox to \savedrigidhsize {\dorecurse\rigidcolumns {\setbox\scratchbox\vsplit\rigidcolumnbox to \scratchdimen \dp\scratchbox\openstrutdepth @@ -1647,10 +1647,10 @@ \hfillneg}% \ifvoid\rigidcolumnbox\exitloop\else\advance\scratchdimen\lineheight\fi}% \iftightrigidcolumns - \setbox\scratchbox\normalhbox{\raise\dp\scratchbox\box\scratchbox}% + \setbox\scratchbox\hbox{\raise\dp\scratchbox\box\scratchbox}% \else \advance\scratchdimen -\openstrutdepth - \setbox\scratchbox\normalhbox{\raise\scratchdimen\box\scratchbox}% + \setbox\scratchbox\hbox{\raise\scratchdimen\box\scratchbox}% \dp\scratchbox\openstrutdepth \ht\scratchbox\scratchdimen \fi @@ -1665,14 +1665,14 @@ %D like: %D %D \starttyping -%D \normalvbox +%D \vbox %D \bgroup %D \startvboxtohbox ... \stopvboxtohbox %D \startvboxtohbox ... \stopvboxtohbox %D \startvboxtohbox ... \stopvboxtohbox %D \egroup %D -%D \normalvbox +%D \vbox %D \bgroup %D \convertvboxtohbox %D \egroup @@ -1692,25 +1692,25 @@ \fi \divide\scratchdimen \hsize \multiply\scratchdimen 64 - \xdef\normalvboxtohboxfactor{\withoutpt\the\scratchdimen}% + \xdef\vboxtohboxfactor{\withoutpt\the\scratchdimen}% \egroup} \unexpanded\def\startvboxtohbox {\bgroup \setvboxtohbox - \setbox\scratchbox\normalhbox\bgroup} + \setbox\scratchbox\hbox\bgroup} \unexpanded\def\stopvboxtohbox {\egroup \dp\scratchbox\zeropoint - \ht\scratchbox\normalvboxtohboxfactor\wd\scratchbox + \ht\scratchbox\vboxtohboxfactor\wd\scratchbox \box\scratchbox \egroup} \unexpanded\def\convertvboxtohbox {\setvboxtohbox \makehboxofhboxes - \setbox0\normalhbox{\unhbox0 \removehboxes}% + \setbox0\hbox{\unhbox0 \removehboxes}% \noindent\unhbox0\par} \unexpanded\def\makehboxofhboxes @@ -1718,7 +1718,7 @@ \loop % \doloop { .. \exitloop .. } \setbox2\lastbox \ifhbox2 - \setbox0\normalhbox{\box2\unhbox0}% + \setbox0\hbox{\box2\unhbox0}% \repeat} \unexpanded\def\removehboxes @@ -1743,16 +1743,16 @@ \nopenalties \dontcomplain \forgetall - \setbox\unhhedbox\normalvbox{\hskip\hhboxindent\strut\unhbox#1}% => \hsize + \setbox\unhhedbox\vbox{\hskip\hhboxindent\strut\unhbox#1}% => \hsize \doloop {\setbox\hhbox\vsplit\unhhedbox to \lineheight \ifvoid\unhhedbox - \setbox\hhbox\normalhbox{\strut\normalhboxofvbox\hhbox}% + \setbox\hhbox\hbox{\strut\hboxofvbox\hhbox}% \fi \ht\hhbox\strutht \dp\hhbox\strutdp \ifzeropt\hhboxindent\else % \ifdim\hhboxindent=\zeropoint\else - \setbox\hhbox\normalhbox{\hskip-\hhboxindent\box\hhbox}% + \setbox\hhbox\hbox{\hskip-\hhboxindent\box\hhbox}% \hhboxindent\zeropoint \fi \global\lasthhboxwidth\wd\hhbox @@ -1765,11 +1765,11 @@ \egroup} \def\dohboxofvbox - {\setbox0\normalvbox{\unvbox\scratchcounter\global\setbox1\lastbox}% + {\setbox0\vbox{\unvbox\scratchcounter\global\setbox1\lastbox}% \unhbox1 \egroup} -\unexpanded\def\normalhboxofvbox +\unexpanded\def\hboxofvbox {\bgroup \afterassignment\dohboxofvbox \scratchcounter=} @@ -1781,8 +1781,8 @@ %D headers. %D %D \startbuffer -%D \setbox0=\normalhbox{\input tufte \relax} -%D \setbox2=\normalhbox{\input knuth \relax} +%D \setbox0=\hbox{\input tufte \relax} +%D \setbox2=\hbox{\input knuth \relax} %D \unhhbox0\with{\ruledhbox{\box\hhbox}} %D \hskip1em plus 1em minus 1em %D \hhboxindent=\lasthhboxwidth @@ -1809,8 +1809,8 @@ %D \doifcontent{pre content}{post content}{no content}\somebox %D \stoptyping %D -%D Where \type{\somebox} is either a \type{\normalhbox} or -%D \type{\normalvbox}. If the dimension of this box suggest some +%D Where \type{\somebox} is either a \type{\hbox} or +%D \type{\vbox}. If the dimension of this box suggest some %D content, the resulting box is unboxed and surrounded by the %D first two arguments, else the third arguments is executed. @@ -1833,11 +1833,11 @@ %D So when we say: %D %D \startbuffer -%D \doifcontent{[}{]}{}\normalhbox{content sensitive typesetting} +%D \doifcontent{[}{]}{}\hbox{content sensitive typesetting} %D -%D \doifcontent{}{\page}{}\normalvbox{content sensitive typesetting} +%D \doifcontent{}{\page}{}\vbox{content sensitive typesetting} %D -%D \doifcontent{}{}{\message{Didn't you forget something?}}\normalhbox{} +%D \doifcontent{}{}{\message{Didn't you forget something?}}\hbox{} %D \stopbuffer %D %D \typebuffer @@ -1875,7 +1875,7 @@ % \fi} % % \def\syst_boxes_process_yes -% {\dowithnextboxcs\syst_boxes_process_content\normalhbox\bgroup} +% {\dowithnextboxcs\syst_boxes_process_content\hbox\bgroup} % % \def\syst_boxes_process_content % {\removeunwantedspaces @@ -1898,7 +1898,7 @@ \doifnextbgroupelse\syst_boxes_process_yes\syst_boxes_process_nop} \def\syst_boxes_process_yes - {\dowithnextboxcs\syst_boxes_process_content\normalhbox} + {\dowithnextboxcs\syst_boxes_process_content\hbox} \def\syst_boxes_process_content {\removeunwantedspaces @@ -1933,17 +1933,17 @@ {%\removeunwantedspaces % already done \scratchdepth\dp\ifdim\dp\nextbox>\dp\processbox\nextbox\else\processbox\fi \ifdim\ht\nextbox>\ht\processbox - \setbox\processbox\normalvbox to \ht\nextbox {\dp\processbox\zeropoint\vss\box\processbox\vss}% + \setbox\processbox\vbox to \ht\nextbox {\dp\processbox\zeropoint\vss\box\processbox\vss}% \else - \setbox\nextbox \normalvbox to \ht\processbox{\dp\nextbox \zeropoint\vss\box\nextbox \vss}% + \setbox\nextbox \vbox to \ht\processbox{\dp\nextbox \zeropoint\vss\box\nextbox \vss}% \fi \dp\nextbox \scratchdepth \dp\processbox\scratchdepth \scratchwidth\wd\ifdim\wd\nextbox>\wd\processbox\nextbox\else\processbox\fi - \setbox\processbox\normalhbox to \scratchwidth - {\normalhbox to \scratchwidth{\hss\box\processbox\hss}% + \setbox\processbox\hbox to \scratchwidth + {\hbox to \scratchwidth{\hss\box\processbox\hss}% \hskip-\scratchwidth - \normalhbox to \scratchwidth{\hss\box\nextbox \hss}}} + \hbox to \scratchwidth{\hss\box\nextbox \hss}}} \unexpanded\def\startoverlay {\bgroup @@ -1958,7 +1958,7 @@ %D The next macro is a rather silly one, but saves space. %D %D \starttyping -%D \normalhbox{\fakebox0} +%D \hbox{\fakebox0} %D \stoptyping %D %D returns an empty box with the dimensions of the box @@ -1987,16 +1987,16 @@ %D \rbox{text ...} %D \stoptyping %D -%D Are similar to \type {\normalvbox}, which means that they also +%D Are similar to \type {\vbox}, which means that they also %D accept something like \type{to 3cm}, but align to the left, %D middle and right. These box types can be used to typeset %D paragraphs. \def\syst_boxes_lrc_process#1{\bgroup\forgetall\let\\\endgraf#1\let\next} -\unexpanded\def\lbox#1#{\normalvbox#1\syst_boxes_lrc_process\raggedleft } -\unexpanded\def\cbox#1#{\normalvbox#1\syst_boxes_lrc_process\raggedcenter} -\unexpanded\def\rbox#1#{\normalvbox#1\syst_boxes_lrc_process\raggedright } +\unexpanded\def\lbox#1#{\vbox#1\syst_boxes_lrc_process\raggedleft } +\unexpanded\def\cbox#1#{\vbox#1\syst_boxes_lrc_process\raggedcenter} +\unexpanded\def\rbox#1#{\vbox#1\syst_boxes_lrc_process\raggedright } \unexpanded\def\ltop#1#{\normalvtop#1\syst_boxes_lrc_process\raggedleft } \unexpanded\def\ctop#1#{\normalvtop#1\syst_boxes_lrc_process\raggedcenter} @@ -2022,14 +2022,14 @@ %D %D \getbuffer -\unexpanded\def\tbox{\normalhbox\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\normalhbox} -\unexpanded\def\bbox{\normalhbox\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\normalhbox} +\unexpanded\def\tbox{\hbox\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox} +\unexpanded\def\bbox{\hbox\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox} \def\syst_boxes_tbox_finish {\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax \ht\nextbox\ht\strutbox \dp\nextbox\scratchdepth - \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% + \setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}% \ht\nextbox\ht\strutbox \dp\nextbox\scratchdepth \box\nextbox @@ -2039,7 +2039,7 @@ {\scratchheight\dimexpr\ht\nextbox+\dp\nextbox-\dp\strutbox\relax \dp\nextbox\dp\strutbox \ht\nextbox\scratchheight - \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% + \setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}% \dp\nextbox\dp\strutbox \ht\nextbox\scratchheight \box\nextbox @@ -2050,13 +2050,13 @@ %D %D A few more boxes. -\def\dodolhbox{\normalhbox to \hsize{\box\nextbox\hss }} -\def\dodomhbox{\normalhbox to \hsize{\hss\box\nextbox\hss}} -\def\dodorhbox{\normalhbox to \hsize{\hss\box\nextbox }} +\def\dodolhbox{\hbox to \hsize{\box\nextbox\hss }} +\def\dodomhbox{\hbox to \hsize{\hss\box\nextbox\hss}} +\def\dodorhbox{\hbox to \hsize{\hss\box\nextbox }} -\unexpanded\def\lhbox{\dowithnextboxcs\dodolhbox\normalhbox} -\unexpanded\def\mhbox{\dowithnextboxcs\dodomhbox\normalhbox} -\unexpanded\def\rhbox{\dowithnextboxcs\dodorhbox\normalhbox} +\unexpanded\def\lhbox{\dowithnextboxcs\dodolhbox\hbox} +\unexpanded\def\mhbox{\dowithnextboxcs\dodomhbox\hbox} +\unexpanded\def\rhbox{\dowithnextboxcs\dodorhbox\hbox} \let\lefthbox \lhbox \let\midhbox \mhbox @@ -2070,7 +2070,7 @@ %D additions, we can use: %D %D \starttyping -%D \boxofsize \normalvbox 10cm 3cm -5cm {the text to be typeset} +%D \boxofsize \vbox 10cm 3cm -5cm {the text to be typeset} %D \stoptyping %D %D This example demonstrates that one can use positive and @@ -2104,12 +2104,12 @@ {\dowithnextbox {\dimen0=#1\hsize \ifdim\wd\nextbox>\dimen0 - \setbox\nextbox\normalhbox + \setbox\nextbox\hbox {\advance\dimen0 -.1\hsize \limitatetext{\unhbox\nextbox}{\dimen0}{\nobreak#2}}% \fi \unhbox\nextbox} - \normalhbox} + \hbox} \unexpanded\def\fittoptobaselinegrid % weg hier {\dowithnextbox @@ -2118,7 +2118,7 @@ \dimen0\ht\nextbox \ht\nextbox\strutht \dp\nextbox\strutdp - \normalhbox{\box\nextbox} + \hbox{\box\nextbox} \prevdepth\strutdp \doloop {\advance\dimen0 -\lineheight @@ -2126,10 +2126,10 @@ \exitloop \else \nobreak - \normalhbox{\strut} + \hbox{\strut} \fi} \egroup} - \normalvbox} + \vbox} %D Some more undocumented macros (used in m-chart). @@ -2137,14 +2137,14 @@ \newbox\fakedboxcursor -\setbox\fakedboxcursor\normalhbox +\setbox\fakedboxcursor\hbox {\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint} \unexpanded\def\boxcursor % overloaded in core-vis {\iftraceboxplacement \bgroup \scratchdimen2\onepoint - \setbox\scratchbox\normalhbox to \zeropoint + \setbox\scratchbox\hbox to \zeropoint {\hss \vrule \!!width \scratchdimen @@ -2158,20 +2158,20 @@ \fi} \unexpanded\def\placedbox - {\iftraceboxplacement\ruledhbox\else\normalhbox\fi} + {\iftraceboxplacement\ruledhbox\else\hbox\fi} \newdimen\boxoffset \newdimen\boxhdisplacement \newdimen\boxvdisplacement -\unexpanded\def\rightbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox} -\unexpanded\def\leftbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox} -\unexpanded\def\topbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox} -\unexpanded\def\bottombox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox} -\unexpanded\def\lefttopbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox} -\unexpanded\def\righttopbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox} -\unexpanded\def\leftbottombox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox} -\unexpanded\def\rightbottombox{\normalhbox\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox} +\unexpanded\def\rightbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox} +\unexpanded\def\leftbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox} +\unexpanded\def\topbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox} +\unexpanded\def\bottombox {\hbox\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox} +\unexpanded\def\lefttopbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox} +\unexpanded\def\righttopbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox} +\unexpanded\def\leftbottombox {\hbox\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox} +\unexpanded\def\rightbottombox{\hbox\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox} \let\topleftbox \lefttopbox \let\toprightbox \righttopbox @@ -2237,10 +2237,10 @@ \boxcursor\hskip\boxhdisplacement\lower\boxvdisplacement\box\nextbox \egroup} -\unexpanded\def\middlebox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox} -\unexpanded\def\baselinemiddlebox{\normalhbox\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox} -\unexpanded\def\baselineleftbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox} -\unexpanded\def\baselinerightbox {\normalhbox\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox} +\unexpanded\def\middlebox {\hbox\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox} +\unexpanded\def\baselinemiddlebox{\hbox\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox} +\unexpanded\def\baselineleftbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox} +\unexpanded\def\baselinerightbox {\hbox\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox} \def\syst_boxes_middlebox_finish {\global\boxhdisplacement-.5\wd\nextbox @@ -2314,11 +2314,11 @@ %D \savebox{one}{p}{test p} %D \savebox{one}{q}{test q} %D -%D \normalhbox{a:\foundbox{one}{a}} \par -%D \normalhbox{q:\foundbox{one}{q}} \par -%D \normalhbox{p:\foundbox{one}{p}} \par -%D \normalhbox{x:\foundbox{one}{x}} \par -%D \normalhbox{y:\foundbox{two}{a}} \par +%D \hbox{a:\foundbox{one}{a}} \par +%D \hbox{q:\foundbox{one}{q}} \par +%D \hbox{p:\foundbox{one}{p}} \par +%D \hbox{x:\foundbox{one}{x}} \par +%D \hbox{y:\foundbox{two}{a}} \par %D \stoptyping \def\@@stackbox{@box@} @@ -2328,7 +2328,7 @@ {\ifcsname\@@stackbox:#1:#2\endcsname\else \expandafter\newbox\csname\@@stackbox:#1:#2\endcsname \fi - \global\setbox\csname\@@stackbox:#1:#2\endcsname\normalvbox} + \global\setbox\csname\@@stackbox:#1:#2\endcsname\vbox} \unexpanded\def\initializeboxstack#1% {\def\docommand##1{\setstackbox{#1}{##1}{}}% @@ -2348,7 +2348,7 @@ \setstackbox{#1}{#2}} \unexpanded\def\foundbox#1#2% - {\normalvbox + {\vbox {\ifcsname\@@stackbox:#1:#2\endcsname \copy\csname\@@stackbox:#1:#2\endcsname \fi}} @@ -2419,8 +2419,8 @@ %D article. %D %D \starttyping -%D \raisebox{100pt}\normalhbox{test} -%D \hsmash{\raisebox{100pt}\normalhbox{test}} +%D \raisebox{100pt}\hbox{test} +%D \hsmash{\raisebox{100pt}\hbox{test}} %D \stoptyping \unexpanded\def\raisebox#1{\bgroup\afterassignment\syst_boxes_raise_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted @@ -2430,14 +2430,14 @@ \def\syst_boxes_lower_indeed{\dowithnextboxcs\syst_boxes_lower_finish} \def\syst_boxes_raise_finish#1% - {\setbox\nextbox\normalhbox{\raise\scratchdimen\box\nextbox}% + {\setbox\nextbox\hbox{\raise\scratchdimen\box\nextbox}% \ht\nextbox\strutht \dp\nextbox\strutdp \box\nextbox \egroup} \def\syst_boxes_lower_finish#1% - {\setbox\nextbox\normalhbox{\lower\scratchdimen\box\nextbox}% + {\setbox\nextbox\hbox{\lower\scratchdimen\box\nextbox}% \ht\nextbox\strutht \dp\nextbox\strutdp \box\nextbox @@ -2446,8 +2446,8 @@ % vcenter in text, we kunnen vcenter overloaden \unexpanded\def\halfwaybox - {\normalhbox\bgroup - \dowithnextboxcs\syst_boxes_halfwaybox_finish\normalhbox} + {\hbox\bgroup + \dowithnextboxcs\syst_boxes_halfwaybox_finish\hbox} \def\syst_boxes_halfwaybox_finish {\dp\nextbox\zeropoint @@ -2461,15 +2461,15 @@ %D And even rawer: -\let\naturalhbox \normalhbox -\let\naturalvbox \normalvbox +\let\naturalhbox \hbox +\let\naturalvbox \vbox \let\naturalvtop \normalvtop \let\naturalvcenter\normalvtop \ifdefined\textdir - \unexpanded\def\naturalhbox{\normalhbox dir TLT} - \unexpanded\def\naturalvbox{\normalvbox dir TLT} + \unexpanded\def\naturalhbox{\hbox dir TLT} + \unexpanded\def\naturalvbox{\vbox dir TLT} %\unexpanded\def\naturalvtop{\normalvtop dir TLT} \fi @@ -2479,14 +2479,12 @@ %D %D Also new: tex mode \type {\vcenter}. -\let\verynormalvcenter \vcenter % since \vcenter can be visualized - \unexpanded\def\vcenter - {\normalvbox\bgroup - \dowithnextboxcs\syst_boxes_vcenter_finish\normalvbox} + {\vbox\bgroup + \dowithnextboxcs\syst_boxes_vcenter_finish\vbox} \def\syst_boxes_vcenter_finish - {\normalhbox{$\verynormalvcenter{\box\nextbox}$}% + {\hbox{$\normalvcenter{\box\nextbox}$}% \egroup} % could be \everymathematics @@ -2500,11 +2498,11 @@ %D A not so well unhboxable box can be made with: \unexpanded\def\frozenhbox - {\normalhbox\bgroup - \dowithnextboxcs\syst_boxes_frozenhbox_finish\normalhbox} + {\hbox\bgroup + \dowithnextboxcs\syst_boxes_frozenhbox_finish\hbox} \def\syst_boxes_frozenhbox_finish - {\normalhbox{\normalhbox{\box\nextbox}}% + {\hbox{\hbox{\box\nextbox}}% \egroup} %D \macros diff --git a/tex/context/base/supp-num.mkiv b/tex/context/base/supp-num.mkiv index a9211d62b..be0df026d 100644 --- a/tex/context/base/supp-num.mkiv +++ b/tex/context/base/supp-num.mkiv @@ -95,7 +95,7 @@ %D the grouped call, the other branch handles the fuzzy %D delimited calls. -\ifx\mbox\undefined \let\mbox\normalhbox \fi +\ifdefined\mbox \else \let\mbox\hbox \fi \unexpanded\def\digits {\bgroup diff --git a/tex/context/base/symb-ini.mkiv b/tex/context/base/symb-ini.mkiv index 7e5f34b2e..af9c14c00 100644 --- a/tex/context/base/symb-ini.mkiv +++ b/tex/context/base/symb-ini.mkiv @@ -46,6 +46,9 @@ \installcorenamespace{symbol} \installcorenamespace{symbolset} +\let\currentsymbol \empty +\let\currentsymbolset\empty + \newtoks\t_symb_setups \let\m_symb_current_set\empty @@ -71,9 +74,9 @@ \letvalue{\??symbolset}\empty -\def\doifinsymbolsetelse#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} -\def\doifinsymbolset #1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi} -\def\doifsymbolsetelse #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\unexpanded\def\doifinsymbolsetelse#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\unexpanded\def\doifinsymbolset #1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi} +\unexpanded\def\doifsymbolsetelse #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} \def\symbolset#1{\csname\??symbolset\ifcsname\??symbolset#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc @@ -97,21 +100,34 @@ \expandafter\symb_place_special \fi} -\def\symb_place_normal[#1][#2]% - {\setfalse\c_symb_found - \ifsecondargument - \edef\currentsymbol{#2}% - \ifcsname\??symbol#1:#2\endcsname - \symb_place_indeed{#1:#2}% - \fi +\def\symb_place_normal + {\ifsecondargument + \expandafter\symb_place_normal_a + \else + \expandafter\symb_place_normal_b + \fi} + +\def\symb_place_normal_a[#1][#2]% + {\edef\currentsymbol{#2}% + \ifcsname\??symbol#1:#2\endcsname + \symb_place_indeed{#1:#2}% + \else + \symb_place_normal_c + \fi} + +\def\symb_place_normal_b[#1][#2]% + {\edef\currentsymbol{#1}% + \ifcsname\??symbol\currentsymbolset:#1\endcsname + \symb_place_indeed{\currentsymbolset:#1}% \else - \edef\currentsymbol{#1}% - \fi + \symb_place_normal_c + \fi} + +\def\symb_place_normal_c + {\setfalse\c_symb_found + \the\t_symb_setups \ifconditional\c_symb_found \else - \the\t_symb_setups - \ifconditional\c_symb_found \else - \symb_place_retry\currentsymbol - \fi + \symb_place_retry\currentsymbol % hm, isn't this redundant? \fi} \def\symb_place_special[#1][#2]#3% @@ -131,7 +147,7 @@ \def\directsymbol#1#2% no \relax, there can be an argument, see lists {\csname\??symbol\ifcsname\??symbol#1:#2\endcsname#1:#2\fi\endcsname} -\def\symb_fetch +\unexpanded\def\symb_fetch {\ifconditional\c_symb_found \expandafter\gobbleoneargument \else @@ -247,6 +263,8 @@ %D \showsetup{setupsymbolset} %D \showsetup{startsymbolset} +\installcorenamespace{symbolsets} + \unexpanded\def\startsymbolset[#1]% {\pushmacro\m_symb_current_set \def\m_symb_current_set{#1}} @@ -255,7 +273,14 @@ {\popmacro\m_symb_current_set} \unexpanded\def\setupsymbolset[#1]% - {\prependtoksonce\symb_fetch{#1}\to\t_symb_setups} + {\edef\currentsymbolset{#1}% + \ifcsname\??symbolsets\currentsymbolset\endcsname \else + \symb_setup_symbol_set + \fi} + +\def\symb_setup_symbol_set + {\normalexpanded{\t_symb_setups{\symb_fetch{\currentsymbolset}\the\t_symb_setups}}% + \letvalue{\??symbolsets\currentsymbolset}\empty} % speedup \unexpanded\def\resetsymbolset {\t_symb_setups\emptytoks} diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 4c02939ad..7f680bfae 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -140,24 +140,15 @@ \def\s!empty {empty} -%D \macros -%D {doubleexpandafter,tripleexpandafter,expanded,startexpanded} -%D -%D When in unprotected mode, to be entered with -%D \type{\unprotect}, one can use \type{\@EA} as equivalent -%D of \type{\expandafter}. +%D These are not needed any more now that we have wide screens (and +%D bytes come cheap). -\let\singleexpandafter \expandafter -\def\doubleexpandafter{\expandafter\expandafter\expandafter} -\def\tripleexpandafter{\expandafter\doubleexpandafter\expandafter} - -%D not needed any more now that we have wide screens +\let\@EA \singleexpandafter +\let\@EAEAEA \doubleexpandafter +\let\@EAEAEAEAEAEA\tripleexpandafter \let\@NX \noexpand -\let\@EA \expandafter \def\@EAEA {\expandafter\expandafter} % can often be avoided -\let\@EAEAEA \doubleexpandafter -\let\@EAEAEAEAEAEA\tripleexpandafter %D Sometimes we pass macros as arguments to commands that %D don't expand them before interpretation. Such commands can @@ -835,11 +826,15 @@ % !9yes=\doifcommonelse{,a,}{,,,a,}{yes}{nop} % !9yes=\doifcommonelse{,,a,}{,,,a,}{yes}{nop} +\let\m_syst_common_a\empty +\let\m_syst_common_b\empty +\let\m_syst_common_c\empty + \def\syst_helpers_do_quit_if_common_else#1],\relax#2],\relax{\firstoftwoarguments} \def\syst_helpers_do_check_if_common_else_one#1,#2% - {\edef\!!stringc{#1}% - \ifx\!!stringc\v_syst_helpers_right_optional_bracket + {\edef\m_syst_common_c{#1}% + \ifx\m_syst_common_c\v_syst_helpers_right_optional_bracket \expandafter\thirdofthreearguments \else \expandafter\syst_helpers_do_common_check @@ -861,7 +856,7 @@ \fi} \def\syst_helpers_do_do_do_check_if_common_else_two - {\ifx\!!stringc\commalistelement + {\ifx\m_syst_common_c\commalistelement \expandafter\syst_helpers_do_quit_if_common_else \else \expandafter\syst_helpers_do_check_if_common_else_two @@ -869,24 +864,24 @@ \def\syst_helpers_re_do_check_if_common_else_one#1{\syst_helpers_do_check_if_common_else_one} +\def\syst_helpers_do_common_check + {\expandafter\syst_helpers_do_check_if_common_else_two\m_syst_common_b,],\relax}% + +\def\syst_helpers_do_do_do_if_common_else + {\expandafter\syst_helpers_do_check_if_common_else_one\m_syst_common_a,],\relax} + \def\syst_helpers_do_do_if_common_else#1#2#3#4% - {\edef\!!stringa{#3}% - \edef\!!stringb{#4}% - \ifx\!!stringa\empty + {\edef\m_syst_common_a{#3}% + \edef\m_syst_common_b{#4}% + \ifx\m_syst_common_a\empty \expandafter\secondoftwoarguments - \else\ifx\!!stringb\empty + \else\ifx\m_syst_common_b\empty \expandafter\expandafter\expandafter\secondoftwoarguments \else \expandafter\expandafter\expandafter\syst_helpers_do_do_do_if_common_else \fi\fi #1#2} -\def\syst_helpers_do_common_check - {\expandafter\syst_helpers_do_check_if_common_else_two\!!stringb,],\relax}% - -\def\syst_helpers_do_do_do_if_common_else - {\expandafter\syst_helpers_do_check_if_common_else_one\!!stringa,],\relax} - \unexpanded\def\doifcommonelse{\syst_helpers_do_do_if_common_else\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifcommon {\syst_helpers_do_do_if_common_else\firstofoneargument \gobbleoneargument } \unexpanded\def\doifnotcommon {\syst_helpers_do_do_if_common_else\gobbleoneargument \firstofoneargument } @@ -3281,80 +3276,6 @@ \fi} %D \macros -%D {newconditional, -%D settrue, setfalse, -%D ifconditional,then} -%D -%D \TEX's lacks boolean variables, although the \PLAIN\ format -%D implements \type{\newif}. The main disadvantage of this -%D scheme is that it takes three hash table entries. A more -%D memory saving alternative is presented here. A conditional -%D is defined by: -%D -%D \starttyping -%D \newconditional\doublesided -%D \setfalse -%D \stoptyping -%D Setting a conditional is done by \type{\settrue} and -%D \type{\setfalse}: -%D -%D \starttyping -%D \settrue\doublesided -%D \setfalse -%D \stoptyping -%D while testing is accomplished by: -%D -%D \starttyping -%D \ifconditional\doublesided ... \else ... \fi -%D \setfalse -%D \stoptyping -%D We cannot use the simple scheme: -%D -%D \starttyping -%D \def\settrue #1{\let#1=\iftrue} -%D \def\setfalse#1{\let#1=\iffalse} -%D \stoptyping -%D -%D Such an implementation gives problems with nested -%D conditionals. The next implementation is abaou as fast -%D and just as straightforward: - -% maybe reserve special zero and plusone - -\unexpanded\def\settrue #1{\let#1\zerocount} -\unexpanded\def\setfalse#1{\let#1\plusone } - -\let\newconditional\setfalse -\let\ifconditional \ifcase - -\let\conditionalfalse\plusone -\let\conditionaltrue \zerocount - -\let\then\relax % so that we can say: \ifnum1>2\then -) - -% demands that each conditional is defined .. it would be handy to have -% a primitive \unless\ifcase .. then we could use better values -% -% \def\settrue #1{#1\zerocount} -% \def\setfalse#1{#1\plusone} -% -% \def\newconditional#1{\ifdefined#1\else\newcount#1\fi\setfalse#1} -% \let\ifconditional \ifcase - -%D \macros -%D {ifzeropt} -%D -%D The next macro is both cosmetic and byte saving. It is -%D pretty \type{\if}||safe too. It can be used in cases -%D like: -%D -%D \starttyping -%D \ifzeropt \somedimen ... \else ... \fi -%D \stoptyping - -\let\ifzeropt\ifcase - -%D \macros %D {dorecurse,recurselevel,recursedepth, %D dostepwiserecurse, %D for} @@ -3919,7 +3840,7 @@ \def\docheckifassignmentelse#1=#2#3\@end@{\if#2@}% -\def\doifassignmentelse#1% +\def\doifassignmentelse#1% expandable {\expandafter\docheckifassignmentelse\detokenize{#1}=@@\@end@ \expandafter\secondoftwoarguments \else @@ -6211,19 +6132,35 @@ {\setdimensionwithunit\scratchdimen#1{#2}\edef#1{\the\scratchdimen}} %D \macros -%D {doifsometokselse} +%D {doifsometokselse, doifsometoks} %D %D Not that fast I guess, but here's a way to test for token %D registers being empty. -\def\doifsometokselse#1% % #2#3% - {\edef\!!stringa{\the#1}% - \ifx\!!stringa\empty % #3\else#2\fi} +\def\doifsometokselse#1% + {\edef\!!stringa{\the#1}% one level expansion so quite ok + \ifx\!!stringa\empty \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments \fi} +\def\doifsometoks#1% + {\edef\!!stringa{\the#1}% one level expansion so quite ok + \ifx\!!stringa\empty + \expandafter\gobbleoneargument + \else + \expandafter\firstofoneargument + \fi} + +\def\doifemptytoks#1% + {\edef\!!stringa{\the#1}% one level expansion so quite ok + \ifx\!!stringa\empty + \expandafter\firstofoneargument + \else + \expandafter\gobbleoneargument + \fi} + %D \macros %D {startstrictinspectnextcharacter} %D @@ -6604,7 +6541,7 @@ \doubleexpandafter\firstofoneargument \fi\fi} -\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey % [bypasses k!prefix] +\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey {\expandafter\def\csname#1#3\expandafter\endcsname\expandafter{\csname#1#5\endcsname}} % \buildarray[test][aa,bb,cc,dd,ee,ff] diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index f0cd6ec0b..bcf15b96c 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -399,6 +399,15 @@ \newcount \maxcard \maxcard = 65536 % pdftex has less mathchars \fi +%D \macros +%D {doubleexpandafter,tripleexpandafter,expanded,startexpanded} +%D +%D A few handy shortcuts + +\let\singleexpandafter \expandafter +\def\doubleexpandafter{\expandafter\expandafter\expandafter} +\def\tripleexpandafter{\expandafter\doubleexpandafter\expandafter} + %D We prefer the more readable variant than in plain %D \TEX. User should only use \type {\emptybox}: @@ -653,6 +662,74 @@ \normaleveryjob{\the\everyjob} +%D \macros +%D {newconditional, +%D settrue, setfalse, +%D ifconditional,then} +%D +%D \TEX's lacks boolean variables, although the \PLAIN\ format +%D implements \type{\newif}. The main disadvantage of this +%D scheme is that it takes three hash table entries. A more +%D memory saving alternative is presented here. A conditional +%D is defined by: +%D +%D \starttyping +%D \newconditional\doublesided +%D \setfalse +%D \stoptyping +%D Setting a conditional is done by \type{\settrue} and +%D \type{\setfalse}: +%D +%D \starttyping +%D \settrue\doublesided +%D \setfalse +%D \stoptyping +%D while testing is accomplished by: +%D +%D \starttyping +%D \ifconditional\doublesided ... \else ... \fi +%D \setfalse +%D \stoptyping +%D We cannot use the simple scheme: +%D +%D \starttyping +%D \def\settrue #1{\let#1=\iftrue} +%D \def\setfalse#1{\let#1=\iffalse} +%D \stoptyping +%D +%D Such an implementation gives problems with nested +%D conditionals. The next implementation is about as fast +%D and just as straightforward: + +\let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef +\let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef + +\normalprotected\def\settrue #1{\let#1\conditionaltrue } +\normalprotected\def\setfalse#1{\let#1\conditionalfalse} + +\let\newconditional\setfalse +\let\ifconditional \ifcase + +\let\then\relax % so that we can say: \ifnum1>2\then -) + +%D It would be handy to have a primitive \unless\ifcase because +%D then we could use nicer values. Anyhow, this conditional code +%D used to be in the \type {syst-aux} module but is now promoted +%D to here. + +%D \macros +%D {ifzeropt} +%D +%D The next macro is both cosmetic and byte saving. It is +%D pretty \type{\if}||safe too. It can be used in cases +%D like: +%D +%D \starttyping +%D \ifzeropt \somedimen ... \else ... \fi +%D \stoptyping + +\let\ifzeropt\ifcase + % these token list helpers might move to syst-aux.mkiv % % we assume a \cs. not toks0 or so diff --git a/tex/context/base/type-fbk.mkiv b/tex/context/base/type-fbk.mkiv new file mode 100644 index 000000000..e8413ec9f --- /dev/null +++ b/tex/context/base/type-fbk.mkiv @@ -0,0 +1,70 @@ +%D \module +%D [ file=type-sfbk, +%D version=2005.02.04, % moved from ini/def/set +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Fallbacks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\definetypescriptprefix [serif] [Serif] +\definetypescriptprefix [sans] [Sans] +\definetypescriptprefix [mono] [Mono] + +\definefontsynonym [DefaultFont] [\s!file:lmmonoprop10-regular] % was cmvtt10 + +\startsetups [font:fallback:serif] + \definefontsynonym [Serif] [DefaultFont] + \definefontsynonym [SerifBold] [Serif] + \definefontsynonym [SerifItalic] [Serif] + \definefontsynonym [SerifSlanted] [SerifItalic] + \definefontsynonym [SerifBoldItalic] [Serif] + \definefontsynonym [SerifBoldSlanted] [SerifBoldItalic] + \definefontsynonym [SerifCaps] [Serif] +\stopsetups + +\startsetups [font:fallback:sans] + \definefontsynonym [Sans] [DefaultFont] + \definefontsynonym [SansBold] [Sans] + \definefontsynonym [SansItalic] [Sans] + \definefontsynonym [SansSlanted] [SansItalic] + \definefontsynonym [SansBoldItalic] [Sans] + \definefontsynonym [SansBoldSlanted] [SansBoldItalic] + \definefontsynonym [SansCaps] [Sans] +\stopsetups + +\startsetups [font:fallback:mono] + \definefontsynonym [Mono] [DefaultFont] + \definefontsynonym [MonoBold] [Mono] + \definefontsynonym [MonoItalic] [Mono] + \definefontsynonym [MonoSlanted] [MonoItalic] + \definefontsynonym [MonoBoldItalic] [Mono] + \definefontsynonym [MonoBoldSlanted] [MonoBoldItalic] + \definefontsynonym [MonoCaps] [Mono] +\stopsetups + +\starttypescript [serif,sans,mono] [fallback] + \setups[\s!font:\s!fallback:\typescriptone] +\stoptypescript + +\startsetups [font:allbold:serif] + \definefontsynonym [Serif] [SerifBold] + \definefontsynonym [SerifItalic] [SerifBoldItalic] + \definefontsynonym [SerifSlanted] [SerifBoldSlanted] + %definefontsynonym [SerifCaps] [SerifBold] +\stopsetups + +\startsetups [font:allbold:sans] + \definefontsynonym [Sans] [SansBold] + \definefontsynonym [SansItalic] [SansBoldItalic] + \definefontsynonym [SansSlanted] [SansBoldSlanted] + %definefontsynonym [SansCaps] [SansBold] +\stopsetups + +\protect \endinput diff --git a/tex/context/base/type-ini.mkiv b/tex/context/base/type-ini.mkiv deleted file mode 100644 index f0b20cbed..000000000 --- a/tex/context/base/type-ini.mkiv +++ /dev/null @@ -1,540 +0,0 @@ -%D \module -%D [ file=type-ini, -%D version=2001.03.05, -%D title=\CONTEXT\ Typescript Macros, -%D subtitle=Initialization, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Typescript Macros / Initialization} - -\registerctxluafile{type-ini}{1.001} - -%D The default fontclass is empty. We could demand always using fontclasses, -%D and then make the calling macros simplier (always assume fontclass) but -%D apart from downward compatibility issues, it would make global, class -%D spanning definitions a pain. Some day we will introduce a default class. - -%D Todo: store them at the lua end - -\unprotect - -\unexpanded\def\starttypescriptcollection - {\dosingleempty\dostarttypescriptcollection} - -\def\dostarttypescriptcollection[#1]% - {} - -\unexpanded\def\stoptypescriptcollection - {} - -\let\typescriptfiles\empty - -\unexpanded\def\usetypescriptfile[#1]% - {\doifelse{#1}\v!reset - {\let\typescriptfiles\empty} - {\splitfilename{#1}% - \addtocommalist\splitoffbase\typescriptfiles}} - -% SO FAR - -\let\currenttypescripts\empty - -\newif\iftypescriptfound - -\let\@@typescriptone \empty \let\typescriptone \empty -\let\@@typescripttwo \empty \let\typescripttwo \empty -\let\@@typescriptthree\empty \let\typescriptthree\empty - -% method 2 is for Hans van der Meer - -\newtoks\documenttypescripts - -% tricky ... here we push/pop - -\chardef\typescriptmethod\plusone % 1: empty==all==true 2: empty==false -\chardef\typescriptstate \plustwo % 1: process 2: store - -\unexpanded\def\usetypescript {\let\typescriptmethod\plusone\dotripleempty\dousetypescript} -\unexpanded\def\usetypescriptexact{\let\typescriptmethod\plustwo\dotripleempty\dousetypescript} - -\def\dousetypescript[#1][#2][#3]% - {\normalexpanded{\noexpand\dodousetypescript[#1][#2][#3]}} - -\def\dodousetypescript[#1][#2][#3]% also loads type-loc, a user file - {\pushmacro\@@typescriptone \edef\@@typescriptone {\truetypescript{#1}}% - \pushmacro\@@typescripttwo \edef\@@typescripttwo {\truetypescript{#2}}% - \pushmacro\@@typescriptthree\edef\@@typescriptthree{\truetypescript{#3}}% - \pushmacro\typescriptone - \pushmacro\typescripttwo - \pushmacro\typescriptthree - \pushmacro\typescriptmethod - \pushmacro\typescriptstate \let\typescriptstate\plusone % process - \pushmacro\stoptypescript - \typescriptfoundfalse - \iftracetypescripts\writestatus\m!fonts{request: [\@@typescriptone] [\@@typescripttwo] [\@@typescriptthree]}\fi - \processcommacommand[\typescriptfiles]\dododousetypescriptfile - \the\documenttypescripts - \firsttypescriptpassfalse % testen - \popmacro\stoptypescript - \popmacro\typescriptstate - \popmacro\typescriptmethod - \popmacro\typescriptthree - \popmacro\typescripttwo - \popmacro\typescriptone - \popmacro\@@typescriptthree - \popmacro\@@typescripttwo - \popmacro\@@typescriptone} - -\newconditional\preloadingtypescripts - -\def\preloadtypescripts{\ifproductionrun\settrue\preloadingtypescripts\fi} - -\prependtoks - \preloadtypescripts -\to \everyjob - -% \long\def\xxstarttypescript#1\stoptypescript -% {\global\loadedtypescripts\@EA{\the\loadedtypescripts\starttypescript#1\stoptypescript}} -% -% \long\def\xxstarttypescriptcollection#1\stoptypescriptcollection -% {\global\loadedtypescripts\@EA{\the\loadedtypescripts\starttypescriptcollection#1\stoptypescriptcollection}} - -\newcount\nofpreloadedtypescripts % it's faster to append references than blobs - -\long\def\xxstarttypescript#1\stoptypescript - {\global\advance\nofpreloadedtypescripts\plusone - \edef\currentpreloadedtypescript{\??ts:\the\nofpreloadedtypescripts}% - \setgvalue\currentpreloadedtypescript{\starttypescript#1\stoptypescript}% - %\global\loadedtypescripts\@EAEAEA{\@EA\the\@EA\loadedtypescripts\@EA\getvalue\@EA{\currentpreloadedtypescript}}} - \normalexpanded{\global\loadedtypescripts{\the\@EA\loadedtypescripts\noexpand\csname\currentpreloadedtypescript\endcsname}}} - -\long\def\xxstarttypescriptcollection#1\stoptypescriptcollection - {\global\advance\nofpreloadedtypescripts\plusone - \edef\currentpreloadedtypescript{\??ts:\the\nofpreloadedtypescripts}% - \setgvalue\currentpreloadedtypescript{\starttypescriptcollection#1\stoptypescriptcollection}% - %\global\loadedtypescripts\@EAEAEA{\@EA\the\@EA\loadedtypescripts\@EA\getvalue\@EA{\currentpreloadedtypescript}}} - \normalexpanded{\global\loadedtypescripts{\the\@EA\loadedtypescripts\noexpand\csname\currentpreloadedtypescript\endcsname}}} - -\def\dododousetypescriptfile#1% - {\setfalse\quittingtypescript - \pushmacro\currenttypefile - \def\currenttypefile{#1}% - \ifconditional\preloadingtypescripts - \doprocessandbuffertypescriptfile - \else - \doprocesstypescriptfile - \fi - \popmacro\currenttypefile - \ifconditional\quittingtypescript - \quitcommalist - \setfalse\quittingtypescript - \fi} - -\def\doprocessandbuffertypescriptfile - {\expandafter\let\expandafter\loadedtypescripts\csname\??ts:\c!file:\currenttypefile\endcsname - \ifx\loadedtypescripts\relax - \dobuffertypescriptfile - \fi - \the\loadedtypescripts} - -\def\dobuffertypescriptfile - {\newtoks\loadedtypescripts - \bgroup - \let\starttypescript\xxstarttypescript - \let\starttypescriptcollection\xxstarttypescriptcollection - \doprocesstypescriptfile - \egroup - \expandafter\let\csname\??ts:\c!file:\currenttypefile\endcsname\loadedtypescripts} - -\def\doprocesstypescriptfile - {\ctxcommand{doprocesstypescriptfile("\currenttypefile")}} - -\def\usetypescriptonce - {\dotripleempty\dousetypescriptonce} - -\def\dousetypescriptonce[#1][#2][#3]% - {\doifelseflagged{ts:#1:#2:#3}% - {\writestatus\m!fonts{once (#1) (#2) (#3)}} - {\setflag{ts:#1:#2:#3}% - \normalexpanded{\noexpand\dodousetypescript[#1][#2][#3]}}} - -% \definetypescriptsynonym[lbr][cmr] - -\unexpanded\def\definetypescriptsynonym - {\dodoubleempty\dodefinetypescriptsynonym} - -\def\dodefinetypescriptsynonym[#1][#2]% - {\ifsecondargument\setevalue{\??tm#1}{#2}\fi} - -\def\truetypescript#1% - {\ifcsname\??tm#1\endcsname - \@EA\truetypescript\csname\??tm#1\endcsname\else#1% - \fi} - -% script [serif] [default] [size] -% script [serif] [computer-modern] [size] -% script [serif] [computer-modern] [ec] -% script [serif] [computer-modern] [name] -% script [serif] [computer-modern] [special] - -% todo, make firsttypescriptpass conditional - -\newif\iffirsttypescriptpass \firsttypescriptpasstrue - -\prependtoks\firsttypescriptpasstrue\to\everyjob - -\def\typescript@@all{all} - -\newif\iftracetypescripts - -\let\stoptypescript\relax - -\unexpanded\def\starttypescript - {\ifcase\typescriptstate - % 0 = skip - \@EA\gobbleuntil\@EA\stoptypescript - \or - % 1 = process - \expandafter\dostarttypescript - \or - % 2 = store - \expandafter\nostarttypescript - \else - % ? = skip - \@EA\gobbleuntil\@EA\stoptypescript - \fi} - -\long\def\nostarttypescript#1\stoptypescript - {\appendtoks\starttypescript#1\stoptypescript\to\documenttypescripts} - -\def\dostarttypescript - {\let\typescriptone \@@typescriptone - \let\typescripttwo \@@typescripttwo - \let\typescriptthree\@@typescriptthree - \let\typescriptmatch\empty - \doifnextoptionalelse\dostarttypescriptone\dostarttypescriptall} - -\long\def\dostarttypescriptall - {\iffirsttypescriptpass - \expandafter\doprocesstypescript - \else - % skip this since it may do unwanted resets, like - % setting symbolic font names to unknown, especially - % in run time user type scripts - \expandafter\noprocesstypescript - \fi} - -\def\typescriptwritestatus - {\writestatus\m!fonts{match:\ifx\currenttypefile\relax\space *\fi \typescriptmatch}} - -\long\def\dostarttypescriptyes - {\ifdone - \typescriptfoundtrue - \iftracetypescripts\typescriptwritestatus\fi - \expandafter\doprocesstypescript - \else - \expandafter\noprocesstypescript - \fi} - -\long\def\dostarttypescriptone - {\dochecktypescript\@@typescriptone\typescriptone\redostarttypescriptone} - -\long\def\dostarttypescripttwo - {\dochecktypescript\@@typescripttwo\typescripttwo\redostarttypescripttwo} - -\long\def\dostarttypescriptthree - {\dochecktypescript\@@typescriptthree\typescriptthree\redostarttypescriptthree} - -\long\def\redostarttypescriptone - {\doifnextoptionalelse\dostarttypescripttwo\dostarttypescriptyes} - -\long\def\redostarttypescripttwo - {\doifnextoptionalelse\dostarttypescriptthree\dostarttypescriptyes} - -\long\def\redostarttypescriptthree - {\dostarttypescriptyes} - -\def\doprocesstypescript - {\pushmacro\fontclass} - -\unexpanded\def\stoptypescript - {\popmacro\fontclass} - -\long\def\noprocesstypescript#1\stoptypescript - {} - -\let\typescriptmatch\empty - -\def\dochecktypescript#1#2#3[#4]% script use value next - {\donefalse - \def\@@typescriptcheck{#4}% - \ifx\@@typescriptcheck\empty % no longer needed / met - \ifcase\typescriptmethod\or\donetrue\fi - \else\ifx#1\typescript@@all - \donetrue - \else\ifx\@@typescriptcheck\typescript@@all - \donetrue - \else\ifx#1\@@typescriptcheck % saves 10% trace so probably faster too - \donetrue - \let#2\@@typescriptcheck - \else - \normalexpanded{\noexpand\doifcommonelse{\@@typescriptcheck}{#1}}\donetrue\donefalse - \ifdone - \let#2\commalistelement - \fi - \fi\fi\fi\fi - \ifdone - \edef\typescriptmatch{\typescriptmatch\space[#4]}% - \expandafter#3% - \else - \expandafter\noprocesstypescript - \fi} - -%D Yet another speed up: when issued inside typescript, the call -%D -%D \starttyping -%D \quittypescriptscanning -%D \stoptyping -%D -%D quits further loading. For an example, see type-exa: - -\newconditional\quittingtypescript \setfalse\quittingtypescript - -\def\quittypescriptscanning{\settrue\quittingtypescript} - -%D Map files will go away in \LUATEX, but till that happens we -%D use stripped down support for loading them. - -\def\loadmapfile{\dosingleempty\doloadmapfile} -\def\loadmapline{\dodoubleempty\doloadmapline} - -\def\doloadmapfile [#1]{\ctxlua{fonts.mappings.loadfile("#1")}} -\def\doloadmapline [#1][#2]{\ctxlua{fonts.mappings.loadline("#1","#2")}} -\def\forgetmapfiles {\ctxlua{fonts.mappings.reset()}} - -% \appendtoks -% \pdfmapfile{}% somehow does not work at the lua end -% \to \everyjob - -\prependtoks - \loadmapfile[mkiv-base.map]% -\to \everystarttext - -%D A handy shortcut: - -% \definetypescriptprefix[serif][Serif] -% \definetypescriptprefix[sans] [Sans] -% \definetypescriptprefix[mono] [Mono] -% -%\starttypescript [serif,sans,mono] [handling,hanging,hz] [pure,normal,hz,quality] -% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree] -% \stoptypescript - -\unexpanded\def\definetypescriptprefix - {\dodoubleargument\dodefinetypescriptprefix} - -\def\dodefinetypescriptprefix[#1][#2]% - {\setgvalue{\??ts::#1}{#2}} % made global - -% without testing: -% -% \def\typescriptprefix#1% -% {\csname\??ts::#1\endcsname} -% -% with testing: - -\def\typescriptprefix#1% - {\executeifdefined{\??ts::#1}{#1}} - -% defining typefaces: -% -% \definetypeface [#1:joke] [#2:rm] -% \definetypeface [#1:joke] [#2:rm] [#3:...] -% \definetypeface [#1:joke] [#2:rm] [#3:serif] [#4:lucida] [#5:size] [#6:...] - -\unexpanded\def\definetypeface - {\dosixtupleargument\dodefinetypeface} - -\def\tsvar#1#2% \executeifdefined{\??ts#1}{#2} - {\@EA\ifx\csname\??ts#1\endcsname\empty - #2% - \else - \csname\??ts#1\endcsname - \fi} - -% #1=main #2=rm #3=serif #4=fontname #5=size #6=settings - -\let\typefaceencoding\s!default % obsolete - -\newtoks \everybeforedefinetypeface -\newtoks \everyafterdefinetypeface - -\appendtoks - \resetfontclassmathfamilies\fontclass -\to \everybeforedefinetypeface - -\let\fontclassstyle\empty - -\def\dostarttypefacedefining#1#2#3% - {\geteparameters[\??ts][\s!rscale=\plusone,\s!features=,\s!fallbacks=,\s!goodies=,\s!direction=,#3]% - \pushmacro\fontclass - \pushmacro\fontclassstyle - \setcurrentfontclass{#1}% - \pushmacro\relativefontsize - \let\relativefontsize\@@tsrscale % still needed ? - \savefontclassparameters{#2}\@@tsrscale\@@tsfeatures\@@tsfallbacks\@@tsgoodies\@@tsdirection - \the\everybeforedefinetypeface} - -\def\dostoptypefacedefining - {\the\everyafterdefinetypeface - \popmacro\relativefontsize - \popmacro\fontclassstyle - \popmacro\fontclass} - -\def\dofastdefinetypeface#1#2#3#4#5% - {\dododefinetypeface[#1][#2]% - \dostarttypefacedefining{#1}{#2}{#5}% - \usetypescript[#3][#4][\s!size]% - \dostoptypefacedefining} - -\def\dodefinetypeface[#1][#2][#3][#4][#5][#6]% - {\iffifthargument % sixth is optional, we need to expand since in #6 there can be a \typescripttwo - \iftracetypescripts\writestatus\m!fonts{define: [#1] [#2] [#3] [#4]}\fi - \dododefinetypeface[#1][#2]% - \dostarttypefacedefining{#1}{#2}{#6}% - \usetypescript[#3][#4][\s!name,\s!default]% - \usetypescript[#3][#5][\s!size]% - \dostoptypefacedefining - \else\iffourthargument - \iftracetypescripts\writestatus\m!fonts{define: [#1] [#2] [#3] [#4]}\fi - \dododefinetypeface[#1][#2]% - \dostarttypefacedefining{#1}{#2}{}% - \usetypescript[#3][#4][\s!name,\s!default]% - \usetypescript[#3][\s!default][\s!size]% - \dostoptypefacedefining - \else\ifthirdargument - \dododefinetypeface[#1][#2]% - \getparameters[\??tf#1#2][#3]% - \else % use definitions in lfg file - \ctxlua{fonts.definetypeface(\!!bs#1\!!es,\!!bs#2\!!es)}% - \fi\fi\fi} - -\def\dododefinetypeface[#1][#2]% saveguard against redefinition - {\doifsomething{#1} - {\ifcsname\??tf#1\s!default\endcsname \else - \registerfontclass{#1}% - \setgvalue{\??tf#1\s!default}{#2}% - \fi - \ifcsname#1\endcsname \else - \setugvalue{#1}{\switchtotypeface[#1][#2]}% hm, what if #2 changes - \fi}} - -\unexpanded\def\setuptypeface% [class] [settings] - {\doquadrupleempty\doswitchtotypeface[\setupbodyfont][\fontclass]} - -\unexpanded\def\switchtotypeface% [class] [settings] - {\doquadrupleempty\doswitchtotypeface[\switchtobodyfont][\globalfontclass]} - -\def\doswitchtotypeface[#1][#2][#3][#4]% - {%\doifinsetelse{\s!default,\v!reset}{#3} - % {\setcurrentfontclass\empty} - % {\setcurrentfontclass{#3}}% - \setcurrentfontclass{#3}% - \let\globalfontclass#2% - \iffourthargument - #1[#4]% - \else\ifx\fontclass\empty - #1[\c!rm]% - \else\ifcsname\??tf\fontclass\s!default\endcsname - #1[\csname\??tf\fontclass\s!default\endcsname]% - \else - #1[\c!rm]% - \fi \fi \fi - \ifmmode\mr\else\tf\fi} % needed ? - -% \def\usetypefile[#1]% recurses on path ! -% {\edef\currenttypefile{\f!typeprefix#1}% -% \readfile{\currenttypefile.\mksuffix}\donothing{\readfile\currenttypefile\donothing\donothing}} - -\def\usetypefile[#1]% recurses on path ! % no storage? obsolete? - {\edef\currenttypefile{#1}% - \ctxcommand{doprocesstypescriptfile("\currenttypefile")}} - -%D For Taco: -%D -%D \starttyping -%D \inherittypeface[palatino][rm][postscript] -%D \inherittypeface[palatino][rm][\fontclass] -%D \inherittypeface[palatino][rm] % == \fontclass -%D \inherittypeface[palatino] % == [rm,ss,tt,mm] -%D \stoptyping - -\def\inherittypeface - {\dotripleempty\doinherittypeface} - -\def\doinherittypeface[#1][#2][#3]% - {\doifelsenothing{#2} - {\doinherittypeface[#1][\c!rm,\c!ss,\c!tt,\c!mm][\fontclass]} - {\doifnot{#1}{#3} - {\global\let\checkfontclass\docheckfontclass - \def\dodoinherittypeface##1{\setevalue{#1-##1}{#3}}% - \processcommalist[#2]\dodoinherittypeface}}} - -%D This hooks into the font mechanism with: - -% \def\checkfontclass#1% called often -% {\edef\fontclass{\executeifdefined{\fontclass-#1}{\fontclass}}} - -% \def\checkfontclass#1% called often -% {\edef\fontclass{\ifcsname\fontclass-#1\endcsname\csname\fontclass-#1\endcsname\else\fontclass\fi}} - -\def\docheckfontclass#1% called often - {\ifcsname\fontclass-#1\endcsname - \expandafter\let\expandafter\fontclass\csname\fontclass-#1\endcsname - \fi} - -\let\checkfontclass\gobbleoneargument - -\fetchruntimecommand \typetypescript {\f!typeprefix\s!run} % will become module - -\protect \endinput - -% Computer Modern Roman : Donald Knuth -% Latin Modern: LM Font Revision Team - -% LM math vs CM math (analysis by Taco): -% -% lmex10.tfm % identical -% lmmi5.tfm % identical -% lmmi6.tfm % identical -% lmmi7.tfm % identical -% lmmi8.tfm % identical -% lmmi9.tfm % identical -% lmmi10.tfm % identical -% lmmi12.tfm % identical -% lmmib10.tfm % identical -% lmsy5.tfm % extra chars: 254,255 (octal) -% lmsy6.tfm % extra chars: 254,255 (octal) -% lmsy7.tfm % extra chars: 254,255 (octal) -% lmsy8.tfm % extra chars: 254,255 (octal) -% lmsy9.tfm % extra chars: 254,255 (octal) -% lmsy10.tfm % extra chars: 254,255 (octal) -% lmbsy10.tfm % extra chars: 254,255 (octal) -% -% From the 'AMS' set: -% -% lmmib5.tfm % identical -% lmmib7.tfm % identical -% lmbsy5.tfm % extra chars: 254,255 (octal) -% lmbsy7.tfm % extra chars: 254,255 (octal) -% -% The two extra characters are: -% -% /lessorequalslant -% /greaterorequalslant diff --git a/tex/context/base/type-ini.mkvi b/tex/context/base/type-ini.mkvi new file mode 100644 index 000000000..efe360bdb --- /dev/null +++ b/tex/context/base/type-ini.mkvi @@ -0,0 +1,560 @@ +%D \module +%D [ file=type-ini, +%D version=2001.03.05, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typescript Macros / Initialization} + +\registerctxluafile{type-ini}{1.001} + +%D The default fontclass is empty. We could demand always using fontclasses, +%D and then make the calling macros simplier (always assume fontclass) but +%D apart from downward compatibility issues, it would make global, class +%D spanning definitions a pain. Some day we will introduce a default class. + +%D The \type {type-ini} and \type {font-ini} modules come as a pair and have +%D mutual dependencies. + +%D Todo: store them at the lua end + +\unprotect + +\newcount \c_font_typescripts_n_of_preloaded +\newconditional\c_font_typescripts_quit +\newtoks \c_font_typescripts_document +\newconditional\c_font_typescripts_preload +\newconditional\c_font_typescripts_first_pass \settrue\c_font_typescripts_first_pass + +\newif \iftypescriptfound % will become a mode +\newif \iftracetypescripts + +\newtoks \everybeforedefinetypeface +\newtoks \everyafterdefinetypeface + +\let\typescriptfiles \empty +\let\currenttypescripts\empty +\let\currenttypefile \empty + +\let\typescriptone \empty % public, used in typescripts +\let\typescripttwo \empty % public, used in typescripts +\let\typescriptthree\empty % public, used in typescripts + +\let\fontclassstyle \empty + +\let\m_font_typescripts_one \empty +\let\m_font_typescripts_two \empty +\let\m_font_typescripts_three\empty +\let\m_font_typescripts_check\empty +\let\m_font_typescripts_match\empty + +\let\t_font_typescripts\relax % uses as synonym + +\installcorenamespace{typescriptcache} +\installcorenamespace{typescriptfiles} +\installcorenamespace{typescriptonce} +\installcorenamespace{typescriptsynonyms} +\installcorenamespace{typescriptprefix} +\installcorenamespace{typescriptinheritances} +\installcorenamespace{typescriptdefaultstyles} +\installcorenamespace{typescriptrelatives} + +\definesystemvariable{ts} % TypeScript + +% tricky ... here we push/pop + +\chardef\typescriptmethod\plusone % 1: empty==all==true 2: empty==false +\chardef\typescriptstate \plustwo % 1: process 2: store + +\unexpanded\def\starttypescriptcollection + {\dosingleempty\font_typescripts_collection_start} + +\def\font_typescripts_collection_start[#tag]% + {} + +\let\stoptypescriptcollection\relax + +\unexpanded\def\usetypescriptfile[#filename]% + {\doifelse{#filename}\v!reset + {\let\typescriptfiles\empty} + {\splitfilename{#filename}% + \addtocommalist\splitoffbase\typescriptfiles}} + +\unexpanded\def\usetypescript {\dotripleempty\font_typescripts_use_one} +\unexpanded\def\usetypescriptexact{\dotripleempty\font_typescripts_use_two} + +\def\font_typescripts_use_one{\let\typescriptmethod\plusone\font_typescripts_use} +\def\font_typescripts_use_two{\let\typescriptmethod\plustwo\font_typescripts_use} + +\unexpanded\def\font_typescripts_use[#one][#two][#three]% + {\pushmacro\m_font_typescripts_one + \pushmacro\m_font_typescripts_two + \pushmacro\m_font_typescripts_three + \edef\m_font_typescripts_one {\truetypescript{#one}}% + \edef\m_font_typescripts_two {\truetypescript{#two}}% + \edef\m_font_typescripts_three{\truetypescript{#three}}% + \pushmacro\typescriptone + \pushmacro\typescripttwo + \pushmacro\typescriptthree + \pushmacro\typescriptmethod + \pushmacro\typescriptstate + \pushmacro\stoptypescript + \typescriptfoundfalse + \let\typescriptstate\plusone + \iftracetypescripts + \writestatus\m!fonts{request: [\m_font_typescripts_one] [\m_font_typescripts_two] [\m_font_typescripts_three]}% + \fi + \processcommacommand[\typescriptfiles]\font_typescripts_load_file + \the\c_font_typescripts_document + \setfalse\c_font_typescripts_first_pass + \popmacro\stoptypescript + \popmacro\typescriptstate + \popmacro\typescriptmethod + \popmacro\typescriptthree + \popmacro\typescripttwo + \popmacro\typescriptone + \popmacro\m_font_typescripts_three + \popmacro\m_font_typescripts_two + \popmacro\m_font_typescripts_one} + +\unexpanded\def\preloadtypescripts + {\ifproductionrun\settrue\c_font_typescripts_preload\fi} + +\prependtoks + \preloadtypescripts +\to \everyjob + +\unexpanded\def\quittypescriptscanning + {\settrue\c_font_typescripts_quit} % public + +\def\font_typescripts_start_store#definitions\stoptypescript + {\global\advance\c_font_typescripts_n_of_preloaded\plusone + \expandafter\normalgdef\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname + {\starttypescript#definitions\stoptypescript}% + %\normalexpanded{\global\t_font_typescripts{\the\expandafter\t_font_typescripts\noexpand\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}}} + \global\t_font_typescripts\expandafter\expandafter\expandafter + {\expandafter\the\expandafter\t_font_typescripts + \csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}} + +\def\font_typescripts_collection_start_store#definitions\stoptypescriptcollection + {\global\advance\c_font_typescripts_n_of_preloaded\plusone + \expandafter\normalgdef\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname + {\starttypescriptcollection#definitions\stoptypescriptcollection}% + %\normalexpanded{\global\t_font_typescripts{\the\expandafter\t_font_typescripts\noexpand\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}}} + \global\t_font_typescripts\expandafter\expandafter\expandafter + {\expandafter\the\expandafter\t_font_typescripts + \csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}} + +\def\font_typescripts_load_file#filename% + {\setfalse\c_font_typescripts_quit + \pushmacro\currenttypefile + \def\currenttypefile{#filename}% + \ifconditional\c_font_typescripts_preload + \font_typescript_process_typescript_file_and_store + \else + \font_typescript_process_typescript_file + \fi + \popmacro\currenttypefile + \ifconditional\c_font_typescripts_quit + \quitcommalist + \setfalse\c_font_typescripts_quit + \fi} + +\def\font_typescript_process_typescript_file_and_store + {\expandafter\let\expandafter\t_font_typescripts\csname\??typescriptfiles\currenttypefile\endcsname + \ifx\t_font_typescripts\relax + \font_typescript_process_typescript_store_indeed + \fi + \the\t_font_typescripts} + +\def\font_typescript_process_typescript_store_indeed + {\newtoks\t_font_typescripts % is \relaxed elsewhere + \begingroup + \let\starttypescript \font_typescripts_start_store + \let\starttypescriptcollection\font_typescripts_collection_start_store + \font_typescript_process_typescript_file + \endgroup + \expandafter\let\csname\??typescriptfiles\currenttypefile\endcsname\t_font_typescripts} + +\def\font_typescript_process_typescript_file + {\ctxcommand{doprocesstypescriptfile("\currenttypefile")}} + +\unexpanded\def\usetypescriptonce + {\dotripleempty\font_typescripts_use_once} + +\def\font_typescripts_use_once[#one][#two][#three]% + {\ifcsname\??typescriptonce#one:#two:#three\endcsname + \writestatus\m!fonts{once (#one) (#two) (#three)}% + \else + \expandafter\let\csname\??typescriptonce#one:#two:#three\endcsname\relax + \font_typescripts_use[#one][#two][#three]% + \fi} + +% \definetypescriptsynonym[lbr][cmr] + +\unexpanded\def\definetypescriptsynonym + {\dodoubleempty\font_typescripts_synonym_define} + +\def\font_typescripts_synonym_define[#name][#synonym]% + {\ifsecondargument\setevalue{\??typescriptsynonyms#name}{#synonym}\fi} + +\def\truetypescript#name% + {\ifcsname\??typescriptsynonyms#name\endcsname + \expandafter\truetypescript\csname\??typescriptsynonyms#name\endcsname\else#name% + \fi} + +% script [serif] [default] [size] +% script [serif] [computer-modern] [size] +% script [serif] [computer-modern] [ec] +% script [serif] [computer-modern] [name] +% script [serif] [computer-modern] [special] + +\prependtoks + \settrue\c_font_typescripts_first_pass +\to \everyjob + +\unexpanded\def\starttypescript + {\ifcase\typescriptstate + % 0 = skip + \expandafter\font_typescripts_start_gobble + \or + % 1 = process + \expandafter\font_typescripts_start_process + \or + % 2 = store + \expandafter\font_typescripts_start_document + \else + % ? = skip + \expandafter\font_typescripts_start_gobble + \fi} + +\def\font_typescripts_start_gobble#definitions\stoptypescript{} + +\def\font_typescripts_start_document#definitions\stoptypescript + %{\appendtoks\starttypescript#definitions\stoptypescript\to\c_font_typescripts_document} + {\c_font_typescripts_document\expandafter{\the\c_font_typescripts_document\starttypescript#definitions\stoptypescript}} + +\def\font_typescripts_start_process % could be a faster \doifnextoptionalelse if needed + {\let\typescriptone \m_font_typescripts_one + \let\typescripttwo \m_font_typescripts_two + \let\typescriptthree\m_font_typescripts_three + \let\m_font_typescripts_match\empty + \doifnextoptionalelse\font_typescripts_start_process_one\font_typescripts_start_process_all} + +\def\font_typescripts_start_process_all % could be a \let + {\ifconditional\c_font_typescripts_first_pass + \expandafter\font_typescripts_start_process_indeed + \else + % skip this since it may do unwanted resets, like + % setting symbolic font names to unknown, especially + % in run time user type scripts + \expandafter\font_typescripts_start_gobble + \fi} + +\def\font_typescripts_show_match + {\writestatus\m!fonts{match:\ifx\currenttypefile\relax\space *\fi \m_font_typescripts_match}} + +\def\font_typescripts_start_process_yes + {\ifdone + \typescriptfoundtrue + \iftracetypescripts\font_typescripts_show_match\fi + \expandafter\font_typescripts_start_process_indeed + \else + \expandafter\font_typescripts_start_gobble + \fi} + +\def\font_typescripts_start_process_one + {\font_typescripts_check\m_font_typescripts_one\typescriptone\font_typescripts_start_process_again_one} + +\def\font_typescripts_start_process_two + {\font_typescripts_check\m_font_typescripts_two\typescripttwo\font_typescripts_start_process_again_two} + +\def\font_typescripts_start_process_three + {\font_typescripts_check\m_font_typescripts_three\typescriptthree\font_typescripts_start_process_again_three} + +\def\font_typescripts_start_process_again_one + {\doifnextoptionalelse\font_typescripts_start_process_two\font_typescripts_start_process_yes} + +\def\font_typescripts_start_process_again_two + {\doifnextoptionalelse\font_typescripts_start_process_three\font_typescripts_start_process_yes} + +% \def\font_typescripts_start_process_again_three +% {\font_typescripts_start_process_yes} + +\let\font_typescripts_start_process_again_three\font_typescripts_start_process_yes + +\def\font_typescripts_start_process_indeed + {\pushmacro\fontclass} + +\unexpanded\def\stoptypescript + {\popmacro\fontclass} + +\def\font_typescripts_check#asked#target#followup[#value]% script use value next + {\donefalse + \edef\m_font_typescripts_check{#value}% + \ifx\m_font_typescripts_check\empty % no longer needed / met + \ifcase\typescriptmethod\or\donetrue\fi + \else\ifx#asked\s!all + \donetrue + \else\ifx\m_font_typescripts_check\s!all + \donetrue + \else\ifx#asked\m_font_typescripts_check % saves 10% trace so probably faster too + \donetrue + \let#target\m_font_typescripts_check + \else + \doifcommonelse\m_font_typescripts_check#asked\donetrue\donefalse + \ifdone + \let#target\commalistelement + \fi + \fi\fi\fi\fi + \ifdone + \iftracetypescripts\extendtypescriptmatch\fi + \expandafter#followup% + \else + \expandafter\font_typescripts_start_gobble + \fi} + +\def\extendtypescriptmatch + {\edef\m_font_typescripts_match{\m_font_typescripts_match\space[\m_font_typescripts_check]}} + +%D Map files will go away in \LUATEX, but till that happens we +%D use stripped down support for loading them. + +\unexpanded\def\loadmapfile{\dosingleempty\font_map_load_file} +\unexpanded\def\loadmapline{\dodoubleempty\font_map_load_line} + +\def\font_map_load_file[#filename]% + {\ctxlua{fonts.mappings.loadfile("#filename")}} + +\def\font_map_load_line[#kind][#data]% + {\ctxlua{fonts.mappings.loadline("#kind","#data")}} + +\unexpanded\def\forgetmapfiles + {\ctxlua{fonts.mappings.reset()}} + +\prependtoks + \loadmapfile[mkiv-base.map]% can't we preload this one? +\to \everystarttext + +%D A handy shortcut: + +% \definetypescriptprefix[serif][Serif] +% \definetypescriptprefix[sans] [Sans] +% \definetypescriptprefix[mono] [Mono] +% +%\starttypescript [serif,sans,mono] [handling,hanging,hz] [pure,normal,hz,quality] +% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree] +% \stoptypescript + +\unexpanded\def\definetypescriptprefix + {\dodoubleargument\font_typescripts_define_prefix} + +\def\font_typescripts_define_prefix[#name][#prefix]% + {\setgvalue{\??typescriptprefix#name}{#prefix}} % made global + +% without testing: +% +% \def\typescriptprefix#name% +% {\csname\??typescriptprefix#name\endcsname} +% +% with testing: + +\def\typescriptprefix#name% + {\ifcsname\??typescriptprefix#name\endcsname\csname\??typescriptprefix#name\endcsname\else#name\fi} + +% defining typefaces: +% +% \definetypeface [joke] [rm] +% \definetypeface [joke] [rm] [settings] +% \definetypeface [joke] [rm] [serif] [lucida] +% \definetypeface [joke] [rm] [serif] [lucida] [size] +% \definetypeface [joke] [rm] [serif] [lucida] [size] [settings] +% \definetypeface [joke] [specification] + +\unexpanded\def\definetypeface + {\dosixtupleargument\font_typefaces_define} + +\appendtoks + \font_helpers_reset_fontclass_math_families\fontclass +\to \everybeforedefinetypeface + +\def\font_typefaces_define + {\iffifthargument + \singleexpandafter\font_typefaces_define_a + \else\iffourthargument + \doubleexpandafter\font_typefaces_define_b + \else\ifthirdargument + \tripleexpandafter\font_typefaces_define_c + \else + \tripleexpandafter\font_typefaces_define_d + \fi\fi\fi} + +\def\font_typefaces_define_a[#name][#style][#fontshape][#fontname][#fontsize][#settings]% + {\iftracetypescripts\writestatus\m!fonts{define: [#name] [#style] [#fontshape] [#fontname]}\fi + \font_typefaces_define_indeed[#name][#style]% + \font_typefaces_defining_start{#name}{#style}{#settings}% + \font_typescripts_use_one[#fontshape][#fontname][\s!name,\s!default]% + \font_typescripts_use_one[#fontshape][#fontsize][\s!size]% + \font_typefaces_defining_stop} + +\def\font_typefaces_define_b[#name][#style][#fontshape][#fontname][#dummya][#dummyb]% + {\font_typefaces_define_a[#name][#style][#fontshape][#fontname][\s!default][#dummyb]} + +% \def\font_typefaces_define_c[#name][#style][#settings][#dummya][#dummyb][#dummyc]% misuse for settings +% {\font_typefaces_define_indeed[#name][#style]% +% \getparameters[\??tf#name#style][#settings]} % not used + +\def\font_typefaces_define_c[#name][#style][#dummya][#dummyb][#dummyc][#dummyd]% + {\font_typefaces_define_indeed[#name][#style]} + +\def\font_typefaces_define_d[#name][#specification][#dummya][#dummyb][#dummyc][#dummyd]% use definitions in lfg file + {\ctxlua{fonts.definetypeface("#name",\!!bs#specification\!!es)}} + +\def\font_typefaces_define_indeed[#name][#style]% saveguard against redefinition + {\doifsomething{#name} + {\ifcsname\??typescriptdefaultstyles#name\endcsname \else + \registerfontclass{#name}% + \setxvalue{\??typescriptdefaultstyles#name}{#style}% + \fi + \ifcsname#name\endcsname \else + \setugvalue{#name}{\switchtotypeface[#name][#style]}% + \fi}} + +\def\font_typefaces_defining_start#name#style#settings% + {\let\@@tsrscale \plusone + \let\@@tsfeatures \empty + \let\@@tsfallbacks\empty + \let\@@tsgoodies \empty + \let\@@tsdirection\empty + \geteparameters[\??ts][#settings]% + \pushmacro\fontclass + \pushmacro\fontclassstyle + \setcurrentfontclass{#name}% + \pushmacro\relativefontsize % hm, can be a counter + \let\relativefontsize\@@tsrscale % still needed ? + \savefontclassparameters{#style}\@@tsrscale\@@tsfeatures\@@tsfallbacks\@@tsgoodies\@@tsdirection + \the\everybeforedefinetypeface} + +\def\tsvar#key#default% undocumented and unofficial + {\expandafter\ifx\csname\??ts#key\endcsname\empty + \csname\??ts#key\endcsname + \else + #default% + \fi} + +\def\font_typefaces_defining_stop + {\the\everyafterdefinetypeface + \popmacro\relativefontsize + \popmacro\fontclassstyle + \popmacro\fontclass} + +\def\dofastdefinetypeface#name#style#fontshape#fontsize#settings% called from the lua end (via case d) + {\font_typefaces_define_indeed[#name][#style]% + \font_typefaces_defining_start{#name}{#style}{#settings}% + \font_typescripts_use_one[#fontshape][#fontsize][\s!size]% + \font_typefaces_defining_stop} + +\unexpanded\def\setuptypeface% [class] [settings] + {\dodoubleempty\font_typefaces_setup} + +\unexpanded\def\switchtotypeface% [class] [settings] + {\dodoubleempty\font_typefaces_switch} + +\def\font_typefaces_setup[#class][#settings]% + {\setcurrentfontclass{#class}% + \let\globalfontclass\fontclass + \iffourthargument + \setupbodyfont[#settings]% + \else\ifx\fontclass\empty + \setupbodyfont[\s!rm]% + \else\ifcsname\??typescriptdefaultstyles\fontclass\endcsname + \setupbodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]% + \else + \setupbodyfont[\s!rm]% + \fi \fi \fi + \ifmmode\mr\else\tf\fi} % needed ? + +\def\font_typefaces_switch[#class][#settings]% + {\setcurrentfontclass{#class}% + \let\globalfontclass\globalfontclass + \iffourthargument + \switchtobodyfont[#settings]% + \else\ifx\fontclass\empty + \switchtobodyfont[\s!rm]% + \else\ifcsname\??typescriptdefaultstyles\fontclass\endcsname + \switchtobodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]% + \else + \switchtobodyfont[\s!rm]% + \fi \fi \fi + \ifmmode\mr\else\tf\fi} % needed ? + +\unexpanded\def\usetypefile[#type]% recurses on path ! % no storage? obsolete? + {\edef\currenttypefile{#type}% + \ctxcommand{doprocesstypescriptfile("\currenttypefile")}} + +%D For Taco: +%D +%D \starttyping +%D \inherittypeface[palatino][rm][postscript] +%D \inherittypeface[palatino][rm][\fontclass] +%D \inherittypeface[palatino][rm] % == \fontclass +%D \inherittypeface[palatino] % == [rm,ss,tt,mm] +%D \stoptyping + +\def\inherittypeface + {\dotripleempty\font_typescripts_inherit_indeed} + +\def\font_typescripts_inherit_indeed[#name][#styles][#parentclass]% + {\doifelsenothing{#styles} + {\font_typescripts_inherit_indeed[#name][\s!rm,\s!ss,\s!tt,\s!mm][\fontclass]} + {\doifnot{#name}{#parentclass} + {\global\let\font_typescripts_inherit_check\font_typescripts_inherit_check_indeed + \def\font_typescripts_inherit_check_step#style{\setevalue{\??typescriptinheritances#name:#style}{#parentclass}}% + \processcommalist[#styles]\font_typescripts_inherit_check_step}}} + +%D This hooks into the font mechanism with: + +\def\font_typescripts_inherit_check_indeed#name% called often + {\ifcsname\??typescriptinheritances\fontclass:#name\endcsname + \expandafter\let\expandafter\fontclass\csname\??typescriptinheritances\fontclass:#name\endcsname + \fi} + +\let\font_typescripts_inherit_check\gobbleoneargument + +% not yet: +% +% \def\font_helpers_check_relative_font_id +% {\ifcsname\??typescriptrelatives\fontclass\endcsname +% \expandafter\let\expandafter\relativefontid\csname\??typescriptrelatives\fontclass\endcsname +% \else +% \expandafter\normalxdef\csname\??typescriptrelatives\fontclass\endcsname{\the\lastfontid}% +% \let\relativefontid\empty +% \fi} + +\def\v_font_string_d % default fontstyle (expands to \s!Serif in font-ini) + {\expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!rm \s!Serif \else + \expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!ss \s!Sans \else + \expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!tt \s!Mono \else + \s!Serif \fi\fi\fi} + +\unexpanded\def\font_helpers_set_fontstyle_of_fontclass + {\ifx\fontclass\empty + \let\fontstyle\s!rm + \else\ifcsname\??typescriptdefaultstyles\fontclass\endcsname + \edef\fontstyle{\csname\??typescriptdefaultstyles\fontclass\endcsname}% + \else + \let\fontstyle\s!rm + \fi\fi} + +%D This might become a module: + +\fetchruntimecommand \typetypescript {\f!typeprefix\s!run} + +\protect \endinput diff --git a/tex/context/base/type-set.mkiv b/tex/context/base/type-set.mkiv index 562c29a4f..2cb82ae9e 100644 --- a/tex/context/base/type-set.mkiv +++ b/tex/context/base/type-set.mkiv @@ -13,65 +13,11 @@ \unprotect -\definetypescriptprefix [serif] [Serif] -\definetypescriptprefix [sans] [Sans] -\definetypescriptprefix [mono] [Mono] +\loadmarkfile{type-def} % preloaded +\loadmarkfile{type-lua} % preloaded +\loadmarkfile{type-siz} % preloaded -\definefontsynonym [DefaultFont] [\s!file:lmmonoprop10-regular] % was cmvtt10 - -\startsetups [font:fallback:serif] - \definefontsynonym [Serif] [DefaultFont] - \definefontsynonym [SerifBold] [Serif] - \definefontsynonym [SerifItalic] [Serif] - \definefontsynonym [SerifSlanted] [SerifItalic] - \definefontsynonym [SerifBoldItalic] [Serif] - \definefontsynonym [SerifBoldSlanted] [SerifBoldItalic] - \definefontsynonym [SerifCaps] [Serif] -\stopsetups - -\startsetups [font:fallback:sans] - \definefontsynonym [Sans] [DefaultFont] - \definefontsynonym [SansBold] [Sans] - \definefontsynonym [SansItalic] [Sans] - \definefontsynonym [SansSlanted] [SansItalic] - \definefontsynonym [SansBoldItalic] [Sans] - \definefontsynonym [SansBoldSlanted] [SansBoldItalic] - \definefontsynonym [SansCaps] [Sans] -\stopsetups - -\startsetups [font:fallback:mono] - \definefontsynonym [Mono] [DefaultFont] - \definefontsynonym [MonoBold] [Mono] - \definefontsynonym [MonoItalic] [Mono] - \definefontsynonym [MonoSlanted] [MonoItalic] - \definefontsynonym [MonoBoldItalic] [Mono] - \definefontsynonym [MonoBoldSlanted] [MonoBoldItalic] - \definefontsynonym [MonoCaps] [Mono] -\stopsetups - -\starttypescript [serif,sans,mono] [fallback] - \setups[\s!font:\s!fallback:\typescriptone] -\stoptypescript - -\startsetups [font:allbold:serif] - \definefontsynonym [Serif] [SerifBold] - \definefontsynonym [SerifItalic] [SerifBoldItalic] - \definefontsynonym [SerifSlanted] [SerifBoldSlanted] - %definefontsynonym [SerifCaps] [SerifBold] -\stopsetups - -\startsetups [font:allbold:sans] - \definefontsynonym [Sans] [SansBold] - \definefontsynonym [SansItalic] [SansBoldItalic] - \definefontsynonym [SansSlanted] [SansBoldSlanted] - %definefontsynonym [SansCaps] [SansBold] -\stopsetups - -%usetypescriptfile[def] % preloaded in main context.mkiv file -%usetypescriptfile[lua] % preloaded in main context.mkiv file -%usetypescriptfile[tmf] % replaced by otf (mkiv) en one (mkii) -\usetypescriptfile[siz] -\usetypescriptfile[otf] -\usetypescriptfile[loc] +\usetypescriptfile[otf] % runtime +\usetypescriptfile[loc] % runtime \protect \endinput diff --git a/tex/context/base/type-siz.mkiv b/tex/context/base/type-siz.mkiv index ed1aa6ed5..4e9b2b9c3 100644 --- a/tex/context/base/type-siz.mkiv +++ b/tex/context/base/type-siz.mkiv @@ -11,382 +11,398 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\starttypescriptcollection[size] +\unprotect -\starttypescript [serif] [default] [size] +% beware: no \s! before keys as these are interpreted + +\starttypescriptcollection[\s!size] + +\starttypescript [\s!serif] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [rm] [default] + [\s!rm] [\s!default] \stoptypescript -\starttypescript [sans] [default] [size] +\starttypescript [\s!sans] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [ss] [default] + [\s!ss] [\s!default] \stoptypescript -\starttypescript [mono] [default] [size] +\starttypescript [\s!mono] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [tt] [default] + [\s!tt] [\s!default] \stoptypescript -\starttypescript [math] [default] [size] +\starttypescript [\s!math] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [mm] [default] + [\s!mm] [\s!default] \stoptypescript -\starttypescript [handwriting] [default] [size] +\starttypescript [\s!handwriting] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [hw] [default] + [\s!hw] [\s!default] \stoptypescript -\starttypescript [calligraphy] [default] [size] +\starttypescript [\s!calligraphy] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [cg] [default] + [\s!cg] [\s!default] \stoptypescript -\starttypescript [casual] [default] [size] +\starttypescript [\s!casual] [\s!default] [\s!size] \definebodyfont [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] - [rm] [default] + [\s!rm] [\s!default] \stoptypescript -\starttypescript [all] [dtp] [size] +\starttypescript [\s!all] [\s!dtp] [\s!size] \definebodyfontenvironment [4pt] [\s!text=4pt,\s!script=4pt,\s!scriptscript=4pt, - \c!x=4pt,\c!xx=4pt,\c!big=6pt,\c!small=4pt] + \s!x=4pt,\s!xx=4pt,\v!big=6pt,\v!small=4pt] \definebodyfontenvironment [5pt] [\s!text=5pt,\s!script=5pt,\s!scriptscript=5pt, - \c!x=5pt,\c!xx=5pt,\c!big=7pt,\c!small=5pt] + \s!x=5pt,\s!xx=5pt,\v!big=7pt,\v!small=5pt] \definebodyfontenvironment [6pt] [\s!text=6pt,\s!script=5pt,\s!scriptscript=5pt, - \c!x=5pt,\c!xx=5pt,\c!big=8pt,\c!small=5pt] + \s!x=5pt,\s!xx=5pt,\v!big=8pt,\v!small=5pt] \definebodyfontenvironment [7pt] [\s!text=7pt,\s!script=6pt,\s!scriptscript=5pt, - \c!x=6pt,\c!xx=5pt,\c!big=9pt,\c!small=5pt] + \s!x=6pt,\s!xx=5pt,\v!big=9pt,\v!small=5pt] \definebodyfontenvironment [8pt] [\s!text=8pt,\s!script=6pt,\s!scriptscript=5pt, - \c!x=6pt,\c!xx=5pt,\c!big=10pt,\c!small=6pt] + \s!x=6pt,\s!xx=5pt,\v!big=10pt,\v!small=6pt] \definebodyfontenvironment [9pt] [\s!text=9pt,\s!script=7pt,\s!scriptscript=5pt, - \c!x=7pt,\c!xx=5pt,\c!big=11pt,\c!small=7pt] + \s!x=7pt,\s!xx=5pt,\v!big=11pt,\v!small=7pt] \definebodyfontenvironment [10pt] [\s!text=10pt,\s!script=7pt,\s!scriptscript=5pt, - \c!x=8pt,\c!xx=6pt,\c!big=12pt,\c!small=8pt] + \s!x=8pt,\s!xx=6pt,\v!big=12pt,\v!small=8pt] \definebodyfontenvironment [11pt] [\s!text=11pt,\s!script=8pt,\s!scriptscript=6pt, - \c!x=9pt,\c!xx=7pt,\c!big=13pt,\c!small=9pt] + \s!x=9pt,\s!xx=7pt,\v!big=13pt,\v!small=9pt] \definebodyfontenvironment [12pt] [\s!text=12pt,\s!script=9pt,\s!scriptscript=7pt, - \c!x=10pt,\c!xx=8pt,\c!big=14pt,\c!small=10pt] + \s!x=10pt,\s!xx=8pt,\v!big=14pt,\v!small=10pt] \definebodyfontenvironment [13pt] [\s!text=13pt,\s!script=10pt,\s!scriptscript=8pt, - \c!x=11pt,\c!xx=9pt,\c!big=16pt,\c!small=11pt] + \s!x=11pt,\s!xx=9pt,\v!big=16pt,\v!small=11pt] \definebodyfontenvironment [14pt] [\s!text=14pt,\s!script=10pt,\s!scriptscript=7pt, - \c!x=12pt,\c!xx=10pt,\c!big=16pt,\c!small=12pt] + \s!x=12pt,\s!xx=10pt,\v!big=16pt,\v!small=12pt] \definebodyfontenvironment [16pt] [\s!text=16pt,\s!script=12pt,\s!scriptscript=9pt, - \c!x=13pt,\c!xx=11pt,\c!big=18pt,\c!small=14pt] + \s!x=13pt,\s!xx=11pt,\v!big=18pt,\v!small=14pt] % suboptimal math sizes \definebodyfontenvironment [18pt] [\s!text=18pt,\s!script=16pt,\s!scriptscript=14pt, - \c!x=16pt,\c!xx=14pt,\c!big=22pt,\c!small=16pt] + \s!x=16pt,\s!xx=14pt,\v!big=22pt,\v!small=16pt] \definebodyfontenvironment [22pt] [\s!text=22pt,\s!script=22pt,\s!scriptscript=18pt, - \c!x=18pt,\c!xx=16pt,\c!big=28pt,\c!small=18pt] + \s!x=18pt,\s!xx=16pt,\v!big=28pt,\v!small=18pt] \definebodyfontenvironment [28pt] [\s!text=28pt,\s!script=22pt,\s!scriptscript=18pt, - \c!x=22pt,\c!xx=18pt,\c!big=28pt,\c!small=22pt] + \s!x=22pt,\s!xx=18pt,\v!big=28pt,\v!small=22pt] \stoptypescript -\starttypescript [serif] [dtp] [size] +\starttypescript [\s!serif] [\s!dtp] [\s!size] \definebodyfont [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] - [rm] [default] + [\s!rm] [\s!default] \stoptypescript -\starttypescript [sans] [dtp] [size] +\starttypescript [\s!sans] [\s!dtp] [\s!size] \definebodyfont [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] - [ss] [default] + [\s!ss] [\s!default] \stoptypescript -\starttypescript [mono] [dtp] [size] +\starttypescript [\s!mono] [\s!dtp] [\s!size] \definebodyfont [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] - [tt] [default] + [\s!tt] [\s!default] \stoptypescript -\starttypescript [math] [dtp] [size] +\starttypescript [\s!math] [\s!dtp] [\s!size] \definebodyfont [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] - [mm] [default] + [\s!mm] [\s!default] \stoptypescript \stoptypescriptcollection +% This can become type-lmr + \starttypescriptcollection[size-mkiv] -\starttypescript [serif] [computer-modern] [size] - - \definebodyfont [12pt] [rm] - [tf=LMRoman12-Regular, - bf=LMRoman12-Bold, - it=LMRoman12-Italic, - sl=LMRoman12-Oblique, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [11pt] [rm] - [tf=LMRoman10-Regular sa 1, - bf=LMRoman10-Bold sa 1, - it=LMRoman10-Italic sa 1, - sl=LMRoman10-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [10pt] [rm] - [tf=LMRoman10-Regular, - bf=LMRoman10-Bold, - it=LMRoman10-Italic, - sl=LMRoman10-Oblique, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [9pt] [rm] - [tf=LMRoman9-Regular, - bf=LMRoman9-Bold, - it=LMRoman9-Italic, - sl=LMRoman9-Oblique, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [8pt] [rm] - [tf=LMRoman8-Regular, - bf=LMRoman8-Bold, - it=LMRoman8-Italic, - sl=LMRoman8-Oblique, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [7pt] [rm] - [tf=LMRoman7-Regular, - bf=LMRoman7-Bold, - it=LMRoman7-Italic sa 1, - sl=LMRoman8-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [6pt] [rm] - [tf=LMRoman6-Regular, - bf=LMRoman6-Bold, - it=LMRoman7-Italic sa 1, - sl=LMRoman8-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [5pt] [rm] - [tf=LMRoman5-Regular, - bf=LMRoman5-Bold, - it=LMRoman7-Italic sa 1, - sl=LMRoman8-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [4pt] [rm] - [tf=LMRoman5-Regular sa 1, - bf=LMRoman5-Bold sa 1, - it=LMRoman7-Italic sa 1, - sl=LMRoman8-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] - - \definebodyfont [14.4pt,17.3pt,20.7pt] [rm] - [tf=LMRoman12-Regular sa 1, - bf=LMRoman12-Bold sa 1, - it=LMRoman12-Italic sa 1, - sl=LMRoman12-Oblique sa 1, - bi=LMRoman10-BoldItalic sa 1, - bs=LMRoman10-BoldOblique sa 1, - sc=LMRoman10-CapsRegular sa 1] +\definesystemconstant{LMRoman} +\definesystemconstant{LMSans} +\definesystemconstant{LMTypewriter} +\definesystemconstant{LMMathRoman} + +\starttypescript [\s!serif] [computer-modern] [\s!size] + + \definebodyfont [12pt] [\s!rm] + [tf=\s!LMRoman12-Regular, + bf=\s!LMRoman12-Bold, + it=\s!LMRoman12-Italic, + sl=\s!LMRoman12-Oblique, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [11pt] [\s!rm] + [tf=\s!LMRoman10-Regular sa 1, + bf=\s!LMRoman10-Bold sa 1, + it=\s!LMRoman10-Italic sa 1, + sl=\s!LMRoman10-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [10pt] [\s!rm] + [tf=\s!LMRoman10-Regular, + bf=\s!LMRoman10-Bold, + it=\s!LMRoman10-Italic, + sl=\s!LMRoman10-Oblique, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [9pt] [\s!rm] + [tf=\s!LMRoman9-Regular, + bf=\s!LMRoman9-Bold, + it=\s!LMRoman9-Italic, + sl=\s!LMRoman9-Oblique, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [8pt] [\s!rm] + [tf=\s!LMRoman 8-Regular, + bf=\s!LMRoman 8-Bold, + it=\s!LMRoman 8-Italic, + sl=\s!LMRoman 8-Oblique, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [7pt] [\s!rm] + [tf=\s!LMRoman 7-Regular, + bf=\s!LMRoman 7-Bold, + it=\s!LMRoman 7-Italic sa 1, + sl=\s!LMRoman 8-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [6pt] [\s!rm] + [tf=\s!LMRoman 6-Regular, + bf=\s!LMRoman 6-Bold, + it=\s!LMRoman 7-Italic sa 1, + sl=\s!LMRoman 8-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [5pt] [\s!rm] + [tf=\s!LMRoman 5-Regular, + bf=\s!LMRoman 5-Bold, + it=\s!LMRoman 7-Italic sa 1, + sl=\s!LMRoman 8-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [4pt] [\s!rm] + [tf=\s!LMRoman 5-Regular sa 1, + bf=\s!LMRoman 5-Bold sa 1, + it=\s!LMRoman 7-Italic sa 1, + sl=\s!LMRoman 8-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] + + \definebodyfont [14.4pt,17.3pt,20.7pt] [\s!rm] + [tf=\s!LMRoman12-Regular sa 1, + bf=\s!LMRoman12-Bold sa 1, + it=\s!LMRoman12-Italic sa 1, + sl=\s!LMRoman12-Oblique sa 1, + bi=\s!LMRoman10-BoldItalic sa 1, + bs=\s!LMRoman10-BoldOblique sa 1, + sc=\s!LMRoman10-CapsRegular sa 1] \stoptypescript -\starttypescript [sans] [computer-modern] [size] - - \definebodyfont [12pt] [ss] - [tf=LMSans12-Regular, - bf=LMSans10-Bold sa 1, - it=LMSans12-Oblique, - sl=LMSans12-Oblique, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans12-Regular] - - \definebodyfont [11pt] [ss] - [tf=LMSans10-Regular sa 1, - bf=LMSans10-Bold sa 1, - it=LMSans10-Oblique sa 1, - sl=LMSans10-Oblique sa 1, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans10-Regular sa 1] - - \definebodyfont [10pt] [ss] - [tf=LMSans10-Regular, - bf=LMSans10-Bold, - it=LMSans10-Oblique, - sl=LMSans10-Oblique, - bi=LMSans10-BoldOblique, - bs=LMSans10-BoldOblique, - sc=LMSans10-Regular] - - \definebodyfont [9pt] [ss] - [tf=LMSans9-Regular, - bf=LMSans10-Bold sa 1, - it=LMSans9-Oblique sa 1, - sl=LMSans9-Oblique sa 1, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans9-Regular] - - \definebodyfont [8pt] [ss] - [tf=LMSans8-Regular, - bf=LMSans10-Bold sa 1, - it=LMSans8-Oblique, - sl=LMSans8-Oblique, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans8-Regular] - - \definebodyfont [7pt,6pt,5pt,4pt] [ss] - [tf=LMSans8-Regular sa 1, - bf=LMSans10-Bold sa 1, - it=LMSans8-Oblique sa 1, - sl=LMSans8-Oblique sa 1, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans8-Regular sa 1] - - \definebodyfont [14.4pt,17.3pt,20.7pt] [ss] - [tf=LMSans12-Regular sa 1, - bf=LMSans10-Bold sa 1, - it=LMSans12-Oblique sa 1, - sl=LMSans12-Oblique sa 1, - bi=LMSans10-BoldOblique sa 1, - bs=LMSans10-BoldOblique sa 1, - sc=LMSans12-Regular sa 1] +\starttypescript [\s!sans] [computer-modern] [\s!size] + + \definebodyfont [12pt] [\s!ss] + [tf=\s!LMSans12-Regular, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans12-Oblique, + sl=\s!LMSans12-Oblique, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans12-Regular] + + \definebodyfont [11pt] [\s!ss] + [tf=\s!LMSans10-Regular sa 1, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans10-Oblique sa 1, + sl=\s!LMSans10-Oblique sa 1, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans10-Regular sa 1] + + \definebodyfont [10pt] [\s!ss] + [tf=\s!LMSans10-Regular, + bf=\s!LMSans10-Bold, + it=\s!LMSans10-Oblique, + sl=\s!LMSans10-Oblique, + bi=\s!LMSans10-BoldOblique, + bs=\s!LMSans10-BoldOblique, + sc=\s!LMSans10-Regular] + + \definebodyfont [9pt] [\s!ss] + [tf=\s!LMSans 9-Regular, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans 9-Oblique sa 1, + sl=\s!LMSans 9-Oblique sa 1, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans 9-Regular] + + \definebodyfont [8pt] [\s!ss] + [tf=\s!LMSans 8-Regular, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans 8-Oblique, + sl=\s!LMSans 8-Oblique, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans8-Regular] + + \definebodyfont [7pt,6pt,5pt,4pt] [\s!ss] + [tf=\s!LMSans 8-Regular sa 1, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans 8-Oblique sa 1, + sl=\s!LMSans 8-Oblique sa 1, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans 8-Regular sa 1] + + \definebodyfont [14.4pt,17.3pt,20.7pt] [\s!ss] + [tf=\s!LMSans12-Regular sa 1, + bf=\s!LMSans10-Bold sa 1, + it=\s!LMSans12-Oblique sa 1, + sl=\s!LMSans12-Oblique sa 1, + bi=\s!LMSans10-BoldOblique sa 1, + bs=\s!LMSans10-BoldOblique sa 1, + sc=\s!LMSans12-Regular sa 1] \stoptypescript -\starttypescript [mono] [computer-modern] [size] - - \definebodyfont [12pt] [tt] - [tf=LMTypewriter12-Regular, - it=LMTypewriter10-Italic sa 1, - sl=LMTypewriter10-Oblique sa 1, - bf=LMTypewriter10-Dark sa 1, - bs=LMTypewriter10-DarkOblique sa 1, - sc=LMTypewriter10-CapsRegular sa 1] - - \definebodyfont [9pt] [tt] - [tf=LMTypewriter9-Regular, - it=LMTypewriter10-Italic sa 1, - sl=LMTypewriter10-Oblique sa 1, - bf=LMTypewriter10-Dark sa 1, - bs=LMTypewriter10-DarkOblique sa 1, - sc=LMTypewriter10-CapsRegular sa 1] - - \definebodyfont [8pt] [tt] - [tf=LMTypewriter8-Regular, - it=LMTypewriter10-Italic sa 1, - sl=LMTypewriter10-Oblique sa 1, - bf=LMTypewriter10-Dark sa 1, - bs=LMTypewriter10-DarkOblique sa 1, - sc=LMTypewriter10-CapsRegular sa 1] - - \definebodyfont [11pt,10pt,7pt,6pt,5pt,4pt] [tt] - [tf=LMTypewriter10-Regular sa 1, - it=LMTypewriter10-Italic sa 1, - sl=LMTypewriter10-Oblique sa 1, - bf=LMTypewriter10-Dark sa 1, - bs=LMTypewriter10-DarkOblique sa 1, - sc=LMTypewriter10-CapsRegular sa 1] - - \definebodyfont [14.4pt,17.3pt,20.7pt] [tt] - [tf=LMTypewriter12-Regular sa 1, - it=LMTypewriter10-Italic sa 1, - sl=LMTypewriter10-Oblique sa 1, - bf=LMTypewriter10-Dark sa 1, - bs=LMTypewriter10-DarkOblique sa 1, - sc=LMTypewriter10-CapsRegular sa 1] +\starttypescript [\s!mono] [computer-modern] [\s!size] + + \definebodyfont [12pt] [\s!tt] + [tf=\s!LMTypewriter12-Regular, + bf=\s!LMTypewriter10-Dark sa 1, + it=\s!LMTypewriter10-Italic sa 1, + sl=\s!LMTypewriter10-Oblique sa 1, + bi=\s!LMTypewriter10-DarkOblique sa 1, + bs=\s!LMTypewriter10-DarkOblique sa 1, + sc=\s!LMTypewriter10-CapsRegular sa 1] + + \definebodyfont [9pt] [\s!tt] + [tf=\s!LMTypewriter 9-Regular, + bf=\s!LMTypewriter10-Dark sa 1, + it=\s!LMTypewriter10-Italic sa 1, + sl=\s!LMTypewriter10-Oblique sa 1, + bi=\s!LMTypewriter10-DarkOblique sa 1, + bs=\s!LMTypewriter10-DarkOblique sa 1, + sc=\s!LMTypewriter10-CapsRegular sa 1] + + \definebodyfont [8pt] [\s!tt] + [tf=\s!LMTypewriter 8-Regular, + bf=\s!LMTypewriter10-Dark sa 1, + it=\s!LMTypewriter10-Italic sa 1, + sl=\s!LMTypewriter10-Oblique sa 1, + bi=\s!LMTypewriter10-DarkOblique sa 1, + bs=\s!LMTypewriter10-DarkOblique sa 1, + sc=\s!LMTypewriter10-CapsRegular sa 1] + + \definebodyfont [11pt,10pt,7pt,6pt,5pt,4pt] [\s!tt] + [tf=\s!LMTypewriter10-Regular sa 1, + bf=\s!LMTypewriter10-Dark sa 1, + it=\s!LMTypewriter10-Italic sa 1, + sl=\s!LMTypewriter10-Oblique sa 1, + bi=\s!LMTypewriter10-DarkOblique sa 1, + bs=\s!LMTypewriter10-DarkOblique sa 1, + sc=\s!LMTypewriter10-CapsRegular sa 1] + + \definebodyfont [14.4pt,17.3pt,20.7pt] [\s!tt] + [tf=\s!LMTypewriter12-Regular sa 1, + bf=\s!LMTypewriter10-Dark sa 1, + it=\s!LMTypewriter10-Italic sa 1, + sl=\s!LMTypewriter10-Oblique sa 1, + bi=\s!LMTypewriter10-DarkOblique sa 1, + bs=\s!LMTypewriter10-DarkOblique sa 1, + sc=\s!LMTypewriter10-CapsRegular sa 1] \stoptypescript -\starttypescript [math] [modern,computer-modern,latin-modern] [size] +\starttypescript [\s!math] [modern,computer-modern,latin-modern] [\s!size] - \definebodyfont [12pt] [mm] [mr=LMMathRoman12-Regular sa 1,mb=LMMathRoman12-Regular sa 1] - \definebodyfont [11pt] [mm] [mr=LMMathRoman10-Regular sa 1,mb=LMMathRoman10-Regular sa 1] - \definebodyfont [10pt] [mm] [mr=LMMathRoman10-Regular sa 1,mb=LMMathRoman10-Regular sa 1] - \definebodyfont [9pt] [mm] [mr=LMMathRoman9-Regular sa 1,mb=LMMathRoman9-Regular sa 1] - \definebodyfont [8pt] [mm] [mr=LMMathRoman8-Regular sa 1,mb=LMMathRoman8-Regular sa 1] - \definebodyfont [7pt] [mm] [mr=LMMathRoman7-Regular sa 1,mb=LMMathRoman7-Regular sa 1] - \definebodyfont [6pt] [mm] [mr=LMMathRoman6-Regular sa 1,mb=LMMathRoman6-Regular sa 1] - \definebodyfont [5pt] [mm] [mr=LMMathRoman5-Regular sa 1,mb=LMMathRoman5-Regular sa 1] - \definebodyfont [4pt] [mm] [mr=LMMathRoman5-Regular sa 1,mb=LMMathRoman5-Regular sa 1] + \definebodyfont [12pt] [\s!mm] [mr=\s!LMMathRoman12-Regular sa 1,mb=\s!LMMathRoman12-Regular sa 1] + \definebodyfont [11pt] [\s!mm] [mr=\s!LMMathRoman10-Regular sa 1,mb=\s!LMMathRoman10-Regular sa 1] + \definebodyfont [10pt] [\s!mm] [mr=\s!LMMathRoman10-Regular sa 1,mb=\s!LMMathRoman10-Regular sa 1] + \definebodyfont [9pt] [\s!mm] [mr=\s!LMMathRoman 9-Regular sa 1,mb=\s!LMMathRoman 9-Regular sa 1] + \definebodyfont [8pt] [\s!mm] [mr=\s!LMMathRoman 8-Regular sa 1,mb=\s!LMMathRoman 8-Regular sa 1] + \definebodyfont [7pt] [\s!mm] [mr=\s!LMMathRoman 7-Regular sa 1,mb=\s!LMMathRoman 7-Regular sa 1] + \definebodyfont [6pt] [\s!mm] [mr=\s!LMMathRoman 6-Regular sa 1,mb=\s!LMMathRoman 6-Regular sa 1] + \definebodyfont [5pt] [\s!mm] [mr=\s!LMMathRoman 5-Regular sa 1,mb=\s!LMMathRoman 5-Regular sa 1] + \definebodyfont [4pt] [\s!mm] [mr=\s!LMMathRoman 5-Regular sa 1,mb=\s!LMMathRoman 5-Regular sa 1] - \definebodyfont [14.4pt,17.3pt,20.7pt] [mm] - [mr=LMMathRoman12-Regular sa 1, - mb=LMMathRoman12-Regular sa 1] + \definebodyfont [14.4pt,17.3pt,20.7pt] [\s!mm] + [mr=\s!LMMathRoman12-Regular sa 1, + mb=\s!LMMathRoman12-Regular sa 1] \stoptypescript \stoptypescriptcollection -\endinput +\protect \endinput diff --git a/tex/context/base/typo-cap.mkiv b/tex/context/base/typo-cap.mkiv index 80b5270d2..2ed50ce20 100644 --- a/tex/context/base/typo-cap.mkiv +++ b/tex/context/base/typo-cap.mkiv @@ -200,7 +200,7 @@ \setupcapitals [\c!title=\v!yes, - \c!sc=\v!no] + sc=\v!no] % no \c!sc any longer % \definestartstop is not yet in available at core-spa time % diff --git a/tex/context/bib/backup/sample.bib b/tex/context/bib/backup/sample.bib new file mode 100644 index 000000000..3f8df623e --- /dev/null +++ b/tex/context/bib/backup/sample.bib @@ -0,0 +1,38 @@ +@STRING{hh = {Hans Hagen}} + +@ELECTRONIC{hh2010, + author = hh, + year = {2010}, + title = {Metafun. \CONTEXT\ mkiv}, + url = {http://www.pragma-ade.nl/general/manuals/metafun-s.pdf}, +} + +@ARTICLE{hh2010a, + author = hh, + title = {The Font Name Mess}, + journal = {MAPS}, + year = {2010}, + volume = {40}, + pages = {2-8}, + keywords = {context}, +} + +@ARTICLE{hh2010b, + author = hh, + title = {Grouping in Hybrid Environments}, + journal = {MAPS}, + year = {2010}, + volume = {40}, + pages = {67-71}, + keywords = {context}, +} + +@BOOK{Eijkhout1991, + title = {\TeX\ by Topic. A \TeX nician's Reference}, + publisher = {Addison-Wesley}, + year = {1991}, + author = {Victor Eijkhout}, + address = {London}, + keywords = {general}, +} + diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index d609ca635..e8e2e258a 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 : 01/02/12 21:59:34 +-- merge date : 01/09/12 10:08:43 do -- begin closure to overcome local limits and interference |