When computing a cell metrics, it is now possible to specify whether it
is tight (at least as tall as 'x') or not (as tall as the max height of
the font).
Use this to make sure that grid insets have large enough cells. It
will probably appear that other cells needn't be tight. Currently, the
only cell which is known to be tight is the nucleus of the root inset.
Others should be examined one by one. It might be that the default of
MathData::metrics tight parameter should be `false'.
Fixes bug #11050.
(cherry picked from commit
7bcb78a77875ecae0f54063ff02ec90e1b78f8b6)
for (idx_type i = 0; i < nargs(); ++i) {
if (cellinfo_[i].multi_ != CELL_PART_OF_MULTICOLUMN) {
Dimension dimc;
- cell(i).metrics(mi, dimc);
+ // the 'false' is to make sure that the cell is tall enough
+ cell(i).metrics(mi, dimc, false);
}
}
// reserve some space for marker.
dim.wid += 2;
-
- // make it at least as high as the current font
- int asc = 0;
- int des = 0;
- math_font_max_dim(mi.base.font, asc, des);
- dim.asc = max(dim.asc, asc);
- dim.des = max(dim.des, des);
}
Dimension dimr;
if (root) {
Changer script = mi.base.font.changeStyle(LM_ST_SCRIPTSCRIPT);
- root->metrics(mi, dimr);
// make sure that the dim is high enough for any character
- Dimension fontDim;
- math_font_max_dim(mi.base.font, fontDim.asc, fontDim.des);
- dimr += fontDim;
+ root->metrics(mi, dimr, false);
}
Dimension dimn;
nucleus.metrics(mi, dimn);
- // make sure that the dim is high enough for any character
- // Dimension fontDim;
- // math_font_max_dim(mi.base.font, fontDim.asc, fontDim.des);
- // dimn += fontDim;
// Some room for the decoration
// The width of left decoration was 9 pixels with a 10em font
#endif
-void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
+void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
{
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
- dim = fm.dimension('I');
+ int const Iascent = fm.dimension('I').ascent();
int xascent = fm.dimension('x').ascent();
- if (xascent >= dim.asc)
- xascent = (2 * dim.asc) / 3;
+ if (xascent >= Iascent)
+ xascent = (2 * Iascent) / 3;
minasc_ = xascent;
mindes_ = (3 * xascent) / 4;
slevel_ = (4 * xascent) / 5;
mrow_cache_[mi.base.bv] = mrow;
kerning_ = mrow.kerning(mi.base.bv);
+ // Set a minimal ascent/descent for the cell
+ if (tight)
+ // FIXME: this is the minimal ascent seen empirically, check
+ // what the TeXbook says.
+ dim.asc = max(dim.asc, fm.ascent('x'));
+ else {
+ dim.asc = max(dim.asc, fm.maxAscent());
+ dim.des = max(dim.des, fm.maxDescent());
+ }
+
// Cache the dimension.
mi.base.bv->coordCache().arrays().add(this, dim);
}
bool addToMathRow(MathRow &, MetricsInfo & mi) const;
/// rebuild cached metrics information
- void metrics(MetricsInfo & mi, Dimension & dim) const;
+ /** 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.
+ */
+ void metrics(MetricsInfo & mi, Dimension & dim, bool tight = true) const;
///
Dimension const & dimension(BufferView const &) const;
void MathRow::metrics(MetricsInfo & mi, Dimension & dim)
{
- frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
- // FIXME: this is the minimal ascent seen empirically, check
- // what the TeXbook says.
- dim.asc = fm.ascent('x');
- dim.wid = 0;
// In order to compute the dimension of macros and their
// arguments, it is necessary to keep track of them.
vector<pair<InsetMath const *, Dimension>> dim_insets;
}
break;
case BOX:
- d = fm.dimension('I');
+ d = theFontMetrics(mi.base.font).dimension('I');
if (e.color != Color_none) {
// allow for one pixel before/after the box.
d.wid += e.before + e.after + 2;