2002-05-30 07:09:54 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
* \file InsetMathFont.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-05-30 07:09:54 +00:00
|
|
|
#ifndef MATH_FONTINSET_H
|
|
|
|
#define MATH_FONTINSET_H
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathNest.h"
|
2002-05-30 07:09:54 +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
|
|
|
/// Inset for font changes
|
2006-09-16 18:11:38 +00:00
|
|
|
class InsetMathFont : public InsetMathNest {
|
2002-05-30 07:09:54 +00:00
|
|
|
public:
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathFont(Buffer * buf, latexkeys const * key);
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFont * asFontInset() override { return this; }
|
2002-10-29 08:23:32 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFont const * asFontInset() const override { return this; }
|
2002-07-18 11:02:33 +00:00
|
|
|
/// are we in math mode, text mode, or unsure?
|
2020-10-01 07:42:11 +00:00
|
|
|
mode_type currentMode() const override;
|
2009-07-03 00:05:58 +00:00
|
|
|
/// do we allow changing mode during latex export?
|
2020-10-01 07:42:11 +00:00
|
|
|
bool lockedMode() const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(WriteStream & os) const override;
|
2016-09-10 16:32:44 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring name() const override;
|
2002-08-01 15:53:46 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void drawT(TextPainter & pi, int x, int y) const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures & features) const override;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void mathmlize(MathStream &) const override;
|
2009-12-31 16:59:56 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void htmlize(HtmlStream &) const override;
|
2010-03-31 18:57:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void infoize(odocstream & os) const override;
|
2007-03-21 17:21:59 +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_FONT_CODE; }
|
2002-05-30 07:09:54 +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-05-30 07:09:54 +00:00
|
|
|
/// the font to be used on screen
|
2002-07-17 10:25:33 +00:00
|
|
|
latexkeys const * key_;
|
2002-05-30 07:09:54 +00:00
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2002-05-30 07:09:54 +00:00
|
|
|
#endif
|