diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-01-27 16:14:16 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-01-27 16:14:16 +0100 |
commit | 95a1799032dc61dbca4a11e495be34b4397c8fec (patch) | |
tree | 4b24bf117a90ba704dedf19ab1b1a734d78f4e45 /tex/context/base/mkiv/spac-ver.mkiv | |
parent | 0cfeab235554eeee0dddd6c3f44d3939ab490ff1 (diff) | |
download | context-95a1799032dc61dbca4a11e495be34b4397c8fec.tar.gz |
2017-01-27 14:46:00
Diffstat (limited to 'tex/context/base/mkiv/spac-ver.mkiv')
-rw-r--r-- | tex/context/base/mkiv/spac-ver.mkiv | 97 |
1 files changed, 85 insertions, 12 deletions
diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv index 5bc73abb8..229963997 100644 --- a/tex/context/base/mkiv/spac-ver.mkiv +++ b/tex/context/base/mkiv/spac-ver.mkiv @@ -1443,6 +1443,7 @@ \installcorenamespace{gridsnappers} \installcorenamespace{gridsnapperattributes} +\installcorenamespace{gridsnappersets} \newskip \bodyfontlineheight \newdimen \bodyfontstrutheight @@ -1462,12 +1463,34 @@ \attribute \snapvboxattribute \attribute\snapmethodattribute}% \fi} -\unexpanded\def\installsnapvalues#1#2% todo: a proper define - {\edef\currentsnapper{#1:#2}% - \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else - \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}% +% \unexpanded\def\installsnapvalues#1#2% todo: a proper define +% {\edef\currentsnapper{#1:#2}% +% \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else +% \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}% +% \fi +% \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}} + +\def\spac_grids_expand_snapper#1% + {\edef\m_spac_snapper + {\ifx\m_spac_snapper\empty\else\m_spac_snapper,\fi + \ifcsname\??gridsnappersets#1\endcsname + \lastnamedcs\else#1% + \fi}} + +\unexpanded\def\installsnapvalues#1#2% + {\let\m_spac_snapper\empty + \rawprocesscommacommand[#2]\spac_grids_expand_snapper + \edef\currentsnapper{#1:\m_spac_snapper}% + \ifcsname\??gridsnapperattributes\currentsnapper\endcsname + \scratchcounter\lastnamedcs % already defined + \else + \scratchcounter\clf_definesnapmethod{#1}{\m_spac_snapper}% + \setevalue{\??gridsnapperattributes\currentsnapper}{\the\scratchcounter}% \fi - \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}} + \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\the\scratchcounter\relax}% + \letvalue{\??gridsnappersets#1}\m_spac_snapper} + +\def\theexpandedsnapperset#1{\begincsname\??gridsnappersets#1\endcsname} % only for manuals \unexpanded\def\usegridparameter#1% no checking here {\edef\m_spac_grid_asked{#1\c!grid}% @@ -1518,6 +1541,9 @@ % offset:-3tp vertical shift within box % bottom:lines % top:lines +% box centers a box rounded upwards (box:.5 -> tolerance) +% min centers a box rounded downwards +% max centers a box rounded upwards %D We're not downward compatible with \MKII ! @@ -1527,7 +1553,6 @@ \definegridsnapping[\v!strict] [\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut] \definegridsnapping[\v!tolerant] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut] -\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut] % experimental, maybe 1.1 \definegridsnapping[\v!top] [\v!minheight,\v!maxdepth,\v!strut] \definegridsnapping[\v!bottom] [\v!maxheight,\v!mindepth,\v!strut] @@ -1544,15 +1569,18 @@ \definegridsnapping[\v!none] [\v!none] \definegridsnapping[\v!line] [\v!line] \definegridsnapping[\v!strut] [\v!strut] -\definegridsnapping[\v!box] [\v!box] % centers a box rounded upwards (box:.5 -> tolerance) -\definegridsnapping[\v!min] [\v!min] % centers a box rounded downwards -\definegridsnapping[\v!max] [\v!max] % centers a box rounded upwards - -\definegridsnapping[\v!max] [\v!maxdepth,\v!maxheight,\v!strut] -\definegridsnapping[\v!min] [\v!mindepth,\v!minheight,\v!strut] +\definegridsnapping[\v!box] [\v!box] +\definegridsnapping[\v!min] [\v!min] +\definegridsnapping[\v!max] [\v!max] \definegridsnapping[\v!middle] [\v!maxheight,\v!maxdepth] % used in placement +\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut] % experimental, maybe 1.1 +\definegridsnapping[\v!math:\v!line] [\v!math,\v!line,\v!split] +\definegridsnapping[\v!math:\v!halfline] [\v!math,\v!halfline,\v!split] +\definegridsnapping[\v!math:-\v!line] [\v!math,-\v!line,\v!split] +\definegridsnapping[\v!math:-\v!halfline][\v!math,-\v!halfline,\v!split] + \unexpanded\def\synchronizelocallinespecs {\bodyfontlineheight \normallineheight \bodyfontstrutheight\strutht @@ -1653,6 +1681,51 @@ \spac_grids_check_yes \fi\fi\fi} +\unexpanded\def\setupgridsnapping[#1]% less overhead than setuplayout (needs testing) + {\setlayoutparameter\c!grid{#1}\synchronizegridsnapping} + +\unexpanded\def\checkgridmethod#1% + {\edef\p_grid{#1}% + \ifx\p_grid\empty + \let\checkedgridmethod\empty + \let\checkedgridscope \v!local + \else + \splitatcolon\p_grid\checkedgridscope\checkedgridmethod + \ifx\checkedgridmethod\empty + \ifx\checkedgridscope\v!local\else\ifx\checkedgridscope\v!global\else + \let\checkedgridmethod\checkedgridscope + \let\checkedgridscope \v!local + \fi\fi + \fi + \fi} + +\unexpanded\def\applygridmethod#1#2#3% content localsettings (used in head rendering) + {\checkgridmethod{#1}% + \ifx\checkedgridscope\v!global + \ifx\checkedgridmethod\empty \else + % we assume that the call is grouped because grouping here has the side + % effect that the eventually constructed line will get the value outside + % the group + % + % overkill: \setupgridsnapping[\checkedgridmethod]% + % maybe : \spac_grids_snap_value_auto\checkedgridmethod + \spac_grids_snap_value_set\checkedgridmethod + \fi + \hbox{#3}% + \else + % the extra hbox will trigger the global snapper on top of the local and + % we really need that in this case (compatibility etc etc) so here we don't + % het an already done hit (otherwise we would not snap) + \hbox\bgroup + \ifx\checkedgridmethod\empty\else + \ifconditional\headisdisplay + #2% + \fi + \fi + \snaptogrid[\checkedgridmethod]\hbox{#3}% + \egroup + \fi} + \unexpanded\gdef\page_layouts_calculate_overshoot {\ifgridsnapping\ifcase\layoutlines \getnoflines\textheight |