On 2017-01-23 14:09, Rik Kabel wrote:
On 2017-01-23 00:06, Alan Braslau wrote:
> On Sun, 22 Jan 2017 22:39:53 -0500 Rik Kabel > <context@rik.users.panix.com> wrote: > >> So, how can I make the inner glyph (‘?’ in the example below) >> transparent, so that the background shows through along with >> anything else that lives on a lower layer? I’ve seen a method for >> constructed shapes, but nothing that I can apply to text glyphs. >> Undraw doesn’t do it. > > Undraw is simply draw using the background color. > > Transparency is a MetaFun extension to MetaPost (so part of > ConTeXt). > > draw q withtransparency (1,0.5) ; % (method,transparency) > > Alan

Hmmm. That does not work for me (with any of many method and transparency values).  The  ‘?’ is solid black. I do see a message in the log that looks related:
mkiv lua stats  > page group warning: transparencies are used but no pagecolormodel is set
but adding \setcolors[state=start,cmyk=yes] does not change that; both the warning and the solid black glyph remain. Could this be an issue of the PDF viewer? Is it a font issue?
Okay, I got a clean compile using \definecolor and referencing that in the MP page.
\setupbackgrounds
  [page]
  [background=color,backgroundcolor=yellow]
\definecolor[Transp][r=1,t=0,a=12]
\definefont
  [DVSrB]
  [file:DejaVuSerif-Bold.ttf]
\startuseMPgraphic{HeartTest 1}
  picture h,q ;
  h := "♥" infont "\truefontname{DejaVuSerif-Bold.ttf}" scaled 20 ;
  q := textext("{\DVSrB ?}") scaled 10 ;
  q := q shifted - (xpart center q, 12pt) ;
  draw h withcolor blue ;
  draw q withtransparency(12,0) ;
  draw q shifted (72pt,0) withtransparency(12,0) ;
\stopuseMPgraphic
\startuseMPgraphic{HeartTest 2}
  picture h,q ;
  h := "♥" infont "\truefontname{DejaVuSerif-Bold.ttf}" scaled 20 ;
  q := textext("\color[Transp]{\DVSrB ?}") scaled 10 ;
  q := q shifted - (xpart center q, 12pt) ;
  draw h withcolor blue ;
  draw q ;
  draw q shifted (72pt,0) ;
\stopuseMPgraphic
\starttext
 \useMPgraphic{HeartTest 1}
 \useMPgraphic{HeartTest 2}
\stoptext
Unfortunately, the result is not what I want. The result is that the “?” disappears, allowing the color directly behind it to show through. The example above shows that it works with \definecolor but not with withtransparency. I have no idea why, and certainly realize it could be my error.

What I want is that the background of the page (yellow in this case) should show through. That is what is done with fill / reverse / cycle, as in:
\setupbackgrounds
  [page]
  [background=color,backgroundcolor=yellow]
\startuseMPgraphic{CircleTest}
  path p,q ;
  p := fullcircle scaled 2cm ;
  q := fullcircle scaled 1cm ;
  fill p -- reverse q -- cycle withcolor blue;
\stopuseMPgraphic
\starttext
 \useMPgraphic{CircleTest}
\stoptext
where the background color (yellow) comes through the inner circle (path q).

Can this be done with text characters? I suspect that the answer is that the glyphs have to be converted to paths and that it will only work when there are no islands (as in ‘P’).

--
Rik