-- André Pönitz ............................................. [EMAIL PROTECTED]
Index: 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 --- math_charinset.C 2001/08/17 15:47:02 1.9 +++ math_charinset.C 2001/08/22 15:56:52 @@ -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: 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 --- math_defs.h 2001/08/17 15:47:02 1.56 +++ math_defs.h 2001/08/22 15:56:52 @@ -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: 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 --- math_factory.C 2001/08/21 14:20:50 1.6 +++ math_factory.C 2001/08/22 15:56:52 @@ -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: 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 --- math_hash.C 2001/08/21 14:20:50 1.43 +++ math_hash.C 2001/08/22 15:56:52 @@ -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: 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 --- math_parser.h 2001/08/21 14:20:50 1.29 +++ math_parser.h 2001/08/22 15:56:52 @@ -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: 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 --- math_symbolinset.C 2001/08/16 12:34:48 1.7 +++ math_symbolinset.C 2001/08/22 15:56:52 @@ -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: 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 --- math_symbolinset.h 2001/08/09 15:19:31 1.6 +++ math_symbolinset.h 2001/08/22 15:56:52 @@ -28,6 +28,13 @@ public: private: /// + MathTextCodes code() const; + + /// latexkeys const * sym_; + /// + mutable int h_; + /// + const bool fontok_; }; #endif Index: 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 --- support.C 2001/08/17 15:47:02 1.28 +++ support.C 2001/08/22 15:56:52 @@ -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: 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 --- support.h 2001/08/14 09:35:44 1.16 +++ support.h 2001/08/22 15:56:52 @@ -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