namespace lyx {
-
-extern bool use_gui;
-
namespace frontend {
int GuiFontMetrics::maxAscent() const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.ascent();
}
int GuiFontMetrics::maxDescent() const
{
- if (!lyx::use_gui)
- return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
return metrics_.descent() + 1;
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
-
// Qt rbearing is from the right edge of the char's width().
QChar sc = ucs4_to_qchar(c);
return metrics_.width(sc) - metrics_.rightBearing(sc);
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx::use_gui)
- return 1;
-
int w = 0;
int const ls = s.length();
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx::use_gui)
- return ls;
-
QString const ucs2 = toqstr(s, ls);
if (smallcaps_shape_)