X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlatexaccent.C;h=01bd28aea7d8ace358914129450bdbf70593b221;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=1db7eb8ce41451f07df51c5b84ce953290233f9e;hpb=85798535a19919e82cc94a177a8414c542a9c5bf;p=lyx.git diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 1db7eb8ce4..01bd28aea7 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -19,7 +19,9 @@ #include "lyxrc.h" #include "support/lstrings.h" #include "Painter.h" +#include "font.h" +using std::ostream; using std::endl; /* LatexAccent. Proper handling of accented characters */ @@ -178,7 +180,7 @@ void InsetLatexAccent::checkContents() plusasc = true; // at the top (not really needed) break; default: - printf ("Default\n"); + lyxerr[Debug::KEY] << "Default" << endl; // unknow accent (or something else) return; } @@ -261,13 +263,13 @@ int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const int max; if (candisp) { if (ic == ' ') - max = font.ascent('a'); + max = lyxfont::ascent('a', font); else - max = font.ascent(ic); + max = lyxfont::ascent(ic, font); if (plusasc) - max += (font.maxAscent() + 3) / 3; + max += (lyxfont::maxAscent(font) + 3) / 3; } else - max = font.maxAscent() + 4; + max = lyxfont::maxAscent(font) + 4; return max; } @@ -277,13 +279,13 @@ int InsetLatexAccent::descent(Painter &, LyXFont const & font) const int max; if (candisp) { if (ic == ' ') - max = font.descent('a'); + max = lyxfont::descent('a', font); else - max = font.descent(ic); + max = lyxfont::descent(ic, font); if (plusdesc) max += 3; } else - max = font.maxDescent() + 4; + max = lyxfont::maxDescent(font) + 4; return max; } @@ -291,21 +293,21 @@ int InsetLatexAccent::descent(Painter &, LyXFont const & font) const int InsetLatexAccent::width(Painter &, LyXFont const & font) const { if (candisp) - return font.textWidth(&ic, 1); + return lyxfont::width(ic, font); else - return font.stringWidth(contents) + 4; + return lyxfont::width(contents, font) + 4; } int InsetLatexAccent::Lbearing(LyXFont const & font) const { - return font.lbearing(ic); + return lyxfont::lbearing(ic, font); } int InsetLatexAccent::Rbearing(LyXFont const & font) const { - return font.rbearing(ic); + return lyxfont::rbearing(ic, font); } @@ -373,7 +375,7 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font, int y; if (plusasc) { // mark at the top - hg = font.maxDescent(); + hg = lyxfont::maxDescent(font); y = baseline - asc; if (font.shape() == LyXFont::ITALIC_SHAPE) @@ -391,15 +393,15 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font, pain.text(int(x), baseline, ic, font); if (remdot) { - int tmpvar = baseline - font.ascent('i'); + int tmpvar = baseline - lyxfont::ascent('i', font); float tmpx = 0; if (font.shape() == LyXFont::ITALIC_SHAPE) tmpx += (8.0 * hg) / 10.0; // italic lyxerr[Debug::KEY] << "Removing dot." << endl; // remove the dot first pain.fillRectangle(int(x + tmpx), tmpvar, wid, - font.ascent('i') - - font.ascent('x') - 1, + lyxfont::ascent('i', font) - + lyxfont::ascent('x', font) - 1, LColor::background); // the five lines below is a simple hack to // make the display of accent 'i' and 'j' @@ -415,148 +417,68 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font, switch (modtype) { case ACUTE: // acute 0xB4 { -#if 0 - pain.line(int(x2), int(y + hg), - int(x2 + hg35), y + hg35); -#else - pain.text(x2 - (font.rbearing(0xB4) - font.lbearing(0xB4)) / 2, - baseline - font.ascent(ic) - font.descent(0xB4) - (font.ascent(0xB4) + font.descent(0xB4)) / 2, + pain.text(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2, char(0xB4), font); -#endif break; } case GRAVE: // grave 0x60 { -#if 0 - pain.line(int(x2), int(y + hg), - int(x2 - hg35), y + hg35); -#else - pain.text(x2 - (font.rbearing(0x60) - font.lbearing(0x60)) / 2, - baseline - font.ascent(ic) - font.descent(0x60) - (font.ascent(0x60) + font.descent(0x60)) / 2.0, + pain.text(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0, char(0x60), font); -#endif break; } case MACRON: // macron { -#if 0 - pain.line(int(x2 - wid * 0.4), - int(y + hg), - int(x2 + wid * 0.4), - int(y + hg)); -#else - pain.text(x2 - (font.rbearing(0xAF) - font.lbearing(0xAF)) / 2, - baseline - font.ascent(ic) - font.descent(0xAF) - (font.ascent(0xAF) + font.descent(0xAF)), + pain.text(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)), char(0xAF), font); -#endif break; } case TILDE: // tilde { -#if 0 - if (hg35 > 2.0) hg35 -= 1.0; - x2 += (hg35 / 2.0); - int xp[4], yp[4]; - - xp[0] = int(x2 - 2.0 * hg35); - yp[0] = int(y + hg); - - xp[1] = int(x2 - hg35); - yp[1] = int(y + hg35); - - xp[2] = int(x2); - yp[2] = int(y + hg); - - xp[3] = int(x2 + hg35); - yp[3] = int(y + hg35); - - pain.lines(xp, yp, 4); -#else - pain.text(x2 - (font.rbearing('~') - font.lbearing('~')) / 2, - baseline - font.ascent(ic) - font.descent('~') - (font.ascent('~') + font.descent('~')) / 2, + pain.text(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2, '~', font); -#endif break; } case UNDERBAR: // underbar 0x5F { -#if 0 - pain.line(int(x2 - wid * 0.4), - y + hg / 2.0, - int(x2 + wid * 0.4), - y + hg / 2.0); -#else - pain.text(x2 - (font.rbearing(0x5F) - font.lbearing(0x5F)) / 2, baseline, + pain.text(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2, baseline, char(0x5F), font); -#endif break; } case CEDILLA: // cedilla { -#if 0 - int xp[4], yp[4]; - - xp[0] = int(x2); - yp[0] = y; - - xp[1] = int(x2); - yp[1] = y + int(hg / 3.0); - - xp[2] = int(x2 + (hg / 3.0)); - yp[2] = y + int(hg / 2.0); - - xp[3] = int(x2 - (hg / 4.0)); - yp[3] = y + int(hg); - - pain.lines(xp, yp, 4); -#else - pain.text(x2 - (font.rbearing(0xB8) - font.lbearing(0xB8)) / 2, baseline, + pain.text(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2, baseline, char(0xB8), font); -#endif break; } case UNDERDOT: // underdot { -#if 0 - pain.arc(int(x2), y + hg35, - 3, 3, 0, 360 * 64); -#else - pain.text(x2 - (font.rbearing('.') - font.lbearing('.')) / 2.0, - baseline + 3.0 / 2.0 * (font.ascent('.') + font.descent('.')), + pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0, + baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font)), '.', font); -#endif break; } case DOT: // dot { -#if 0 - pain.arc(int(x2), y + hg * 0.5, - (hg + 3.0)/5.0, - (hg + 3.0)/5.0, - 0, 360 * 64); -#else - pain.text(x2 - (font.rbearing('.') - font.lbearing('.')) / 2.0, - baseline - font.ascent(ic) - font.descent('.') - (font.ascent('.') + font.descent('.')) / 2, + pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2, '.', font); -#endif break; } case CIRCLE: // circle { -#if 0 - pain.arc(int(x2 - (hg / 2.0)), - y + (hg / 2.0), hg, hg , 0, - 360 * 64); -#else LyXFont tmpf(font); tmpf.decSize().decSize(); - pain.text(x2 - (tmpf.rbearing(0xB0) - tmpf.lbearing(0xB0)) / 2.0, - baseline - font.ascent(ic) - tmpf.descent(0xB0) - (tmpf.ascent(0xB0) + tmpf.descent(0xB0)) / 3.0, + pain.text(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0, char(0xB0), tmpf); -#endif break; } case TIE: // tie @@ -602,76 +524,28 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font, } case HUNGARIAN_UMLAUT: // hung. umlaut { -#if 0 - int xs1[2], xs2[2], ys1[2], ys2[2]; - - xs1[0] = int(x2 - (hg / 2.0)); - ys1[0] = int(y + hg); - - xs2[0] = int(x2 + hg35 - (hg / 2.0)); - ys2[0] = int(y + hg35); - - xs1[1] = int(x2 + (hg / 2.0)); - ys1[1] = int(y + hg); - - xs2[1] = int(x2 + hg35 + (hg / 2.0)); - ys2[1] = int(y + hg35); - - pain.segments(xs1, ys1, xs2, ys2, 2); -#else - pain.text(x2 - (font.rbearing('´') - font.lbearing('´')), - baseline - font.ascent(ic) - font.descent('´') - (font.ascent('´') + font.descent('´')) / 2, + pain.text(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font)), + baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2, '´', font); pain.text(x2, - baseline - font.ascent(ic) - font.descent('´') - (font.ascent('´') + font.descent('´')) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2, '´', font); -#endif break; } case UMLAUT: // umlaut { -#if 0 - float rad = hg / 2.0; - if (rad <= 1.0) { - pain.point(int(x2 - 4.0 * hg / 7.0), - y + hg35); - pain.point(int(x2 + 4.0 * hg / 7.0), - y + hg35); - } else { - rad += .5; // this ensures that f.ex. 1.5 will - // not be rounded down to .5 and then - // converted to int = 0 - pain.arc(int(x2 - 2.0 * hg / 4.0), - y + hg35, - rad, rad, - 0, 360 * 64); - pain.arc(int(x2 + 2.0 * hg / 4.0), - y + hg35, - rad, rad, 0, 360*64); - } -#else - pain.text(x2 - (font.rbearing('¨') - font.lbearing('¨')) / 2, - baseline - font.ascent(ic) - font.descent('¨') - ( font.ascent('¨') + font.descent('¨')) / 2, + pain.text(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - ( lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2, '¨', font); -#endif break; } case CIRCUMFLEX: // circumflex { -#if 0 - int xp[3], yp[3]; - - xp[0] = int(x2 - hg35); yp[0] = y + int(hg); - xp[1] = int(x2); yp[1] = int(y + hg35); - xp[2] = int(x2 + hg35); yp[2] = y + int(hg); - pain.lines(xp, yp, 3); -#else LyXFont tmpf(font); tmpf.decSize().decSize().decSize(); - pain.text(x2 - (tmpf.rbearing(0x5E) - tmpf.lbearing(0x5E)) / 2, - baseline - font.ascent(ic) - tmpf.descent(0x5E) - (tmpf.ascent(0x5E) + tmpf.descent(0x5E)) / 3.0, + pain.text(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2, + baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0, char(0x5E), tmpf); -#endif break; } case OGONEK: // ogonek @@ -746,7 +620,14 @@ void InsetLatexAccent::Read(LyXLex & lex) int InsetLatexAccent::Latex(ostream & os, - signed char /*fragile*/, bool/*fs*/) const + bool /*fragile*/, bool/*fs*/) const +{ + os << contents; + return 0; +} + + +int InsetLatexAccent::Ascii(ostream & os) const { os << contents; return 0;