# [metapost] MetaPost and XeTeX

Nicola nvitacolonna at gmail.com
Tue Jun 8 12:38:11 CEST 2010

In article <4C0640E0.5040808 at fc.up.pt>,
José Carlos Santos <jcsantos at fc.up.pt> wrote:

> On 02-06-2010 12:03, Taco Hoekwater wrote:
>
> >> Yesterday, Taco Hoekwater made a reference to MetaPost 2.0. I would like
> >> to know if this new version will be able to work with XeTeX. [...] and I
> >> wanted to be able to use within the graphics the same fonts that were
> >> used within the text.

If it's ok for you to create stand-alone PDF graphics and include that
in your document, XeConTeXt has the ability to to what you want. This is
a minimal document:

\definetypeface [myface][rm][serif][hoefler][default][encoding=uc]
\setupbodyfont[myface,12pt]

\startMPenvironment
\switchtobodyfont[myface,12pt]
\stopMPenvironment

\starttext
\setupcolors[state=start]

\startMPpage
fill fullcircle scaled 3cm withcolor .7red;
label.bot(\sometxt{Hoefler text},(0,2mm));
\stopMPpage

\stoptext
\end

The code in \startMPpage-\stopMPpage is plain MetaPost code, with labels
drawn by \sometxt rather than btex.. etex (there is also \textext, but
for unknown reasons I've never been able to use it with XeTeX). If the
code above is saved as myfig.tex then you can compile it with

texexex --xtx myfig.tex

to generate myfig.pdf. More details are provided in ConTeXt Wiki, in
particular:

http://wiki.contextgarden.net/Mpgraphic
http://wiki.contextgarden.net/Fonts_in_XeTeX

Nicola
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7813683152198792, "perplexity": 14451.100241683604}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 5, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-26/segments/1529267863463.3/warc/CC-MAIN-20180620050428-20180620070428-00541.warc.gz"}