Hans Hagen
8. Juli 2018 um 23:02

it needs a bit of thinking (even bidi) ... it compares to global and local bodyfonts

what if a page break occurs in the middle of japanese local text while the global script is chinese

I can understand your concerns.

Another way is to add additional commands which let you set the script for all environments (body text + footnotes).


1. Add "global" to the attribute definition (or add another keyword which doesn’t add the reset to the local token list but using "global" should be enough).

%%%%%% attr-ini.mkiv
\def\attr_basics_define_indeed#1[#2][#3]%
  {\ifcsname\??attributecount#2\endcsname\else
     \scratchcounter\clf_defineattribute{#2}{#1}\relax
    %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}%
     \expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter
     \expandafter\newconstant \csname\??attributeid#2\endcsname
     \csname\??attributeid#2\endcsname\scratchcounter
     % some attributes are always global
     \doifelseinset\s!global{#3}%
       {\etoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}%
-      {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}%
+      {\doifnotinset\s!none{#3}
+         {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}}%
     \doifinset\s!nomath{#3}%
       {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}%
     % here public means 'visible' so it's not to be confused with 'public' at the lua end
     \doifinset\s!public{#3}%
       {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}%
   \fi}
%%%%%%



2. Create a flag which can be used to prevent the reset of the attributes when you use the global-commands. The old \setscript command will be a synonym for the local settings while you can use the global command when the document contains only one language.

%%%%%% scrp-ini.mkiv
\newconditional\c_scripts_reset \settrue\c_scripts_reset

\appendtoks
    \ifconditional\c_scripts_reset
        \doresetattribute{scriptinjection}%
        \doresetattribute{scriptsplitting}%
        \doresetattribute{scriptstatus}%
    \fi
\to \t_attr_list_local

%\unexpanded\def\setscript[#1]%
%  {\edef\currentscript{#1}%
%   \scripts_basics_set}

\unexpanded\def\setlocalscript[#1]%
  {\settrue\c_scripts_reset
   \edef\currentscript{#1}%
   \scripts_basics_set}

\let\setscript\setlocalscript

\unexpanded\def\setglobalscript[#1]%
  {\setfalse\c_scripts_reset
   \edef\currentscript{#1}%
   \scripts_basics_set}
%%%%%%


Wolfgang