mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Introduce FontMetrics::xHeight
Use it instead of measuring the height of character 'x'.
This commit is contained in:
parent
30c6d4fafe
commit
9b3fede789
@ -65,6 +65,8 @@ public:
|
||||
virtual Dimension const defaultDimension() const = 0;
|
||||
/// return the em size
|
||||
virtual int em() const = 0;
|
||||
/// return the x height
|
||||
virtual int xHeight() const = 0;
|
||||
/// return the width of a line for underlining
|
||||
virtual int lineWidth() const = 0;
|
||||
/// return the distance from the base line to where an underline
|
||||
|
@ -117,6 +117,13 @@ int GuiFontMetrics::em() const
|
||||
}
|
||||
|
||||
|
||||
int GuiFontMetrics::xHeight() const
|
||||
{
|
||||
// LATTEST(metrics_.xHeight() == ascent('x'));
|
||||
return metrics_.xHeight();
|
||||
}
|
||||
|
||||
|
||||
int GuiFontMetrics::lineWidth() const
|
||||
{
|
||||
return metrics_.lineWidth();
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
virtual int maxDescent() const;
|
||||
virtual Dimension const defaultDimension() const;
|
||||
virtual int em() const;
|
||||
virtual int xHeight() const;
|
||||
virtual int lineWidth() const;
|
||||
virtual int underlinePos() const;
|
||||
virtual int strikeoutPos() const;
|
||||
|
@ -352,7 +352,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
int const w = dim.wid;
|
||||
int const h = theFontMetrics(pi.base.font).ascent('x');
|
||||
int const h = theFontMetrics(pi.base.font).xHeight();
|
||||
int xp[4], yp[4];
|
||||
|
||||
xp[0] = x;
|
||||
|
@ -202,7 +202,7 @@ void drawLogo(PainterInfo & pi, int & x, int const y, InsetSpecialChar::Kind kin
|
||||
/** 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');
|
||||
@ -265,7 +265,7 @@ 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?
|
||||
|
@ -271,7 +271,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
|
||||
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
||||
BufferView * bv = mi.base.bv;
|
||||
int const Iascent = fm.dimension('I').ascent();
|
||||
int xascent = fm.dimension('x').ascent();
|
||||
int xascent = fm.xHeight();
|
||||
if (xascent >= Iascent)
|
||||
xascent = (2 * Iascent) / 3;
|
||||
minasc_ = xascent;
|
||||
@ -288,7 +288,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
|
||||
if (tight)
|
||||
// FIXME: this is the minimal ascent seen empirically, check
|
||||
// what the TeXbook says.
|
||||
dim.asc = max(dim.asc, fm.ascent('x'));
|
||||
dim.asc = max(dim.asc, fm.xHeight());
|
||||
else {
|
||||
dim.asc = max(dim.asc, fm.maxAscent());
|
||||
dim.des = max(dim.des, fm.maxDescent());
|
||||
|
@ -129,7 +129,8 @@ public:
|
||||
|
||||
/// rebuild cached metrics information
|
||||
/** When \c tight is true, the height of the cell will be at least
|
||||
* that of 'x'. Otherwise, it will be the max height of the font.
|
||||
* the x height of the font. Otherwise, it will be the max height
|
||||
* of the font.
|
||||
*/
|
||||
void metrics(MetricsInfo & mi, Dimension & dim, bool tight = true) const;
|
||||
///
|
||||
|
@ -520,7 +520,7 @@ int mathed_font_em(FontInfo const & font)
|
||||
|
||||
int mathed_font_x_height(FontInfo const & font)
|
||||
{
|
||||
return theFontMetrics(font).ascent('x');
|
||||
return theFontMetrics(font).xHeight();
|
||||
}
|
||||
|
||||
/* The math units. Quoting TeX by Topic, p.205:
|
||||
|
Loading…
Reference in New Issue
Block a user