From 2806246e1eac1908d4a5afe58165e53fe35044b5 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Fri, 31 Aug 2001 21:15:57 +0000 Subject: [PATCH] Few math fonts improvements (use cmr for uppercase greek, support for \mathbb) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2647 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 + src/FontInfo.C | 2 + src/FontLoader.C | 9 +- src/FontLoader.h | 4 +- src/frontends/xforms/MathsSymbols.C | 7 +- src/lyxfont.C | 8 +- src/lyxfont.h | 6 +- src/mathed/ChangeLog | 9 ++ src/mathed/Makefile.am | 4 - src/mathed/formulabase.C | 1 + src/mathed/math_bigopinset.C | 44 ------ src/mathed/math_bigopinset.h | 34 ----- src/mathed/math_charinset.C | 1 + src/mathed/math_defs.h | 6 +- src/mathed/math_factory.C | 8 +- src/mathed/math_hash.C | 229 ++++++++++++++-------------- src/mathed/math_macrotable.C | 25 ++- src/mathed/math_noglyphinset.C | 44 ------ src/mathed/math_noglyphinset.h | 31 ---- src/mathed/math_notinset.C | 12 +- src/mathed/math_parser.h | 6 +- src/mathed/math_symbolinset.C | 18 ++- src/mathed/math_symbolinset.h | 2 + src/mathed/support.C | 97 ++++++++---- 24 files changed, 275 insertions(+), 336 deletions(-) delete mode 100644 src/mathed/math_bigopinset.C delete mode 100644 src/mathed/math_bigopinset.h delete mode 100644 src/mathed/math_noglyphinset.C delete mode 100644 src/mathed/math_noglyphinset.h diff --git a/src/ChangeLog b/src/ChangeLog index fb236df1ae..2ad6f9ee4d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-09-01 Dekel Tsur + + * FontLoader.C: Support for cmr font. + 2001-08-31 Dekel Tsur * FontLoader.C (getFontinfo): Handle latex symbol fonts. diff --git a/src/FontInfo.C b/src/FontInfo.C index 03e00a7d40..486f4ca03a 100644 --- a/src/FontInfo.C +++ b/src/FontInfo.C @@ -134,6 +134,8 @@ void FontInfo::query() // We have matches. Run them through for (int i = 0; i < matches; ++i) { string name(list[i]); + lyxerr[Debug::FONT] << "match #" << i << " " + << name << endl; sizes[i] = lyx::atoi(token(name, '-', 7)); strings[i] = name; if (sizes[i] == 0) { diff --git a/src/FontLoader.C b/src/FontLoader.C index 760013b63a..d45e58949e 100644 --- a/src/FontLoader.C +++ b/src/FontLoader.C @@ -60,7 +60,7 @@ void FontLoader::update() void FontLoader::reset() { // Clear font infos, font structs and font metrics - for (int i1 = 0; i1 < 9; ++i1) + for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) { fontinfo[i1][i2][i3] = 0; @@ -75,7 +75,7 @@ void FontLoader::reset() void FontLoader::unload() { // Unload all fonts - for (int i1 = 0; i1 < 9; ++i1) + for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) { if (fontinfo[i1][i2][i3]) { @@ -111,6 +111,11 @@ void FontLoader::getFontinfo(LyXFont::FONT_FAMILY family, new FontInfo("-*-symbol-*-*-*-*-*-*-*-*-*-*-*-*"); return; + case LyXFont::CMR_FAMILY: + fontinfo[family][series][shape] = + new FontInfo("-*-cmr-medium-*-*-*-*-*-*-*-*-*-*-*"); + return; + case LyXFont::CMSY_FAMILY: fontinfo[family][series][shape] = new FontInfo("-*-cmsy-*-*-*-*-*-*-*-*-*-*-*-*"); diff --git a/src/FontLoader.h b/src/FontLoader.h index 9ddd8e1f3a..66e1676068 100644 --- a/src/FontLoader.h +++ b/src/FontLoader.h @@ -53,10 +53,10 @@ public: private: /// Array of font structs - XFontStruct * fontstruct[9][2][4][10]; + XFontStruct * fontstruct[LyXFont::NUM_FAMILIES][2][4][10]; /// Array of font infos - FontInfo * fontinfo[9][2][4]; + FontInfo * fontinfo[LyXFont::NUM_FAMILIES][2][4]; /// Reset font handler void reset(); diff --git a/src/frontends/xforms/MathsSymbols.C b/src/frontends/xforms/MathsSymbols.C index 0278edc4e8..188ebe7bae 100644 --- a/src/frontends/xforms/MathsSymbols.C +++ b/src/frontends/xforms/MathsSymbols.C @@ -301,8 +301,13 @@ char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx) case LM_TK_SQRT: data = mathed_get_pixmap_from_icon(MM_SQRT); break; - case LM_TK_BIGSYM: case LM_TK_SYM: + case LM_TK_CMR: + case LM_TK_CMSY: + case LM_TK_CMEX: + case LM_TK_CMM: + case LM_TK_MSA: + case LM_TK_MSB: // I have to use directly the bitmap data since the // bitmap tables are not yet created when this // function is called. diff --git a/src/lyxfont.C b/src/lyxfont.C index 7e4014b74f..927ce95e83 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -39,9 +39,9 @@ using std::strlen; namespace { -char const * GUIFamilyNames[11] = +char const * GUIFamilyNames[12] = { N_("Roman"), N_("Sans serif"), N_("Typewriter"), N_("Symbol"), - "cmsy", "cmm", "cmex", "msa", "msb", + "cmr", "cmsy", "cmm", "cmex", "msa", "msb", N_("Inherit"), N_("Ignore") }; char const * GUISeriesNames[4] = @@ -63,9 +63,9 @@ char const * GUIMiscNames[5] = // // Strings used to read and write .lyx format files // -char const * LyXFamilyNames[11] = +char const * LyXFamilyNames[12] = { "roman", "sans", "typewriter", "symbol", - "cmsy", "cmm", "cmex", "msa", "msb", + "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "default", "error" }; char const * LyXSeriesNames[4] = diff --git a/src/lyxfont.h b/src/lyxfont.h index d230cfa6b4..4bd9ad0e95 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -45,6 +45,8 @@ public: /// SYMBOL_FAMILY, /// + CMR_FAMILY, + /// CMSY_FAMILY, /// CMM_FAMILY, @@ -57,7 +59,9 @@ public: /// INHERIT_FAMILY, /// - IGNORE_FAMILY + IGNORE_FAMILY, + /// + NUM_FAMILIES = INHERIT_FAMILY }; /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 5008d127e9..652c517fca 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,12 @@ +2001-09-01 Dekel Tsur + + * support.C (whichFont): Add support for cmr font. + Add support for \mathbb. + + * math_notinset.C (draw, metrics): Use cmsy symbol if available. + + * math_macrotable.C (builtinMacros): Add 3 builtin macros + 2001-08-31 Dekel Tsur * math_hash.C: Read symbols information from external file diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index aa18fccd2b..5ffdd9c7e5 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -22,8 +22,6 @@ libmathed_la_SOURCES = \ formulamacro.h \ math_arrayinset.C \ math_arrayinset.h \ - math_bigopinset.C \ - math_bigopinset.h \ math_binominset.C \ math_binominset.h \ math_charinset.C \ @@ -70,8 +68,6 @@ libmathed_la_SOURCES = \ math_nestinset.h \ math_notinset.C \ math_notinset.h \ - math_noglyphinset.C \ - math_noglyphinset.h \ math_parser.C \ math_parser.h \ math_rootinset.C \ diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 5caf393738..48e92c0d28 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -523,6 +523,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break; case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break; case LFUN_CODE: handleFont(bv, LM_TC_TT); break; + case LFUN_NOUN: handleFont(bv, LM_TC_BB); break; case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break; case LFUN_MATH_MODE: diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C deleted file mode 100644 index e71494399f..0000000000 --- a/src/mathed/math_bigopinset.C +++ /dev/null @@ -1,44 +0,0 @@ -#include "math_bigopinset.h" -#include "mathed/math_parser.h" -#include "mathed/support.h" -#include "support/LOstream.h" - - -using std::ostream; - -MathBigopInset::MathBigopInset(const latexkeys * l) - : sym_(l) -{} - - -MathInset * MathBigopInset::clone() const -{ - return new MathBigopInset(*this); -} - - -void MathBigopInset::write(ostream & os, bool /* fragile */) const -{ - os << '\\' << sym_->name << ' '; -} - - -void MathBigopInset::writeNormal(ostream & os) const -{ - os << "[bigop " << sym_->name << "] "; -} - - -void MathBigopInset::metrics(MathStyles st) const -{ - size_ = st; - mathed_char_dim(LM_TC_BSYM, st, sym_->id, ascent_, descent_, width_); -} - - -void MathBigopInset::draw(Painter & pain, int x, int y) const -{ - xo(x); - yo(y); - drawChar(pain, LM_TC_BSYM, size_, x, y, sym_->id); -} diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h deleted file mode 100644 index 66f30e2c57..0000000000 --- a/src/mathed/math_bigopinset.h +++ /dev/null @@ -1,34 +0,0 @@ -// -*- C++ -*- -#ifndef MATH_BIGOPINSET_H -#define MATH_BIGOPINSET_H - -// This inset is for things like "\sum" and "\int" that get displayed -// larger in displayed formulae and take limits - -#include "math_diminset.h" - -struct latexkeys; - -/// big operators -class MathBigopInset : public MathDimInset { -public: - /// - explicit MathBigopInset(latexkeys const *); - /// - MathInset * clone() const; - /// - void write(std::ostream &, bool fragile) const; - /// - void writeNormal(std::ostream &) const; - /// - void metrics(MathStyles st) const; - /// - void draw(Painter &, int x, int y) const; - /// - bool isScriptable() const { return true; } - -private: - /// - latexkeys const * sym_; -}; -#endif diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index 898868b9a3..8c1ca673b4 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -19,6 +19,7 @@ char const * math_font_name[] = { "mathrm", "mathcal", "mathbf", + "mathbb", "mathsf", "mathtt", "mathit", diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index c42578fa0a..5fd004fca3 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -65,6 +65,8 @@ enum MathTextCodes { LM_TC_CAL, /// LM_TC_BF, + // + LM_TC_BB, /// LM_TC_SF, /// @@ -82,7 +84,9 @@ enum MathTextCodes { /// Internal code for symbols LM_TC_SYMB, /// internal code for symbols that get bigger in displayed math - LM_TC_BSYM, + LM_TC_BOLDSYMB, + /// + LM_TC_CMR, /// LM_TC_CMSY, /// diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index fae6732e92..01df5f2838 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -1,7 +1,6 @@ #include #include "math_parser.h" -#include "math_bigopinset.h" #include "math_binominset.h" #include "math_decorationinset.h" #include "math_dotsinset.h" @@ -11,7 +10,6 @@ #include "math_kerninset.h" #include "math_macro.h" #include "math_macrotable.h" -#include "math_noglyphinset.h" #include "math_notinset.h" #include "math_rootinset.h" #include "math_spaceinset.h" @@ -24,16 +22,12 @@ MathInset * createMathInset(latexkeys const * l) { switch (l->token) { - case LM_TK_NOGLYPH: - case LM_TK_NOGLYPHB: - return new MathNoglyphInset(l); - case LM_TK_BIGSYM: - return new MathBigopInset(l); case LM_TK_FUNCLIM: return new MathFuncLimInset(l); case LM_TK_SPECIAL: return new MathSpecialCharInset(l->id); case LM_TK_SYM: + case LM_TK_CMR: case LM_TK_CMSY: case LM_TK_CMM: case LM_TK_CMEX: diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 17833dc609..0ddfd118e4 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -26,122 +26,121 @@ struct latexkeys_a { short token; /// unsigned int id; - /// - MathSymbolTypes type; }; latexkeys_a wordlist_array[] = { - {"!", LM_TK_SPACE, 0, LMB_NONE}, - {"#", LM_TK_SPECIAL, '#', LMB_NONE}, - {"$", LM_TK_SPECIAL, '$', LMB_NONE}, - {"%", LM_TK_SPECIAL, '%', LMB_NONE}, - {"&", LM_TK_SPECIAL, '&', LMB_NONE}, - {"(", LM_TK_BEGIN, LM_OT_SIMPLE, LMB_NONE}, - {")", LM_TK_END, LM_OT_SIMPLE, LMB_NONE}, - {",", LM_TK_SPACE, 1, LMB_NONE}, - {".", LM_TK_SPECIAL, '.', LMB_NONE}, - {":", LM_TK_SPACE, 2, LMB_NONE}, - {";", LM_TK_SPACE, 3, LMB_NONE}, - {"Pr", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"[", LM_TK_BEGIN, LM_OT_EQUATION, LMB_NONE}, - {"\\", LM_TK_NEWLINE, static_cast(-1), LMB_NONE}, // -1 needed in mathed_parse_lines! - {"]", LM_TK_END, LM_OT_EQUATION, LMB_NONE}, - {"_", LM_TK_SPECIAL, '_', LMB_NONE}, - {"acute", LM_TK_DECORATION, LM_acute, LMB_NONE}, - {"arccos", LM_TK_FUNC, 0, LMB_NONE}, - {"arcsin", LM_TK_FUNC, 0, LMB_NONE}, - {"arctan", LM_TK_FUNC, 0, LMB_NONE}, - {"arg", LM_TK_FUNC, 0, LMB_NONE}, - {"atop", LM_TK_ATOP, 0, LMB_NONE}, - {"backslash", LM_TK_SPECIAL, '\\', LMB_NONE}, - {"bar", LM_TK_DECORATION, LM_bar, LMB_NONE}, - {"begin", LM_TK_BEGIN, 0, LMB_NONE}, - {"binom", LM_TK_BINOM, 0, LMB_NONE}, - {"bmod", LM_TK_FUNC, 0, LMB_NONE}, - {"breve", LM_TK_DECORATION, LM_breve, LMB_NONE}, - {"cal", LM_TK_OLDFONT, LM_TC_CAL, LMB_OPERATOR}, - {"cdots", LM_TK_DOTS, LM_cdots, LMB_NONE}, - {"check", LM_TK_DECORATION, LM_check, LMB_NONE}, - {"choose", LM_TK_CHOOSE, 0, LMB_NONE}, - {"cos", LM_TK_FUNC, 0, LMB_NONE}, - {"cosh", LM_TK_FUNC, 0, LMB_NONE}, - {"cot", LM_TK_FUNC, 0, LMB_NONE}, - {"coth", LM_TK_FUNC, 0, LMB_NONE}, - {"csc", LM_TK_FUNC, 0, LMB_NONE}, - {"ddot", LM_TK_DECORATION, LM_ddot, LMB_NONE}, - {"ddots", LM_TK_DOTS, LM_ddots, LMB_NONE}, - {"deg", LM_TK_FUNC, 0, LMB_NONE}, - {"det", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"dim", LM_TK_FUNC, 0, LMB_NONE}, - //{"displaystyle", LM_TK_STY, LM_ST_DISPLAY, LMB_NONE}, - {"dot", LM_TK_DECORATION, LM_dot, LMB_NONE}, - {"end", LM_TK_END, 0, LMB_NONE}, - {"exp", LM_TK_FUNC, 0, LMB_NONE}, - {"frac", LM_TK_FRAC, 0, LMB_NONE}, - {"gcd", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"grave", LM_TK_DECORATION, LM_grave, LMB_NONE}, - {"hat", LM_TK_DECORATION, LM_hat, LMB_NONE}, - {"hom", LM_TK_FUNC, 0, LMB_NONE}, - {"inf", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"ker", LM_TK_FUNC, 0, LMB_NONE}, - {"kern", LM_TK_KERN, 0, LMB_NONE}, - {"label", LM_TK_LABEL, 0, LMB_NONE}, - {"ldots", LM_TK_DOTS, LM_ldots, LMB_NONE}, - {"left", LM_TK_LEFT, 0, LMB_NONE}, - {"lg", LM_TK_FUNC, 0, LMB_NONE}, - {"lim", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"liminf", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"limits", LM_TK_LIMIT, 1 , LMB_NONE}, - {"limsup", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"ln", LM_TK_FUNC, 0, LMB_NONE}, - {"log", LM_TK_FUNC, 0, LMB_NONE}, - {"mathbf", LM_TK_FONT, LM_TC_BF, LMB_NONE}, - {"mathcal", LM_TK_FONT, LM_TC_CAL, LMB_NONE}, - {"mathit", LM_TK_FONT, LM_TC_IT, LMB_NONE}, - {"mathnormal", LM_TK_FONT, LM_TC_VAR, LMB_NONE}, - {"mathrm", LM_TK_FONT, LM_TC_RM, LMB_NONE}, - {"mathsf", LM_TK_FONT, LM_TC_SF, LMB_NONE}, - {"mathtt", LM_TK_FONT, LM_TC_TT, LMB_NONE}, - {"max", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"min", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"newcommand", LM_TK_NEWCOMMAND, 0 , LMB_NONE}, - {"nolimits", LM_TK_LIMIT, static_cast(-1), LMB_NONE}, - {"nonumber", LM_TK_NONUM, 0, LMB_NONE}, - {"not", LM_TK_NOT, LM_not, LMB_NONE}, - {"over", LM_TK_OVER, 0, LMB_NONE}, - {"overbrace", LM_TK_DECORATION, LM_overbrace, LMB_NONE}, - {"overleftarrow", LM_TK_DECORATION, LM_overleftarrow, LMB_NONE}, - {"overline", LM_TK_DECORATION, LM_overline, LMB_NONE}, - {"overrightarrow", LM_TK_DECORATION, LM_overightarrow, LMB_NONE}, - {"protect", LM_TK_PROTECT, 0, LMB_RELATION}, - {"qquad", LM_TK_SPACE, 5, LMB_NONE}, - {"quad", LM_TK_SPACE, 4, LMB_NONE}, - {"right", LM_TK_RIGHT, 0, LMB_NONE}, - {"root", LM_TK_ROOT, 0, LMB_NONE}, - //{"scriptscriptstyle", LM_TK_STY, LM_ST_SCRIPTSCRIPT, LMB_NONE}, - //{"scriptstyle", LM_TK_STY, LM_ST_SCRIPT, LMB_NONE}, - {"sec", LM_TK_FUNC, 0, LMB_NONE}, - {"sin", LM_TK_FUNC, 0, LMB_NONE}, - {"sinh", LM_TK_FUNC, 0, LMB_NONE}, - {"sqrt", LM_TK_SQRT, 0, LMB_NONE}, - {"stackrel", LM_TK_STACK, 0, LMB_NONE}, - {"sup", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"tan", LM_TK_FUNC, 0, LMB_NONE}, - {"tanh", LM_TK_FUNC, 0, LMB_NONE}, - {"textrm", LM_TK_FONT, LM_TC_TEXTRM, LMB_NONE}, - //{"textstyle", LM_TK_STY, LM_ST_TEXT, LMB_NONE}, - {"tilde", LM_TK_DECORATION, LM_tilde, LMB_NONE}, - {"underbrace", LM_TK_DECORATION, LM_underbrace, LMB_NONE}, - {"underline", LM_TK_DECORATION, LM_underline, LMB_NONE}, - {"vdots", LM_TK_DOTS, LM_vdots, LMB_NONE}, - {"vec", LM_TK_DECORATION, LM_vec, LMB_NONE}, - {"widehat", LM_TK_DECORATION, LM_widehat, LMB_NONE}, - {"widetilde", LM_TK_DECORATION, LM_widetilde, LMB_NONE}, - {"{", LM_TK_SPECIAL, '{', LMB_NONE}, - {"|", LM_TK_UNDEF, '|', LMB_NONE}, - {"}", LM_TK_SPECIAL, '}', LMB_NONE}, - {"", LM_TK_SPECIAL, 0, LMB_NONE} + {"!", LM_TK_SPACE, 0}, + {"#", LM_TK_SPECIAL, '#'}, + {"$", LM_TK_SPECIAL, '$'}, + {"%", LM_TK_SPECIAL, '%'}, + {"&", LM_TK_SPECIAL, '&'}, + {"(", LM_TK_BEGIN, LM_OT_SIMPLE}, + {")", LM_TK_END, LM_OT_SIMPLE}, + {",", LM_TK_SPACE, 1}, + {".", LM_TK_SPECIAL, '.'}, + {":", LM_TK_SPACE, 2}, + {";", LM_TK_SPACE, 3}, + {"Pr", LM_TK_FUNCLIM, 0}, + {"[", LM_TK_BEGIN, LM_OT_EQUATION}, + {"\\", LM_TK_NEWLINE, static_cast(-1)}, // -1 needed in mathed_parse_lines! + {"]", LM_TK_END, LM_OT_EQUATION}, + {"_", LM_TK_SPECIAL, '_'}, + {"acute", LM_TK_DECORATION, LM_acute}, + {"arccos", LM_TK_FUNC, 0}, + {"arcsin", LM_TK_FUNC, 0}, + {"arctan", LM_TK_FUNC, 0}, + {"arg", LM_TK_FUNC, 0}, + {"atop", LM_TK_ATOP, 0}, + {"backslash", LM_TK_SPECIAL, '\\'}, + {"bar", LM_TK_DECORATION, LM_bar}, + {"begin", LM_TK_BEGIN, 0}, + {"binom", LM_TK_BINOM, 0}, + {"bmod", LM_TK_FUNC, 0}, + {"breve", LM_TK_DECORATION, LM_breve}, + {"cal", LM_TK_OLDFONT, LM_TC_CAL}, + {"cdots", LM_TK_DOTS, LM_cdots}, + {"check", LM_TK_DECORATION, LM_check}, + {"choose", LM_TK_CHOOSE, 0}, + {"cos", LM_TK_FUNC, 0}, + {"cosh", LM_TK_FUNC, 0}, + {"cot", LM_TK_FUNC, 0}, + {"coth", LM_TK_FUNC, 0}, + {"csc", LM_TK_FUNC, 0}, + {"ddot", LM_TK_DECORATION, LM_ddot}, + {"ddots", LM_TK_DOTS, LM_ddots}, + {"deg", LM_TK_FUNC, 0}, + {"det", LM_TK_FUNCLIM, 0}, + {"dim", LM_TK_FUNC, 0}, + //{"displaystyle", LM_TK_STY, LM_ST_DISPLAY}, + {"dot", LM_TK_DECORATION, LM_dot}, + {"end", LM_TK_END, 0}, + {"exp", LM_TK_FUNC, 0}, + {"frac", LM_TK_FRAC, 0}, + {"gcd", LM_TK_FUNCLIM, 0}, + {"grave", LM_TK_DECORATION, LM_grave}, + {"hat", LM_TK_DECORATION, LM_hat}, + {"hom", LM_TK_FUNC, 0}, + {"inf", LM_TK_FUNCLIM, 0}, + {"ker", LM_TK_FUNC, 0}, + {"kern", LM_TK_KERN, 0}, + {"label", LM_TK_LABEL, 0}, + {"ldots", LM_TK_DOTS, LM_ldots}, + {"left", LM_TK_LEFT, 0}, + {"lg", LM_TK_FUNC, 0}, + {"lim", LM_TK_FUNCLIM, 0}, + {"liminf", LM_TK_FUNCLIM, 0}, + {"limits", LM_TK_LIMIT, 1 }, + {"limsup", LM_TK_FUNCLIM, 0}, + {"ln", LM_TK_FUNC, 0}, + {"log", LM_TK_FUNC, 0}, + {"mathbb", LM_TK_FONT, LM_TC_BB}, + {"mathbf", LM_TK_FONT, LM_TC_BF}, + {"mathcal", LM_TK_FONT, LM_TC_CAL}, + {"mathit", LM_TK_FONT, LM_TC_IT}, + {"mathnormal", LM_TK_FONT, LM_TC_VAR}, + {"mathrm", LM_TK_FONT, LM_TC_RM}, + {"mathsf", LM_TK_FONT, LM_TC_SF}, + {"mathtt", LM_TK_FONT, LM_TC_TT}, + {"max", LM_TK_FUNCLIM, 0}, + {"min", LM_TK_FUNCLIM, 0}, + {"newcommand", LM_TK_NEWCOMMAND, 0 }, + {"nolimits", LM_TK_LIMIT, static_cast(-1)}, + {"nonumber", LM_TK_NONUM, 0}, + {"not", LM_TK_NOT, LM_not}, + {"over", LM_TK_OVER, 0}, + {"overbrace", LM_TK_DECORATION, LM_overbrace}, + {"overleftarrow", LM_TK_DECORATION, LM_overleftarrow}, + {"overline", LM_TK_DECORATION, LM_overline}, + {"overrightarrow", LM_TK_DECORATION, LM_overightarrow}, + {"protect", LM_TK_PROTECT, 0}, + {"qquad", LM_TK_SPACE, 5}, + {"quad", LM_TK_SPACE, 4}, + {"right", LM_TK_RIGHT, 0}, + {"root", LM_TK_ROOT, 0}, + //{"scriptscriptstyle", LM_TK_STY, LM_ST_SCRIPTSCRIPT}, + //{"scriptstyle", LM_TK_STY, LM_ST_SCRIPT}, + {"sec", LM_TK_FUNC, 0}, + {"sin", LM_TK_FUNC, 0}, + {"sinh", LM_TK_FUNC, 0}, + {"sqrt", LM_TK_SQRT, 0}, + {"stackrel", LM_TK_STACK, 0}, + {"sup", LM_TK_FUNCLIM, 0}, + {"tan", LM_TK_FUNC, 0}, + {"tanh", LM_TK_FUNC, 0}, + {"textrm", LM_TK_FONT, LM_TC_TEXTRM}, + //{"textstyle", LM_TK_STY, LM_ST_TEXT}, + {"tilde", LM_TK_DECORATION, LM_tilde}, + {"underbrace", LM_TK_DECORATION, LM_underbrace}, + {"underline", LM_TK_DECORATION, LM_underline}, + {"vdots", LM_TK_DOTS, LM_vdots}, + {"vec", LM_TK_DECORATION, LM_vec}, + {"widehat", LM_TK_DECORATION, LM_widehat}, + {"widetilde", LM_TK_DECORATION, LM_widetilde}, + {"{", LM_TK_SPECIAL, '{'}, + {"|", LM_TK_UNDEF, '|'}, + {"}", LM_TK_SPECIAL, '}'}, + {"", LM_TK_SPECIAL, 0} }; @@ -159,7 +158,7 @@ void ReadSymbols(string const & filename) tmp.name = p->name; tmp.token = p->token; tmp.id = p->id; - tmp.type = p->type; + tmp.type = LMB_NONE; tmp.latex_font_id = 0; wordlist.push_back(tmp); } @@ -185,7 +184,9 @@ void ReadSymbols(string const & filename) if (lex.next()) type = lex.getString(); - if (font == "cmsy") + if (font == "cmr") + tmp.token = LM_TK_CMR; + else if (font == "cmsy") tmp.token = LM_TK_CMSY; else if (font == "cmm") tmp.token = LM_TK_CMM; diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 167b8fb809..0387ffae24 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -100,6 +100,24 @@ void MathMacroTable::builtinMacros() createTemplate("gets", 0, "\\leftarrow"); createTemplate("to", 0, "\\rightarrow"); + createTemplate("longleftrightarrow", 0, "\\leftarrow\\kern-6mu\\rightarrow"); + createTemplate("Longleftrightarrow", 0, "\\Leftarrow\\kern-6mu\\Rightarrow"); + createTemplate("doteq", 0, "\\stackrel{\\cdot}{=}"); + +#if 0 + // The following either require using the latex fonts, + // or don't look good, so they are disabled + + createTemplate("hookrightarrow", 0, "\\lhook\\kern-3mu\\rightarrow"); + createTemplate("hookleftarrow", 0, "\\leftarrow\\kern-3mu\\rhook"); + createTemplate("bowtie", 0, "\\triangleright\\kern-3mu\\triangleleft"); + + createTemplate("models", 0, "|\\kern-9mu="); + createTemplate("longrightarrow", 0, "-\\kern-9mu\\rightarrow"); + createTemplate("longleftarrow", 0, "\\leftarrow\\kern-9mu-"); + createTemplate("Longrightarrow", 0, "=\\kern-9mu\\Rightarrow"); + createTemplate("Longleftarrow", 0, "\\Leftarrow\\kern-9mu="); + //amsfonts.sty createTemplate("dasharrow", 0, "\\dashrightarrow"); @@ -115,12 +133,7 @@ void MathMacroTable::builtinMacros() createTemplate("doublecap", 0, "\\Cap"); createTemplate("llless", 0, "\\lll"); createTemplate("gggtr", 0, "\\ggg"); - -// #ifdef WITH_WARNINGS -// #warning 9em looks like too much but it is somehow working on screen.. -// #endif WITH_WARNINGS -// createTemplate("ll", 0, "<\\kern-9em<"); -// createTemplate("gg", 0, ">\\kern-9em>"); +#endif //createTemplate("lint", 4, "\\int_#1^#2#3 d#4"); //createTemplate("silentmult", 0, "\\cdot"); diff --git a/src/mathed/math_noglyphinset.C b/src/mathed/math_noglyphinset.C deleted file mode 100644 index a62dc9477f..0000000000 --- a/src/mathed/math_noglyphinset.C +++ /dev/null @@ -1,44 +0,0 @@ -#include "math_noglyphinset.h" -#include "math_parser.h" -#include "support.h" -#include "support/LOstream.h" - - -using std::ostream; - -MathNoglyphInset::MathNoglyphInset(const latexkeys * l) - : sym_(l) -{} - - -MathInset * MathNoglyphInset::clone() const -{ - return new MathNoglyphInset(*this); -} - - -void MathNoglyphInset::write(ostream & os, bool /* fragile */) const -{ - os << '\\' << sym_->name << ' '; -} - - -void MathNoglyphInset::writeNormal(ostream & os) const -{ - os << "[bigop " << sym_->name << "] "; -} - - -void MathNoglyphInset::metrics(MathStyles st) const -{ - size(st); - mathed_string_dim(LM_TC_TEX, st, sym_->name, ascent_, descent_, width_); -} - - -void MathNoglyphInset::draw(Painter & pain, int x, int y) const -{ - xo(x); - yo(y); - drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name); -} diff --git a/src/mathed/math_noglyphinset.h b/src/mathed/math_noglyphinset.h deleted file mode 100644 index 70ec34bef7..0000000000 --- a/src/mathed/math_noglyphinset.h +++ /dev/null @@ -1,31 +0,0 @@ -// -*- C++ -*- -#ifndef MATH_NOGLYPHINSET_H -#define MATH_NOGLYPHINSET_H - -#include "math_diminset.h" - -struct latexkeys; - -// "normal" symbols for which we don't have a glyph aailable to display -// them properly - -class MathNoglyphInset : public MathDimInset { -public: - /// - explicit MathNoglyphInset(latexkeys const *); - /// - MathInset * clone() const; - /// - void write(std::ostream &, bool fragile) const; - /// - void writeNormal(std::ostream &) const; - /// - void metrics(MathStyles st) const; - /// - void draw(Painter &, int x, int y) const; - -private: - /// - latexkeys const * sym_; -}; -#endif diff --git a/src/mathed/math_notinset.C b/src/mathed/math_notinset.C index 0d16cd9006..a187a3173f 100644 --- a/src/mathed/math_notinset.C +++ b/src/mathed/math_notinset.C @@ -31,7 +31,12 @@ void MathNotInset::writeNormal(ostream & os) const void MathNotInset::metrics(MathStyles st) const { size(st); - mathed_char_dim(LM_TC_VAR, size_, '/', ascent_, descent_, width_); + if (math_font_available(LM_TC_CMSY)) + mathed_char_dim(LM_TC_CMSY, size_, 54, + ascent_, descent_, width_); + else + mathed_char_dim(LM_TC_VAR, size_, '/', + ascent_, descent_, width_); width_ = 0; } @@ -41,5 +46,8 @@ void MathNotInset::draw(Painter & pain, int x, int y) const xo(x); yo(y); - drawChar(pain, LM_TC_VAR, size_, x, y, '/'); + if (math_font_available(LM_TC_CMSY)) + drawChar(pain, LM_TC_CMSY, size_, x, y, 54); + else + drawChar(pain, LM_TC_VAR, size_, x, y, '/'); } diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index 27f647ead4..e1b167a2d4 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -75,11 +75,7 @@ enum MathTokenEnum /// LM_TK_FUNCLIM, /// - LM_TK_BIGSYM, - /// - LM_TK_NOGLYPH, - /// - LM_TK_NOGLYPHB, + LM_TK_CMR, /// LM_TK_CMSY, /// diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 9983df5dd6..cf39db7fc4 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -31,6 +31,8 @@ void MathSymbolInset::writeNormal(ostream & os) const MathTextCodes MathSymbolInset::code() const { switch(sym_->token) { + case LM_TK_CMR: + return LM_TC_CMR; case LM_TK_CMSY: return LM_TC_CMSY; case LM_TK_CMM: @@ -46,6 +48,16 @@ MathTextCodes MathSymbolInset::code() const } } + +MathTextCodes MathSymbolInset::code2() const +{ + if (sym_->token == LM_TK_CMEX) + return LM_TC_BOLDSYMB; + else + return LM_TC_SYMB; +} + + void MathSymbolInset::metrics(MathStyles st) const { size_ = st; @@ -60,7 +72,7 @@ void MathSymbolInset::metrics(MathStyles st) const } } else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB)) { - mathed_char_dim(LM_TC_SYMB, size_, sym_->id, + mathed_char_dim(code2(), size_, sym_->id, ascent_, descent_, width_); } else { mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_); @@ -76,8 +88,8 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const if (sym_->latex_font_id > 0 && math_font_available(Code)) drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id); else if (sym_->id > 0 && sym_->id < 255 && - math_font_available(LM_TC_SYMB)) - drawChar(pain, LM_TC_SYMB, size_, x, y, sym_->id); + math_font_available(LM_TC_SYMB)) + drawChar(pain, code2(), size_, x, y, sym_->id); else drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name); } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index bd3b7b55b9..68054886a4 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -31,6 +31,8 @@ public: private: /// MathTextCodes code() const; + /// + MathTextCodes code2() const; /// latexkeys const * sym_; diff --git a/src/mathed/support.C b/src/mathed/support.C index e9c587e8e6..ddb3719ff9 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -103,38 +103,61 @@ LyXFont * MathFonts = 0; bool font_available[LM_FONT_END]; bool font_available_initialized[LM_FONT_END]; +enum MathFont { + FONT_IT, + FONT_SYMBOL, + FONT_SYMBOLI, + FONT_BF, + FONT_BB, + FONT_CAL, + FONT_TT, + FONT_RM, + FONT_SF, + FONT_CMR, + FONT_CMSY, + FONT_CMM, + FONT_CMEX, + FONT_MSA, + FONT_MSB, + FONT_NUM +}; + void mathed_init_fonts() { - MathFonts = new LyXFont[13]; //DEC cxx cannot initialize all fonts + MathFonts = new LyXFont[FONT_NUM]; //DEC cxx cannot initialize all fonts //at once (JMarc) rc - for (int i = 0 ; i < 13 ; ++i) { + for (int i = 0 ; i < FONT_NUM ; ++i) { MathFonts[i] = LyXFont(LyXFont::ALL_SANE); } - MathFonts[0].setShape(LyXFont::ITALIC_SHAPE); + MathFonts[FONT_IT].setShape(LyXFont::ITALIC_SHAPE); + + MathFonts[FONT_SYMBOL].setFamily(LyXFont::SYMBOL_FAMILY); - MathFonts[1].setFamily(LyXFont::SYMBOL_FAMILY); + MathFonts[FONT_SYMBOLI].setFamily(LyXFont::SYMBOL_FAMILY); + MathFonts[FONT_SYMBOLI].setShape(LyXFont::ITALIC_SHAPE); - MathFonts[2].setFamily(LyXFont::SYMBOL_FAMILY); - MathFonts[2].setShape(LyXFont::ITALIC_SHAPE); + MathFonts[FONT_BF].setSeries(LyXFont::BOLD_SERIES); - MathFonts[3].setSeries(LyXFont::BOLD_SERIES); + MathFonts[FONT_BB].setSeries(LyXFont::BOLD_SERIES); + MathFonts[FONT_BB].setFamily(LyXFont::TYPEWRITER_FAMILY); - MathFonts[4].setFamily(LyXFont::SANS_FAMILY); - MathFonts[4].setShape(LyXFont::ITALIC_SHAPE); + MathFonts[FONT_CAL].setFamily(LyXFont::SANS_FAMILY); + MathFonts[FONT_CAL].setShape(LyXFont::ITALIC_SHAPE); - MathFonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY); + MathFonts[FONT_TT].setFamily(LyXFont::TYPEWRITER_FAMILY); - MathFonts[6].setFamily(LyXFont::ROMAN_FAMILY); + MathFonts[FONT_RM].setFamily(LyXFont::ROMAN_FAMILY); - MathFonts[7].setFamily(LyXFont::SANS_FAMILY); + MathFonts[FONT_SF].setFamily(LyXFont::SANS_FAMILY); - MathFonts[8].setFamily(LyXFont::CMSY_FAMILY); - MathFonts[9].setFamily(LyXFont::CMM_FAMILY); - MathFonts[10].setFamily(LyXFont::CMEX_FAMILY); - MathFonts[11].setFamily(LyXFont::MSA_FAMILY); - MathFonts[12].setFamily(LyXFont::MSB_FAMILY); + MathFonts[FONT_CMR].setFamily(LyXFont::CMR_FAMILY); + MathFonts[FONT_CMSY].setFamily(LyXFont::CMSY_FAMILY); + MathFonts[FONT_CMM].setFamily(LyXFont::CMM_FAMILY); + MathFonts[FONT_CMEX].setFamily(LyXFont::CMEX_FAMILY); + MathFonts[FONT_MSA].setFamily(LyXFont::MSA_FAMILY); + MathFonts[FONT_MSB].setFamily(LyXFont::MSB_FAMILY); for (int i = 0; i < LM_FONT_END; ++i) font_available_initialized[i] = false; @@ -148,45 +171,57 @@ LyXFont const & whichFontBase(MathTextCodes type) switch (type) { case LM_TC_SYMB: - case LM_TC_BSYM: - return MathFonts[2]; + case LM_TC_BOLDSYMB: + return MathFonts[FONT_SYMBOLI]; case LM_TC_VAR: case LM_TC_IT: - return MathFonts[0]; + return MathFonts[FONT_IT]; case LM_TC_BF: - return MathFonts[3]; + return MathFonts[FONT_BF]; + + case LM_TC_BB: + if (math_font_available(LM_TC_MSB)) + return MathFonts[FONT_MSB]; + else + return MathFonts[FONT_BB]; case LM_TC_CAL: - return MathFonts[4]; + if (math_font_available(LM_TC_CMSY)) + return MathFonts[FONT_CMSY]; + else + return MathFonts[FONT_CAL]; case LM_TC_TT: - return MathFonts[5]; + return MathFonts[FONT_TT]; case LM_TC_TEXTRM: case LM_TC_CONST: case LM_TC_TEX: case LM_TC_RM: - return MathFonts[6]; + return MathFonts[FONT_RM]; case LM_TC_SF: - return MathFonts[7]; + return MathFonts[FONT_SF]; + + case LM_TC_CMR: + return MathFonts[FONT_CMR]; case LM_TC_CMSY: - return MathFonts[8]; + return MathFonts[FONT_CMSY]; case LM_TC_CMM: - return MathFonts[9]; + return MathFonts[FONT_CMM]; case LM_TC_CMEX: - return MathFonts[10]; + return MathFonts[FONT_CMEX]; case LM_TC_MSA: - return MathFonts[11]; + return MathFonts[FONT_MSA]; case LM_TC_MSB: - return MathFonts[12]; + return MathFonts[FONT_MSB]; default: break; @@ -201,7 +236,7 @@ LyXFont whichFont(MathTextCodes type, MathStyles size) switch (size) { case LM_ST_DISPLAY: - if (type == LM_TC_BSYM || type == LM_TC_CMEX) { + if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) { f.incSize(); f.incSize(); } -- 2.39.2