-/* This file is part of
- * ======================================================
+/**
+ * \file insetlatexaccent.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Lars Gullik Bjønnes
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
#include "support/lstrings.h"
#include "BufferView.h"
#include "frontends/Painter.h"
-#include "font.h"
+#include "frontends/font_metrics.h"
#include "language.h"
+#include "lyxlex.h"
using std::ostream;
using std::endl;
// REMOVE IN 0.13
// Dirty Hack for backward compability. remove in 0.13 (Lgb)
- contents = frontStrip(strip(contents));
+ contents = trim(contents);
if (!contains(contents, "{") && !contains(contents, "}")) {
if (contents.length() == 2) {
string tmp;
int max;
if (candisp) {
if (ic == ' ')
- max = lyxfont::ascent('a', font);
+ max = font_metrics::ascent('a', font);
else
- max = lyxfont::ascent(ic, font);
+ max = font_metrics::ascent(ic, font);
if (plusasc)
- max += (lyxfont::maxAscent(font) + 3) / 3;
+ max += (font_metrics::maxAscent(font) + 3) / 3;
} else
- max = lyxfont::maxAscent(font) + 4;
+ max = font_metrics::maxAscent(font) + 4;
return max;
}
int max;
if (candisp) {
if (ic == ' ')
- max = lyxfont::descent('a', font);
+ max = font_metrics::descent('a', font);
else
- max = lyxfont::descent(ic, font);
+ max = font_metrics::descent(ic, font);
if (plusdesc)
max += 3;
} else
- max = lyxfont::maxDescent(font) + 4;
+ max = font_metrics::maxDescent(font) + 4;
return max;
}
int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
{
if (candisp)
- return lyxfont::width(ic, font);
+ return font_metrics::width(ic, font);
else
- return lyxfont::width(contents, font) + 4;
+ return font_metrics::width(contents, font) + 4;
}
int InsetLatexAccent::lbearing(LyXFont const & font) const
{
- return lyxfont::lbearing(ic, font);
+ return font_metrics::lbearing(ic, font);
}
int InsetLatexAccent::rbearing(LyXFont const & font) const
{
- return lyxfont::rbearing(ic, font);
+ return font_metrics::rbearing(ic, font);
}
int y;
if (plusasc) {
// mark at the top
- hg = lyxfont::maxDescent(font);
+ hg = font_metrics::maxDescent(font);
y = baseline - asc;
if (font.shape() == LyXFont::ITALIC_SHAPE)
pain.text(int(x), baseline, ic, font);
if (remdot) {
- int tmpvar = baseline - lyxfont::ascent('i', font);
+ int tmpvar = baseline - font_metrics::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,
- lyxfont::ascent('i', font) -
- lyxfont::ascent('x', font) - 1,
+ font_metrics::ascent('i', font) -
+ font_metrics::ascent('x', font) - 1,
backgroundColor());
// the five lines below is a simple hack to
// make the display of accent 'i' and 'j'
switch (modtype) {
case ACUTE: // acute 0xB4
{
- pain.text(int(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,
+ pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - font_metrics::lbearing(0xB4, font)) / 2),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB4, font) - (font_metrics::ascent(0xB4, font) + font_metrics::descent(0xB4, font)) / 2,
char(0xB4), font);
break;
}
case GRAVE: // grave 0x60
{
- pain.text(int(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2),
- int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0),
+ pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
+ int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0),
char(0x60), font);
break;
}
case MACRON: // macron
{
- pain.text(int(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)),
+ pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
char(0xAF), font);
break;
}
case TILDE: // tilde
{
- pain.text(int(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2,
'~', font);
break;
}
case UNDERBAR: // underbar 0x5F
{
- pain.text(int(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2), baseline,
+ pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
char(0x5F), font);
break;
}
case CEDILLA: // cedilla
{
- pain.text(int(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2), baseline,
+ pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
char(0xB8), font);
break;
}
case UNDERDOT: // underdot
{
- pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
- int(baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font))),
+ pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
+ int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
'.', font);
break;
}
case DOT: // dot
{
- pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2,
'.', font);
break;
}
{
LyXFont tmpf(font);
tmpf.decSize().decSize();
- pain.text(int(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0),
- int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0),
+ pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
+ int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
char(0xB0), tmpf);
break;
}
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
- pain.text(int(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font))),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
pain.text(int(x2),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
break;
}
case UMLAUT: // umlaut
{
- pain.text(int(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - (lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
'¨', font);
break;
}
{
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
- pain.text(int(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2),
- int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0),
+ pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
+ int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
char(0x5E), tmpf);
break;
}
}
-int InsetLatexAccent::docbook(Buffer const *, ostream & os) const
+int InsetLatexAccent::docbook(Buffer const *, ostream & os, bool) const
{
os << contents;
return 0;