Changes

Jump to navigation Jump to search
6,022 bytes removed ,  16:59, 24 December 2020
Replaced content with "A test"
A test  <context source="yes"> %------------------------------------------------------------------------------ \setuppapersize [A4] %------------------------------------------------------------------------------ \def\MyFont{\definedfont[name:%texgyrepagellabold%%exo2black%%agaramondprobold%*default at 55pt]} %------------------------------------------------------------------------------ \startluacode function document.outlinepaths(character) local chardata = fonts.hashes.characters[true] -- by unicode local shapedata = fonts.hashes.shapes[true] -- by index local c = chardata[character] if c and c.index and shapedata then local shapeglyphs = shapedata.glyphs or { } local glyph = shapeglyphs[c.index] if glyph and (glyph.segments or glyph.sequence) then local units = shapedata.units or 1000 local factor = 100/units return fonts.metapost.paths(glyph,factor) end end return { }end function document.defineoutline(char,target) local outlines = document.outlinepaths(char) local nofpaths = #outlines context("\\startMPdrawing") -- ADDED by garulfo context("path %s[] ;",target) context("numeric %sn ; %sn := %s ;",target,target,nofpaths) for i=1,nofpaths do context("%s[%i] := %s ; ",target,i,outlines[i]) end context("\\stopMPdrawing") -- ADDED by garulfoend \stopluacode %------------------------------------------------------------------------------ \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} %------------------------------------------------------------------------------ \def\MaFunction#1%{%\resetMPdrawing\MPtoks={}%\startMPdrawing numeric dimA ; dimA := 10cm; numeric dimB ; dimB := 10cm; % picture pic[] ; numeric wid[], len[], pos[], n ; wid[0] := len[0] := pos[0] := n := 0 ;% numeric scaling;% picture pictA; path pictB ;% pair shiftB ; % picture monImageA; monImageA := nullpicture; picture monImageB; monImageB := nullpicture;% numeric dimC ; dimC := 2cm; % path frame ; color colorframe; colorframe := 0.6white;% \stopMPdrawing%\MyFont\handletokens#1\with\whatever%\startMPdrawing frame := unitsquare xscaled ( (xpart urcorner monImageB - xpart llcorner monImageB) + 5mm ) yscaled ( (ypart urcorner monImageB - ypart llcorner monImageB) + 5mm ); frame := frame shifted (center monImageB - center frame); addto monImageB contour frame withpostscript "evenodd" withcolor transparent (1,1.,colorframe); draw monImageB ; draw monImageA ;\stopMPdrawing% \MPdrawingdonetrue\getMPdrawing} %------------------------------------------------------------------------------ \def\whatever#1% {\appendtoks#1\to\MPtoks \setbox\MPbox=\hbox{\MyFont\the\MPtoks}% % \startMPdrawing n := n + 1 ; len[n] := \the\wd\MPbox ; \stopMPdrawing % \mpdefineoutlines{M}{MaLettre} \startMPdrawing pictA := textext.drt("\MyFont M") ; pictB := MaLettre[1]; scaling := bbheight pictA / bbheight pictB; \stopMPdrawing % \doifinstringelse{~}{#1}{}{% HOW TO PROPERLY COPE WITH SPACES ? \mpdefineoutlines{#1}{MyGlyph} \startMPdrawing string sb; sb := "i"; pic[n] := textext.drt("\MyFont\setstrut\strut#1") ; % shiftB := - llcorner pic[n]; pic[n] := pic[n] shifted shiftB ; % wid[n] := abs(xpart urcorner pic[n] - xpart llcorner pic[n]) ; pos[n] := len[n]-wid[n] ; % addto monImageB contour ((MyGlyph[1] scaled scaling) shifted ( (pos[n],0) + shiftB)) withpostscript "collect"; % if MyGlyphn > 1 : for ind=2 upto MyGlyphn : if (((xpart llcorner MyGlyph[ind]) > (xpart llcorner MyGlyph[1])) and ((ypart llcorner MyGlyph[ind]) > (ypart llcorner MyGlyph[1])) and ((xpart urcorner MyGlyph[ind]) < (xpart urcorner MyGlyph[1])) and ((ypart urcorner MyGlyph[ind]) < (ypart urcorner MyGlyph[1]))) : % addto monImageA contour (MyGlyph[ind] scaled scaling) shifted ( (pos[n],0) + shiftB) withcolor transparent (1,1.,colorframe); else : addto monImageB contour (MyGlyph[ind] scaled scaling) shifted ( (pos[n],0) + shiftB) withpostscript "collect"; fi; endfor; fi; \stopMPdrawing}}  %==============================================================================%==============================================================================  \starttext %------------------------------------------------------------------------------ \startuseMPgraphic{MyBackgroundGraphic} path pathbackground ; numeric dimA ; dimA := \the\paperwidth; numeric dimB ; dimB := \the\paperheight; pathbackground := unitsquare xscaled dimA yscaled dimB ; fill pathbackground withshademethod "linear" withshadedirection(0,1) withshadecolors (red,blue);\stopuseMPgraphic %------------------------------------------------------------------------------ \definelayer[MyBackgroundLayer]\setlayer[MyBackgroundLayer]{\useMPgraphic{MyBackgroundGraphic}}\setupbackgrounds[page][background={MyBackgroundLayer}] %------------------------------------------------------------------------------ \MaFunction{MetaPost~is~fun!}\MaFunction{ABCDEFGHIJ}\MaFunction{KLMNOPQRST}\MaFunction{UVWXYZ!?\&*}\MaFunction{abcdefghij}\MaFunction{klmnopqrst}\MaFunction{uvwxyz}\MaFunction{0123456789} \stoptext  %==============================================================================%============================================================================== </context>

Navigation menu