mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Correctly implement rule 18a in appendix G of the TeXbook
* src/mathed/InsetMathScript.C (isAlphaSymbol): New. Return true if nucleus is a letter or a symbol whose type is mathord or mathalpha. (InsetMathScript::dy01): Apply rule 18a accounting for nucleus type. * src/mathed/MathData.C (MathArray::metrics): Account for the fact that some fonts (eg. mathcal) do not have a lower case x glyph. * src/mathed/InsetMathSymbol.[Ch] (InsetMathSymbol::isOrdAlpha): New. Return true if type of symbol is mathord or mathalpha. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17518 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5653a3d744
commit
7fb8a4a595
@ -15,6 +15,7 @@
|
||||
#include "MathStream.h"
|
||||
#include "MathSupport.h"
|
||||
#include "InsetMathSymbol.h"
|
||||
#include "InsetMathFont.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
@ -146,22 +147,48 @@ MathArray & InsetMathScript::nuc()
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
bool isAlphaSymbol(MathAtom const & at)
|
||||
{
|
||||
if (at->asCharInset() ||
|
||||
(at->asSymbolInset() &&
|
||||
at->asSymbolInset()->isOrdAlpha()))
|
||||
return true;
|
||||
|
||||
if (at->asFontInset()) {
|
||||
MathArray const & ar = at->asFontInset()->cell(0);
|
||||
for (size_t i = 0; i < ar.size(); ++i) {
|
||||
if (!(ar[i]->asCharInset() ||
|
||||
(ar[i]->asSymbolInset() &&
|
||||
ar[i]->asSymbolInset()->isOrdAlpha())))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
int InsetMathScript::dy01(int asc, int des, int what) const
|
||||
{
|
||||
int dasc = 0;
|
||||
int slevel = 0;
|
||||
bool isCharBox = nuc().size() ? isAlphaSymbol(nuc().back()) : false;
|
||||
if (hasDown()) {
|
||||
dasc = down().ascent();
|
||||
slevel = nuc().slevel();
|
||||
int ascdrop = dasc - slevel;
|
||||
int desdrop = des + nuc().sshift();
|
||||
int desdrop = isCharBox ? 0 : des + nuc().sshift();
|
||||
int mindes = nuc().mindes();
|
||||
des = max(desdrop, ascdrop);
|
||||
des = max(mindes, des);
|
||||
}
|
||||
if (hasUp()) {
|
||||
int minasc = nuc().minasc();
|
||||
int ascdrop = asc - up().mindes();
|
||||
int ascdrop = isCharBox ? 0 : asc - up().mindes();
|
||||
int udes = up().descent();
|
||||
asc = udes + nuc().sshift();
|
||||
asc = max(ascdrop, asc);
|
||||
|
@ -116,6 +116,12 @@ bool InsetMathSymbol::isRelOp() const
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathSymbol::isOrdAlpha() const
|
||||
{
|
||||
return sym_->extra == "mathord" || sym_->extra == "mathalpha";
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathSymbol::isScriptable() const
|
||||
{
|
||||
return scriptable_;
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
|
||||
///
|
||||
bool isRelOp() const;
|
||||
///
|
||||
bool isOrdAlpha() const;
|
||||
/// do we take scripts?
|
||||
bool isScriptable() const;
|
||||
/// do we take \limits or \nolimits?
|
||||
|
@ -242,8 +242,11 @@ bool isInside(DocIterator const & it, MathArray const & ar,
|
||||
|
||||
void MathArray::metrics(MetricsInfo & mi) const
|
||||
{
|
||||
dim_ = theFontMetrics(mi.base.font).dimension('I');
|
||||
int xascent = theFontMetrics(mi.base.font).dimension('x').ascent();
|
||||
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
||||
dim_ = fm.dimension('I');
|
||||
int xascent = fm.dimension('x').ascent();
|
||||
if (xascent >= dim_.asc)
|
||||
xascent = (2 * dim_.asc) / 3;
|
||||
minasc_ = xascent;
|
||||
mindes_ = (3 * xascent) / 4;
|
||||
slevel_ = (4 * xascent) / 5;
|
||||
|
Loading…
Reference in New Issue
Block a user