2002-07-17 10:25:33 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
* \file InsetMathFontOld.h
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2002-07-17 10:25:33 +00:00
|
|
|
#ifndef MATH_FONTOLDINSET_H
|
|
|
|
#define MATH_FONTOLDINSET_H
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathNest.h"
|
2002-07-17 10:25:33 +00:00
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
2002-07-17 10:25:33 +00:00
|
|
|
class latexkeys;
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
/// Old-style font changes
|
2006-09-16 18:11:38 +00:00
|
|
|
class InsetMathFontOld : public InsetMathNest {
|
2002-07-17 10:25:33 +00:00
|
|
|
public:
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathFontOld(Buffer * buf, latexkeys const * key);
|
2010-08-14 17:57:06 +00:00
|
|
|
/// we inherit the mode
|
2020-10-01 07:42:11 +00:00
|
|
|
mode_type currentMode() const override { return current_mode_; }
|
2002-07-17 10:25:33 +00:00
|
|
|
/// we write extra braces in any case...
|
2020-10-01 07:42:11 +00:00
|
|
|
bool extraBraces() const override { return true; }
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void drawT(TextPainter & pi, int x, int y) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-12-26 19:04:36 +00:00
|
|
|
void write(TeXMathStream & os) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void normalize(NormalStream &) const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void infoize(odocstream & os) const override;
|
2007-03-23 18:55:50 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int kerning(BufferView const * bv) const override { return cell(0).kerning(bv); }
|
2009-07-16 19:00:24 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return MATH_FONTOLD_CODE; }
|
2002-07-17 10:25:33 +00:00
|
|
|
|
|
|
|
private:
|
Remove a conversion to_utf8() inside FontSetChanger
This requires to change many docstrings into std::strings. The logic behind that
is that they represent a fixed set of math fonts, and therefore “string” means
here “poor man's enum” rather than text (this is consistent with MetricsBase).
Profiling of scrolling inside a document over macro-instensive areas:
Before the patch:
44,1% BufferView::updateMetrics()
-> 34,8% InsetMathHull::metrics()
-> 9,8% FontSetChanger::FontSetChanger()
28,4% BufferView::draw()
After the patch:
35,3% BufferView::updateMetrics()
-> 27,2% InsetMathHull::metrics
-> 0,4% FontSetChanger::FontSetChanger()
47,5% BufferView::draw()
FontSetChanger::FontSetChanger() is made 41x less expensive (with reference
BV::draw()) just by removing this conversion. The remaining 0,4% could be
squished by replacing the strings with a proper enum, but this is premature. Of
course, this only treats the symptoms: there is no good reason that this
function is called 45500 times over the time of 40 repaints.
2016-06-07 21:58:55 +00:00
|
|
|
std::string font() const;
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override;
|
2002-07-17 10:25:33 +00:00
|
|
|
/// the font to be used on screen
|
|
|
|
latexkeys const * key_;
|
2010-08-14 17:57:06 +00:00
|
|
|
/// the inherited mode
|
|
|
|
mutable mode_type current_mode_;
|
2002-07-17 10:25:33 +00:00
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2002-07-17 10:25:33 +00:00
|
|
|
#endif
|