Next try.

-- 
André Pönitz ............................................. [EMAIL PROTECTED]
Index: FontLoader.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/FontLoader.C,v
retrieving revision 1.29
diff -u -p -r1.29 FontLoader.C
--- FontLoader.C        2001/08/03 18:28:03     1.29
+++ FontLoader.C        2001/08/22 16:31:46
@@ -60,7 +60,7 @@ void FontLoader::update()
 void FontLoader::reset()
 {
        // Clear font infos, font structs and font metrics
-       for (int i1 = 0; i1 < 4; ++i1)
+       for (int i1 = 0; i1 < 10; ++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 < 4; ++i1)
+       for (int i1 = 0; i1 < 10; ++i1)
                for (int i2 = 0; i2 < 2; ++i2)
                        for (int i3 = 0; i3 < 4; ++i3) {
                                if (fontinfo[i1][i2][i3]) {
@@ -103,11 +103,48 @@ void FontLoader::getFontinfo(LyXFont::FO
        if (fontinfo[family][series][shape] != 0)
                return;
 
-       // Special code for the symbol family
-       if (family == LyXFont::SYMBOL_FAMILY){
-               fontinfo[family][series][shape] = new FontInfo("-*-symbol-*");
-               return;
+       // Special fonts
+       switch (family) 
+       {
+               case LyXFont::SYMBOL_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-symbol-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::SYMBOLCM_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-cmsy-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::SYMBOLAMSA_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-msam-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::SYMBOLEX_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-cmex-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::FRAKTUR_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-eufrak-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::MATHSCR_FAMILY:
+                       fontinfo[family][series][shape] =
+                               new FontInfo("-*-eus-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               case LyXFont::SYMBOLAMSB_FAMILY:
+                       fontinfo[family][series][shape] = 
+                               new FontInfo("-*-msbm-*-*-*-*-*-*-*-*-*-*-*-*");
+                       return;
+
+               default:
+                       break;
        }
+ 
 
        // Normal font. Let's search for an existing name that matches.
        string ffamily;
@@ -251,6 +288,7 @@ XFontStruct * FontLoader::doLoad(LyXFont
        XFontStruct * fs = 0;
 
        current_view->owner()->messagePush(_("Loading font into X-Server..."));
+       //lyxerr << "\nTrying to load font '" << font << "'\n";
 
        fs = XLoadQueryFont(GUIRunTime::x11Display(), font.c_str());
        
@@ -281,4 +319,12 @@ XFontStruct * FontLoader::doLoad(LyXFont
 
        fontstruct[family][series][shape][size] = fs;
        return fs;
+}
+
+
+bool FontLoader::available(LyXFont const & f)
+{
+       load(f.family(), f.series(), f.realShape(), f.size());
+       return fontinfo[f.family()][f.series()][f.realShape()]
+               ->getFontname(f.size()).size();
 }
Index: FontLoader.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/FontLoader.h,v
retrieving revision 1.10
diff -u -p -r1.10 FontLoader.h
--- FontLoader.h        2001/07/03 14:15:39     1.10
+++ FontLoader.h        2001/08/22 16:31:46
@@ -48,12 +48,15 @@ public:
                else
                        return doLoad(family, series, shape, size);
        };
+       /// Do we have anything matching?
+       bool available(LyXFont const & f);
+       
 private:
        /// Array of font structs
-       XFontStruct * fontstruct[4][2][4][10];
+       XFontStruct * fontstruct[10][2][4][10];
 
        /// Array of font infos
-       FontInfo * fontinfo[4][2][4];
+       FontInfo * fontinfo[10][2][4];
 
        /// Reset font handler
        void reset();
Index: Painter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Painter.C,v
retrieving revision 1.27
diff -u -p -r1.27 Painter.C
--- Painter.C   2001/08/03 18:28:03     1.27
+++ Painter.C   2001/08/22 16:31:46
@@ -284,7 +284,12 @@ PainterBase & Painter::text(int x, int y
                XChar2b * xs = new XChar2b[ls];
                Encoding const * encoding = f.language()->encoding();
                LyXFont font(f);
-               if (f.family() == LyXFont::SYMBOL_FAMILY) {
+               if (f.family() == LyXFont::SYMBOL_FAMILY ||
+                   f.family() == LyXFont::MATHSCR_FAMILY ||
+                   f.family() == LyXFont::FRAKTUR_FAMILY ||
+                   f.family() == LyXFont::SYMBOLEX_FAMILY ||
+                   f.family() == LyXFont::SYMBOLAMSA_FAMILY ||
+                               f.family() == LyXFont::SYMBOLAMSB_FAMILY) {
 #ifdef USE_UNICODE_FOR_SYMBOLS
                        font.setFamily(LyXFont::ROMAN_FAMILY);
                        font.setShape(LyXFont::UP_SHAPE);
Index: font.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/font.C,v
retrieving revision 1.17
diff -u -p -r1.17 font.C
--- font.C      2001/07/24 22:08:45     1.17
+++ font.C      2001/08/22 16:31:46
@@ -114,7 +114,11 @@ int lyxfont::width(char const * s, size_
                Encoding const * encoding = f.language()->encoding();
                //LyXFont const * font = &f;
                LyXFont font(f);
-               if (f.family() == LyXFont::SYMBOL_FAMILY) {
+               if (f.family() == LyXFont::SYMBOL_FAMILY ||
+                   f.family() == LyXFont::SYMBOLCM_FAMILY ||
+                   f.family() == LyXFont::SYMBOLAMSA_FAMILY ||
+                   f.family() == LyXFont::SYMBOLAMSB_FAMILY ||
+                   f.family() == LyXFont::SYMBOLEX_FAMILY) {
 #ifdef USE_UNICODE_FOR_SYMBOLS
                        //LyXFont font2 = f;
                        font.setFamily(LyXFont::ROMAN_FAMILY);
Index: lyxfont.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfont.C,v
retrieving revision 1.65
diff -u -p -r1.65 lyxfont.C
--- lyxfont.C   2001/08/11 18:31:11     1.65
+++ lyxfont.C   2001/08/22 16:31:46
@@ -33,16 +33,16 @@ using std::endl;
 using std::strlen;
 #endif
 
-
 //
 // Names for the GUI
 //
 
 namespace {
 
-char const * GUIFamilyNames[6] = 
-{ N_("Roman"), N_("Sans serif"), N_("Typewriter"), N_("Symbol"), N_("Inherit"),
-  N_("Ignore") };
+char const * GUIFamilyNames[12] = 
+{ N_("Roman"), N_("Sans serif"), N_("Typewriter"), N_("Symbol"),
+       N_("Symbol2"), N_("Symbol3"), N_("SymbolEx"), N_("Fraktur"),
+       N_("Mathscr"), N_("MathBB"), N_("Inherit"), N_("Ignore") };
 
 char const * GUISeriesNames[4] = 
 { N_("Medium"), N_("Bold"), N_("Inherit"), N_("Ignore") };
@@ -63,8 +63,9 @@ char const * GUIMiscNames[5] = 
 //
 // Strings used to read and write .lyx format files
 //
-char const * LyXFamilyNames[6] = 
-{ "roman", "sans", "typewriter", "symbol", "default", "error" };
+char const * LyXFamilyNames[12] = 
+{ "roman", "sans", "typewriter", "symbol", "symbol2", "symbol3", 
+       "symbolex", "fraktur", "mathscr", "mathbb", "default", "error" };
 
 char const * LyXSeriesNames[4] = 
 { "medium", "bold", "default", "error" };
Index: lyxfont.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfont.h,v
retrieving revision 1.41
diff -u -p -r1.41 lyxfont.h
--- lyxfont.h   2001/08/11 18:31:11     1.41
+++ lyxfont.h   2001/08/22 16:31:46
@@ -45,6 +45,18 @@ public:
                ///
                SYMBOL_FAMILY,
                ///
+               SYMBOLCM_FAMILY,
+               ///
+               SYMBOLAMSA_FAMILY,
+               ///
+               SYMBOLEX_FAMILY,
+               ///
+               FRAKTUR_FAMILY,
+               ///
+               MATHSCR_FAMILY,
+               ///
+               SYMBOLAMSB_FAMILY,
+               ///
                INHERIT_FAMILY,
                ///
                IGNORE_FAMILY
Index: mathed/math_charinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_charinset.C,v
retrieving revision 1.9
diff -u -p -r1.9 math_charinset.C
--- mathed/math_charinset.C     2001/08/17 15:47:02     1.9
+++ mathed/math_charinset.C     2001/08/22 16:31:47
@@ -13,6 +13,21 @@
 #include "debug.h"
 
 
+namespace {
+
+char const * math_font_name[] = {
+       "mathrm",
+       "mathcal",
+       "mathbf",
+       "mathsf",
+       "mathtt",
+       "mathit",
+       "textrm"
+};
+
+}
+
+
 MathCharInset::MathCharInset(char c)
        : char_(c), code_(nativeCode(c))
 {
Index: mathed/math_defs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_defs.h,v
retrieving revision 1.56
diff -u -p -r1.56 math_defs.h
--- mathed/math_defs.h  2001/08/17 15:47:02     1.56
+++ mathed/math_defs.h  2001/08/22 16:31:47
@@ -83,8 +83,20 @@ enum MathTextCodes  {
        LM_TC_GREEK1,
        /// Internal code for symbols
        LM_TC_SYMB,
-       /// Internal code for symbols that get bigger in displayed math
+       /// internal code for symbols that get bigger in displayed math
        LM_TC_BSYM,
+       /// 
+       LM_TC_SYMCM,
+       ///
+       LM_TC_SYMAMSA,
+       ///
+       LM_TC_SYMAMSB,
+       ///
+       LM_TC_SYMEX,
+       ///
+       LM_TC_MATHSCR,
+       ///
+       LM_TC_FRAKTUR,
        ///
        LM_FONT_END,
        
Index: mathed/math_factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_factory.C,v
retrieving revision 1.6
diff -u -p -r1.6 math_factory.C
--- mathed/math_factory.C       2001/08/21 14:20:50     1.6
+++ mathed/math_factory.C       2001/08/22 16:31:47
@@ -30,6 +30,12 @@ MathInset * createMathInset(latexkeys co
                        return new MathBigopInset(l);
                case LM_TK_FUNCLIM:
                        return new MathFuncLimInset(l);
+               case LM_TK_SYMAMSA: 
+               case LM_TK_SYMAMSB: 
+               case LM_TK_SYMEX: 
+               case LM_TK_SYMCM: 
+               case LM_TK_FRAKTUR: 
+               case LM_TK_MATHSCR: 
                case LM_TK_SYM: 
                        return new MathSymbolInset(l);
                case LM_TK_STACK:
Index: mathed/math_hash.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hash.C,v
retrieving revision 1.43
diff -u -p -r1.43 math_hash.C
--- mathed/math_hash.C  2001/08/21 14:20:50     1.43
+++ mathed/math_hash.C  2001/08/22 16:31:47
@@ -15,7 +15,6 @@ namespace {
 
 latexkeys wordlist[] = 
 {
-       //{"oint",  LM_TK_BIGSYM, LM_oint, LMB_NONE},
        //{"pmod",  LM_TK_SYM, 0, LMB_NONE},
        {"!",  LM_TK_SPACE, 0, LMB_NONE},
        {"#",  LM_TK_SPECIAL, '#', LMB_NONE},
@@ -78,13 +77,15 @@ latexkeys wordlist[] = 
        {"bigodot",  LM_TK_NOGLYPHB, 0, LMB_NONE},
        {"bigoplus",  LM_TK_NOGLYPHB, 0, LMB_NONE},
        {"bigotimes",  LM_TK_NOGLYPHB, 0, LMB_NONE},
-       {"bigsqcup",  LM_TK_NOGLYPHB, 0, LMB_NONE},
+       {"bigsqcup",  LM_TK_SYMEX, 71, LMB_NONE},
        {"bigtriangledown",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
        {"bigtriangleup",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
        {"biguplus",  LM_TK_NOGLYPHB, 0, LMB_NONE},
        {"bigvee",  LM_TK_NOGLYPHB, 0, LMB_NONE},
        {"bigwedge",  LM_TK_NOGLYPHB, 0, LMB_NONE},
        {"binom",  LM_TK_BINOM, 0, LMB_NONE},
+       //
+       {"blacktriangledown", LM_TK_SYMAMSA, 0x48, 0},
        {"bmod",  LM_TK_FUNC, 0, LMB_NONE},
        {"bot",  LM_TK_SYM, LM_bot, LMB_NONE},
        {"bowtie",  LM_TK_NOGLYPH, 0, LMB_RELATION},
@@ -204,6 +205,7 @@ latexkeys wordlist[] = 
        {"nu",  LM_TK_SYM, LM_nu, LMB_NONE},
        {"nwarrow",  LM_TK_NOGLYPH, 0, LMB_NONE},
        {"odot",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
+       {"oint",  LM_TK_SYMEX, 72, LMB_NONE},
        {"omega",  LM_TK_SYM, LM_omega, LMB_NONE},
        {"ominus",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
        {"oplus",  LM_TK_SYM, LM_oplus, LMB_OPERATOR},
@@ -219,7 +221,8 @@ latexkeys wordlist[] = 
        {"phi",  LM_TK_SYM, LM_phi, LMB_NONE},
        {"pi",  LM_TK_SYM, LM_pi, LMB_NONE},
        {"pm",  LM_TK_SYM, LM_pm, LMB_OPERATOR},
-       {"prec",  LM_TK_NOGLYPH, 0, LMB_RELATION},
+//     {"prec",  LM_TK_NOGLYPH, 0, LMB_RELATION},
+//     {"prec",  LM_TK_SYMCM, 0xc2, LMB_RELATION},
        {"preceq",  LM_TK_NOGLYPH, 0, LMB_RELATION},
        {"prime",  LM_TK_SYM, LM_prime, LMB_NONE},
        {"prod",  LM_TK_BIGSYM, LM_prod, LMB_NONE},
@@ -252,7 +255,7 @@ latexkeys wordlist[] = 
        {"smile",  LM_TK_NOGLYPH, 0, LMB_RELATION},
        {"spadesuit",  LM_TK_SYM, LM_spadesuit, LMB_NONE},
        {"sqcap",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
-       {"sqcup",  LM_TK_NOGLYPH, 0, LMB_OPERATOR},
+       {"sqcup",  LM_TK_SYMEX, 70, LMB_OPERATOR},
        {"sqrt",  LM_TK_SQRT, 0, LMB_NONE},
        {"sqsubseteq",  LM_TK_NOGLYPH, 0, LMB_RELATION},
        {"sqsupseteq",  LM_TK_NOGLYPH, 0, LMB_RELATION},
Index: mathed/math_parser.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.h,v
retrieving revision 1.29
diff -u -p -r1.29 math_parser.h
--- mathed/math_parser.h        2001/08/21 14:20:50     1.29
+++ mathed/math_parser.h        2001/08/22 16:31:47
@@ -81,6 +81,18 @@ enum MathTokenEnum
        ///
        LM_TK_NOGLYPHB,
        ///
+       LM_TK_SYMEX,
+       ///
+       LM_TK_SYMCM,
+       ///
+       LM_TK_SYMAMSA,
+       ///
+       LM_TK_SYMAMSB,
+       ///
+       LM_TK_FRAKTUR,
+       ///
+       LM_TK_MATHSCR,
+       ///
        LM_TK_LABEL,
        ///
        LM_TK_NONUM,
Index: mathed/math_symbolinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_symbolinset.C,v
retrieving revision 1.7
diff -u -p -r1.7 math_symbolinset.C
--- mathed/math_symbolinset.C   2001/08/16 12:34:48     1.7
+++ mathed/math_symbolinset.C   2001/08/22 16:31:47
@@ -7,7 +7,8 @@
 using std::ostream;
 
 MathSymbolInset::MathSymbolInset(const latexkeys * l)
-       : sym_(l)
+       : sym_(l), h_(0),
+         fontok_(math_font_available(static_cast<MathTextCodes>(l->token)))
 {}
 
 
@@ -29,10 +30,37 @@ void MathSymbolInset::writeNormal(ostrea
 }
 
 
+MathTextCodes MathSymbolInset::code() const
+{
+       if (sym_->token == LM_TK_SYMAMSA)
+               return LM_TC_SYMAMSA;
+       if (sym_->token == LM_TK_SYMAMSB)
+               return LM_TC_SYMAMSB;
+       if (sym_->token == LM_TK_SYMEX)
+               return LM_TC_SYMEX;
+       if (sym_->token == LM_TK_FRAKTUR)
+               return LM_TC_FRAKTUR;
+       if (sym_->token == LM_TK_SYMCM)
+               return LM_TC_SYMCM;
+       if (sym_->token == LM_TK_MATHSCR)
+               return LM_TC_MATHSCR;
+       return LM_TC_SYMB;
+}
+
 void MathSymbolInset::metrics(MathStyles st) const
 {
-       size(st);
-       mathed_char_dim(LM_TC_SYMB, size_, sym_->id, ascent_, descent_, width_);
+       size_ = st;
+       if (fontok_) {
+               MathTextCodes code_ = code();
+               mathed_char_dim(code_, size_, sym_->id, ascent_, descent_, width_);
+               if (code_ == LM_TC_SYMEX) {
+                       h_ = 4*descent_/5;
+                       ascent_  += h_;
+                       descent_ -= h_;
+               }
+       } else {
+               mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, 
+width_);
+       }
 }
 
 
@@ -40,8 +68,10 @@ void MathSymbolInset::draw(Painter & pai
 {  
        xo(x);
        yo(y);
-
-       drawChar(pain, LM_TC_SYMB, size_, x, y, sym_->id);
+       if (fontok_)
+               drawChar(pain, code(), size_, x, y - h_, sym_->id);
+       else
+               drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
 }
 
 
Index: mathed/math_symbolinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_symbolinset.h,v
retrieving revision 1.6
diff -u -p -r1.6 math_symbolinset.h
--- mathed/math_symbolinset.h   2001/08/09 15:19:31     1.6
+++ mathed/math_symbolinset.h   2001/08/22 16:31:47
@@ -28,6 +28,13 @@ public:
 
 private:
        ///
+       MathTextCodes code() const;
+
+       ///
        latexkeys const * sym_;
+       ///
+       mutable int h_;
+       ///
+       const bool fontok_;
 };
 #endif
Index: mathed/support.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/support.C,v
retrieving revision 1.28
diff -u -p -r1.28 support.C
--- mathed/support.C    2001/08/17 15:47:02     1.28
+++ mathed/support.C    2001/08/22 16:31:47
@@ -4,6 +4,7 @@
 
 #include "mathed/support.h"
 #include "lyxfont.h"
+#include "FontLoader.h"
 #include "font.h"
 #include "math_defs.h"
 #include "math_parser.h"
@@ -98,86 +99,93 @@ void Matrix::transform(float xp, float y
 
 namespace {
 
-LyXFont           * Math_Fonts = 0;
+LyXFont           * MathFonts = 0;
 
 void mathed_init_fonts()
 {
-       Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
+       MathFonts = new LyXFont[13]; //DEC cxx cannot initialize all fonts
        //at once (JMarc) rc
 
-       for (int i = 0 ; i < 8 ; ++i) {
-               Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
+       for (int i = 0 ; i < 13 ; ++i) {
+               MathFonts[i] = LyXFont(LyXFont::ALL_SANE);
        }
 
-       Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
-
-       Math_Fonts[1].setFamily(LyXFont::SYMBOL_FAMILY);
-
-       Math_Fonts[2].setFamily(LyXFont::SYMBOL_FAMILY);
-       Math_Fonts[2].setShape(LyXFont::ITALIC_SHAPE);
-
-       Math_Fonts[3].setSeries(LyXFont::BOLD_SERIES);
-
-       Math_Fonts[4].setFamily(LyXFont::SANS_FAMILY);
-       Math_Fonts[4].setShape(LyXFont::ITALIC_SHAPE);
-
-       Math_Fonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY);
-
-       Math_Fonts[6].setFamily(LyXFont::ROMAN_FAMILY);
-
-       Math_Fonts[7].setFamily(LyXFont::SANS_FAMILY);
+       MathFonts[0].setShape(LyXFont::ITALIC_SHAPE);
+       MathFonts[1].setFamily(LyXFont::SYMBOLEX_FAMILY);
+       MathFonts[2].setFamily(LyXFont::SYMBOL_FAMILY);
+       MathFonts[2].setShape(LyXFont::ITALIC_SHAPE);
+       MathFonts[3].setSeries(LyXFont::BOLD_SERIES);
+       MathFonts[4].setFamily(LyXFont::SANS_FAMILY);
+       MathFonts[4].setShape(LyXFont::ITALIC_SHAPE);
+       MathFonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY);
+       MathFonts[6].setFamily(LyXFont::ROMAN_FAMILY);
+       MathFonts[7].setFamily(LyXFont::SANS_FAMILY);
+       MathFonts[8].setFamily(LyXFont::FRAKTUR_FAMILY);
+       MathFonts[9].setFamily(LyXFont::MATHSCR_FAMILY);
+       MathFonts[10].setFamily(LyXFont::SYMBOLAMSB_FAMILY);
+       MathFonts[11].setFamily(LyXFont::SYMBOLEX_FAMILY);
+       MathFonts[12].setFamily(LyXFont::SYMBOLAMSA_FAMILY);
 }
-
-} // namespace
 
-
-LyXFont WhichFont(MathTextCodes type, MathStyles size)
+LyXFont const & whichFontBase(MathTextCodes type)
 {
-       LyXFont f;
-       
-       if (!Math_Fonts)
+       if (!MathFonts)
                mathed_init_fonts();
 
        switch (type) {
        case LM_TC_SYMB:        
        case LM_TC_BSYM:        
-               f = Math_Fonts[2];
-               break;
+               return MathFonts[2];
 
        case LM_TC_VAR:
        case LM_TC_IT:
-               f = Math_Fonts[0];
-               break;
+               return MathFonts[0];
 
        case LM_TC_BF:
-               f = Math_Fonts[3];
-               break;
-
-       case LM_TC_SF:
-               f = Math_Fonts[7];
-               break;
+               return MathFonts[3];
 
        case LM_TC_CAL:
-               f = Math_Fonts[4];
-               break;
+               return MathFonts[4];
 
        case LM_TC_TT:
-               f = Math_Fonts[5];
-               break;
+               return MathFonts[5];
 
-       case LM_TC_SPECIAL: //f = Math_Fonts[0]; break;
+       case LM_TC_SPECIAL: //f = MathFonts[0]; break;
        case LM_TC_TEXTRM:
        case LM_TC_CONST:
        case LM_TC_TEX:
        case LM_TC_RM:
-               f = Math_Fonts[6];
-               break;
+               return MathFonts[6];
+
+       case LM_TC_SF:
+               return MathFonts[7];
+
+       case LM_TC_FRAKTUR:
+               return MathFonts[8];
 
+       case LM_TC_MATHSCR:
+               return MathFonts[9];
+
+       case LM_TC_SYMAMSB:
+               return MathFonts[10];
+
+       case LM_TC_SYMEX:
+               return MathFonts[11];
+
+       case LM_TC_SYMAMSA:
+               return MathFonts[12];
+
        default:
-               f = Math_Fonts[1];
-               break;
+               ;
        }
+       return MathFonts[1];
+}
 
+
+LyXFont whichFont(MathTextCodes type, MathStyles size)
+{
+       LyXFont f = whichFontBase(type);
+
        switch (size) {
        case LM_ST_DISPLAY:
                if (type == LM_TC_BSYM) {
@@ -214,17 +222,15 @@ LyXFont WhichFont(MathTextCodes type, Ma
        return f;
 }
 
-char const * math_font_name[] = {
-       "mathrm",
-       "mathcal",
-       "mathbf",
-       "mathsf",
-       "mathtt",
-       "mathit",
-       "textrm"
-};
+} // namespace
 
 
+bool math_font_available(MathTextCodes type)
+{
+       return fontloader.available(whichFontBase(type));
+}
+
+
 namespace {
 
 /* 
@@ -501,7 +507,7 @@ deco_struct const * search_deco(int code
 void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
        int & asc, int & des, int & wid)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
        des = lyxfont::descent(c, font);
        asc = lyxfont::ascent(c, font);
        wid = mathed_char_width(type, size, c);
@@ -511,7 +517,7 @@ void mathed_char_dim(MathTextCodes type,
 int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
        int & asc, int & des)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
        des = lyxfont::descent(c, font);
        asc = lyxfont::ascent(c, font);
        return asc + des;
@@ -525,23 +531,27 @@ int mathed_char_height(MathTextCodes typ
        return mathed_char_height(type, size, c, asc, des);
 }
 
+
 int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
        return lyxfont::ascent(c, font);
 }
 
+
 int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
        return lyxfont::descent(c, font);
 }
 
+
 int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
+       LyXFont const f1 = whichFont(LM_TC_TEXTRM, size);
        if (isBinaryOp(c))
-               return lyxfont::width(c, font) + 2 * lyxfont::width(' ', font);
+               return lyxfont::width(c, font) + 2 * lyxfont::width(' ', f1);
        else
                return lyxfont::width(c, font);
 }
@@ -554,10 +564,11 @@ void mathed_string_dim(MathTextCodes typ
        wid = mathed_string_width(type, size, s);
 }
 
+
 int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
                         int & asc, int & des)
 {
-       LyXFont const font = WhichFont(type, size);
+       LyXFont const font = whichFont(type, size);
        asc = des = 0;
        for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
                des = max(des, lyxfont::descent(*it, font));
@@ -566,9 +577,10 @@ int mathed_string_height(MathTextCodes t
        return asc + des;
 }
 
+
 int mathed_string_width(MathTextCodes type, MathStyles size, string const & s)
 {
-       return lyxfont::width(s, WhichFont(type, size));
+       return lyxfont::width(s, whichFont(type, size));
 }
 
 
@@ -662,11 +674,11 @@ void mathed_draw_deco(Painter & pain, in
 }
 
 
-// In a near future maybe we use a better fonts renderer
+// In the future maybe we use a better fonts renderer
 void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
        int x, int y, string const & s)
 {
-       pain.text(x, y, s, WhichFont(type, siz));
+       pain.text(x, y, s, whichFont(type, siz));
 }
 
 
@@ -682,6 +694,7 @@ void drawChar
        drawStr(pain, type, siz, x, y, s);
 }
 
+
 // decrease math size for super- and subscripts
 MathStyles smallerStyleScript(MathStyles st)
 {
@@ -693,6 +706,7 @@ MathStyles smallerStyleScript(MathStyles
        return st;
 }
 
+
 // decrease math size for fractions
 MathStyles smallerStyleFrac(MathStyles st)
 {
@@ -707,10 +721,11 @@ MathStyles smallerStyleFrac(MathStyles s
 
 void math_font_max_dim(MathTextCodes code, MathStyles siz, int & asc, int & des)
 {
-       LyXFont font = WhichFont(code, siz);
+       LyXFont font = whichFont(code, siz);
        asc = lyxfont::maxAscent(font);
        des = lyxfont::maxDescent(font);
 }
+
 
 char const * latex_mathspace[] = {
        "!", ",", ":", ";", "quad", "qquad"
Index: mathed/support.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/support.h,v
retrieving revision 1.16
diff -u -p -r1.16 support.h
--- mathed/support.h    2001/08/14 09:35:44     1.16
+++ mathed/support.h    2001/08/22 16:31:47
@@ -9,7 +9,6 @@
 class Painter;
 class latexkeys;
 
-extern char const * math_font_name[];
 extern char const * latex_mathspace[];
 
 int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
@@ -39,5 +38,7 @@ void drawChar(Painter & pain, MathTextCo
 
 void math_font_max_dim
        (MathTextCodes code, MathStyles siz, int & asc, int & desc);
+
+bool math_font_available(MathTextCodes code);
 
 #endif

Reply via email to