+namespace {
+
+// helper function: draw text and update x.
+void drawChar(PainterInfo & pi, int & x, int const y, char_type ch)
+{
+ FontInfo font = pi.base.font;
+ font.setPaintColor(pi.textColor(font.realColor()));
+ pi.pain.text(x, y, ch, font);
+ x += theFontMetrics(font).width(ch);
+}
+
+
+void drawLogo(PainterInfo & pi, int & x, int const y, InsetSpecialChar::Kind kind)
+{
+ FontInfo const & font = pi.base.font;
+ int const em = theFontMetrics(font).em();
+ switch (kind) {
+ case InsetSpecialChar::PHRASE_LYX:
+ /** Reference macro:
+ * \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\\@};
+ */
+ drawChar(pi, x, y, 'L');
+ x -= em / 6;
+ drawChar(pi, x, y + em / 4, 'Y');
+ x -= em / 8;
+ drawChar(pi, x, y, 'X');
+ break;
+
+ case InsetSpecialChar::PHRASE_TEX: {
+ /** Reference macro:
+ * \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
+ */
+ int const ex = theFontMetrics(font).ascent('x');
+ drawChar(pi, x, y, 'T');
+ x -= em / 6;
+ drawChar(pi, x, y + ex / 2, 'E');
+ x -= em / 8;
+ drawChar(pi, x, y, 'X');
+ break;
+ }
+ case InsetSpecialChar::PHRASE_LATEX2E:
+ /** Reference macro:
+ * \DeclareRobustCommand{\LaTeXe}{\mbox{\m@th
+ * \if b\expandafter\@car\f@series\@nil\boldmath\fi
+ * \LaTeX\kern.15em2$_{\textstyle\varepsilon}$}}
+ */
+ drawLogo(pi, x, y, InsetSpecialChar::PHRASE_LATEX);
+ x += 3 * em / 20;
+ drawChar(pi, x, y, '2');
+ drawChar(pi, x, y + em / 4, char_type(0x03b5));
+ break;
+
+ case InsetSpecialChar::PHRASE_LATEX: {
+ /** Reference macro:
+ * \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
+ * {\sbox\z@ T%
+ * \vbox to\ht\z@{\hbox{\check@mathfonts
+ * \fontsize\sf@size\z@
+ * \math@fontsfalse\selectfont
+ * A}%
+ * \vss}%
+ * }%
+ * \kern-.15em%
+ * \TeX}
+ */
+ drawChar(pi, x, y, 'L');
+ x -= 9 * em / 25;
+ PainterInfo pi2 = pi;
+ pi2.base.font.decSize().decSize();
+ drawChar(pi2, x, y - em / 5, 'A');
+ x -= 3 * em / 20;
+ drawLogo(pi, x, y, InsetSpecialChar::PHRASE_TEX);
+ break;
+ }
+ default:
+ LYXERR0("No information for drawing logo " << kind);
+ }
+}
+
+}
+