> > It is not attached, if I may object. And this time I forgot the new files...
-- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Index: math_fontinset.C =================================================================== RCS file: math_fontinset.C diff -N math_fontinset.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ math_fontinset.C 28 Mar 2002 13:20:38 -0000 @@ -0,0 +1,113 @@ +#include <config.h> + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "math_fontinset.h" +#include "debug.h" +#include "math_mathmlstream.h" +#include "math_support.h" +#include "LaTeXFeatures.h" +#include "textpainter.h" + + +namespace { + + char const * math_font_name(MathTextCodes code) + { + static char const * theFontNames[] = { + "mathrm", + "mathcal", + "mathfrak", + "mathbf", + "mathbb", + "mathsf", + "mathtt", + "mathit", + "textrm" + }; + + if (code >= LM_TC_RM && code <= LM_TC_TEXTRM) + return theFontNames[code - LM_TC_RM]; + return "unknown"; + } + +} + +MathFontInset::MathFontInset(MathTextCodes code) + : MathNestInset(1), code_(code) +{} + + +MathInset * MathFontInset::clone() const +{ + return new MathFontInset(*this); +} + + +void MathFontInset::metrics(MathMetricsInfo & mi) const +{ + mi_ = mi; + whichFont(mi_.font, code_, mi); + xcell(0).metrics(mi_); + width_ = xcell(0).width(); + ascent_ = xcell(0).ascent(); + descent_ = xcell(0).descent(); +} + + +void MathFontInset::draw(MathPainterInfo & pain, int x, int y) const +{ + //lyxerr << "MathFontInset::draw\n"; + LyXFont f = pain.font; + MathTextCodes c = pain.code; + pain.font = mi_.font; + pain.code = code_; + xcell(0).draw(pain, x, y); + pain.font = f; + pain.code = c; +} + + +void MathFontInset::metricsT(TextMetricsInfo const & mi) const +{ + xcell(0).metricsT(mi); + width_ = xcell(0).width(); + ascent_ = xcell(0).ascent(); + descent_ = xcell(0).descent(); +} + + +void MathFontInset::drawT(TextPainter & pain, int x, int y) const +{ + //lyxerr << "drawing font code: " << code_ << '\n'; + xcell(0).drawT(pain, x, y); +} + + +void MathFontInset::write(WriteStream & os) const +{ + os << '\\' << math_font_name(code_) << '{' << cell(0) << '}'; +} + + +void MathFontInset::normalize(NormalStream & os) const +{ + os << "[font_ " << code_ << " " << cell(0) << "]"; +} + + +void MathFontInset::handleFont(MathTextCodes t) +{ + code_ = (code_ == t) ? LM_TC_VAR : t; +} + + +void MathFontInset::validate(LaTeXFeatures & features) const +{ + // Make sure amssymb is put in preamble if Blackboard Bold or + // Fraktur used: + if ((code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK)) + features.require("amssymb"); +} Index: math_fontinset.h =================================================================== RCS file: math_fontinset.h diff -N math_fontinset.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ math_fontinset.h 28 Mar 2002 13:20:38 -0000 @@ -0,0 +1,48 @@ +// -*- C++ -*- +#ifndef MATH_FONTINSET_H +#define MATH_FONTINSET_H + +#include "math_nestinset.h" + +#ifdef __GNUG__ +#pragma interface +#endif + +/** The base character inset. + \author André Pönitz + */ + +class MathFontInset : public MathNestInset { +public: + /// + explicit MathFontInset(MathTextCodes t); + /// + MathInset * clone() const; + /// + void metrics(MathMetricsInfo & st) const; + /// + void draw(MathPainterInfo &, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & st) const; + /// + void drawT(TextPainter &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// + void normalize(NormalStream &) const; + /// identifies Fontinsets + MathFontInset const * asFontInset() const { return this; } + /// + MathTextCodes code() const { return code_; } + /// + void validate(LaTeXFeatures & features) const; + /// + void handleFont(MathTextCodes t); + +private: + /// the font to be used on screen + MathTextCodes code_; + /// + mutable MathMetricsInfo mi_; +}; +#endif