2

Background

Looking to adjust the exterior padding of a METAPOST graphic used as the background for a framedtext.

ConTeXt version 2021.05.15.

SSCCE

Pilfered from the mailing list:

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

  2/12[x1,x2] = x8 + 1cm = x7 + .5cm = x9 - .5cm ;
  y7 =  0cm ;
  y8 = -1cm ;
  y9 =  0cm ;

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

  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[TextBubbleOverlay][\useMPgraphic{TextBubble}]
\defineframedtext[TextBubbleFrame][
  frame=off,
  width=\textwidth,
  background=TextBubbleOverlay,
  offset=.5em,
]

\starttext 
  \input knuth

  \TextBubbleFrame{\input ward \input knuth }

  \input knuth
\stoptext

Problem

The speech bubble dips into the text below:

speech bubble

The after option appears to be ignored and boffset will increase the overall height.

Questions

How would you add enough padding so that the tail is on a line or two by itself? Is there a way to increase the METAPOST graphic height such that the framed text honours the new size?

Using something like \define\PaddedBubble{\TextBubble{...}\blank[1cm]} would work, but doesn't feel like The ConTeXt Way. (Can't use Speech Bubble module because it isn't guaranteed to be installed.)

Related

Similar issues:

1

1 Answer 1

1

The following solution isn't the greatest: the tail height is coupled to the 3*big, indirectly, rather than linked using an option or variable.

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

  2/12[x1,x2] = x8 + 1cm = x7 + .5cm = x9 - .5cm ;
  y7 =  0cm ;
  y8 = -1cm ;
  y9 =  0cm ;

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

  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[TextBubbleOverlay][\useMPgraphic{TextBubble}]
\defineframedtext[TextBubbleFrame][
  frame=off,
  width=\textwidth,
  background=TextBubbleOverlay,
  offset=.5em,
  after={\blank[3*big]},
]

\starttext 
  \input knuth

  \startTextBubbleFrame
    \input ward
  \stopTextBubbleFrame

  \input knuth
\stoptext

I could not get text backgrounds to work. It looks like text background requires iterating over the number of rows in the paragraph.

speech bubble

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .