This can be done by the decorations.text
library gives you a text along path
decoration. See the PGF/TikZ manual (v2.10) on page 337, section 30.6 Text decorations for more details. You can't draw and decorate the path at the same time directly, but can use postaction={..}
to decorate the path after you have drawn it (Thanks goes to Alan Munn for this tip).
To format the text place the style macros between |
in the text
argument. Non-English characters need to be included in braces, e.g. text={|\itshape|Some Text {ö} more text}
. One issue is to raise the font (it is just placed really on the path!). I looked into the source code and found out that the font macros are placed before each single processed character but with an \relax
between it, i.e. <your style>\relax<character>
. You could define a macro which takes two arguments, the first is the \relax
and the second the character, then use \raisebox{<length>}{<content>}
to raise or lower the character.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\node (One) at (-3,0) [shape=circle,draw] {$One$};
\node (Two) at (3,0) [shape=circle,draw] {$Two$};
\def\myshift#1{\raisebox{-2.5ex}}
\draw [->,thick,postaction={decorate,decoration={text along path,text align=center,text={|\sffamily\myshift|Some more bent text}}}] (One) to [bend right=45] (Two);
\def\myshift#1{\raisebox{1ex}}
\draw [->,thick,postaction={decorate,decoration={text along path,text align=center,text={|\sffamily\myshift|Some bent text}}}] (One) to [bend left=45] (Two);
\end{tikzpicture}
\end{document}
\draw [->, thick] (One) to [bend right=45] (Two) node [midway] {some text};