Move metrics computation close to drawing for drawStrRed/Black

This commit is contained in:
Vincent van Ravesteijn 2012-05-03 16:28:28 +02:00
parent a02bfeebc5
commit b0b8e5f54c
6 changed files with 12 additions and 4 deletions

View File

@ -218,7 +218,7 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const
Dimension wdim;
static docstring bracket = from_ascii("[");
mathed_string_dim(mi.base.font, bracket, wdim);
metricsStrRedBlack(mi, wdim, bracket);
int w = wdim.wid;
Dimension dim0;

View File

@ -44,7 +44,7 @@ Inset * InsetMathExFunc::clone() const
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, name_, dim);
metricsStrRedBlack(mi, dim, name_);
}

View File

@ -47,7 +47,7 @@ void InsetMathUnknown::normalize(NormalStream & os) const
void InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, name_, dim);
metricsStrRedBlack(mi, dim, name_);
docstring::const_reverse_iterator rit = name_.rbegin();
kerning_ = mathed_char_kerning(mi.base.font, *rit);
}

View File

@ -62,7 +62,7 @@ void MathMacroArgument::write(WriteStream & os) const
void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, str_, dim);
metricsStrRedBlack(mi, dim, str_);
}

View File

@ -488,6 +488,12 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
}
void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & str)
{
mathed_string_dim(mi.base.font, str, dim);
}
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
{
FontInfo f = pi.base.font;

View File

@ -40,6 +40,8 @@ void mathed_string_dim(FontInfo const & font,
int mathed_string_width(FontInfo const &, docstring const & s);
void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & s);
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s);
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & s);