Works flawlessly, thank you!

Here's a demo with left and right speech bubbles:

\definefont [TextFontEmoji] [OpenSansEmoji]

\startuseMPgraphic{TextBubble}{side}
  z1 = (0, 0) ;
  z2 = (OverlayWidth, 0) ;
  z3 = (OverlayWidth, OverlayHeight) ;
  z4 = (0, OverlayHeight) ;

  offset := 1 ;
  tail := 1 ;

  % Flip the tail's location and direction.
  if \MPvar{side} = 1:
    offset := 5 ;
    tail := -1 ;
  fi

  (offset/6)[x1,x2] = x8 + .25cm * tail = x7 + .25cm = x9 - .25cm ;
  y7 =  0cm ;
  y8 = -.5cm ;
  y9 =  0cm ;

  path p ;
  p = (z1--z7--z8--z9--z2--z3--z4--cycle) cornered .25cm ;
  draw p withpen pencircle scaled 0.75 ;

  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineframedtext[TextBubbleFrame][
  style=TextFontEmoji,
  frame=off,
  width=.618\textwidth,
  autowidth=force,
  offset=.75em,
  after={\blank[2*big]},
]

% Receive text (left-facing).
\defineoverlay[TextBubbleRxOverlay][\useMPgraphic{TextBubble}{side=0}]
\defineframedtext[TextBubbleRxFrame][TextBubbleFrame][
  background=TextBubbleRxOverlay,
  location=left,
]

% Send text (right-facing).
\defineoverlay[TextBubbleTxOverlay][\useMPgraphic{TextBubble}{side=1}]
\defineframedtext[TextBubbleTxFrame][TextBubbleFrame][
  background=TextBubbleTxOverlay,
  location=right,
]

% Map XHTML class names to start/stop environments.
\definestartstop[bubblerx][
  before={\startnarrower\startTextBubbleRxFrame},
  after={\stopTextBubbleRxFrame\stopnarrower},
]

\definestartstop[bubbletx][
  before={\startnarrower\startTextBubbleTxFrame},
  after={\stopTextBubbleTxFrame\stopnarrower},
]

\starttext
  \startbubblerx
    Welcome to the future, human 👽!  \input zapf
  \stopbubblerx

  \startbubbletx
    Welcome to the future, human 👽!  \input zapf
  \stopbubbletx
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to