My question is kind of extending of this answer. I want to decorate a path with text only when text fit the path, but also I want to know if decoration was success. I need to know this to be able to call decoration again with shorter text. I need this to implement solution for my question here.
Currently I end up with modifying decoration along path myself using \makeatletter .. \makeatother in document preambule. I just copy text decoration implementation in my preambule and add the setting flag to the end of the persistent precomputation = {..} of the inital state in the following way:
\newif\iffit
\pgfdeclaredecoration{my text along path}{initial}{
\state{initial}[
width=+0pt,
next state=left indent,
persistent precomputation = {
...
\ifdim\pgf@lib@dec@text@width<\pgfdecoratedpathlength
\global \fittrue
\else
\global \fitfalse
\fi
}]{}
And then I can use \iffit in my code to check if decoration if successful. Is there more elegant solution for such case?