mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Better mechanism for setting cell cell height
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.
This commit is contained in:
parent
4300feb859
commit
7bcb78a778
@ -397,7 +397,8 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,13 +569,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,19 +47,12 @@ void mathed_root_metrics(MetricsInfo & mi, MathData const & nucleus,
|
||||
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
|
||||
|
@ -259,13 +259,13 @@ bool isInside(DocIterator const & it, MathData const & ar,
|
||||
#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;
|
||||
@ -276,6 +276,16 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
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);
|
||||
}
|
||||
|
@ -125,7 +125,10 @@ public:
|
||||
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;
|
||||
|
||||
|
@ -236,11 +236,6 @@ int MathRow::after(int i) 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;
|
||||
@ -287,7 +282,7 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim)
|
||||
}
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user