#include "Dimension.h"
#include "Font.h"
+#include "Language.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "MetricsInfo.h"
return width;
}
-}
+} // namespace
docstring InsetSpecialChar::toolTip(BufferView const &, int, int) const
{
case NOBREAKDASH:
message = from_ascii("Protected Hyphen (SHY)");
break;
+ case LDOTS:
+ case MENU_SEPARATOR:
+ case PHRASE_LYX:
+ case PHRASE_TEX:
+ case PHRASE_LATEX2E:
+ case PHRASE_LATEX:
+ // no tooltip for these ones.
+ break;
}
return message;
}
frontend::FontMetrics const & fm =
theFontMetrics(mi.base.font);
dim.asc = fm.maxAscent();
- dim.des = fm.maxDescent();
+ dim.des = 0;
dim.wid = 0;
docstring s;
switch (kind_) {
case ALLOWBREAK:
+ dim.asc = fm.xHeight();
+ dim.des = fm.descent('g');
dim.wid = fm.em() / 8;
break;
case LIGATURE_BREAK:
s = from_ascii(". . .");
break;
case MENU_SEPARATOR:
- s = from_ascii(" x ");
+ // ▹ U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE
+ // There is a \thinspace on each side of the triangle
+ dim.wid = 2 * fm.em() / 6 + fm.width(char_type(0x25B9));
break;
case HYPHENATION:
dim.wid = fm.width(from_ascii("-"));
break;
case SLASH:
s = from_ascii("/");
+ dim.des = fm.descent(s[0]);
break;
case NOBREAKDASH:
s = from_ascii("-");
case PHRASE_TEX:
case PHRASE_LATEX2E:
case PHRASE_LATEX:
+ dim.asc = fm.maxAscent();
+ dim.des = fm.maxDescent();
dim.wid = logoWidth(mi.base.font, kind_);
break;
}
/** Reference macro:
* \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
*/
- int const ex = theFontMetrics(font).ascent('x');
+ int const ex = theFontMetrics(font).xHeight();
drawChar(pi, x, y, 'T');
x -= em / 6;
drawChar(pi, x, y + ex / 2, 'E');
}
}
-}
+} // namespace
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
{
case ALLOWBREAK:
{
// A small vertical line
- int const asc = theFontMetrics(pi.base.font).ascent('x');
+ int const asc = theFontMetrics(pi.base.font).xHeight();
int const desc = theFontMetrics(pi.base.font).descent('g');
int const x0 = x; // x + 1; // FIXME: incline,
int const x1 = x; // x - 1; // similar to LibreOffice?
frontend::FontMetrics const & fm =
theFontMetrics(font);
- // A triangle the width and height of an 'x'
- int w = fm.width(char_type('x'));
- int ox = fm.width(char_type(' ')) + x;
- int h = fm.ascent(char_type('x'));
- int xp[4], yp[4];
-
- xp[0] = ox; yp[0] = y;
- xp[1] = ox; yp[1] = y - h;
- xp[2] = ox + w; yp[2] = y - h/2;
- xp[3] = ox; yp[3] = y;
-
- pi.pain.lines(xp, yp, 4, Color_special);
+ // There is a \thinspace on each side of the triangle
+ x += fm.em() / 6;
+ // ▹ U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE
+ // ◃ U+25C3 WHITE LEFT-POINTING SMALL TRIANGLE
+ char_type const c = pi.ltr_pos ? 0x25B9 : 0x25C3;
+ font.setColor(Color_special);
+ pi.pain.text(x, y, c, font);
break;
}
case SLASH:
void InsetSpecialChar::latex(otexstream & os,
OutputParams const & rp) const
{
+ bool const rtl = rp.local_font->isRightToLeft();
+ string lswitch = "";
+ string lswitche = "";
+ if (rtl && !rp.use_polyglossia) {
+ lswitch = "\\L{";
+ lswitche = "}";
+ if (rp.local_font->language()->lang() == "arabic_arabi"
+ || rp.local_font->language()->lang() == "farsi")
+ lswitch = "\\textLR{";
+ }
+
switch (kind_) {
case HYPHENATION:
os << "\\-";
os << "\\ldots" << termcmd;
break;
case MENU_SEPARATOR:
- if (rp.local_font->isRightToLeft())
+ if (rtl)
os << "\\lyxarrow*";
else
os << "\\lyxarrow";
case PHRASE_LYX:
if (rp.moving_arg)
os << "\\protect";
- os << "\\LyX" << termcmd;
+ os << lswitch << "\\LyX" << termcmd << lswitche;
break;
case PHRASE_TEX:
if (rp.moving_arg)
os << "\\protect";
- os << "\\TeX" << termcmd;
+ os << lswitch << "\\TeX" << termcmd << lswitche;
break;
case PHRASE_LATEX2E:
if (rp.moving_arg)
os << "\\protect";
- os << "\\LaTeXe" << termcmd;
+ os << lswitch << "\\LaTeXe" << termcmd << lswitche;
break;
case PHRASE_LATEX:
if (rp.moving_arg)
os << "\\protect";
- os << "\\LaTeX" << termcmd;
+ os << lswitch << "\\LaTeX" << termcmd << lswitche;
break;
}
}