scrp-ini.mkiv: Global attributes for \setscript command
Hi Hans, the \setscript command has the same problem with local attributes as the bidi mechanism. Some of the following attributes in scrp-ini.mkiv have to be global: %%%% \definesystemattribute[scriptinjection][public] \definesystemattribute[scriptsplitting][public] \definesystemattribute[scriptstatus] [public] %%%% I know "scriptinjection" has to be global to have linebreaks in footnotes (and margin notes) for chinese and japanese. I guess "scriptsplitting" has to be global too because it is used for thai. Wolfgang
On 7/8/2018 8:28 PM, Wolfgang Schuster wrote:
Hi Hans,
the \setscript command has the same problem with local attributes as the bidi mechanism.
Some of the following attributes in scrp-ini.mkiv have to be global:
%%%% \definesystemattribute[scriptinjection][public] \definesystemattribute[scriptsplitting][public] \definesystemattribute[scriptstatus] [public] %%%%
I know "scriptinjection" has to be global to have linebreaks in footnotes (and margin notes) for chinese and japanese.
I guess "scriptsplitting" has to be global too because it is used for thai. 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 Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen mailto:j.hagen@xs4all.nl 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
On 7/9/2018 8:57 AM, Wolfgang Schuster wrote:
Hans Hagen mailto:j.hagen@xs4all.nl 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} %%%%%%
how about this (a bit like languages and bodyfonts) \unprotect \newconstant\c_scripts_injection \c_scripts_injection\attributeunsetvalue \newconstant\c_scripts_splitting \c_scripts_splitting\attributeunsetvalue \newconstant\c_scripts_status \c_scripts_status \attributeunsetvalue \unexpanded\def\setglobalscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set \c_scripts_injection\attribute\scriptinjectionattribute \c_scripts_splitting\attribute\scriptsplittingattribute \c_scripts_status \attribute\scriptstatusattribute} \unexpanded\def\setlocalscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set} \let\setscript\setlocalscript \appendtoks \attribute\scriptinjectionattribute\c_scripts_injection \attribute\scriptsplittingattribute\c_scripts_splitting \attribute\scriptstatusattribute \c_scripts_status \to \everypagebody \protect ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen mailto:j.hagen@xs4all.nl 9. Juli 2018 um 15:01
how about this (a bit like languages and bodyfonts)
\unprotect
\newconstant\c_scripts_injection \c_scripts_injection\attributeunsetvalue \newconstant\c_scripts_splitting \c_scripts_splitting\attributeunsetvalue \newconstant\c_scripts_status \c_scripts_status \attributeunsetvalue
\unexpanded\def\setglobalscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set \c_scripts_injection\attribute\scriptinjectionattribute \c_scripts_splitting\attribute\scriptsplittingattribute \c_scripts_status \attribute\scriptstatusattribute}
\unexpanded\def\setlocalscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set}
\let\setscript\setlocalscript
\appendtoks \attribute\scriptinjectionattribute\c_scripts_injection \attribute\scriptsplittingattribute\c_scripts_splitting \attribute\scriptstatusattribute \c_scripts_status \to \everypagebody
\protect
It works only when I use a different token list, e.g. \appendtoks ... \to \t_attr_list_local Here is the missing example. \definefontfamily [meiryo] [rm] [Meiryo] \setupbodyfont[meiryo] \setlocalscript[nihongo] %\setglobalscript[nihongo] \setuplayout[leftmargin=6cm,backspace=7cm,width=middle] \starttext \startbuffer[udhr] All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. すべての人間は、生まれながらにして自由であり、かつ、尊厳と権利とについて 平等である。人間は、理性と良心とを授けられており、互いに同胞の精神をもっ て行動しなければならない。 \stopbuffer \getbuffer[udhr] Footnote \startfootnote \getbuffer[udhr] \stopfootnote Margintext\inmargin[style=smallbodyfont]{\getbuffer[udhr]} \stoptext Wolfgang
On 7/9/2018 4:24 PM, Wolfgang Schuster wrote:
Here is the missing example.
\definefontfamily [meiryo] [rm] [Meiryo]
\setupbodyfont[meiryo]
\setlocalscript[nihongo] %\setglobalscript[nihongo]
\setuplayout[leftmargin=6cm,backspace=7cm,width=middle]
\starttext
\startbuffer[udhr] All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.
すべての人間は、生まれながらにして自由であり、かつ、尊厳と権利とについて 平等である。人間は、理性と良心とを授けられており、互いに同胞の精神をもっ て行動しなければならない。 \stopbuffer
\getbuffer[udhr]
Footnote \startfootnote \getbuffer[udhr] \stopfootnote
Margintext\inmargin[style=smallbodyfont]{\getbuffer[udhr]}
\stoptext i made it a bit more generic ... beta on ftp ... 'pickup' is the magic word (script and bidi done that way now) .. your example looks ok
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
There is a typo in typo-dir.mkiv (missing "s" in directions) \unexpanded\def\setglobaldirection[#1]% todo: symbolic names {\clf_setdirection#1\relax - \pickupdirectionattribute} + \pickupdirectionsattribute} Another problem is that you can’t set a global direction because the command is embedded in \setupdirections. \definefontfamily[mainface][rm][ALM Fixed][features=arabic] \setupbodyfont[mainface] \setuplayout[backspace=5cm,width=middle,leftmargin=4cm] \setupdirections[bidi=global] %\setglobaldirection[\number\directionsbidimode] \setupheadertexts[Test امتحان test] \starttext Test امتحان test\footnote{Test امتحان test} Test امتحان test\inmargin{Test امتحان test} \stoptext Wolfgang
Hans Hagen mailto:j.hagen@xs4all.nl 9. Juli 2018 um 18:48 On 7/9/2018 4:24 PM, Wolfgang Schuster wrote:
i made it a bit more generic ... beta on ftp ... 'pickup' is the magic word (script and bidi done that way now) .. your example looks ok
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 7/9/2018 7:38 PM, Wolfgang Schuster wrote:
There is a typo in typo-dir.mkiv (missing "s" in directions)
\unexpanded\def\setglobaldirection[#1]% todo: symbolic names {\clf_setdirection#1\relax - \pickupdirectionattribute} + \pickupdirectionsattribute}
Another problem is that you can’t set a global direction because the command is embedded in \setupdirections. ok, another attempt ... see typo-dir file
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen mailto:j.hagen@xs4all.nl 9. Juli 2018 um 23:12
ok, another attempt ... see typo-dir file
It works for my small test file, Idris can check it with a real document. Thank you very much, Wolfgang
participants (3)
-
Hans Hagen
-
Wolfgang Schuster
-
Wolfgang Schuster