Graphics and media/Collections of tips and tricks/Repetition of a text element to fill a bar using textext

Unofficial ConTeXt Wiki mirror

Last modified: 2025-01-19

Imagine you want to create a frame which consists out of one glyph or a combination of different glyphs in order to make a decorative border. For this purpose a series of such elements should be placed on the bar as pictures, evenly spaced. Probably you want to have at the end of the bar a different glyph inserted as a picture too.

The following code is working but the last picture is not the expected glyph. One would expect 14 times the "?" and at the end of the bar a "*":

What you get is 15 "?" but no "*"!

In order to get this corrected one needs to calculate the boundingbox of the "?" on beforehand. Hans Hagen provided this solution on 14-10-2014.

Now you get 14 "?" and the "*".

A Full Example

There is one important remark: The MPcalculation and the drawing itself must be inside \starttext ... \stoptext.