diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
commit | 8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch) | |
tree | 3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/typo-mir.mkiv | |
parent | 850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff) |
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/typo-mir.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/typo-mir.mkiv | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/typo-mir.mkiv b/Master/texmf-dist/tex/context/base/typo-mir.mkiv new file mode 100644 index 00000000000..fe9d793e051 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/typo-mir.mkiv @@ -0,0 +1,144 @@ +%D \module +%D [ file=typo-mir, +%D version=2009.03.27, % code moved from core-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Mirroring, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=\PRAGMA] +%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 / Mirroring} + +\unprotect + +\registerctxluafile{typo-mir}{1.001} + +\definesystemattribute[mirror] + +% experimental mirroring + +\def\setcharactermirroring + {\ctxlua{mirror.enabled=true}% + \gdef\setcharactermirroring[##1]{\dosetattribute{mirror}{\number##1}}% + \setcharactermirroring} + +\def\resetcharactermirroring + {\doresetattribute{mirror}} + +\newtoks\everysetupdirections + +\def\setupdirections[#1]% there will be more like setting up directions themselves + {\getparameters[\??di][#1]% + \the\everysetupdirections} + +\chardef\directionsbidimode=0 + +\letvalue{\??di:bidi:\v!off }\zerocount +\letvalue{\??di:bidi:\v!global}\plusone +\letvalue{\??di:bidi:\v!local }\plustwo +\letvalue{\??di:bidi:\v!on }\plustwo + +\appendtoks + \chardef\directionsbidimode\executeifdefined{\??di:bidi:\@@dibidi}\zerocount\relax + \ifcase\directionsbidimode + \resetcharactermirroring + \or + \setcharactermirroring[1]% global, chars + \or + \setcharactermirroring[2]% local, attributes + \or + \setcharactermirroring[1]% default + \fi +\to \everysetupdirections + +% bidi: local=obey grouping, global=ignore grouping (unicode has no grouping) + +\setupdirections % maybe start/stop + [bidi=\v!off] + +\unexpanded\def\bidilre{\utfchar{"0x202A}} +\unexpanded\def\bidirle{\utfchar{"0x202B}} +\unexpanded\def\bidipop{\utfchar{"0x202C}} +\unexpanded\def\bidilro{\utfchar{"0x202D}} +\unexpanded\def\bidirlo{\utfchar{"0x202E}} + +\unexpanded\def\dirlre{\ifcase\directionsbidimode\or\bidilre\or\textdir TLT\fi} +\unexpanded\def\dirrle{\ifcase\directionsbidimode\or\bidirle\or\textdir TRT\fi} +\unexpanded\def\dirlro{\ifcase\directionsbidimode\or\bidilro\or\setcharactermirroring[3]\fi} +\unexpanded\def\dirrlo{\ifcase\directionsbidimode\or\bidirlo\or\setcharactermirroring[4]\fi} + +% for the moment: \setcharactermirroring[\plusone] + +\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} {\setcharactermirroring[1]} % enable this +\def\ARAB {محمد} + +\startluacode + function document.split_tokens(str) + for s in str:bytes() do + tex.sprint(tex.ctxcatcodes,string.format("\\hbox{\\char %s}",s)) + end + end +\stopluacode + +\def\biditest#1#2#3% font text raw + {\dontleavehmode\hbox + {\framed[offset=overlay]{\tttf#2}\quad + \ctxlua{mirror.trace = true}% + \framed[offset=overlay]{#1#3}\quad + \ctxlua{mirror.trace = false} + \tttf\ctxlua{document.split_tokens([[\detokenize{#3}]])}}} + +\startbuffer[bidi-sample] +\biditest\Arabic{LATIN BARA}{\textdir TLT\relax \LATIN\ \ARAB}\par +\biditest\Arabic{BARA LATIN}{\textdir TRT\relax \LATIN\ \ARAB}\par +\biditest\Arabic{LATIN ARAB}{\textdir TLT{\bidilro \LATIN\ \ARAB}}\par % right -> left +\biditest\Arabic{LATIN ARAB}{\textdir TRT{\bidilro \LATIN\ \ARAB}}\par % right -> left +\biditest\Arabic{BARA NITAL}{\textdir TLT{\bidirlo \LATIN\ \ARAB}}\par % left -> right +\biditest\Arabic{BARA NITAL}{\textdir TRT{\bidirlo \LATIN\ \ARAB}}\par % left -> right +\stopbuffer + +\startbuffer[bidi-sample] +\biditest\Arabic{LATIN BARA}{\textdir TLT\relax \LATIN\ \ARAB}\par +\biditest\Arabic{BARA LATIN}{\textdir TRT\relax \LATIN\ \ARAB}\par +\biditest\Arabic{LATIN ARAB}{\textdir TLT\bidilro \LATIN\ \ARAB}\par % right -> left +\biditest\Arabic{LATIN ARAB}{\textdir TRT\bidilro \LATIN\ \ARAB}\par % right -> left +\biditest\Arabic{BARA NITAL}{\textdir TLT\bidirlo \LATIN\ \ARAB}\par % left -> right +\biditest\Arabic{BARA NITAL}{\textdir TRT\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]} + +\stoptext |