Open main menu

Changes

Note the <tt>'__main__'</tt> check, so we can test this class from python. <br/>
Next lua layer, which in this case is embed in a tex file:<texcode>\startluacodefunction testFontforge(fontfile,letter) require("python") testoutlines = python.import("test-fontforge") s = testoutlines.simpledraw(fontfile) g = s.getmpostoutline(letter) p = s.getmpostpointsSugar(letter) tex.sprint(tex.ctxcatcodes,"\\startMPcode") tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 1pt;") tex.sprint(tex.ctxcatcodes,string.format("draw %s -- cycle;",g) ) tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 8pt;") tex.sprint(tex.ctxcatcodes,string.format("%s",p) ) tex.sprint(tex.ctxcatcodes,"\\stopMPcode")end\stopluacode  \def\Outline[#1]{%\getparameters[test][#1]%\ctxlua{testFontforge("\testfontfile", "\testletter")}%} \starttext\startTEXpage\Outline[letter={C}, fontfile={lmmono10-regular.otf}]%\Outline[letter={o}, fontfile={lmmono10-regular.otf}]%\Outline[letter={n}, fontfile={lmmono10-regular.otf}]%\Outline[letter={T}, fontfile={lmmono10-regular.otf}]%\Outline[letter={e}, fontfile={lmmono10-regular.otf}]%\Outline[letter={X}, fontfile={lmmono10-regular.otf}]%\Outline[letter={t}, fontfile={lmmono10-regular.otf}]%\stopTEXpage\stoptext</texcode> Here we use <tt>tex.sprint(tex.ctxcatcodes,"\\stopMPcode")</tt> to inject tex code (actually Metapost code) into TeX parser;and in the end <tt>\Outline</tt> is the TeX layer (of course one can write <tt>\Outline</tt> and <tt>testFontforge</tt> in a different manner to avoid use of tex.sprint(..)) <br/>And this is the result