[metapost] glyph operator and contours order
Laurent Méhats
laurent.mehats at gmail.com
Sat Feb 5 16:02:45 CET 2011
Hello,
The MetaPost manual explains that the glyph operator works in such a way
that "all black contours are drawn before white contours". This is
problematic in the case of glyphs in which a black contour lies inside a
white contour, for the inside black contour gets "erased" by the white
one. However, since the contours are accessible, it is possible to fill
them manually in a convenient order.
I believe that glyph contours don't intersect each-other, nor
self-intersect (is that always true ?), so my question would be: given two
non intersecting nor self-intersecting cycles, is there a proper way to
decide whether one lies inside the other ?
Regards,
Laurent Méhats
Here is an example of a problematic glyph.
--%<-- test.mp
verbatimtex%&latex
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
etex;
beginfig(0)
% 'etex .. btex' Theta
picture pct;
pct:=btex\Huge$\Theta$etex;
% glyph operator Theta
picture glp;
glp:=nullpicture;
for tkn within pct:
addto glp also glyph ASCII textpart tkn of fontpart tkn
scaled (fontsize fontpart tkn/1000)
xscaled xxpart tkn
yscaled yypart tkn;
endfor
% contours
numeric num;
path ctr[];
num:=0;
for tkn within glp:
ctr[num]:=pathpart tkn;
num:=num+1;
endfor
% hand-filled contours
picture hnd;
hnd:=nullpicture;
addto hnd contour ctr[1];
addto hnd contour ctr[2] withcolor background;
addto hnd contour ctr[0];
% comparisons
draw pct;
draw glp shifted lrcorner pct;
draw hnd shifted (2*lrcorner pct);
endfig;
end
--%<-- test.mp
More information about the metapost
mailing list