TikZ – Repeated text along path

tikz-pgf

I'm trying to have some text repeated along a path. I tried what was prescribed in the PGF manual under /pgf/decoration/text effects/repeat text, but, as you can see, it doesn't have the effect I want:

Undesired effect

I'd like something like below, but repeated around the path:

Somewhat desired effect

MWE

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}
    [block/.style={draw, rectangle, minimum size=5cm, align=center}]

    \node [block,
           postaction={decoration={text effects along path, text={BOX BOUNDARY\ },
               text effects/.cd,
                   repeat text,
                   character count=\m, character total=\n,
                   characters={text along path, scale=0.5+\m/\n/2}},
               decorate}]
           (box){};
    
\end{tikzpicture}

\end{document}

Best Answer

Apparently, it does not work with a node. Can you use a rectangle? (you can always add your node without text on top of the rectangle)

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\draw[%
postaction={decoration={text effects along path, text={BOX BOUNDARY\ },
text effects/.cd,
repeat text,
character count=\m, character total=\n,
characters={text along path, scale=0.5+\m/\n/2}},
decorate},
] (0,0) rectangle (5,5);           
\end{tikzpicture}
\end{document}

Rectangle with repeated text