diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/typo-dir.mkxl')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkxl/typo-dir.mkxl | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/typo-dir.mkxl b/Master/texmf-dist/tex/context/base/mkxl/typo-dir.mkxl new file mode 100644 index 00000000000..8439ed342d0 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkxl/typo-dir.mkxl @@ -0,0 +1,205 @@ +%D \module +%D [ file=typo-dir, +%D version=2009.03.27, % code moved from core-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Directions, +%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 Typesetting Macros / Directions} + +%D At some point we might default to method 'two' but first I need to make it more +%D efficient (and provide some options). I also want to have some basic tracing. + +\unprotect + +\registerctxluafile{typo-dir}{optimize} +\registerctxluafile{typo-dha}{} +%registerctxluafile{typo-dua}{} +%registerctxluafile{typo-dub}{} +\registerctxluafile{typo-duc}{autosuffix} + +\definesystemattribute[directions][public,pickup] + +\installcorenamespace{directions} +\installcorenamespace{directionsbidimode} + +% plural as we can have a combination but maybe better singular + +\installsimplecommandhandler \??directions {directions} \??directions % no \define... yet + +\immutable\edef\lefttorightmark{\normalUchar"200E} \aliased\let\lrm\lefttorightmark % expandable +\immutable\edef\righttoleftmark{\normalUchar"200F} \aliased\let\rlm\righttoleftmark % expandable + +\permanent\protected\def\setdirection[#1]% todo: symbolic names + {\clf_setdirection#1\relax} + +\permanent\protected\def\resetdirection + {\c_attr_directions\attributeunsetvalue} + +\newconstant\directionsbidimode % this one might become pivate + +% \setupdirections[bidi=global,method=default] +% \setupdirections[bidi=global,method=one] +% \setupdirections[bidi=global,method=two] +% \setupdirections[bidi=global,method=two,fences=no] + +% maybe use chardefs + +\mutable\let\currentbidimode\empty +\mutable\let\currentbidistamp\empty + +\def\typo_dir_get_mode + {\def\currentbidimode{\clf_getbidimode % test edef + scope {\directionsparameter\c!bidi}% + method {\directionsparameter\c!method}% + fences {\directionsparameter\c!fences}% + }% + \gletcsname\??directionsbidimode\currentbidistamp\endcsname\currentbidimode} + +\appendtoks + \edef\p_bidi{\directionsparameter\c!bidi}% + \edef\currentbidistamp + {\p_bidi + :\directionsparameter\c!method + :\directionsparameter\c!fences}% + \expandafter\let\expandafter\currentbidimode\csname\??directionsbidimode\currentbidistamp\endcsname + \ifrelax\currentbidimode + \typo_dir_get_mode + \fi + \directionsbidimode\currentbidimode\relax + \ifcase\directionsbidimode + \resetdirection + \else + \setdirection[\number\directionsbidimode]% + \fi + \ifx\p_bidi\v!global + \pickupdirectionsattribute % pagebuilder + \else + \forgetdirectionsattribute + \fi +\to \everysetupdirections + +\appendtoks + \edef\p_option{\directionsparameter\c!break}% name can change + \bitwiseflip\normalizelinemode\ifx\p_option\v!both\else-\fi\breakafterdircode +\to \everysetupdirections + +% bidi: local=obey grouping, global=ignore grouping (unicode has no grouping) + +\setupdirections % maybe start/stop + [\c!bidi=\v!off, + \c!method=\v!default, + \c!break=\v!both, % experimental value, maybe \v!no will be default (bad name too) + \c!fences=\v!yes] + +\permanent\protected\edef\bidilre{\normalUchar"202A} +\permanent\protected\edef\bidirle{\normalUchar"202B} +\permanent\protected\edef\bidipop{\normalUchar"202C} +\permanent\protected\edef\bidilro{\normalUchar"202D} +\permanent\protected\edef\bidirlo{\normalUchar"202E} + +\permanent\protected\def\dirlre{\ifcase\directionsbidimode\or\bidilre\or\textdirection\directionlefttoright\fi} +\permanent\protected\def\dirrle{\ifcase\directionsbidimode\or\bidirle\or\textdirection\directionrighttoleft\fi} +\permanent\protected\def\dirlro{\ifcase\directionsbidimode\or\bidilro\or\setdirection[3]\fi} +\permanent\protected\def\dirrlo{\ifcase\directionsbidimode\or\bidirlo\or\setdirection[4]\fi} + +% for the moment: \setdirection[\plusone] + +\definecolor[bidi:left:original] [r=.6] +\definecolor[bidi:left:reversed] [g=.6] +\definecolor[bidi:right:original][b=.6] +\definecolor[bidi:right:reversed][r=.6,g=.6] +\definecolor[bidi:mirrored] [r=.6,b=.6] + +\protect \endinput + +% bidi test + +% \definefontfeature +% [arab] +% [mode=node,language=dflt,script=arab, +% init=yes,medi=yes,fina=yes,isol=yes, +% liga=yes,dlig=yes,rlig=yes,clig=yes, +% mark=yes,mkmk=yes,kern=yes,curs=yes] +% +% \font\Arabic=arabtype*arab at 20pt +% +% \def\LATIN{LATIN} {\setdirection[1]} % enable this +% \def\ARAB {عربي} +% +% \startluacode +% function documentdata.split_tokens(str) +% for s in str:bytes() do +% context.sprint(tex.ctxcatcodes,string.format("\\hbox{\\char %s}",s)) +% end +% end +% \stopluacode +% +% \protected\def\biditest#1#2#3% font text raw +% {\dontleavehmode\hbox +% {\framed[offset=overlay]{\tttf#2}\quad +% \enabletrackers[typesetters.directions]% +% \framed[offset=overlay]{#1#3}\quad +% \disabletrackers[typesetters.directions]% +% \tttf\ctxlua{documentdata.split_tokens([[\detokenize{#3}]])}}} +% +% \startbuffer[bidi-sample] +% \biditest\Arabic{LATIN BARA}{\lefttoright\relax \LATIN\ \ARAB}\par +% \biditest\Arabic{BARA LATIN}{\righttoleft\relax \LATIN\ \ARAB}\par +% \biditest\Arabic{LATIN ARAB}{\lefttoright{\bidilro \LATIN\ \ARAB}}\par % right -> left +% \biditest\Arabic{LATIN ARAB}{\righttoleft{\bidilro \LATIN\ \ARAB}}\par % right -> left +% \biditest\Arabic{BARA NITAL}{\lefttoright{\bidirlo \LATIN\ \ARAB}}\par % left -> right +% \biditest\Arabic{BARA NITAL}{\righttoleft{\bidirlo \LATIN\ \ARAB}}\par % left -> right +% \stopbuffer +% +% \startbuffer[bidi-sample] +% \biditest\Arabic{LATIN BARA}{\lefttoright\relax \LATIN\ \ARAB}\par +% \biditest\Arabic{BARA LATIN}{\righttoleft\relax \LATIN\ \ARAB}\par +% \biditest\Arabic{LATIN ARAB}{\lefttoright\bidilro \LATIN\ \ARAB}\par % right -> left +% \biditest\Arabic{LATIN ARAB}{\righttoleft\bidilro \LATIN\ \ARAB}\par % right -> left +% \biditest\Arabic{BARA NITAL}{\lefttoright\bidirlo \LATIN\ \ARAB}\par % left -> right +% \biditest\Arabic{BARA NITAL}{\righttoleft\bidirlo \LATIN\ \ARAB}\par % left -> right +% \stopbuffer +% +% \startbuffer[bidi-setup] +% \setupdirections[bidi=off] +% \stopbuffer +% +% {\typebuffer[bidi-setup] \getbuffer[bidi-setup] \getbuffer[bidi-sample]} +% +% \startbuffer[bidi-setup] +% \setupdirections[bidi=global] +% \stopbuffer +% +% {\typebuffer[bidi-setup] \getbuffer[bidi-setup] \getbuffer[bidi-sample]} +% +% \startbuffer[bidi-setup] +% \setupdirections[bidi=local] +% \stopbuffer +% +% {\typebuffer[bidi-setup] \getbuffer[bidi-setup] \getbuffer[bidi-sample]} +% +% \startbuffer[bidi-sample] +% \setupdirections[bidi=global] +% +% \hbox{\righttoleft\arabicfont (0001)}\par +% \dontleavehmode\hbox{\righttoleft\arabicfont (0002)}\par +% {\righttoleft\arabicfont (0003)\par} +% {\righttoleft\arabicfont (0004)}\par +% \dontleavehmode{\righttoleft\arabicfont (0005)\par} +% \dontleavehmode{\righttoleft\arabicfont (0006)}\par +% \rtlhbox{\arabicfont (0007)}\par +% \ltrhbox{\arabicfont (0008)}\par +% \dontleavehmode\rtlhbox{\arabicfont (0009)}\par +% \dontleavehmode\ltrhbox{\arabicfont (0010)}\par +% \stopsetups +% +% {\typebuffer[bidi-sample] \getbuffer[bidi-sample]} +% +% \stoptext |