Closed franckpastor closed 10 years ago
An useful link I was not able to insert into the previous message (my current browser is not supported by github and so the Edit button is not activated): the latexmp
manual.
I just have pushed a new version.
The stategy I have chosen is more aggressive than that of latexmp but similar to context. While latexmp redefines thelabel
macro only, context and luamplib redefine infont
operator, a primitive of metapost. So, with \mplibtextextlabel{enable}
, even the string tokens in, say, boxit.mybox("my box");
will also be typeset by TeX.
There's some drawback however: be careful about char ... infont ...
syntax. For instance, draw char 1 infont defaultfont
will raise a TeX error. Currently I have no general solution to this issue.
I've downloaded and installed the 2.6.0 version of luamplib, and \mplibtextextlabel
seems to work fine. Again, thanks for having implemented this.
I've read that \fontsize
has been redefined as well. Is this redefinition related to \mplibtextextlabel
?
@franckpastor Yes, there's a close relation. Without fontsize
redefinition, a code as follows will raise a metapost error:
picture pic; pic:= "A" infont "cmr10";
draw origin--(fontsize fontpart pic, 0);
As infont
operator is now the same as textext
, pic
here does not have fontpart
. So the latter returns empty string only, and fontsize
fails to find a tfm font.
OK! Didn't know about that. One last question. In the updated doc's part concerning \mplibtextextlabel
, it is said: "To typeset string labels with current TEX font, assign empty string to defaultfont, that is defaultfont:=””;
." Why must we do that? I thought that the default font always was the current TeX font with luamplib
?
To be more precise: like the btex … etex
flags, the textext()
function selects (as it should) the current TeX font as default font for the picture. Since the point of \mplibtextextlabel{enable}
is to replace infont
by textext()
, I would expect that each string given thereafter as argument to labelling commands (label
, thelabel
, etc.) would be also typesetted automatically with the current TeX font, without having to specify defaultfont:="";
. I'm probably missing something, but what?
@franckpastor I will think on it today. Currently I am inclined to adopting your suggestion. It's quite easy: just removing if ... fi
part in the code redefining infont
operator.
@franckpastor Adopted your suggestion and just pushed revised code. When \mplibtextextlabel
is enabled, every text label will be typeset with current TeX font.
Perfect! It was the right thing to do, we can be sure of that.
Hello,
Currently, each time I use luamplib for my MetaPost drawing, I use the
textext
macro inspired from its ConTeXt namesake that you recently introduced to typeset labels. I think it's one of the most useful features of this package. In fact, I'm using it so frequently that I would like not having to "write" it. To be more precise: one of the handy features of thelatexmp
package (by Jens-Uwe Morawski) I load each time I have to use standalone MetaPost, is to replace the infont operator by thetextext
macro. Quoting thelatexmp
manual:So, if I write in the preamble of a MetaPost file
setupLaTeXMP(textextlabel=enable);
, writinglabel("my text", (a, b))
thereafter is exactly the same aslabel(textext("my text"), (a, b))
, which saves a non-negligible amount of typing.It seems that ConTeXt has a similar behavior when MetaPost code is run into it: quoting the Metafun manual, page 42:
I personally think it would be a very good thing if
luamplib
proposed something like that. For example, something like\mplibtextextlabel{enable}
(latexmp
-like) which would allow the user to replace theinfont
operator by thetextext
macro. Is it reasonable to think so, or would there be problems I didn't think of if this feature was to be implemented?Many thanks for having read this,
Franck Pastor