diff options
41 files changed, 1225 insertions, 725 deletions
diff --git a/doc/context/documents/general/manuals/languages-mkiv.pdf b/doc/context/documents/general/manuals/languages-mkiv.pdf Binary files differindex 480b30d1f..e9c9ba4d9 100644 --- a/doc/context/documents/general/manuals/languages-mkiv.pdf +++ b/doc/context/documents/general/manuals/languages-mkiv.pdf diff --git a/doc/context/documents/general/manuals/luatex.pdf b/doc/context/documents/general/manuals/luatex.pdf Binary files differindex 3c8dd980c..5c74a0705 100644 --- a/doc/context/documents/general/manuals/luatex.pdf +++ b/doc/context/documents/general/manuals/luatex.pdf diff --git a/doc/context/sources/general/manuals/languages/languages-back.tex b/doc/context/sources/general/manuals/languages/languages-back.tex deleted file mode 100644 index aadcc3aa4..000000000 --- a/doc/context/sources/general/manuals/languages/languages-back.tex +++ /dev/null @@ -1,14 +0,0 @@ -% \doifmodeelse {simple} { -% -% \page -% \page[empty,left] -% -% \startMPpage -% DrawCoverPage("back") ; -% \stopMPpage -% -% } { -% -% % not needed as it's part of the cover page -% -% } diff --git a/doc/context/sources/general/manuals/languages/languages-basics.tex b/doc/context/sources/general/manuals/languages/languages-basics.tex index 39ce840f3..840897096 100644 --- a/doc/context/sources/general/manuals/languages/languages-basics.tex +++ b/doc/context/sources/general/manuals/languages/languages-basics.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-basics +\environment languages-environment + \startchapter[title=Some basics][color=darkyellow] \startsection[title={Introduction}] @@ -35,11 +35,11 @@ up to users to provide the information.} \getbuffer -\noindentation You can call up such a table with the following commands: +You can call up such a table with the following commands: \typebuffer -\noindentation Instead you can run \type {context --global languages-system.mkiv}. +Instead you can run \type {context --global languages-system.mkiv}. As you can see, many languages have hyphenation patterns but for Japanese, Korean, Chinese as well as Arabic languages they make no sense. The patterns are @@ -107,7 +107,7 @@ In the line 4 we have a \type {\-} between the two words, and in the last line just a \type {-}. If you look closely you will notice that the snippets can be quite small. If we typeset a word with a 1mm text width we get this: -\blank \noindentation \start \en \hsize 1mm incredibly \par \stop \blank +\blank \start \en \hsize 1mm incredibly \par \stop \blank If you are familiar with the details of hyphenation, you know that the number of characters at the end and beginning of a word is controlled by the two variables @@ -122,7 +122,7 @@ a language. It is insensitive for capitalization as the following text shows: \blank -\startnarrower \noindentation +\startnarrower \hyphenatedword {This time the musical distraction while developing code came from watching youtube performances of Cory Henry (also known from Snarky Puppy, a conglomerate of excellent players). Just search the web for his name with \quote @@ -139,7 +139,7 @@ are of course many more fantastic musicians.} \blank -\noindentation Of course, names are often short and don't need to be hyphenated +Of course, names are often short and don't need to be hyphenated (or the left and right settings prohibit it). Another complication with names is that they can come from another language so we either need to switch language temporarily or we need to add an exception (more about that later). @@ -315,9 +315,9 @@ are several ways to do this: \typebuffer -\noindentation This typesets: +This typesets: -\blank \start \setupindenting[no] \getbuffer \stop \blank +\blank \startpacked \setupindenting[no] \getbuffer \stoppacked \blank When you use setups you can use the following trick: @@ -337,7 +337,7 @@ When you use setups you can use the following trick: \typebuffer -\noindentation As expected we get: +As expected we get: \blank \start \setupindenting[no] \getbuffer \stop \blank diff --git a/doc/context/sources/general/manuals/languages/languages-contents.tex b/doc/context/sources/general/manuals/languages/languages-contents.tex deleted file mode 100644 index 10fadb56b..000000000 --- a/doc/context/sources/general/manuals/languages/languages-contents.tex +++ /dev/null @@ -1,13 +0,0 @@ -% language=uk - -\startcomponent languages-contents - -\environment languages-environment - -\starttitle[title=Contents][color=darkgray] - -\placelist[chapter][criterium=text] - -\stoptitle - -\stopcomponent diff --git a/doc/context/sources/general/manuals/languages/languages-cover.tex b/doc/context/sources/general/manuals/languages/languages-cover.tex deleted file mode 100644 index 75a033b5f..000000000 --- a/doc/context/sources/general/manuals/languages/languages-cover.tex +++ /dev/null @@ -1,133 +0,0 @@ -% language=uk - -\startcomponent languages-cover - -\environment languages-environment - -\startbuffer[abstract] - -This book explains how we support languages (and -scripts) in \CONTEXT\ \MKIV\ and \LUATEX. Some of -the mechanisms discussed are generic and not -\CONTEXT\ specific. We discuss the way languages are -dealt with in the engine, hyphenation, standard -features and additional goodies. Tracing and the -extensibility of code are also discussed. - -\stopbuffer - -\startsetups document:abstract - \framed [ - foregroundstyle=bold, - foregroundcolor=white, - width=7.5cm, - align={normal,tolerant}, - frame=off, - strut=no, - ] { - \getbuffer[abstract] - } -\stopsetups - -\startMPextensions - - def DrawCoverPage (expr what) = - - begingroup ; - - save SpineWidth ; numeric SpineWidth ; SpineWidth := 8mm ; - save PaperBleed ; numeric PaperBleed ; PaperBleed := 2mm ; % todo - - StartCover ; - - save width, size, anchor ; - - numeric width, size ; pair anchor, offset ; - - color ColorVariant[] ; - - % ColorVariant[1] := \MPcolor{darkred} ; - % ColorVariant[2] := \MPcolor{darkgreen} ; - % ColorVariant[3] := \MPcolor{darkblue} ; - % ColorVariant[4] := \MPcolor{darkyellow} ; - - ColorVariant[1] := \MPcolor{darkmagenta} ; - ColorVariant[2] := \MPcolor{darkorange} ; - ColorVariant[3] := \MPcolor{darkyellow} ; - ColorVariant[4] := \MPcolor{darkcyan} ; - - fill CoverPage enlarged PaperBleed withcolor \MPcolor{darkgray} ; - - fill Spine bottomenlarged -.5CoverHeight withcolor ColorVariant[3] ; - fill Spine topenlarged -.5CoverHeight withcolor ColorVariant[2] ; - - width := FrontPageWidth ; - height := FrontPageHeight ; - size := 4 * width / 3 ; - offset := (-1cm,1cm) ; - anchor := .5[lrcorner CoverPage,urcorner CoverPage] ; - - fill anchored.llft(lltriangle scaled size, urcorner FrontPage) withcolor ColorVariant[1] ; - fill anchored.urt (urtriangle scaled size, llcorner FrontPage) withcolor ColorVariant[2] ; - fill anchored.lrt (lrtriangle scaled size, ulcorner FrontPage) withcolor ColorVariant[3] ; - fill anchored.ulft(ultriangle scaled size, lrcorner FrontPage) withcolor ColorVariant[4] ; - - fill anchored.lrt (lrtriangle scaled size, ulcorner BackPage) withcolor ColorVariant[1] ; - fill anchored.llft(lltriangle scaled size, urcorner BackPage) withcolor ColorVariant[3] ; - fill anchored.ulft(ultriangle scaled size, lrcorner BackPage) withcolor ColorVariant[2] ; - fill anchored.urt (urtriangle scaled size, llcorner BackPage) withcolor ColorVariant[4] ; - - draw thetextext.llft(textext("\bf Languages in \ConTeXt\hskip-.1em") rotated 45 ysized .350height, anchor shifted (6*offset+offset)) withcolor white ; - draw thetextext.llft(textext("\bf explaining luatex and mkiv") rotated 45 ysized .275height, anchor shifted (5*offset+offset)) withcolor white ; - draw thetextext.llft(textext("\bf Hans Hagen") rotated 45 ysized .200height, anchor shifted (2*offset+offset)) withcolor white ; - draw thetextext.llft(textext("\bf PRAGMA ADE") rotated 45 ysized .200height, anchor shifted (1*offset+offset)) withcolor white ; - - % for the moment - - draw thetextext.top(textext("\bf work in progress") xsized 4cm, lrcorner Page shifted (-3cm,1cm)) withcolor white ; - - % till here - - width := BackPageWidth ; - - draw thetextext(textext("\bf\setups[document:abstract]") xsized .65width rotated 45 , center BackPage) withcolor white ; - - anchor := .5[ulcorner Spine,urcorner Spine] shifted (0,-1cm); - - draw thetextext.bot(textext("\bf Languages in \ConTeXt\hskip-.1em") rotated 90 xsized .8SpineWidth, anchor) withcolor white ; - - anchor := .5[llcorner Spine,lrcorner Spine] shifted (0,1cm); - - draw thetextext.top(textext("\bf Hans Hagen") rotated 90 xsized .8SpineWidth, anchor) withcolor white ; - - StopCover ; - - if what = "front" : - clip currentpicture to FrontPage ; - elseif what = "back" : - clip currentpicture to BackPage ; - else : - drawboundary CoverPage ; - fi ; - - endgroup ; - - enddef ; - -\stopMPextensions - -\doifmodeelse {simple} { - - \startMPpage - DrawCoverPage("front") ; - \stopMPpage - -} { - - \startMPpage - DrawCoverPage("cover") ; - \stopMPpage - -} - -\stopcomponent diff --git a/doc/context/sources/general/manuals/languages/languages-environment.tex b/doc/context/sources/general/manuals/languages/languages-environment.tex index ff529a8d1..2669fe0c5 100644 --- a/doc/context/sources/general/manuals/languages/languages-environment.tex +++ b/doc/context/sources/general/manuals/languages/languages-environment.tex @@ -1,347 +1,15 @@ \startenvironment languages-environment -\usemodule[visual] -\usemodule[simulate] + \environment manuals-explaining-environment + \environment manuals-explaining-cover -\dontcomplain + \usemodule [s] [languages-hyphenation] + \usemodule [s] [languages-frequencies] + \usemodule [s] [languages-sorting] + \usemodule [s] [languages-counters] + \usemodule [s] [languages-system] -\definepapersize - [book] - [width=18cm, - height=24cm] - -\setuppapersize - [book] - -\startmode[oversized] - - \setuppapersize - [book] - [oversized] - - \setuplayout - [marking=on] - -\stopmode - -\setuplayout - [location=middle, - topspace=1.5cm, - bottomspace=2cm, - backspace=2cm, - cutspace=2cm, - header=0cm, - footer=0cm, - margindistance=.25cm, - margin=1.25cm, - width=middle, - height=middle] - -\setuplayout - [style=\ss] - -\usetypescript - [dejavu-condensed] - -\setupbodyfont - [ipaex,9pt] - -\setupbodyfont - [dejavu,9pt] - -\definetyping - [narrowtyping] - [typing] - [bodyfont=dejavu-condensed] - -% This is way too ugly for a manual: -% -% \setuptyping -% [indentnext=no] -% -% \setupindenting -% [medium,yes] - -\setupwhitespace - [big] - -\defineoverlay - [page] - [\useMPgraphic{page}] - -\setupbackgrounds - [page] - [background=page] - -\setuphead - [chapter,section,subsection] - [color=\namedstructureuservariable{chapter}{color}] - -\setuphead - [chapter] - [style=\bfc] - -\setuphead - [section] - [style=\bfb] - -\setuphead - [subsection] - [style=\bf, - before=\blank, - after=\blank] - -\startsetups document:chapter:inside - \definecolor[maincolor][1.0(\namedheadparameter{chapter}{color})] % this expands the color - \definecolor[halfcolor][0.5(maincolor,white)] -\stopsetups - -\setuphead - [chapter] - [insidesection=\setup{document:chapter:inside}] - -\setuppagenumbering - [alternative=doublesided, - location=] - -\setuplist - [aligntitle=yes] - -\setuplist - [chapter] - [pagenumber=no, - style=bold, - before={\blank\startcolor[\structurelistuservariable{color}]}, - after={\placelist[section]\stopcolor}] - -\setuplist - [chapter,section] - [width=3em] - -\startuseMPgraphic{page} - - StartPage ; - - linecap := butt ; - - if OnRightPage : - - path p ; p := ( - urcorner Page shifted (-2cm,0) -- - urcorner Page -- - urcorner Page shifted (0,-2cm) -- cycle - ) shifted (-2.5mm,-2.5mm) ; - - else : - - path p ; p := ( - ulcorner Page shifted (2cm,0) -- - ulcorner Page -- - ulcorner Page shifted (0,-2cm) -- cycle - ) shifted (2.5mm,-2.5mm) ; - - fi ; - - fill p - withpen pencircle scaled 1mm - % withcolor \MPcolor{\namedstructureuservariable{chapter}{color}} ; - withcolor \MPcolor{maincolor} ; - - draw thetextext("\bf\userpagenumber", - if OnRightPage : urcorner p shifted (-5mm,-5mm) else : ulcorner p shifted (5mm,-5mm) fi) - withcolor white ; - - if OnRightPage : - - path p ; p := ( - lrcorner Page shifted (-5cm,0) -- - lrcorner Page - ) shifted (-5mm,10mm) - - else : - - path p ; p := ( - llcorner Page shifted (5cm,0) -- - llcorner Page - ) shifted (5mm,10mm) ; - - fi ; - - draw p - withpen pencircle scaled 1mm - % withcolor \MPcolor{\namedstructureuservariable{chapter}{color}} ; - withcolor \MPcolor{maincolor} ; - - draw if OnRightPage : - thetextext.lft("\bf\getspecificstructuretitle{chapter}",lrcorner Page shifted (-5mm,5mm)) - else : - thetextext.rt ("\bf\getspecificstructuretitle{chapter}",llcorner Page shifted ( 5mm,5mm)) - fi withcolor \MPcolor{\namedstructureuservariable{chapter}{color}} ; - % fi withcolor \MPcolor{maincolor} ; - - StopPage ; -\stopuseMPgraphic - -\definecolor[orange] [r=1,g=.6,b=.1] - -\definecolor[middlegray] [s=.75] -\definecolor[darkgray] [s=.25] -\definecolor[darkred] [r=.5] -\definecolor[darkgreen] [g=.5] -\definecolor[darkblue] [b=.5] - -\definecolor[darkyellow] [.5(red,green)] -\definecolor[darkmagenta][.5(red,blue)] -\definecolor[darkcyan] [.5(green,blue)] - -\definecolor[darkorange] [.5(orange)] - -\definecolor [mix-1] [r=1,g=.75,b=.25] \definecolor [darkmix-1][.5(mix-1)] -\definecolor [mix-2] [r=1,g=.25,b=.75] \definecolor [darkmix-2][.5(mix-2)] -\definecolor [mix-3] [r=.75,g=1,b=.25] \definecolor [darkmix-3][.5(mix-3)] -\definecolor [mix-4] [r=.75,g=.25,b=1] \definecolor [darkmix-4][.5(mix-4)] -\definecolor [mix-5] [r=.25,g=1,b=.75] \definecolor [darkmix-5][.5(mix-5)] -\definecolor [mix-6] [r=.25,g=.75,b=1] \definecolor [darkmix-6][.5(mix-6)] - -% \blackrule[height=1cm,width=10cm,color=mix-1] \blackrule[height=1cm,width=10cm,color=darkmix-1] -% \blackrule[height=1cm,width=10cm,color=mix-2] \blackrule[height=1cm,width=10cm,color=darkmix-2] -% \blackrule[height=1cm,width=10cm,color=mix-3] \blackrule[height=1cm,width=10cm,color=darkmix-3] -% \blackrule[height=1cm,width=10cm,color=mix-4] \blackrule[height=1cm,width=10cm,color=darkmix-4] -% \blackrule[height=1cm,width=10cm,color=mix-5] \blackrule[height=1cm,width=10cm,color=darkmix-5] -% \blackrule[height=1cm,width=10cm,color=mix-6] \blackrule[height=1cm,width=10cm,color=darkmix-6] - -\definecolor[maincolor] [darkgray] - -% modules - -\usemodule - [abr-01] - -\setupsorting - [logo] - [style=] - -\usemodule [chart] -\usemodule [nodechart] - -% \usemodule [s] [fonts-tables] -% \usemodule [s] [fonts-missing] -% \usemodule [s] [fonts-vectors] -% \usemodule [s] [fonts-features] - -\usemodule [s] [languages-words] -\usemodule [s] [languages-hyphenation] -\usemodule [s] [languages-frequencies] -\usemodule [s] [languages-sorting] -\usemodule [s] [languages-counters] -\usemodule [s] [languages-system] - -\usemodule [s] [math-extensibles] - -\setupFLOWchart - [width=6em, - height=3em, - offset=-2em, % maybe default : todo: hoffset and voffset - dx=2em, - dy=2em] - -\setupFLOWlines - [color=maincolor] - -\setupFLOWshapes - [rulecolor=maincolor] - -% tables - -\setuptabulate - [rulethickness=.5mm, - rulecolor=maincolor] - -% special commands - -\startuniqueMPgraphic{reference}{color} - fill - .5[llcorner OverlayBox,ulcorner OverlayBox] -- - .5[ulcorner OverlayBox,urcorner OverlayBox] -- - .5[urcorner OverlayBox,lrcorner OverlayBox] -- - .5[lrcorner OverlayBox,llcorner OverlayBox] -- cycle - withcolor \MPvar{color} ; -\stopuniqueMPgraphic - -\startuniqueMPgraphic{reference}{color} - path p ; p := OverlayBox enlarged -1mm ; - filldraw - ulcorner p -- - urcorner p -- - lrcorner p -- - .5[lrcorner p,llcorner p] shifted (0,-1ExHeight) -- - llcorner p -- cycle - withpen pencircle scaled 1mm - withcolor \MPvar{color} ; - setbounds currentpicture to OverlayBox enlarged 1ExHeight ; -\stopuniqueMPgraphic - -\defineoverlay[reference][\uniqueMPgraphic{reference}{color=maincolor,}] - -\definecolor[maincolor][red] - -\definemargindata - [appendixdata] -% [inner] - [outer] - [stack=yes] - -\definemarginframed - [appendixdata] - [width=3.5em, - height=\lineheight, % we know what goes in there - align=middle, - offset=overlay, - foregroundcolor=white, - background=reference] - -% todo: -% -% \appendixdata[reference=bla]{} -% -% whole data - -% interaction - -\setupinteraction - [state=start, - click=no, - color=, - contrastcolor=, - style=] - -% extra fonts (shared among chapters) - -\definefontfeature[demo-onum][kern=yes,onum=yes] -%definefontfeature[demo-lnum][kern=yes,lnum=yes] -\definefontfeature[demo-tnum][kern=yes,tnum=yes] -\definefontfeature[demo-pnum][kern=yes,pnum=yes] -\definefontfeature[demo-zero][zero=yes] -\definefontfeature[demo-none][] - -\definefont[DemoOnumLM][file:lmroman10-regular*demo-onum at 42pt] -%definefont[DemoLnumLM][file:lmroman10-regular*demo-lnum at 42pt] -\definefont[DemoTnumLM][file:lmroman10-regular*demo-tnum at 42pt] -\definefont[DemoPnumLM][file:lmroman10-regular*demo-pnum at 42pt] - -\definefont[DemoZeroLM][file:lmroman10-regular*demo-zero at 42pt] -\definefont[DemoNoneLM][file:lmroman10-regular*demo-none at 42pt] - -\definefont[DemoZeroLT][file:lmtypewriter10-regular*demo-zero at 42pt] -\definefont[DemoNoneLT][file:lmtypewriter10-regular*demo-none at 42pt] - -\definestartstop - [notabene] - [before=\blank, - after=\blank, - style=\em] - -\setuphyphenation - [method=default] + \usemodule [s] [math-extensibles] \stopenvironment + diff --git a/doc/context/sources/general/manuals/languages/languages-goodies.tex b/doc/context/sources/general/manuals/languages/languages-goodies.tex index fbbfafc34..32de54db3 100644 --- a/doc/context/sources/general/manuals/languages/languages-goodies.tex +++ b/doc/context/sources/general/manuals/languages/languages-goodies.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-goodies +\environment languages-environment + \startchapter[title=Goodies][color=darkorange] \startsection[title=Introduction] diff --git a/doc/context/sources/general/manuals/languages/languages-hyphenation.tex b/doc/context/sources/general/manuals/languages/languages-hyphenation.tex index 48e6eb385..6698717be 100644 --- a/doc/context/sources/general/manuals/languages/languages-hyphenation.tex +++ b/doc/context/sources/general/manuals/languages/languages-hyphenation.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-hyphenation +\environment languages-environment + \startchapter[title=Hyphenation][color=darkmagenta] \startsection[title=How it works] @@ -339,7 +339,7 @@ aaaaabbbbb \par \typebuffer -\noindentation This code is self explaining and results in: +This code is self explaining and results in: \blank @@ -347,8 +347,7 @@ aaaaabbbbb \par \setupindenting[no]\hsize 1mm \lefthyphenmin 1 \righthyphenmin 1 \getbuffer \stophyphenation -\noindentation There can be multiple hyphens and even multiple words in such a -specification: +There can be multiple hyphens and even multiple words in such a specification: \startbuffer \registerhyphenationexception[aaaaa-bbbbb cc-ccc-ddd-dd] @@ -358,7 +357,7 @@ cccccddddd \par \typebuffer -\noindentation We get: +We get: \blank @@ -520,7 +519,7 @@ When applied to one the tufte example we get: \starthyphenation[traditional] \setuptolerance[tolerant] \sethyphenationfeatures[demo] - \noindentation % \dontleavehmode + \dontleavehmode \input tufte\relax \stophyphenation \stopbuffer @@ -626,7 +625,7 @@ So, we only break a line after symbols. \stophyphenation \stoplinecorrection -\noindentation A quick test can look as follows: +A quick test can look as follows: \startbuffer \starthyphenation[traditional] @@ -663,7 +662,7 @@ superef\zwnj fective \typebuffer[sample] -\noindentation and define two featuresets: +and define two featuresets: \startbuffer \definehyphenationfeatures @@ -678,7 +677,7 @@ superef\zwnj fective \typebuffer \getbuffer -\noindentation We limit the width to 1mm and get: +We limit the width to 1mm and get: \startlinecorrection[blank] \bTABLE[option=stretch,offset=.5ex] @@ -748,7 +747,7 @@ same as the breakpoints mechanism (compounds). \starthyphenation[traditional] \sethyphenationfeatures[demo-3] \dontcomplain - \hsize 1mm \noindentation + \hsize 1mm we use (super)special(ized) patterns \stophyphenation \stopbuffer @@ -764,11 +763,11 @@ We can make this more clever by adding patterns: \typebuffer \blank \getbuffer \blank -\noindentation This gives: +This gives: \blank \getbuffer[demo] \blank -\noindentation A detailed trace shows that these patterns get applied: +A detailed trace shows that these patterns get applied: \starthyphenation[traditional] \ttx @@ -778,8 +777,75 @@ We can make this more clever by adding patterns: \unregisterhyphenationpattern[en][)9] \unregisterhyphenationpattern[en][9(] -\noindentation The somewhat weird hyphens at the edges will in practice not show -up because there is always one regular character there. +The somewhat weird hyphens at the edges will in practice not show up because +there is always one regular character there. + +\stopsection + +\startsection[title=Counting] + +There is not much you can do about patterns. It's a craft to make them and so +they are shipped with the distribution. In order to hyphenate well, \TEX\ looks +at some character properties. In \CONTEXT\ only the characters used in the +patterns of a language get tagged as valid in a word. + +The following example illustrates that there can be corner cases. In fact, this +example might render differently depending on the patterns available. First we +define an extra language, based on French. + +\startbuffer +\installlanguage[frf][default=fr,patterns=fr,factor=yes] +\stopbuffer + +\typebuffer \getbuffer + +Here we set the \type {factor} parameter which tells the loader that it should +look at the characters used in a special way: some count for none, and some count +for more than one when determining the min values used to determine if and where +hyphenation is to be applied. + +\startbuffer +\startmixedcolumns[n=3,balance=yes] + \hsize 1mm \dontcomplain + \language[fr] aesop oedipus æsop œdipus \column + \hsize 1mm \dontcomplain + \language[frf] aesop oedipus æsop œdipus \column + \startexceptions æ-sop \stopexceptions + \hsize 1mm \dontcomplain + \language[frf] aesop oedipus æsop œdipus +\stopmixedcolumns +\stopbuffer + +\typebuffer + +We get three (when writing this manual) different columns: + +\getbuffer + +The trick is in the \type {factor}: when set to \type {yes} an \type {æ} is +counted as two characters. Combining marks count as zero but you will not +find them being used as we already resolve them in an earlier stage. + +\startluacode +context.startcolumns { n = 2 } +context.starttabulate { "|Tc|c|c|l|" } +for u, data in table.sortedhash(languages.hjcounts) do + if data.category ~= "combining" then + context.NC() context("%05U",u) + context.NC() context("%c",u) + context.NC() context(data.count) + context.NC() context(data.category) + context.NC() context.NR() + end +end +context.stoptabulate() +context.stopcolumns() +\stopluacode + +It is very unlikely to find an \type {ffi} in the input and even an \type {ij} is +rare. The \type {æ} is marked as character and the \type {œ} a ligatyure in +\UNICODE. Maybe all the characters here are dubious but al least we provide a +way to experiment with them. \stopsection diff --git a/doc/context/sources/general/manuals/languages/languages-labels.tex b/doc/context/sources/general/manuals/languages/languages-labels.tex index 3d1c00c04..6c806ab1c 100644 --- a/doc/context/sources/general/manuals/languages/languages-labels.tex +++ b/doc/context/sources/general/manuals/languages/languages-labels.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-labels +\environment languages-environment + \startchapter[title=Labels][color=darkcyan] \startsection[title=Introduction] diff --git a/doc/context/sources/general/manuals/languages/languages-mkiv.tex b/doc/context/sources/general/manuals/languages/languages-mkiv.tex index e054cd8de..98ca84814 100644 --- a/doc/context/sources/general/manuals/languages/languages-mkiv.tex +++ b/doc/context/sources/general/manuals/languages/languages-mkiv.tex @@ -15,39 +15,47 @@ \enablemode[simple] % ,oversized -\startproduct languages-mkiv +\startbuffer[abstract] -\environment languages-environment - -\setupbackgrounds[page][background=] - -\component languages-cover - -% \startcovermatter - -\page[dummy] \setupbackgrounds[page][background=page] \resetuserpagenumber + This book explains how we support languages (and scripts) in \CONTEXT\ \MKIV\ + and \LUATEX. Some of the mechanisms discussed are generic and not \CONTEXT\ + specific. We discuss the way languages are dealt with in the engine, + hyphenation, standard features and additional goodies. Tracing and the + extensibility of code are also discussed. -% \stopcovermatter +\stopbuffer -\startfrontmatter - \component languages-contents - \component languages-introduction -\stopfrontmatter - -\startbodymatter - \component languages-basics - \component languages-hyphenation - \component languages-labels - \component languages-numbering - \component languages-typesetting - \component languages-goodies - \component languages-sorting -\stopbodymatter - -\startappendices - \component languages-appendix -\stopappendices - -\component languages-back +\environment languages-environment -\stopproduct +\startdocument + [author=Hans Hagen, + title=Languages in \ConTeXt, + subtitle=explaining luatex and mkiv, + affiliation=PRAGMA ADE, + comment=work in progress, + cover:color:1=darkmagenta, + cover:color:2=darkorange, + cover:color:3=darkyellow, + cover:color:4=darkcyan, + cover:color:5=darkgray] + + \startfrontmatter + \component manuals-explaining-contents + \component languages-introduction + \stopfrontmatter + + \startbodymatter + \component languages-basics + \component languages-hyphenation + \component languages-labels + \component languages-numbering + \component languages-typesetting + \component languages-goodies + \component languages-sorting + \stopbodymatter + + \startappendices + \component languages-appendix + \stopappendices + +\stopdocument diff --git a/doc/context/sources/general/manuals/languages/languages-numbering.tex b/doc/context/sources/general/manuals/languages/languages-numbering.tex index 90deab417..3464826df 100644 --- a/doc/context/sources/general/manuals/languages/languages-numbering.tex +++ b/doc/context/sources/general/manuals/languages/languages-numbering.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-numbering +\environment languages-environment + \startchapter[title=Numbering][color=darkgreen] \startsection[title=Introduction] @@ -19,13 +19,13 @@ how English, Spanish and Slovenian numbers: \blank \startpacked \startcolor[maincolor] -\noindentation\dontleavehmode +\dontleavehmode {\ttbf\mainlanguage[en]\dorecurse{28} {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par -\noindentation\dontleavehmode +\dontleavehmode {\ttbf\mainlanguage[es]\dorecurse{28} {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par -\noindentation\dontleavehmode +\dontleavehmode {\ttbf\mainlanguage[sl]\dorecurse{28} {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par \stopcolor @@ -153,7 +153,7 @@ application: \typebuffer -\noindentation What renders as: +What renders as: \startlines[color=maincolor] \getbuffer @@ -170,7 +170,7 @@ a label text depending on the valu ebeing non|-|zero. \typebuffer -\noindentation This gives: +This gives: \startlines[color=maincolor] \getbuffer @@ -190,7 +190,7 @@ So, \typebuffer -\noindentation Gives: +Gives: \startlines[color=maincolor] \getbuffer @@ -200,17 +200,17 @@ There are also some non language related converters that we mention here for completeness: \blank -\noindentation\type {set 0}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 0}{#1} }\stopcolor\par -\noindentation\type {set 1}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 1}{#1} }\stopcolor\par -\noindentation\type {set 2}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 2}{#1} }\stopcolor\par -\noindentation\type {set 3}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 3}{#1} }\stopcolor\par +\type {set 0}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 0}{#1} }\stopcolor\par +\type {set 1}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 1}{#1} }\stopcolor\par +\type {set 2}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 2}{#1} }\stopcolor\par +\type {set 3}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 3}{#1} }\stopcolor\par \blank When a set overruns we start again at the first element. -\noindentation The ordinal converter produces output like \color [maincolor] -{\convertnumber {ordinal}{123}} and \color [maincolor] {\convertnumber -{ordinal}{654}}. The corresponding string renderer is \type {\highordinalstr}. +The ordinal converter produces output like \color [maincolor] {\convertnumber +{ordinal}{123}} and \color [maincolor] {\convertnumber {ordinal}{654}}. The +corresponding string renderer is \type {\highordinalstr}. % quite limited currently op not documented here: % @@ -250,7 +250,7 @@ specific date with \type {\date}, for instance: \getbuffer \stoplines -\noindentation Possible elements of the specification are: +Possible elements of the specification are: \starttabulate \FL @@ -294,7 +294,7 @@ can also as a specific one, so {\em jalali} \date [y=1395, m=4, d=18] [jalali:from, month, day, {, }, year]. \stopbuffer -\typebuffer \startnarrower \getbuffer stopnarrower +\typebuffer \startnarrower \getbuffer \stopnarrower \stopsection diff --git a/doc/context/sources/general/manuals/languages/languages-sorting.tex b/doc/context/sources/general/manuals/languages/languages-sorting.tex index abf7b292c..ce24f385c 100644 --- a/doc/context/sources/general/manuals/languages/languages-sorting.tex +++ b/doc/context/sources/general/manuals/languages/languages-sorting.tex @@ -1,9 +1,9 @@ % language=uk -\environment languages-environment - \startcomponent languages-sorting +\environment languages-environment + \startchapter[title=Sorting][color=darkblue] \startsection[title=Introduction] diff --git a/doc/context/sources/general/manuals/manuals-explaining-contents.tex b/doc/context/sources/general/manuals/manuals-explaining-contents.tex new file mode 100644 index 000000000..3e1fadabc --- /dev/null +++ b/doc/context/sources/general/manuals/manuals-explaining-contents.tex @@ -0,0 +1,11 @@ +% language=uk + +\startcomponent manuals-explaining-contents + + \starttitle[title=Contents][color=darkgray] + + \placelist[chapter][criterium=text] + + \stoptitle + +\stopcomponent diff --git a/doc/context/sources/general/manuals/manuals-explaining-cover.tex b/doc/context/sources/general/manuals/manuals-explaining-cover.tex new file mode 100644 index 000000000..8b4f3e891 --- /dev/null +++ b/doc/context/sources/general/manuals/manuals-explaining-cover.tex @@ -0,0 +1,199 @@ +% language=uk + +% Please try to be original and don't just copy this cover page as I don't want +% confusion and be associated with (or responsibility for the look of) similar +% looking documents. + +\startenvironment manuals-explaining-cover + +\startsetups document:abstract + \framed [ + foregroundstyle=bold, + foregroundcolor=white, + width=7.5cm, + align={normal,tolerant}, + frame=off, + strut=no, + ] { + \getbuffer[abstract] + } +\stopsetups + +\startMPinclusions + + def DrawCoverPage (expr what) = + + numeric variant ; variant := 1 ; + + StartCover ; + + save width, height, size, anchor, offset, colors ; + + numeric width, height, size ; pair anchor, offset ; string colors[] ; + + colors[1] := "\documentvariable{cover:color:1}" ; + colors[2] := "\documentvariable{cover:color:2}" ; + colors[3] := "\documentvariable{cover:color:3}" ; + colors[4] := "\documentvariable{cover:color:4}" ; + colors[5] := "\documentvariable{cover:color:5}" ; + + fill CoverPage enlarged PaperBleed withcolor colors[5] ; + + fill Spine bottomenlarged -.5PaperHeight withcolor colors[3] ; + fill Spine topenlarged -.5PaperHeight withcolor colors[2] ; + + width := FrontPageWidth ; + height := FrontPageHeight ; + size := 4 * width / 3 ; + offset := (-1cm,1cm) ; + anchor := .5[lrcorner CoverPage,urcorner CoverPage] ; + + fill anchored.llft(lltriangle scaled size, urcorner FrontPage) withcolor colors[1] ; + fill anchored.urt (urtriangle scaled size, llcorner FrontPage) withcolor colors[2] ; + fill anchored.lrt (lrtriangle scaled size, ulcorner FrontPage) withcolor colors[3] ; + fill anchored.ulft(ultriangle scaled size, lrcorner FrontPage) withcolor colors[4] ; + + fill anchored.lrt (lrtriangle scaled size, ulcorner BackPage) withcolor colors[1] ; + fill anchored.llft(lltriangle scaled size, urcorner BackPage) withcolor colors[3] ; + fill anchored.ulft(ultriangle scaled size, lrcorner BackPage) withcolor colors[2] ; + fill anchored.urt (urtriangle scaled size, llcorner BackPage) withcolor colors[4] ; + + draw thetextext.llft( + textext("\bf \documentvariable{title}\hskip-.1em") + rotated 45 ysized .350height, + anchor shifted (6*offset+offset) + ) withcolor white ; + draw thetextext.llft( + textext("\bf \documentvariable{subtitle}") + rotated 45 ysized .275height, + anchor shifted (5*offset+offset) + ) withcolor white ; + draw thetextext.llft( + textext("\bf \documentvariable{author}") + rotated 45 ysized .200height, + anchor shifted (2*offset+offset) + ) withcolor white ; + draw thetextext.llft( + textext("\bf \documentvariable{affiliation}") + rotated 45 ysized .200height, + anchor shifted (1*offset+offset) + ) withcolor white ; + + % for the moment + + if (what = "back") or (what = "cover") : + + draw + thetextext.top( + textext("\bf \documentvariable{comment}") + xsized 4cm, + lrcorner Page shifted (-3cm,1cm) + ) withcolor white ; + + fi ; + + % till here + + width := BackPageWidth ; + + if (what = "back") or (what = "cover") : + + draw thetextext( + textext("\bf\setups[document:abstract]") + xsized .65width rotated 45, + center BackPage + ) withcolor white ; + + fi ; + + if what = "cover" : + + draw thetextext.bot( + textext("\bf \documentvariable{title}\hskip-.1em") + rotated 90 xsized .8SpineWidth, + .5[ulcorner Spine,urcorner Spine] shifted (0,-1cm) + ) withcolor white ; + + draw thetextext.top( + textext("\bf \documentvariable{author}") + rotated 90 xsized .8SpineWidth, + .5[llcorner Spine,lrcorner Spine] shifted (0,1cm) + ) withcolor white ; + + fi ; + + StopCover ; + + if what = "front" : + clip currentpicture to FrontPage ; + elseif what = "back" : + clip currentpicture to BackPage ; + else : + drawboundary CoverPage ; + fi ; + + enddef ; + +\stopMPinclusions + +\startsetups document:start + + % \startcovermatter[front] + + \setupbackgrounds[page][background=] + + \doifmodeelse {simple} { + + \startMPpage + DrawCoverPage("front") ; + \stopMPpage + + } { + + \startMPpage + DrawCoverPage("cover") ; + \stopMPpage + + } + + \page[dummy] + + \setupbackgrounds[page][background=page] + + \resetuserpagenumber + + % \stopcovermatter + +\stopsetups + +\startsetups document:stop + + \doifmodeelse {simple} { + + % \startcovermatter[back] + + \page + + \setuppagenumbering[page=] + + \setupbackgrounds[page][background=] + + \page[empty,left] + + \setupmakeup[doublesided=no,page=no] + + \startMPpage + DrawCoverPage("back") ; + \stopMPpage + + % \stopcovermatter + + } { + + % not needed as it's part of the cover page + + } + +\stopsetups + +\stopenvironment diff --git a/doc/context/sources/general/manuals/manuals-explaining-environment.tex b/doc/context/sources/general/manuals/manuals-explaining-environment.tex new file mode 100644 index 000000000..f896c219b --- /dev/null +++ b/doc/context/sources/general/manuals/manuals-explaining-environment.tex @@ -0,0 +1,325 @@ +\startenvironment manuals-explaining-environment + +\usemodule[abr-01] +\usemodule[visual] +\usemodule[simulate] +\usemodule[chart] +\usemodule[nodechart] + +% done + +\dontcomplain + +\definepapersize + [book] + [width=18cm, + height=24cm] + +\setuppapersize + [book] + +\startmode[oversized] + + \setuppapersize + [book] + [oversized] + + \setuplayout + [marking=on] + +\stopmode + +\setuplayout + [location=middle, + topspace=1.5cm, + bottomspace=2cm, + backspace=2cm, + cutspace=2cm, + header=0cm, + footer=0cm, + margindistance=.25cm, + margin=1.25cm, + width=middle, + height=middle] + +\setuplayout + [style=\ss] + +\usetypescript + [dejavu-condensed] + +\setupbodyfont + [ipaex,9pt] + +\setupbodyfont + [dejavu,9pt] + +\definetyping + [narrowtyping] + [typing] + [bodyfont=dejavu-condensed] + +% This is way too ugly for a manual: +% +% \setuptyping +% [indentnext=no] +% +% \setupindenting +% [medium,yes] + +\setupwhitespace + [big] + +\defineoverlay + [page] + [\useMPgraphic{page}] + +\setupbackgrounds + [page] + [background=page] + +\setuphead + [chapter,section,subsection] + [color=\namedstructureuservariable{chapter}{color}] + +\setuphead + [chapter] + [style=\bfc] + +\setuphead + [section] + [style=\bfb] + +\setuphead + [subsection] + [style=\bf, + before=\blank, + after=\blank] + +\startsetups document:chapter:inside + \definecolor[maincolor][1.0(\namedheadparameter{chapter}{color})] % this expands the color + \definecolor[halfcolor][0.5(maincolor,white)] +\stopsetups + +\setuphead + [chapter] + [insidesection=\directsetup{document:chapter:inside}] + +\setuppagenumbering + [alternative=doublesided, + location=] + +\setuplist + [aligntitle=yes] + +\setuplist + [chapter] + [pagenumber=no, + style=bold, + before={\blank\startcolor[\structurelistuservariable{color}]}, + after={\placelist[section]\stopcolor}] + +\setuplist + [chapter,section] + [width=3em] + +\startuseMPgraphic{page} + + StartPage ; + + linecap := butt ; + + if OnRightPage : + + path p ; p := ( + urcorner Page shifted (-2cm,0) -- + urcorner Page -- + urcorner Page shifted (0,-2cm) -- cycle + ) shifted (-2.5mm,-2.5mm) ; + + else : + + path p ; p := ( + ulcorner Page shifted (2cm,0) -- + ulcorner Page -- + ulcorner Page shifted (0,-2cm) -- cycle + ) shifted (2.5mm,-2.5mm) ; + + fi ; + + fill p + withpen pencircle scaled 1mm + withcolor "maincolor" ; + + draw thetextext("\bf\userpagenumber", + if OnRightPage : urcorner p shifted (-5mm,-5mm) else : ulcorner p shifted (5mm,-5mm) fi) + withcolor white ; + + if OnRightPage : + + path p ; p := ( + lrcorner Page shifted (-5cm,0) -- + lrcorner Page + ) shifted (-5mm,10mm) + + else : + + path p ; p := ( + llcorner Page shifted (5cm,0) -- + llcorner Page + ) shifted (5mm,10mm) ; + + fi ; + + draw p + withpen pencircle scaled 1mm + withcolor "maincolor" ; + + draw if OnRightPage : + thetextext.lft("\bf\getspecificstructuretitle{chapter}",lrcorner Page shifted (-5mm,5mm)) + else : + thetextext.rt ("\bf\getspecificstructuretitle{chapter}",llcorner Page shifted ( 5mm,5mm)) + fi withcolor "\namedstructureuservariable{chapter}{color}" ; + + StopPage ; +\stopuseMPgraphic + +\definecolor[orange] [r=1,g=.6,b=.1] + +\definecolor[middlegray] [s=.75] +\definecolor[darkgray] [s=.25] +\definecolor[darkred] [r=.5] +\definecolor[darkgreen] [g=.5] +\definecolor[darkblue] [b=.5] + +\definecolor[darkyellow] [.5(red,green)] +\definecolor[darkmagenta][.5(red,blue)] +\definecolor[darkcyan] [.5(green,blue)] + +\definecolor[darkorange] [.5(orange)] + +\definecolor[maincolor] [darkgray] + +\definecolor [mix-1] [r=1,g=.75,b=.25] \definecolor [darkmix-1][.5(mix-1)] +\definecolor [mix-2] [r=1,g=.25,b=.75] \definecolor [darkmix-2][.5(mix-2)] +\definecolor [mix-3] [r=.75,g=1,b=.25] \definecolor [darkmix-3][.5(mix-3)] +\definecolor [mix-4] [r=.75,g=.25,b=1] \definecolor [darkmix-4][.5(mix-4)] +\definecolor [mix-5] [r=.25,g=1,b=.75] \definecolor [darkmix-5][.5(mix-5)] +\definecolor [mix-6] [r=.25,g=.75,b=1] \definecolor [darkmix-6][.5(mix-6)] + +% \blackrule[height=1cm,width=10cm,color=mix-1] \blackrule[height=1cm,width=10cm,color=darkmix-1] +% \blackrule[height=1cm,width=10cm,color=mix-2] \blackrule[height=1cm,width=10cm,color=darkmix-2] +% \blackrule[height=1cm,width=10cm,color=mix-3] \blackrule[height=1cm,width=10cm,color=darkmix-3] +% \blackrule[height=1cm,width=10cm,color=mix-4] \blackrule[height=1cm,width=10cm,color=darkmix-4] +% \blackrule[height=1cm,width=10cm,color=mix-5] \blackrule[height=1cm,width=10cm,color=darkmix-5] +% \blackrule[height=1cm,width=10cm,color=mix-6] \blackrule[height=1cm,width=10cm,color=darkmix-6] + +% modules + +\setupsorting + [logo] + [style=] + +\setupFLOWchart + [width=6em, + height=3em, + offset=-2em, % maybe default : todo: hoffset and voffset + dx=2em, + dy=2em] + +\setupFLOWlines + [color=maincolor] + +\setupFLOWshapes + [rulecolor=maincolor] + +% tables + +\setuptabulate + [rulethickness=.5mm, + rulecolor=maincolor] + +% special commands + +\startuniqueMPgraphic{reference}{color} + fill + .5[llcorner OverlayBox,ulcorner OverlayBox] -- + .5[ulcorner OverlayBox,urcorner OverlayBox] -- + .5[urcorner OverlayBox,lrcorner OverlayBox] -- + .5[lrcorner OverlayBox,llcorner OverlayBox] -- cycle + withcolor \MPvar{color} ; +\stopuniqueMPgraphic + +\startuniqueMPgraphic{reference}{color} + path p ; p := OverlayBox enlarged -1mm ; + filldraw + ulcorner p -- + urcorner p -- + lrcorner p -- + .5[lrcorner p,llcorner p] shifted (0,-1ExHeight) -- + llcorner p -- cycle + withpen pencircle scaled 1mm + withcolor \MPvar{color} ; + setbounds currentpicture to OverlayBox enlarged 1ExHeight ; +\stopuniqueMPgraphic + +\defineoverlay + [reference] + [\uniqueMPgraphic{reference}{color=maincolor,}] + +\definecolor + [maincolor] + [red] + +\definemargindata + [appendixdata] + %[inner] + [outer] + [stack=yes] + +\definemarginframed + [appendixdata] + [width=3.5em, + height=\lineheight, % we know what goes in there + align=middle, + offset=overlay, + foregroundcolor=white, + background=reference] + +% todo: +% +% \appendixdata[reference=bla]{} +% +% whole data + +% interaction + +\setupinteraction + [state=start, + click=no, + color=, + contrastcolor=, + style=] + +% whatever + +\definestartstop + [notabene] + [before=\blank, + after=\blank, + style=\em] + +\setuphyphenation + [method=default] + + +\startbuffer[underconstruction] +\startnotabene + This document is still under construction. The functionality discussed here + will stay and more might show up. Of course there are errors, and they're all + mine. The text is not checked for spelling errors. Feel free to let me know + what should get added. +\stopnotabene +\stopbuffer + +\stopenvironment diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 2b9b8bef6..75a6b51b9 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -1538,16 +1538,20 @@ def nofill text t = fill t withpostscript "collect" enddef ; % so we can do: withcolor "red" def resolvedcolor expr s = - % lua.mp.namedcolor(s) % conflicts with macro namedcolor - % lua.mp.NamedColor(s) % okay but, can also be - % lua.mp("NamedColor",s) % which gives expansion mess - runscript("mp.NamedColor('" & s & "')") % faster anyway + % lua.mp.namedcolor(s) % conflicts with macro namedcolor + % lua.mp.NamedColor(s) % okay but, can also be + % lua.mp("NamedColor",s) % which gives expansion mess + if string s : + runscript("mp.NamedColor('" & s & "')") % faster anyway + else : + s + fi enddef ; % A comment will end up on top of the graphic in the output. This can be handy for % locating a graphic: comment("test graphic"). -def comment(expr str) = +def comment expr str = special "metapost.comment[[" & str & "]]" ; enddef ; diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index 09cf24103..9e086f0df 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -1040,7 +1040,7 @@ primarydef p randomized s = ( ((uniformdeviate s) * p) fi elseif string p : - resolvedcolor(p) randomized s + (resolvedcolor(p)) randomized s else : p + uniformdeviate s fi diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 4b36feacb..a8a372180 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index 1213a637f..31db0a691 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -1251,3 +1251,12 @@ end -- inspect(attributes.colors.spec("red")) -- inspect(attributes.colors.spec("red socks")) + +implement { + name = "negatedcolorcomponent", + arguments = "string", + actions = function(s) + s = 1 - (tonumber(s) or 0) + context((s < 0 and 0) or (s > 1 and 1) or s) + end +} diff --git a/tex/context/base/mkiv/colo-ini.mkiv b/tex/context/base/mkiv/colo-ini.mkiv index 915a5559b..4e6e58032 100644 --- a/tex/context/base/mkiv/colo-ini.mkiv +++ b/tex/context/base/mkiv/colo-ini.mkiv @@ -679,20 +679,26 @@ %D %D These speak for themselves. See \type {colo-ext} for usage. +% \def\negatedcolorcomponent#1% +% {\ifdim\dimexpr\onepoint-#1\onepoint\relax<\zeropoint +% \!!zerocount +% \else +% \expandafter\withoutpt\the\dimexpr\onepoint-#1\onepoint\relax +% \fi} +% +% \unexpanded\def\negatecolorcomponent#1% #1 = \macro +% {\scratchdimen\onepoint\advance\scratchdimen-#1\onepoint +% \ifdim\scratchdimen<\zeropoint\scratchdimen\zeropoint\fi +% \edef#1{\withoutpt\the\scratchdimen}} +% +% \unexpanded\def\negatecolorcomponent#1% #1 = \macro +% {\edef#1{\negatedcolorcomponent{#1}}} + \unexpanded\def\negatecolorcomponent#1% #1 = \macro - {\scratchdimen\onepoint\advance\scratchdimen-#1\onepoint - \ifdim\scratchdimen<\zeropoint\scratchdimen\zeropoint\fi - \edef#1{\withoutpt\the\scratchdimen}} + {\edef#1{\clf_negatecolorcomponent{#1}}} \def\negatedcolorcomponent#1% - {\ifdim\dimexpr\onepoint-#1\onepoint\relax<\zeropoint - \!!zerocount - \else - \expandafter\withoutpt\the\dimexpr\onepoint-#1\onepoint\relax - \fi} - -\unexpanded\def\negatecolorcomponent#1% #1 = \macro - {\edef#1{\negatedcolorcomponent{#1}}} + {\clf_negatecolorcomponent{#1}} %D \macros %D {MPcolor} @@ -1330,7 +1336,6 @@ \colo_helpers_inherited_current_ca{#1} % \colo_helpers_inherited_current_ta{#1} } - \def\thecolormodelattribute {\the\attribute\colormodelattribute} %def\thecolorattribute #1{\number\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index cad11bcd0..8e28247cd 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.07.15 23:30} +\newcontextversion{2016.07.18 16:46} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 1a6eccdb9..7259b70ad 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.07.15 23:30} +\edef\contextversion{2016.07.18 16:46} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/lang-cnt.lua b/tex/context/base/mkiv/lang-cnt.lua new file mode 100644 index 000000000..21de6c2d1 --- /dev/null +++ b/tex/context/base/mkiv/lang-cnt.lua @@ -0,0 +1,164 @@ +if not modules then modules = { } end modules ['lang-cnt'] = { + version = 1.001, + comment = "companion to lang-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is generated with help from ctx-checkedcombined.lua (an ugly local +-- helper script). + +-- We don't really need this as we compose and decompose already. The only +-- exception are the ae etc but these can best be entered in their unicode +-- form anyway. So, even if we can support hjcodes with counts is is not +-- needed in practice. It's anyway debatable if æ should be seen as one +-- character or two. And ffi and ij and such are not used in patterns anyway. + +languages = languages or { } + +languages.hjcounts = { -- used: used in registered unicode characters + -- + [0x000C6] = { category = "letter", count = 2 }, -- Æ + [0x000E6] = { category = "letter", count = 2 }, -- æ + -- + [0x01E9E] = { category = "letter", count = 2 }, -- ẞ + [0x000DF] = { category = "letter", count = 2 }, -- ß + -- + [0x00132] = { category = "dubious", count = 2 }, -- IJ + [0x00133] = { category = "dubious", count = 2 }, -- ij + -- + [0x00152] = { category = "dubious", count = 2 }, -- Œ + [0x00153] = { category = "dubious", count = 2 }, -- œ + -- + [0x001C7] = { category = "letter", count = 2 }, -- LJ + [0x001C8] = { category = "letter", count = 2 }, -- Lj + [0x001C9] = { category = "letter", count = 2 }, -- lj + -- + [0x001CA] = { category = "letter", count = 2 }, -- NJ + [0x001CC] = { category = "letter", count = 2 }, -- nj + -- not in patterns + [0x0FB01] = { category = "ligature", count = 2 }, -- fi + [0x0FB02] = { category = "ligature", count = 2 }, -- fl + [0x0FB03] = { category = "ligature", count = 3 }, -- ffi + [0x0FB04] = { category = "ligature", count = 3 }, -- ffl + [0x0FB06] = { category = "ligature", count = 2 }, -- st + -- + [0x00300] = { category = "combining", count = 0, used = true }, -- ̀ + [0x00301] = { category = "combining", count = 0, used = true }, -- ́ + [0x00302] = { category = "combining", count = 0, used = true }, -- ̂ + [0x00303] = { category = "combining", count = 0, used = true }, -- ̃ + [0x00304] = { category = "combining", count = 0, used = true }, -- ̄ + [0x00305] = { category = "combining", count = 0, used = false }, -- ̅ + [0x00306] = { category = "combining", count = 0, used = true }, -- ̆ + [0x00307] = { category = "combining", count = 0, used = true }, -- ̇ + [0x00308] = { category = "combining", count = 0, used = true }, -- ̈ + [0x00309] = { category = "combining", count = 0, used = true }, -- ̉ + [0x0030A] = { category = "combining", count = 0, used = true }, -- ̊ + [0x0030B] = { category = "combining", count = 0, used = true }, -- ̋ + [0x0030C] = { category = "combining", count = 0, used = true }, -- ̌ + [0x0030D] = { category = "combining", count = 0, used = false }, -- ̍ + [0x0030E] = { category = "combining", count = 0, used = false }, -- ̎ + [0x0030F] = { category = "combining", count = 0, used = true }, -- ̏ + [0x00310] = { category = "combining", count = 0, used = false }, -- ̐ + [0x00311] = { category = "combining", count = 0, used = true }, -- ̑ + [0x00312] = { category = "combining", count = 0, used = false }, -- ̒ + [0x00313] = { category = "combining", count = 0, used = true }, -- ̓ + [0x00314] = { category = "combining", count = 0, used = true }, -- ̔ + [0x00315] = { category = "combining", count = 0, used = false }, -- ̕ + [0x00316] = { category = "combining", count = 0, used = false }, -- ̖ + [0x00317] = { category = "combining", count = 0, used = false }, -- ̗ + [0x00318] = { category = "combining", count = 0, used = false }, -- ̘ + [0x00319] = { category = "combining", count = 0, used = false }, -- ̙ + [0x0031A] = { category = "combining", count = 0, used = false }, -- ̚ + [0x0031B] = { category = "combining", count = 0, used = true }, -- ̛ + [0x0031C] = { category = "combining", count = 0, used = false }, -- ̜ + [0x0031D] = { category = "combining", count = 0, used = false }, -- ̝ + [0x0031E] = { category = "combining", count = 0, used = false }, -- ̞ + [0x0031F] = { category = "combining", count = 0, used = false }, -- ̟ + [0x00320] = { category = "combining", count = 0, used = false }, -- ̠ + [0x00321] = { category = "combining", count = 0, used = false }, -- ̡ + [0x00322] = { category = "combining", count = 0, used = false }, -- ̢ + [0x00323] = { category = "combining", count = 0, used = true }, -- ̣ + [0x00324] = { category = "combining", count = 0, used = true }, -- ̤ + [0x00325] = { category = "combining", count = 0, used = true }, -- ̥ + [0x00326] = { category = "combining", count = 0, used = true }, -- ̦ + [0x00327] = { category = "combining", count = 0, used = true }, -- ̧ + [0x00328] = { category = "combining", count = 0, used = true }, -- ̨ + [0x00329] = { category = "combining", count = 0, used = false }, -- ̩ + [0x0032A] = { category = "combining", count = 0, used = false }, -- ̪ + [0x0032B] = { category = "combining", count = 0, used = false }, -- ̫ + [0x0032C] = { category = "combining", count = 0, used = false }, -- ̬ + [0x0032D] = { category = "combining", count = 0, used = true }, -- ̭ + [0x0032E] = { category = "combining", count = 0, used = true }, -- ̮ + [0x0032F] = { category = "combining", count = 0, used = false }, -- ̯ + [0x00330] = { category = "combining", count = 0, used = true }, -- ̰ + [0x00331] = { category = "combining", count = 0, used = true }, -- ̱ + [0x00332] = { category = "combining", count = 0, used = false }, -- ̲ + [0x00333] = { category = "combining", count = 0, used = false }, -- ̳ + [0x00334] = { category = "combining", count = 0, used = false }, -- ̴ + [0x00335] = { category = "combining", count = 0, used = false }, -- ̵ + [0x00336] = { category = "combining", count = 0, used = false }, -- ̶ + [0x00337] = { category = "combining", count = 0, used = false }, -- ̷ + [0x00338] = { category = "combining", count = 0, used = false }, -- ̸ + [0x00339] = { category = "combining", count = 0, used = false }, -- ̹ + [0x0033A] = { category = "combining", count = 0, used = false }, -- ̺ + [0x0033B] = { category = "combining", count = 0, used = false }, -- ̻ + [0x0033C] = { category = "combining", count = 0, used = false }, -- ̼ + [0x0033D] = { category = "combining", count = 0, used = false }, -- ̽ + [0x0033E] = { category = "combining", count = 0, used = false }, -- ̾ + [0x0033F] = { category = "combining", count = 0, used = false }, -- ̿ + [0x00340] = { category = "combining", count = 0, used = false }, -- ̀ + [0x00341] = { category = "combining", count = 0, used = false }, -- ́ + [0x00342] = { category = "combining", count = 0, used = true }, -- ͂ + [0x00343] = { category = "combining", count = 0, used = false }, -- ̓ + [0x00344] = { category = "combining", count = 0, used = false }, -- ̈́ + [0x00345] = { category = "combining", count = 0, used = true }, -- ͅ + [0x00346] = { category = "combining", count = 0, used = false }, -- ͆ + [0x00347] = { category = "combining", count = 0, used = false }, -- ͇ + [0x00348] = { category = "combining", count = 0, used = false }, -- ͈ + [0x00349] = { category = "combining", count = 0, used = false }, -- ͉ + [0x0034A] = { category = "combining", count = 0, used = false }, -- ͊ + [0x0034B] = { category = "combining", count = 0, used = false }, -- ͋ + [0x0034C] = { category = "combining", count = 0, used = false }, -- ͌ + [0x0034D] = { category = "combining", count = 0, used = false }, -- ͍ + [0x0034E] = { category = "combining", count = 0, used = false }, -- ͎ + [0x0034F] = { category = "combining", count = 0, used = false }, -- ͏ + [0x00350] = { category = "combining", count = 0, used = false }, -- ͐ + [0x00351] = { category = "combining", count = 0, used = false }, -- ͑ + [0x00352] = { category = "combining", count = 0, used = false }, -- ͒ + [0x00353] = { category = "combining", count = 0, used = false }, -- ͓ + [0x00354] = { category = "combining", count = 0, used = false }, -- ͔ + [0x00355] = { category = "combining", count = 0, used = false }, -- ͕ + [0x00356] = { category = "combining", count = 0, used = false }, -- ͖ + [0x00357] = { category = "combining", count = 0, used = false }, -- ͗ + [0x00358] = { category = "combining", count = 0, used = false }, -- ͘ + [0x00359] = { category = "combining", count = 0, used = false }, -- ͙ + [0x0035A] = { category = "combining", count = 0, used = false }, -- ͚ + [0x0035B] = { category = "combining", count = 0, used = false }, -- ͛ + [0x0035C] = { category = "combining", count = 0, used = false }, -- ͜ + [0x0035D] = { category = "combining", count = 0, used = false }, -- ͝ + [0x0035E] = { category = "combining", count = 0, used = false }, -- ͞ + [0x0035F] = { category = "combining", count = 0, used = false }, -- ͟ + [0x00360] = { category = "combining", count = 0, used = false }, -- ͠ + [0x00361] = { category = "combining", count = 0, used = false }, -- ͡ + [0x00362] = { category = "combining", count = 0, used = false }, -- ͢ + [0x00363] = { category = "combining", count = 0, used = false }, -- ͣ + [0x00364] = { category = "combining", count = 0, used = false }, -- ͤ + [0x00365] = { category = "combining", count = 0, used = false }, -- ͥ + [0x00366] = { category = "combining", count = 0, used = false }, -- ͦ + [0x00367] = { category = "combining", count = 0, used = false }, -- ͧ + [0x00368] = { category = "combining", count = 0, used = false }, -- ͨ + [0x00369] = { category = "combining", count = 0, used = false }, -- ͩ + [0x0036A] = { category = "combining", count = 0, used = false }, -- ͪ + [0x0036B] = { category = "combining", count = 0, used = false }, -- ͫ + [0x0036C] = { category = "combining", count = 0, used = false }, -- ͬ + [0x0036D] = { category = "combining", count = 0, used = false }, -- ͭ + [0x0036E] = { category = "combining", count = 0, used = false }, -- ͮ + [0x0036F] = { category = "combining", count = 0, used = false }, -- ͯ + [0x00483] = { category = "combining", count = 0, used = false }, -- ҃ + [0x00484] = { category = "combining", count = 0, used = false }, -- ҄ + [0x00485] = { category = "combining", count = 0, used = false }, -- ҅ + [0x00486] = { category = "combining", count = 0, used = false }, -- ҆ + [0x00487] = { category = "combining", count = 0, used = false }, -- ҇ +} diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua index b797f85e1..3d166de40 100644 --- a/tex/context/base/mkiv/lang-hyp.lua +++ b/tex/context/base/mkiv/lang-hyp.lua @@ -333,11 +333,11 @@ local function hyphenate(dictionary,word,n) -- odd is okay end local l = 1 local w = { "." } - -- local d = dictionary.codehash or lcchars[c] + -- local d = dictionary.codehash for i=1,n do local c = word[i] + -- l = l + (d[c] or 1) l = l + 1 - -- w[l] = d[c] or c -- needs testing w[l] = lcchars[c] or c end l = l + 1 diff --git a/tex/context/base/mkiv/lang-ini.lua b/tex/context/base/mkiv/lang-ini.lua index 347cb0281..62786d9ab 100644 --- a/tex/context/base/mkiv/lang-ini.lua +++ b/tex/context/base/mkiv/lang-ini.lua @@ -22,7 +22,7 @@ local type, tonumber = type, tonumber local utfbyte = utf.byte local format, gsub, gmatch, find = string.format, string.gsub, string.gmatch, string.find local concat, sortedkeys, sortedpairs, keys, insert = table.concat, table.sortedkeys, table.sortedpairs, table.keys, table.insert -local utfbytes, strip = string.utfvalues, string.strip +local utfbytes, strip, utfcharacters = string.utfvalues, string.strip, utf.characters local context = context local commands = commands @@ -72,6 +72,11 @@ storage.register("languages/associated",associated,"languages.associated") storage.register("languages/numbers", numbers, "languages.numbers") storage.register("languages/data", data, "languages.data") +local variables = interfaces.variables + +local v_reset = variables.reset +local v_yes = variables.yes + local nofloaded = 0 local function resolve(tag) @@ -133,25 +138,63 @@ local function validdata(loaded,what,tag) end end -local function sethjcodes(instance,loaded,what) +-- languages.hjcounts[unicode].count + +-- hjcode: 0 not to be hyphenated +-- 1--31 length +-- 32 zero length +-- > 32 hyphenated with length 1 + +local function sethjcodes(instance,loaded,what,factor) local l = loaded[what] local c = l and l.characters if c then - local h = l.codehash + local hjcounts = factor and languages.hjcounts or false + -- + local h = loaded.codehash if not h then h = { } - l.codehash = h + loaded.codehash = h + end + -- + local function setcode(l) + local u = uccodes[l] + local s = 1 + if hjcounts then + local c = hjcounts[l] + if c then + c = c.count + if not c then + -- error, keep as 1 + elseif c <= 0 then + -- counts as 0 i.e. ignored + s = 32 + elseif c >= 31 then + -- counts as 31 + s = 31 + else + -- count c times + s = c + end + end + end + sethjcode(instance,l,s) + h[l] = s + if u ~= l and type(u) == "number" then + sethjcode(instance,u,s) + h[u] = s + end end + -- local s = tex.savinghyphcodes tex.savinghyphcodes = 0 - for l in utfbytes(c) do - local u = uccodes[l] - sethjcode(instance,l,l) - h[l] = l - if type(u) == "number" then - -- we don't want ß -> SS - sethjcode(instance,u,l) - h[u] = l + if type(c) == "table" then + for l in next, c do + setcode(utfbyte(l)) + end + else + for l in utfbytes(c) do + setcode(l) end end tex.savinghyphcodes = s @@ -255,7 +298,7 @@ local function loaddefinitions(tag,specification) local definition = definitions[i] if definition == "" then -- error - elseif definition == "reset" then -- interfaces.variables.reset + elseif definition == v_reset then if trace_patterns then report_initialization("clearing patterns for language %a",tag) end @@ -278,8 +321,8 @@ local function loaddefinitions(tag,specification) local loaded = table.load(fullname,gzipped and gzip.load) if loaded then -- todo: version test ok, nofloaded = true, nofloaded + 1 - sethjcodes(instance,loaded,"patterns") - sethjcodes(instance,loaded,"exceptions") + sethjcodes(instance,loaded,"patterns",specification.factor) + sethjcodes(instance,loaded,"exceptions",specification.factor) local p = validdata(loaded,"patterns",tag) local e = validdata(loaded,"exceptions",tag) if p and p ~= "" then @@ -396,10 +439,11 @@ if environment.initex then else - function languages.getnumber(tag,default,patterns) + function languages.getnumber(tag,default,patterns,factor) local l = registered[tag] if l then if l.dirty then + l.factor = factor == v_yes and true or false if trace_patterns then report_initialization("checking patterns for %a with default %a",tag,default) end @@ -454,19 +498,43 @@ function languages.postexhyphenchar(what) return postexhyphenchar(tolang(what)) -- e['user-friendly'] = 'user=friend-ly' -- e['exceptionally-friendly'] = 'excep-tionally=friend-ly' +local invalid = { "{", "}", "-" } + +local function collecthjcodes(data,str) + local found = data.extras and data.extras.characters or { } + for s in utfcharacters(str) do + if not found[s] then + found[s] = true + end + end + for i=1,#invalid do -- less checks this way + local c = invalid[i] + if found[c] then + found[c] = nil + end + end + data.extras = { characters = found } + sethjcodes(data.instance,data,"extras",data.factor) +end + function languages.loadwords(tag,filename) local data, instance = resolve(tag) if data then statistics.starttiming(languages) - instance:hyphenation(io.loaddata(filename) or "") + local str = io.loaddata(filename) or "" + collecthjcodes(data,str) + instance:hyphenation(str) statistics.stoptiming(languages) end end + function languages.setexceptions(tag,str) local data, instance = resolve(tag) if data then - instance:hyphenation(strip(str)) -- we need to strip leading spaces + str = strip(str) -- we need to strip leading spaces + collecthjcodes(data,str) + instance:hyphenation(str) end end @@ -523,7 +591,7 @@ end) implement { name = "languagenumber", actions = { languages.getnumber, context }, - arguments = { "string", "string", "string" } + arguments = { "string", "string", "string", "string" } } implement { @@ -555,7 +623,6 @@ implement { arguments = { "string", "string" } } - implement { name = "currentprehyphenchar", actions = function() diff --git a/tex/context/base/mkiv/lang-ini.mkiv b/tex/context/base/mkiv/lang-ini.mkiv index 214ce8ca3..4e6b203ad 100644 --- a/tex/context/base/mkiv/lang-ini.mkiv +++ b/tex/context/base/mkiv/lang-ini.mkiv @@ -24,6 +24,7 @@ \registerctxluafile{lang-ini}{1.001} \registerctxluafile{lang-def}{1.001} +\registerctxluafile{lang-cnt}{1.001} \unprotect @@ -458,6 +459,7 @@ {\currentlanguage}% {\defaultlanguage\currentlanguage}% {\languageparameter\s!patterns}% + {\languageparameter\c!factor}% \relax \normallanguage\csname\??languagenumbers\currentlanguage\endcsname} @@ -583,36 +585,26 @@ %D Fast switcher -% \def\lang_basics_switch_asked -% {\ifx\askedlanguage\empty \else -% \ifcsname\??languagelinked\askedlanguage\endcsname -% \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% -% \ifx\currentlanguage\askedlanguage \else -% \setcurrentlanguage\currentmainlanguage\askedlanguage -% \lang_basics_synchronize -% \fi -% \fi -% \fi} - \def\lang_basics_switch_asked - {\ifx\askedlanguage\empty \else - \ifcsname\??languagelinked\askedlanguage\endcsname - %\edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% - \edef\askedlanguage{\lastnamedcs}% - \ifx\currentlanguage\askedlanguage \else - \setcurrentlanguage\currentmainlanguage\askedlanguage - \lang_basics_synchronize - \fi + {\ifcsname\??languagelinked\askedlanguage\endcsname + \edef\askedlanguage{\lastnamedcs}% + \ifx\currentlanguage\askedlanguage \else + \setcurrentlanguage\currentmainlanguage\askedlanguage + \lang_basics_synchronize \fi \fi} \unexpanded\def\uselanguageparameter#1% {\edef\askedlanguage{#1\c!language}% - \lang_basics_switch_asked} + \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi} + +\unexpanded\def\douselanguageparameter#1% fast setter + {\edef\askedlanguage{#1}% + \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi} \unexpanded\def\lang_basics_set_current[#1]% {\edef\askedlanguage{#1}% - \lang_basics_switch_asked} + \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi} \unexpanded\def\language {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage} @@ -809,6 +801,9 @@ \clf_setlanguageexceptions{\askedlanguage}{#2}% \endgroup} +\unexpanded\def\hyphenation + {\clf_setlanguageexceptions{\currentlanguage}} + %D For the moment here: \uchyph 1 % also treat uppercase diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua index 72800bc64..15ce2ca82 100644 --- a/tex/context/base/mkiv/lpdf-ano.lua +++ b/tex/context/base/mkiv/lpdf-ano.lua @@ -25,7 +25,8 @@ local trace_references = false trackers.register("references.references" local trace_destinations = false trackers.register("references.destinations", function(v) trace_destinations = v end) local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end) -local log_destinations = false directives.register("destinations.log", function(v) log_destinations = v end) +local log_destinations = false directives.register("destinations.log", function(v) log_destinations = v end) +local untex_urls = true directives.register("references.untexurls", function(v) untex_urls = v end) local report_reference = logs.reporter("backend","references") local report_destination = logs.reporter("backend","destinations") @@ -579,10 +580,15 @@ local function pdffilelink(filename,destination,page,actions) } end +local untex = references.urls.untex + local function pdfurllink(url,destination,page) if not url or url == "" then return false end + if untex_urls then + url = untex(url) -- last minute cleanup of \* and spaces + end if destination and destination ~= "" then url = url .. "#" .. destination end diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua index 711b860b8..5dbb308bc 100644 --- a/tex/context/base/mkiv/mlib-pdf.lua +++ b/tex/context/base/mkiv/mlib-pdf.lua @@ -391,7 +391,9 @@ local function setvariables(figure) return variables end -function metapost.comment() end +local function nocomment() end + +metapost.comment = nocomment function metapost.flush(result,flusher,askedfig) if result then @@ -408,7 +410,7 @@ function metapost.flush(result,flusher,askedfig) local textfigure = flusher.textfigure local processspecial = flusher.processspecial or metapost.processspecial local variables = setvariables(figure) -- also resets then in case of not found - metapost.comment = flusher.comment + metapost.comment = flusher.comment or nocomment for index=1,#figures do local figure = figures[index] local properties = setproperties(figure) @@ -633,7 +635,7 @@ function metapost.flush(result,flusher,askedfig) end end end - function metapost.comment() end + metapost.comment = nocomment end end end diff --git a/tex/context/base/mkiv/page-lay.mkiv b/tex/context/base/mkiv/page-lay.mkiv index 1fde9e9c9..eff30046f 100644 --- a/tex/context/base/mkiv/page-lay.mkiv +++ b/tex/context/base/mkiv/page-lay.mkiv @@ -372,7 +372,11 @@ \doifelseassignment{#2} {\definelayouttarget[#1][#2]} {\setevalue{\??layoutpaper#1}{#2}% - \setevalue{\??layoutprint#1}{#3}}% + \ifthirdargument + \setevalue{\??layoutprint#1}{#3}% + \else + \setevalue{\??layoutprint#1}{#2}% + \fi}% \fi} \appendtoks @@ -447,15 +451,12 @@ \let\setuppaper\page_paper_setup_size_settings \unexpanded\def\adaptpapersize - {\global\let\page_paper_reinstate\page_paper_reinstate_indeed + {\glet\page_paper_reinstate\page_paper_restore \setuppapersize} -\unexpanded\def\page_paper_reinstate_indeed - {\page_paper_restore - \global\let\page_paper_reinstate\relax} - \appendtoks \page_paper_reinstate + \global\let\page_paper_reinstate\relax \to \everyaftershipout \unexpanded\def\page_paper_set_restore#1#2% diff --git a/tex/context/base/mkiv/scrn-ini.mkvi b/tex/context/base/mkiv/scrn-ini.mkvi index 0e00fb456..6a4967961 100644 --- a/tex/context/base/mkiv/scrn-ini.mkvi +++ b/tex/context/base/mkiv/scrn-ini.mkvi @@ -177,15 +177,52 @@ %D Identity +% \def\scrn_identity_synchronize +% {\clf_setupidentity +% title {\interactionparameter\c!title}% +% subtitle {\interactionparameter\c!subtitle}% +% author {\interactionparameter\c!author}% +% creator {ConTeXt - \contextversion}% +% date {\interactionparameter\c!date}% +% keywords {\interactionparameter\c!keyword}% +% \relax} + +\newconditional\c_scrn_identity_preroll + +\installtexdirective + {interaction.identity.preroll} + {\settrue \c_scrn_identity_preroll} + {\setfalse\c_scrn_identity_preroll} + +\def\scrn_identity_prerolled#1% + {\begingroup + \edef\tempstring{\interactionparameter#1}% + \ifx\tempstring\empty + \endgroup + \else + \the\everypreroll + \nodestostring\tempstring{\tempstring}% + \normalexpanded{\endgroup\setexpandedinteractionparameter{#1}{\tempstring}}% + \fi} + \def\scrn_identity_synchronize - {\clf_setupidentity + {\begingroup + \ifconditional\c_scrn_identity_preroll + \scrn_identity_prerolled\c!title + \scrn_identity_prerolled\c!subtitle + \scrn_identity_prerolled\c!author + \scrn_identity_prerolled\c!date + \scrn_identity_prerolled\c!keyword + \fi + \clf_setupidentity title {\interactionparameter\c!title}% subtitle {\interactionparameter\c!subtitle}% author {\interactionparameter\c!author}% creator {ConTeXt - \contextversion}% date {\interactionparameter\c!date}% keywords {\interactionparameter\c!keyword}% - \relax} + \relax + \endgroup} \appendtoks \scrn_identity_synchronize @@ -193,11 +230,18 @@ % this comes before starttext +\def\scrn_identity_document#1#2% + {\doifvariable{document}{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}} + \appendtoks % not interfaced i.e. english - \doifvariable{document}{metadata:author} {\setupinteraction [\c!author=\documentvariable{metadata:author}]}% - \doifvariable{document}{metadata:title} {\setupinteraction [\c!title=\documentvariable{metadata:title}]}% - \doifvariable{document}{metadata:subject} {\setupinteraction[\c!subject=\documentvariable{metadata:subject}]}% - \doifvariable{document}{metadata:keywords}{\setupinteraction[\c!keyword=\documentvariable{metadata:keywords}]}% + \scrn_identity_document {title}\c!title + \scrn_identity_document {subject}\c!subject + \scrn_identity_document{subtitle}\c!subtitle + \scrn_identity_document {author}\c!author + \scrn_identity_document {authors}\c!author + \scrn_identity_document {keyword}\c!keyword + \scrn_identity_document{keywords}\c!keyword + \scrn_identity_document {date}\c!date \to \everysetupdocument \setupinteraction diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv index ab877d1d1..89ade8cfd 100644 --- a/tex/context/base/mkiv/spac-hor.mkiv +++ b/tex/context/base/mkiv/spac-hor.mkiv @@ -692,7 +692,7 @@ \global\s_spac_narrower_left \zeropoint \global\s_spac_narrower_right \zeropoint \global\s_spac_narrower_middle\zeropoint - \processcommalistwithparameters[#1]\spac_narrower_initialize + \normalexpanded{\processcommalistwithparameters[#1]}\spac_narrower_initialize \advance\leftskip \dimexpr\s_spac_narrower_left +\s_spac_narrower_middle\relax \advance\rightskip\dimexpr\s_spac_narrower_right+\s_spac_narrower_middle\relax \seteffectivehsize} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex c8d2ebb99..814d9d80a 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex ce6b42056..0234cf08f 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-ref.lua b/tex/context/base/mkiv/strc-ref.lua index 4cb74095b..b678bd0d7 100644 --- a/tex/context/base/mkiv/strc-ref.lua +++ b/tex/context/base/mkiv/strc-ref.lua @@ -20,6 +20,7 @@ local rawget, tonumber, type = rawget, tonumber, type local lpegmatch = lpeg.match local insert, remove, copytable = table.insert, table.remove, table.copy local formatters = string.formatters +local P, Cs, lpegmatch = lpeg.P, lpeg.Cs, lpeg.match local allocate = utilities.storage.allocate local mark = utilities.storage.mark @@ -33,9 +34,7 @@ local trace_empty = false trackers.register("structures.referencing.empt local check_duplicates = true -directives.register("structures.referencing.checkduplicates", function(v) - check_duplicates = v -end) +directives.register("structures.referencing.checkduplicates", function(v) check_duplicates = v end) local report_references = logs.reporter("references") local report_unknown = logs.reporter("references","unknown") @@ -580,13 +579,24 @@ end) -- urls -local urls = references.urls or { } -references.urls = urls -local urldata = urls.data or { } -urls.data = urldata +local urls = references.urls or { } +references.urls = urls +local urldata = urls.data or { } +urls.data = urldata + +local p_untexurl = Cs ( ( + P("\\")/"" * (P("%")/"%%" + P(1)) + + P(" ")/"%%20" + + P(1) +)^1 ) + +function urls.untex(url) + return lpegmatch(p_untexurl,url) or url +end function urls.define(name,url,file,description) if name and name ~= "" then + -- url = lpegmatch(replacer,url) urldata[name] = { url or "", file or "", description or url or file or ""} end end diff --git a/tex/context/base/mkiv/typo-del.mkiv b/tex/context/base/mkiv/typo-del.mkiv index eb51a06e1..4c6d374a6 100644 --- a/tex/context/base/mkiv/typo-del.mkiv +++ b/tex/context/base/mkiv/typo-del.mkiv @@ -267,10 +267,41 @@ \def\c_typo_delimited_nesting{\csname\??delimitedtextlevel\currentparentdelimitedtext\endcsname} -\def\typo_delimited_push#1% - {\globalpushmacro\currentdelimitedtext - \def\currentdelimitedtext{#1}% - \setlanguageparameter\delimitedtextparameter +% the \setlanguageparameter macro sets but we are ungrouped .. only used here +% +% \currentusedlanguage +% \usedlanguageparameter + +\let\currentdelimitedlanguage\empty + +\def\typo_delimited_push#1#2% + {\globalpushmacro\currentdelimitedtext % can we combine these two + \globalpushmacro\currentdelimitedlanguage + \edef\currentdelimitedtext{#1}% + \edef\m_delimited_argument{#2}% + \expandafter\splitstring\m_delimited_argument\at:\to\outerdelimitedlanguage\and\innerdelimitedlanguage + \edef\m_delimited_argument_checked{\outerdelimitedlanguage:}% + \ifx\m_delimited_argument\m_delimited_argument_checked + \let\currentdelimitedlanguage\empty + \setlanguageparameter\delimitedtextparameter + \else + \ifx\innerdelimitedlanguage\empty + \let\currentdelimitedlanguage\empty + \else + \doiflanguageelse\innerdelimitedlanguage + {\let\currentdelimitedlanguage\innerdelimitedlanguage + \let\m_delimited_argument\empty}% + {\let\currentdelimitedlanguage\empty}% + \fi + \ifx\outerdelimitedlanguage\empty + \setlanguageparameter\delimitedtextparameter + \else + \doiflanguageelse\outerdelimitedlanguage + {\let\currentlanguage\outerdelimitedlanguage + \let\m_delimited_argument\empty}% + {\setlanguageparameter\delimitedtextparameter}% + \fi + \fi \let\currentparentdelimitedtext\currentdelimitedtext \global\advance\c_typo_delimited_nesting\plusone \edef\delimitedtextlevel{\number\c_typo_delimited_nesting}% @@ -279,6 +310,7 @@ \def\typo_delimited_pop {\global\advance\c_typo_delimited_nesting\minusone + \globalpopmacro\currentdelimitedlanguage \globalpopmacro\currentdelimitedtext} \installcorenamespace{delimitedtext} @@ -308,6 +340,7 @@ \c!right=, %\c!level=0, \c!method=, + %\c!language\v!local, \c!repeat=\v!no] \def\typo_delimited_repeat_ideed @@ -317,9 +350,12 @@ \let\typo_delimited_repeat\relax -\unexpanded\def\startdelimitedtext[#1]% +\unexpanded\def\startdelimitedtext + {\dodoubleempty\typo_delimited_text_start} + +\unexpanded\def\typo_delimited_text_start[#1][#2]% {\begingroup - \typo_delimited_push{#1}% + \typo_delimited_push{#1}{#2}% \dostarttaggedchained\t!delimitedblock\currentdelimitedtext\??delimitedtext \edef\p_delimited_method{\delimitedtextparameter\c!method}% \ifx\p_delimited_method\s!font @@ -355,12 +391,40 @@ \fi\fi} \def\typo_delimitedtexts_finish_font - {\removeunwantedspaces + {\removeunwantedspaces % again ? \dostarttagged\t!delimitedsymbol\empty \dotagsetdelimitedsymbol\s!right \delimitedtextparameter\c!right \dostoptagged} +\def\typo_delimited_show_language_indeed#1#2% + {\begingroup + \infofont + \setbox\scratchbox\hpack{\lower\strutht\hbox to \zeropoint{\darkred#1\currentlanguage:\currentdelimitedlanguage#2}}% + \vsmashbox\scratchbox + \box\scratchbox + \endgroup} + +\let\typo_delimited_show_language\gobbletwoarguments + +\installtextracker{delimited.language} + {\let\typo_delimited_show_language\typo_delimited_show_language_indeed} + {\let\typo_delimited_show_language\gobbletwoarguments} + +\def\typo_delimited_start_content + {\dostarttagged\t!delimitedcontent\empty + \begingroup + \douselanguageparameter\currentdelimitedlanguage + \typo_delimited_show_language<\hss + \ignorespaces} + +\def\typo_delimited_stop_content + {\removeunwantedspaces + \removelastskip % redundant + \typo_delimited_show_language\hss<% + \endgroup + \dostoptagged} + \def\typo_delimited_start_par {\dosingleempty\typo_delimited_start_par_indeed} @@ -373,14 +437,19 @@ \blank[\p_delimited_spacebefore]% \fi \delimitedtextparameter\c!before - \edef\m_typo_delimited_narrower{#1}% - \ifx\m_typo_delimited_narrower\empty + \iffirstargument + \edef\m_delimited_argument{#1}% + \fi + \ifx\m_delimited_argument\empty + \let\m_delimited_argument\m_delimited_argument + \fi + \ifx\m_delimited_argument\empty \endgraf \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% \let\typo_delimited_stop_par_indeed\endgraf \else % backward compatible direct directive - \startnarrower[#1]% + \startnarrower[\m_delimited_argument]% \let\typo_delimited_stop_par_indeed\stopnarrower \fi % so far @@ -400,13 +469,10 @@ \setnextleftdelimitedtextmark \setnextrightdelimitedtextmark % - \ignorespaces - \dostarttagged\t!delimitedcontent\empty} + \typo_delimited_start_content} \def\typo_delimited_stop_par - {\removeunwantedspaces - \removelastskip - \dostoptagged + {\typo_delimited_stop_content \rightdelimitedtextmark \carryoverpar\endgroup % new per 2013-01-21 ... please left floats \popmacro\checkindentation @@ -424,12 +490,10 @@ \begingroup \usedelimitedtextstyleandcolor\c!style\c!color \typo_delimited_handle_left\c!left - \ignorespaces - \dostarttagged\t!delimitedcontent\empty} + \typo_delimited_start_content} \def\typo_delimited_stop_txt - {\removeunwantedspaces - \dostoptagged + {\typo_delimited_stop_content \typo_delimited_handle_right\c!right \endgroup} @@ -439,9 +503,12 @@ \typo_delimited_pop \endgroup} -\unexpanded\def\delimitedtext[#1]% +\unexpanded\def\delimitedtext + {\dodoubleempty\typo_delimited_text} + +\unexpanded\def\typo_delimited_text[#1][#2]% {\dontleavehmode % following ones can be omited - \typo_delimited_push{#1}% + \typo_delimited_push{#1}{#2}% \edef\p_delimited_method{\delimitedtextparameter\c!method}% \ifx\p_delimited_method\s!font \expandafter\typo_delimited_fontdriven @@ -569,7 +636,7 @@ % \stoptext \def\typo_delimited_handle_middle#1% - {\dostoptagged + {\typo_delimited_stop_content \begingroup \usedelimitedtextstyleandcolor\c!symstyle\c!symcolor \setbox\scratchbox\hbox{\delimitedtextparameter#1}% @@ -591,7 +658,7 @@ \kern\d_typo_delimited_signal % +- \prewordbreak \fi \endgroup - \dostarttagged\t!delimitedcontent\empty} + \typo_delimited_start_content} \def\typo_delimited_handle_left#1% {\begingroup @@ -652,10 +719,10 @@ {\dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext % block? \usedelimitedtextstyleandcolor\c!style\c!color \typo_delimited_handle_left\c!left - \dostarttagged\t!delimitedcontent\empty} - {\dostoptagged + \typo_delimited_start_content} + {\typo_delimited_stop_content \typo_delimited_handle_right\c!right - \removelastskip + \removelastskip % hm \dostoptagged \typo_delimited_pop}} @@ -667,52 +734,56 @@ \expandafter\typo_delimited_quoted \fi} -\def\typo_delimited_quoted_b - {\dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext +\def\typo_delimited_quoted + {\dontleavehmode + \begingroup + \dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext \typo_delimited_handle_left\c!left \usedelimitedtextstyleandcolor\c!style\c!color - \dostarttagged\t!delimitedcontent\empty} + \typo_delimited_start_content + \bgroup + \aftergroup\typo_delimited_quoted_e + \let\next=} \def\typo_delimited_quoted_e - {\dostoptagged + {\typo_delimited_stop_content \typo_delimited_handle_right\c!right \removelastskip % ? \dostoptagged - \typo_delimited_pop} + \typo_delimited_pop + \endgroup} -\def\typo_delimited_attributed_b - {\dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext +\def\typo_delimited_attributed + {\dontleavehmode + \begingroup + \dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext \usedelimitedtextstyleandcolor\c!style\c!color - \dostarttagged\t!delimitedcontent\empty - \ignorespaces} + \typo_delimited_start_content + \typo_delimited_attributed_e + \let\next=} \def\typo_delimited_attributed_e - {\dostoptagged + {\typo_delimited_stop_content \dostoptagged - \typo_delimited_pop} + \typo_delimited_pop + \endgroup} -\def\typo_delimited_fontdriven_b - {\dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext +\def\typo_delimited_fontdriven + {\dontleavehmode + \begingroup + \dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext \usedlanguageparameter{\c!left\currentparentdelimitedtext}% was: \currentdelimitedtext \usedelimitedtextstyleandcolor\c!style\c!color - \dostarttagged\t!delimitedcontent\empty} + \typo_delimited_start_content + \aftergroup\typo_delimited_fontdriven_e + \let\next=} \def\typo_delimited_fontdriven_e - {\dostoptagged + {\typo_delimited_stop_content \usedlanguageparameter{\c!right\currentparentdelimitedtext}% was: \currentdelimitedtext \dostoptagged - \typo_delimited_pop} - -% We now assume proper argument usage (so no longer grouped -% command). - -% \def\typo_delimited_quoted {\groupedcommand \typo_delimited_quoted_b \typo_delimited_quoted_e } -% \def\typo_delimited_attributed{\groupedcommand \typo_delimited_attributed_b\typo_delimited_attributed_e} -% \def\typo_delimited_fontdriven{\simplegroupedcommand\typo_delimited_fontdriven_b\typo_delimited_fontdriven_e} - -\def\typo_delimited_quoted {\bgroup\typo_delimited_quoted_b \aftergroup\typo_delimited_quoted_e \let\next=} -\def\typo_delimited_attributed{\bgroup\typo_delimited_attributed_b\aftergroup\typo_delimited_attributed_e\let\next=} -\def\typo_delimited_fontdriven{\bgroup\typo_delimited_fontdriven_b\aftergroup\typo_delimited_fontdriven_e\let\next=} + \typo_delimited_pop + \endgroup} % testcase for nesting: % diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex ef3eda61d..47ccdf72d 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-language.xml b/tex/context/interface/mkiv/i-language.xml index 26bdbf060..2339d925a 100644 --- a/tex/context/interface/mkiv/i-language.xml +++ b/tex/context/interface/mkiv/i-language.xml @@ -40,6 +40,10 @@ <cd:parameter name="patterns"> <cd:constant type="cd:file"/> </cd:parameter> + <cd:parameter name="factor"> + <cd:constant type="yes"/> + <cd:constant type="no" default="yes"/> + </cd:parameter> <cd:parameter name="lefthyphenmin"> <cd:constant type="cd:number"/> </cd:parameter> @@ -127,7 +131,7 @@ <cd:resolve name="argument-false"/> </cd:arguments> </cd:command> - + <cd:command name="doiflanguageelse" file="lang-ini.mkiv"> <cd:arguments> <cd:resolve name="argument-language"/> @@ -143,7 +147,7 @@ <cd:resolve name="argument-false"/> </cd:arguments> </cd:command> - + <cd:command name="doifpatternselse" file="lang-ini.mkiv"> <cd:arguments> <cd:resolve name="argument-language"/> @@ -197,4 +201,4 @@ </cd:arguments> </cd:command> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 1dc8b1bcd..3f81a9213 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/common/s-abr-01.tex b/tex/context/modules/common/s-abr-01.tex index 156b9b938..fd6c66419 100644 --- a/tex/context/modules/common/s-abr-01.tex +++ b/tex/context/modules/common/s-abr-01.tex @@ -179,6 +179,7 @@ \logo [METATYPE] {MetaType1} \logo [MODULA] {Modula} \logo [MOV] {mov} +\logo [MPEG] {mpeg} \logo [MPS] {mps} \logo [MPTOPDF] {mptopdf} \logo [MPLIB] {mplib} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index e293f83d7..3fb2ad368 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 07/15/16 23:30:10 +-- merge date : 07/18/16 16:46:35 do -- begin closure to overcome local limits and interference |