font_metrics part 1

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4203 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-05-24 14:34:32 +00:00
parent 86a566a27d
commit 2dabaa33de
35 changed files with 335 additions and 294 deletions

View File

@ -14,7 +14,6 @@
#include "commandtags.h" #include "commandtags.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "debug.h" #include "debug.h"
#include "font.h"
#include "bufferview_funcs.h" #include "bufferview_funcs.h"
#include "TextCache.h" #include "TextCache.h"
#include "bufferlist.h" #include "bufferlist.h"

View File

@ -1,3 +1,14 @@
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* LColor.C: remove spurious X include
* BufferView_pimpl.C:
* Makefile.am:
* font.h:
* font.C:
* text.C:
* text2.C: move font metrics to frontends/
2002-05-24 Juergen Vigna <jug@sad.it> 2002-05-24 Juergen Vigna <jug@sad.it>
* undo_funcs.C (textHandleUndo): fix the cursor selection after * undo_funcs.C (textHandleUndo): fix the cursor selection after

View File

@ -13,8 +13,6 @@
#pragma implementation #pragma implementation
#endif #endif
#include <X11/Xlib.h>
#include "debug.h" #include "debug.h"
#include "LColor.h" #include "LColor.h"
#include "support/LAssert.h" #include "support/LAssert.h"

View File

@ -114,8 +114,6 @@ lyx_SOURCES = \
encoding.h \ encoding.h \
exporter.C \ exporter.C \
exporter.h \ exporter.h \
font.C \
font.h \
gettext.C \ gettext.C \
gettext.h \ gettext.h \
importer.C \ importer.C \

View File

@ -1,3 +1,11 @@
2002-05-23 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
* font_metrics.h: add placeholder
* Painter.C:
* screen.C: use placeholder
2002-05-23 John Levon <moz@compsoc.man.ac.uk> 2002-05-23 John Levon <moz@compsoc.man.ac.uk>
* WorkArea.h: * WorkArea.h:

View File

@ -36,5 +36,6 @@ libfrontends_la_SOURCES = \
LyXView.h \ LyXView.h \
WorkArea.C \ WorkArea.C \
WorkArea.h \ WorkArea.h \
font_metrics.h \
screen.C \ screen.C \
screen.h screen.h

View File

@ -16,7 +16,7 @@
#include "Painter.h" #include "Painter.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "WorkArea.h" #include "WorkArea.h"
#include "font.h" #include "font_metrics.h"
int PainterBase::paperMargin() const int PainterBase::paperMargin() const
@ -97,7 +97,7 @@ PainterBase & PainterBase::rectText(int x, int baseline,
int ascent; int ascent;
int descent; int descent;
lyxfont::rectText(str, font, width, ascent, descent); font_metrics::rectText(str, font, width, ascent, descent);
rectangle(x, baseline - ascent, width, ascent + descent, frame); rectangle(x, baseline - ascent, width, ascent + descent, frame);
fillRectangle(x + 1, baseline - ascent + 1, width - 1, fillRectangle(x + 1, baseline - ascent + 1, width - 1,
ascent + descent - 1, back); ascent + descent - 1, back);
@ -114,7 +114,7 @@ PainterBase & PainterBase::buttonText(int x, int baseline,
int ascent; int ascent;
int descent; int descent;
lyxfont::buttonText(str, font, width, ascent, descent); font_metrics::buttonText(str, font, width, ascent, descent);
button(x, baseline - ascent, width, descent + ascent); button(x, baseline - ascent, width, descent + ascent);
text(x + 4, baseline, str, font); text(x + 4, baseline, str, font);
return *this; return *this;

View File

@ -0,0 +1,3 @@
//// temporary
#include "xforms/xfont_metrics.h"

View File

@ -23,7 +23,7 @@
#include "frontends/WorkArea.h" #include "frontends/WorkArea.h"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h" #include "BufferView.h"
#include "font.h" #include "font_metrics.h"
#include "insets/insettext.h" #include "insets/insettext.h"
#include "ColorHandler.h" #include "ColorHandler.h"
#include "language.h" #include "language.h"
@ -241,8 +241,8 @@ void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
shape = (text->real_current_font.isVisibleRightToLeft()) shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE; ? REVERSED_L_SHAPE : L_SHAPE;
showManualCursor(text, text->cursor.x(), text->cursor.y(), showManualCursor(text, text->cursor.x(), text->cursor.y(),
lyxfont::maxAscent(text->real_current_font), font_metrics::maxAscent(text->real_current_font),
lyxfont::maxDescent(text->real_current_font), font_metrics::maxDescent(text->real_current_font),
shape); shape);
} }
} }

View File

@ -1,3 +1,10 @@
2002-05-23 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
* XPainter.C:
* xfont_metrics.h:
* xfont_metrics.C: moved font metrics code
2002-05-24 Juergen Vigna <jug@sad.it> 2002-05-24 Juergen Vigna <jug@sad.it>
* FormMathsBitmap.C: include local includes first (selfcontainment) * FormMathsBitmap.C: include local includes first (selfcontainment)

View File

@ -214,6 +214,8 @@ libxforms_la_SOURCES = \
XFormsView.h \ XFormsView.h \
XPainter.C \ XPainter.C \
XPainter.h \ XPainter.h \
xfont_metrics.C \
xfont_metrics.h \
xforms_helpers.C \ xforms_helpers.C \
xforms_helpers.h \ xforms_helpers.h \
xforms_resize.C \ xforms_resize.C \

View File

@ -18,7 +18,7 @@
#include "debug.h" #include "debug.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "WorkArea.h" #include "WorkArea.h"
#include "font.h" #include "xfont_metrics.h"
#include "ColorHandler.h" #include "ColorHandler.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "encoding.h" #include "encoding.h"
@ -220,7 +220,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
GC gc = lyxColorHandler->getGCForeground(f.realColor()); GC gc = lyxColorHandler->getGCForeground(f.realColor());
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
lyxfont::XSetFont(display(), gc, f); font_metrics::XSetFont(display(), gc, f);
XDrawString(display(), owner.getPixmap(), gc, x, y, s, ls); XDrawString(display(), owner.getPixmap(), gc, x, y, s, ls);
} else { } else {
LyXFont smallfont(f); LyXFont smallfont(f);
@ -229,21 +229,21 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
for (size_t i = 0; i < ls; ++i) { for (size_t i = 0; i < ls; ++i) {
char const c = uppercase(s[i]); char const c = uppercase(s[i]);
if (c != s[i]) { if (c != s[i]) {
lyxfont::XSetFont(display(), gc, smallfont); font_metrics::XSetFont(display(), gc, smallfont);
XDrawString(display(), owner.getPixmap(), gc, XDrawString(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1); tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth(smallfont, &c, 1); tmpx += font_metrics::XTextWidth(smallfont, &c, 1);
} else { } else {
lyxfont::XSetFont(display(), gc, f); font_metrics::XSetFont(display(), gc, f);
XDrawString(display(), owner.getPixmap(), gc, XDrawString(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1); tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth(f, &c, 1); tmpx += font_metrics::XTextWidth(f, &c, 1);
} }
} }
} }
if (f.underbar() == LyXFont::ON) { if (f.underbar() == LyXFont::ON) {
underline(f, x, y, lyxfont::width(s, ls, f)); underline(f, x, y, font_metrics::width(s, ls, f));
} }
return *this; return *this;
@ -255,7 +255,7 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
{ {
GC gc = lyxColorHandler->getGCForeground(f.realColor()); GC gc = lyxColorHandler->getGCForeground(f.realColor());
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
lyxfont::XSetFont(display(), gc, f); font_metrics::XSetFont(display(), gc, f);
XDrawString16(display(), owner.getPixmap(), gc, x, y, s, ls); XDrawString16(display(), owner.getPixmap(), gc, x, y, s, ls);
} else { } else {
LyXFont smallfont(f); LyXFont smallfont(f);
@ -270,21 +270,21 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
c.byte2 = uppercase(s[i].byte2); c.byte2 = uppercase(s[i].byte2);
} }
if (c.byte2 != s[i].byte2) { if (c.byte2 != s[i].byte2) {
lyxfont::XSetFont(display(), gc, smallfont); font_metrics::XSetFont(display(), gc, smallfont);
XDrawString16(display(), owner.getPixmap(), gc, XDrawString16(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1); tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth16(smallfont, &c, 1); tmpx += font_metrics::XTextWidth16(smallfont, &c, 1);
} else { } else {
lyxfont::XSetFont(display(), gc, f); font_metrics::XSetFont(display(), gc, f);
XDrawString16(display(), owner.getPixmap(), gc, XDrawString16(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1); tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth16(f, &c, 1); tmpx += font_metrics::XTextWidth16(f, &c, 1);
} }
} }
} }
if (f.underbar() == LyXFont::ON) { if (f.underbar() == LyXFont::ON) {
underline(f, x, y, lyxfont::width(s, ls, f)); underline(f, x, y, font_metrics::width(s, ls, f));
} }
return *this; return *this;
@ -293,8 +293,8 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
void Painter::underline(LyXFont const & f, int x, int y, int width) void Painter::underline(LyXFont const & f, int x, int y, int width)
{ {
int const below = max(lyxfont::maxDescent(f) / 2, 2); int const below = max(font_metrics::maxDescent(f) / 2, 2);
int const height = max((lyxfont::maxDescent(f) / 4) - 1, 1); int const height = max((font_metrics::maxDescent(f) / 4) - 1, 1);
if (height < 2) if (height < 2)
line(x, y + below, x + width, y + below, f.color()); line(x, y + below, x + width, y + below, f.color());
else else

View File

@ -15,7 +15,7 @@
#endif #endif
#include "support/lstrings.h" #include "support/lstrings.h"
#include "font.h" #include "xfont_metrics.h"
#include "FontLoader.h" #include "FontLoader.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "encoding.h" #include "encoding.h"
@ -41,19 +41,19 @@ XID getFontID(LyXFont const & f)
} // namespace anon } // namespace anon
int lyxfont::maxAscent(LyXFont const & f) int font_metrics::maxAscent(LyXFont const & f)
{ {
return getXFontstruct(f)->ascent; return getXFontstruct(f)->ascent;
} }
int lyxfont::maxDescent(LyXFont const & f) int font_metrics::maxDescent(LyXFont const & f)
{ {
return getXFontstruct(f)->descent; return getXFontstruct(f)->descent;
} }
int lyxfont::ascent(char c, LyXFont const & f) int font_metrics::ascent(char c, LyXFont const & f)
{ {
XFontStruct * finfo = getXFontstruct(f); XFontStruct * finfo = getXFontstruct(f);
unsigned int uc = static_cast<unsigned char>(c); unsigned int uc = static_cast<unsigned char>(c);
@ -66,7 +66,7 @@ int lyxfont::ascent(char c, LyXFont const & f)
} }
int lyxfont::descent(char c, LyXFont const & f) int font_metrics::descent(char c, LyXFont const & f)
{ {
XFontStruct * finfo = getXFontstruct(f); XFontStruct * finfo = getXFontstruct(f);
unsigned int uc = static_cast<unsigned char>(c); unsigned int uc = static_cast<unsigned char>(c);
@ -79,7 +79,7 @@ int lyxfont::descent(char c, LyXFont const & f)
} }
int lyxfont::lbearing(char c, LyXFont const & f) int font_metrics::lbearing(char c, LyXFont const & f)
{ {
XFontStruct * finfo = getXFontstruct(f); XFontStruct * finfo = getXFontstruct(f);
unsigned int uc = static_cast<unsigned char>(c); unsigned int uc = static_cast<unsigned char>(c);
@ -92,7 +92,7 @@ int lyxfont::lbearing(char c, LyXFont const & f)
} }
int lyxfont::rbearing(char c, LyXFont const & f) int font_metrics::rbearing(char c, LyXFont const & f)
{ {
XFontStruct * finfo = getXFontstruct(f); XFontStruct * finfo = getXFontstruct(f);
unsigned int uc = static_cast<unsigned char>(c); unsigned int uc = static_cast<unsigned char>(c);
@ -105,7 +105,20 @@ int lyxfont::rbearing(char c, LyXFont const & f)
} }
int lyxfont::width(char const * s, size_t n, LyXFont const & f) int font_metrics::width(char c, LyXFont const & f)
{
return width(&c, 1, f);
}
int font_metrics::width(string const & s, LyXFont const & f)
{
if (s.empty()) return 0;
return width(s.data(), s.length(), f);
}
int font_metrics::width(char const * s, size_t n, LyXFont const & f)
{ {
if (!lyxrc.use_gui) if (!lyxrc.use_gui)
return n; return n;
@ -150,7 +163,7 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
} }
int lyxfont::signedWidth(string const & s, LyXFont const & f) int font_metrics::signedWidth(string const & s, LyXFont const & f)
{ {
if (s.empty()) if (s.empty())
return 0; return 0;
@ -161,8 +174,8 @@ int lyxfont::signedWidth(string const & s, LyXFont const & f)
} }
//int lyxfont::width(wstring const & s, int n, LyXFont const & f) //int font_metrics::width(wstring const & s, int n, LyXFont const & f)
int lyxfont::width(XChar2b const * s, int n, LyXFont const & f) int font_metrics::width(XChar2b const * s, int n, LyXFont const & f)
{ {
if (!lyxrc.use_gui) if (!lyxrc.use_gui)
return n; return n;
@ -192,43 +205,43 @@ int lyxfont::width(XChar2b const * s, int n, LyXFont const & f)
} }
} }
int lyxfont::XTextWidth(LyXFont const & f, char const * str, int count) int font_metrics::XTextWidth(LyXFont const & f, char const * str, int count)
{ {
return ::XTextWidth(getXFontstruct(f), str, count); return ::XTextWidth(getXFontstruct(f), str, count);
} }
int lyxfont::XTextWidth16(LyXFont const & f, XChar2b const * str, int count) int font_metrics::XTextWidth16(LyXFont const & f, XChar2b const * str, int count)
{ {
return ::XTextWidth16(getXFontstruct(f), str, count); return ::XTextWidth16(getXFontstruct(f), str, count);
} }
void lyxfont::XSetFont(Display * display, GC gc, LyXFont const & f) void font_metrics::XSetFont(Display * display, GC gc, LyXFont const & f)
{ {
::XSetFont(display, gc, getFontID(f)); ::XSetFont(display, gc, getFontID(f));
} }
void lyxfont::rectText(string const & str, LyXFont const & font, void font_metrics::rectText(string const & str, LyXFont const & font,
int & width, int & ascent, int & descent) int & width, int & ascent, int & descent)
{ {
static int const d = 2; static int const d = 2;
width = lyxfont::width(str, font) + d * 2 + 2; width = font_metrics::width(str, font) + d * 2 + 2;
ascent = lyxfont::maxAscent(font) + d; ascent = font_metrics::maxAscent(font) + d;
descent = lyxfont::maxDescent(font) + d; descent = font_metrics::maxDescent(font) + d;
} }
void lyxfont::buttonText(string const & str, LyXFont const & font, void font_metrics::buttonText(string const & str, LyXFont const & font,
int & width, int & ascent, int & descent) int & width, int & ascent, int & descent)
{ {
static int const d = 3; static int const d = 3;
width = lyxfont::width(str, font) + d * 2 + 2; width = font_metrics::width(str, font) + d * 2 + 2;
ascent = lyxfont::maxAscent(font) + d; ascent = font_metrics::maxAscent(font) + d;
descent = lyxfont::maxDescent(font) + d; descent = font_metrics::maxDescent(font) + d;
} }

View File

@ -22,72 +22,53 @@
class LyXFont; class LyXFont;
namespace font_metrics {
//namespace lyx { //namespace lyx {
//namespace font { //namespace font {
/// ///
struct lyxfont { //istruct lyxfont {
/// ///
static
int maxAscent(LyXFont const & f); int maxAscent(LyXFont const & f);
/// ///
static
int maxDescent(LyXFont const & f); int maxDescent(LyXFont const & f);
/// ///
static
int ascent(char c, LyXFont const & f); int ascent(char c, LyXFont const & f);
/// ///
static
int descent(char c, LyXFont const & f); int descent(char c, LyXFont const & f);
/// ///
static
int lbearing(char c, LyXFont const & f); int lbearing(char c, LyXFont const & f);
/// ///
static
int rbearing(char c, LyXFont const & f); int rbearing(char c, LyXFont const & f);
/// ///
static
int width(char c, LyXFont const & f) {
return width(&c, 1, f);
}
///
static
int width(char const * s, size_t n, LyXFont const & f); int width(char const * s, size_t n, LyXFont const & f);
/// ///
static int width(char c, LyXFont const & f);
int width(string const & s, LyXFont const & f) { ///
if (s.empty()) return 0; int width(string const & s, LyXFont const & f);
return width(s.data(), s.length(), f);
}
/// ///
//static //static
//int width(char const * s, LyXFont const & f) { //int width(char const * s, LyXFont const & f) {
// return width(s, strlen(s), f); // return width(s, strlen(s), f);
//} //}
/// ///
static
int signedWidth(string const & s, LyXFont const & f); int signedWidth(string const & s, LyXFont const & f);
/// ///
static
int XTextWidth(LyXFont const & f, char const * str, int count); int XTextWidth(LyXFont const & f, char const * str, int count);
/// ///
static
int width(XChar2b const * s, int n, LyXFont const & f); int width(XChar2b const * s, int n, LyXFont const & f);
/// ///
static
int XTextWidth16(LyXFont const & f, XChar2b const * str, int count); int XTextWidth16(LyXFont const & f, XChar2b const * str, int count);
/// ///
static
void XSetFont(Display * display, GC gc, LyXFont const & f); void XSetFont(Display * display, GC gc, LyXFont const & f);
// A couple of more high-level metrics // A couple of more high-level metrics
/// ///
static
void rectText(string const & str, LyXFont const & font, void rectText(string const & str, LyXFont const & font,
int & width, int & ascent, int & descent); int & width, int & ascent, int & descent);
/// ///
static
void buttonText(string const & str, LyXFont const & font, void buttonText(string const & str, LyXFont const & font,
int & width, int & ascent, int & descent); int & width, int & ascent, int & descent);
}; //};
}
//} // end of namespace font //} // end of namespace font

View File

@ -1,3 +1,17 @@
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* insetbib.C:
* insetbutton.C:
* insetcaption.C:
* insetcollapsable.C:
* inseterror.C:
* insetgraphics.C:
* insetlatexaccent.C:
* insetquotes.C:
* insetspecialchar.C:
* insettabular.C:
* insettext.C: name change for font metrics
2002-05-24 Juergen Vigna <jug@sad.it> 2002-05-24 Juergen Vigna <jug@sad.it>
* insetgraphics.h: include inset.h first (for LString.h) * insetgraphics.h: include inset.h first (for LString.h)

View File

@ -11,7 +11,7 @@
#include "gettext.h" #include "gettext.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "lyxtextclasslist.h" #include "lyxtextclasslist.h"
@ -353,7 +353,7 @@ string const bibitemWidest(Buffer const * buffer)
while (par) { while (par) {
if (par->bibkey) { if (par->bibkey) {
int const wx = int const wx =
lyxfont::width(par->bibkey->getBibLabel(), font_metrics::width(par->bibkey->getBibLabel(),
font); font);
if (wx > w) { if (wx > w) {
w = wx; w = wx;

View File

@ -20,7 +20,7 @@
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "font.h" #include "frontends/font_metrics.h"
using std::ostream; using std::ostream;
using std::endl; using std::endl;
@ -38,10 +38,10 @@ int InsetButton::ascent(BufferView * bv, LyXFont const &) const
int descent; int descent;
string const s = getScreenLabel(bv->buffer()); string const s = getScreenLabel(bv->buffer());
if (editable()) { if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent); font_metrics::buttonText(s, font, width, ascent, descent);
} else { } else {
lyxfont::rectText(s, font, width, ascent, descent); font_metrics::rectText(s, font, width, ascent, descent);
} }
return ascent; return ascent;
@ -60,10 +60,10 @@ int InsetButton::descent(BufferView * bv, LyXFont const &) const
int descent; int descent;
string const s = getScreenLabel(bv->buffer()); string const s = getScreenLabel(bv->buffer());
if (editable()) { if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent); font_metrics::buttonText(s, font, width, ascent, descent);
} else { } else {
lyxfont::rectText(s, font, width, ascent, descent); font_metrics::rectText(s, font, width, ascent, descent);
} }
return descent; return descent;
@ -82,10 +82,10 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
int descent; int descent;
string const s = getScreenLabel(bv->buffer()); string const s = getScreenLabel(bv->buffer());
if (editable()) { if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent); font_metrics::buttonText(s, font, width, ascent, descent);
} else { } else {
lyxfont::rectText(s, font, width, ascent, descent); font_metrics::rectText(s, font, width, ascent, descent);
} }
return width + 4; return width + 4;

View File

@ -16,7 +16,7 @@
#include "insetcaption.h" #include "insetcaption.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "BufferView.h" #include "BufferView.h"
#include "FloatList.h" #include "FloatList.h"
#include "insets/insetfloat.h" #include "insets/insetfloat.h"
@ -89,7 +89,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
string const label = _(fl) + " " + num + ":"; string const label = _(fl) + " " + num + ":";
Painter & pain = bv->painter(); Painter & pain = bv->painter();
int const w = lyxfont::width(label, f); int const w = font_metrics::width(label, f);
pain.text(int(x), baseline, label, f); pain.text(int(x), baseline, label, f);
x += w; x += w;

View File

@ -21,7 +21,7 @@
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "debug.h" #include "debug.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "insets/insettext.h" #include "insets/insettext.h"
@ -113,7 +113,7 @@ int InsetCollapsable::ascent_collapsed() const
int width = 0; int width = 0;
int ascent = 0; int ascent = 0;
int descent = 0; int descent = 0;
lyxfont::buttonText(label, labelfont, width, ascent, descent); font_metrics::buttonText(label, labelfont, width, ascent, descent);
return ascent; return ascent;
} }
@ -123,7 +123,7 @@ int InsetCollapsable::descent_collapsed() const
int width = 0; int width = 0;
int ascent = 0; int ascent = 0;
int descent = 0; int descent = 0;
lyxfont::buttonText(label, labelfont, width, ascent, descent); font_metrics::buttonText(label, labelfont, width, ascent, descent);
return descent; return descent;
} }
@ -134,7 +134,7 @@ int InsetCollapsable::width_collapsed() const
int width; int width;
int ascent; int ascent;
int descent; int descent;
lyxfont::buttonText(label, labelfont, width, ascent, descent); font_metrics::buttonText(label, labelfont, width, ascent, descent);
return width + (2*TEXT_TO_INSET_OFFSET); return width + (2*TEXT_TO_INSET_OFFSET);
} }

View File

@ -15,7 +15,7 @@
#endif #endif
#include "BufferView.h" #include "BufferView.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "gettext.h" #include "gettext.h"
#include "inseterror.h" #include "inseterror.h"
@ -36,7 +36,7 @@ int InsetError::ascent(BufferView *, LyXFont const & font) const
{ {
LyXFont efont; LyXFont efont;
efont.setSize(font.size()).decSize(); efont.setSize(font.size()).decSize();
return lyxfont::maxAscent(efont) + 1; return font_metrics::maxAscent(efont) + 1;
} }
@ -44,7 +44,7 @@ int InsetError::descent(BufferView *, LyXFont const & font) const
{ {
LyXFont efont; LyXFont efont;
efont.setSize(font.size()).decSize(); efont.setSize(font.size()).decSize();
return lyxfont::maxDescent(efont) + 1; return font_metrics::maxDescent(efont) + 1;
} }
@ -52,7 +52,7 @@ int InsetError::width(BufferView *, LyXFont const & font) const
{ {
LyXFont efont; LyXFont efont;
efont.setSize(font.size()).decSize(); efont.setSize(font.size()).decSize();
return 6 + lyxfont::width(_("Error"), efont); return 6 + font_metrics::width(_("Error"), efont);
} }

View File

@ -88,7 +88,7 @@ TODO Before initial production release:
#include "converter.h" #include "converter.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "font.h" // For the lyxfont class. #include "frontends/font_metrics.h"
#include "debug.h" #include "debug.h"
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
@ -263,13 +263,13 @@ int InsetGraphics::width(BufferView *, LyXFont const & font) const
string const justname = OnlyFilename (params().filename); string const justname = OnlyFilename (params().filename);
if (!justname.empty()) { if (!justname.empty()) {
msgFont.setSize(LyXFont::SIZE_FOOTNOTE); msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
font_width = lyxfont::width(justname, msgFont); font_width = font_metrics::width(justname, msgFont);
} }
string const msg = statusMessage(); string const msg = statusMessage();
if (!msg.empty()) { if (!msg.empty()) {
msgFont.setSize(LyXFont::SIZE_TINY); msgFont.setSize(LyXFont::SIZE_TINY);
int const msg_width = lyxfont::width(msg, msgFont); int const msg_width = font_metrics::width(msg, msgFont);
font_width = std::max(font_width, msg_width); font_width = std::max(font_width, msg_width);
} }
@ -329,7 +329,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
if (!justname.empty()) { if (!justname.empty()) {
msgFont.setSize(LyXFont::SIZE_FOOTNOTE); msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
paint.text(old_x + 8, paint.text(old_x + 8,
baseline - lyxfont::maxAscent(msgFont) - 4, baseline - font_metrics::maxAscent(msgFont) - 4,
justname, msgFont); justname, msgFont);
} }

View File

@ -20,7 +20,7 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "BufferView.h" #include "BufferView.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "language.h" #include "language.h"
using std::ostream; using std::ostream;
@ -270,13 +270,13 @@ int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
int max; int max;
if (candisp) { if (candisp) {
if (ic == ' ') if (ic == ' ')
max = lyxfont::ascent('a', font); max = font_metrics::ascent('a', font);
else else
max = lyxfont::ascent(ic, font); max = font_metrics::ascent(ic, font);
if (plusasc) if (plusasc)
max += (lyxfont::maxAscent(font) + 3) / 3; max += (font_metrics::maxAscent(font) + 3) / 3;
} else } else
max = lyxfont::maxAscent(font) + 4; max = font_metrics::maxAscent(font) + 4;
return max; return max;
} }
@ -286,13 +286,13 @@ int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
int max; int max;
if (candisp) { if (candisp) {
if (ic == ' ') if (ic == ' ')
max = lyxfont::descent('a', font); max = font_metrics::descent('a', font);
else else
max = lyxfont::descent(ic, font); max = font_metrics::descent(ic, font);
if (plusdesc) if (plusdesc)
max += 3; max += 3;
} else } else
max = lyxfont::maxDescent(font) + 4; max = font_metrics::maxDescent(font) + 4;
return max; return max;
} }
@ -300,21 +300,21 @@ int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
int InsetLatexAccent::width(BufferView *, LyXFont const & font) const int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
{ {
if (candisp) if (candisp)
return lyxfont::width(ic, font); return font_metrics::width(ic, font);
else else
return lyxfont::width(contents, font) + 4; return font_metrics::width(contents, font) + 4;
} }
int InsetLatexAccent::lbearing(LyXFont const & font) const 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 int InsetLatexAccent::rbearing(LyXFont const & font) const
{ {
return lyxfont::rbearing(ic, font); return font_metrics::rbearing(ic, font);
} }
@ -388,7 +388,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
int y; int y;
if (plusasc) { if (plusasc) {
// mark at the top // mark at the top
hg = lyxfont::maxDescent(font); hg = font_metrics::maxDescent(font);
y = baseline - asc; y = baseline - asc;
if (font.shape() == LyXFont::ITALIC_SHAPE) if (font.shape() == LyXFont::ITALIC_SHAPE)
@ -406,15 +406,15 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
pain.text(int(x), baseline, ic, font); pain.text(int(x), baseline, ic, font);
if (remdot) { if (remdot) {
int tmpvar = baseline - lyxfont::ascent('i', font); int tmpvar = baseline - font_metrics::ascent('i', font);
float tmpx = 0; float tmpx = 0;
if (font.shape() == LyXFont::ITALIC_SHAPE) if (font.shape() == LyXFont::ITALIC_SHAPE)
tmpx += (8.0 * hg) / 10.0; // italic tmpx += (8.0 * hg) / 10.0; // italic
lyxerr[Debug::KEY] << "Removing dot." << endl; lyxerr[Debug::KEY] << "Removing dot." << endl;
// remove the dot first // remove the dot first
pain.fillRectangle(int(x + tmpx), tmpvar, wid, pain.fillRectangle(int(x + tmpx), tmpvar, wid,
lyxfont::ascent('i', font) - font_metrics::ascent('i', font) -
lyxfont::ascent('x', font) - 1, font_metrics::ascent('x', font) - 1,
backgroundColor()); backgroundColor());
// the five lines below is a simple hack to // the five lines below is a simple hack to
// make the display of accent 'i' and 'j' // make the display of accent 'i' and 'j'
@ -429,58 +429,58 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
// now the rest - draw within (x, y, x+wid, y+hg) // now the rest - draw within (x, y, x+wid, y+hg)
switch (modtype) { switch (modtype) {
case ACUTE: // acute 0xB4 case ACUTE: // acute 0xB4
{ {
pain.text(int(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2), pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - font_metrics::lbearing(0xB4, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(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); char(0xB4), font);
break; break;
} }
case GRAVE: // grave 0x60 case GRAVE: // grave 0x60
{ {
pain.text(int(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2), pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0), 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); char(0x60), font);
break; break;
} }
case MACRON: // macron case MACRON: // macron
{ {
pain.text(int(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2), pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)), baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
char(0xAF), font); char(0xAF), font);
break; break;
} }
case TILDE: // tilde case TILDE: // tilde
{ {
pain.text(int(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2), pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
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); '~', font);
break; break;
} }
case UNDERBAR: // underbar 0x5F 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); char(0x5F), font);
break; break;
} }
case CEDILLA: // cedilla 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); char(0xB8), font);
break; break;
} }
case UNDERDOT: // underdot case UNDERDOT: // underdot
{ {
pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0), pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
int(baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font))), int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
'.', font); '.', font);
break; break;
} }
case DOT: // dot case DOT: // dot
{ {
pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0), pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
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); '.', font);
break; break;
} }
@ -489,8 +489,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
{ {
LyXFont tmpf(font); LyXFont tmpf(font);
tmpf.decSize().decSize(); tmpf.decSize().decSize();
pain.text(int(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0), pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::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), 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); char(0xB0), tmpf);
break; break;
} }
@ -537,18 +537,18 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
} }
case HUNGARIAN_UMLAUT: // hung. umlaut case HUNGARIAN_UMLAUT: // hung. umlaut
{ {
pain.text(int(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font))), pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
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); '´', font);
pain.text(int(x2), 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); '´', font);
break; break;
} }
case UMLAUT: // umlaut case UMLAUT: // umlaut
{ {
pain.text(int(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2), pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
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); '¨', font);
break; break;
} }
@ -556,8 +556,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
{ {
LyXFont tmpf(font); LyXFont tmpf(font);
tmpf.decSize().decSize().decSize(); tmpf.decSize().decSize().decSize();
pain.text(int(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2), pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0), 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); char(0x5E), tmpf);
break; break;
} }

View File

@ -23,7 +23,7 @@
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "buffer.h" #include "buffer.h"
#include "debug.h" #include "debug.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "language.h" #include "language.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "lyxrc.h" #include "lyxrc.h"
@ -186,13 +186,13 @@ string const InsetQuotes::dispString(Language const * loclang) const
int InsetQuotes::ascent(BufferView *, LyXFont const & font) const int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
{ {
return lyxfont::maxAscent(font); return font_metrics::maxAscent(font);
} }
int InsetQuotes::descent(BufferView *, LyXFont const & font) const int InsetQuotes::descent(BufferView *, LyXFont const & font) const
{ {
return lyxfont::maxDescent(font); return font_metrics::maxDescent(font);
} }
@ -203,11 +203,11 @@ int InsetQuotes::width(BufferView *, LyXFont const & font) const
for (string::size_type i = 0; i < text.length(); ++i) { for (string::size_type i = 0; i < text.length(); ++i) {
if (text[i] == ' ') if (text[i] == ' ')
w += lyxfont::width('i', font); w += font_metrics::width('i', font);
else if (i == 0 || text[i] != text[i-1]) else if (i == 0 || text[i] != text[i-1])
w += lyxfont::width(text[i], font); w += font_metrics::width(text[i], font);
else else
w += lyxfont::width(',', font); w += font_metrics::width(',', font);
} }
return w; return w;

View File

@ -18,7 +18,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "BufferView.h" #include "BufferView.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "lyxfont.h" #include "lyxfont.h"
@ -37,13 +37,13 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
{ {
return lyxfont::maxAscent(font); return font_metrics::maxAscent(font);
} }
int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
{ {
return lyxfont::maxDescent(font); return font_metrics::maxDescent(font);
} }
@ -52,30 +52,30 @@ int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
switch (kind_) { switch (kind_) {
case HYPHENATION: case HYPHENATION:
{ {
int w = lyxfont::width('-', font); int w = font_metrics::width('-', font);
if (w > 5) if (w > 5)
w -= 2; // to make it look shorter w -= 2; // to make it look shorter
return w; return w;
} }
case LIGATURE_BREAK: case LIGATURE_BREAK:
{ {
return lyxfont::width('|', font); return font_metrics::width('|', font);
} }
case END_OF_SENTENCE: case END_OF_SENTENCE:
{ {
return lyxfont::width('.', font); return font_metrics::width('.', font);
} }
case LDOTS: case LDOTS:
{ {
return lyxfont::width(". . .", font); return font_metrics::width(". . .", font);
} }
case MENU_SEPARATOR: case MENU_SEPARATOR:
{ {
return lyxfont::width(" x ", font); return font_metrics::width(" x ", font);
} }
case PROTECTED_SEPARATOR: case PROTECTED_SEPARATOR:
{ {
return lyxfont::width('x', font); return font_metrics::width('x', font);
} }
} }
@ -121,9 +121,9 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
case MENU_SEPARATOR: case MENU_SEPARATOR:
{ {
// A triangle the width and height of an 'x' // A triangle the width and height of an 'x'
int w = lyxfont::width('x', font); int w = font_metrics::width('x', font);
int ox = lyxfont::width(' ', font) + int(x); int ox = font_metrics::width(' ', font) + int(x);
int h = lyxfont::ascent('x', font); int h = font_metrics::ascent('x', font);
int xp[4], yp[4]; int xp[4], yp[4];
xp[0] = ox; yp[0] = baseline; xp[0] = ox; yp[0] = baseline;
@ -138,7 +138,7 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
case PROTECTED_SEPARATOR: case PROTECTED_SEPARATOR:
{ {
float w = width(bv, font); float w = width(bv, font);
int h = lyxfont::ascent('x', font); int h = font_metrics::ascent('x', font);
int xp[4], yp[4]; int xp[4], yp[4];
xp[0] = int(x); xp[0] = int(x);

View File

@ -23,7 +23,7 @@
#include "debug.h" #include "debug.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "insets/insettext.h" #include "insets/insettext.h"
@ -1429,8 +1429,8 @@ void InsetTabular::toggleInsetCursor(BufferView * bv)
LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos); LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
if (isCursorVisible()) if (isCursorVisible())
bv->hideLockedInsetCursor(); bv->hideLockedInsetCursor();
@ -1447,8 +1447,8 @@ void InsetTabular::showInsetCursor(BufferView * bv, bool show)
if (!isCursorVisible()) { if (!isCursorVisible()) {
LyXFont font; // = GetFont(par, cursor.pos); LyXFont font; // = GetFont(par, cursor.pos);
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc); bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
if (show) if (show)
bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc); bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
@ -1477,9 +1477,10 @@ void InsetTabular::fitInsetCursor(BufferView * bv) const
} }
LyXFont font; LyXFont font;
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
resetPos(bv); resetPos(bv);
if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc)) if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
need_update = FULL; need_update = FULL;
} }

View File

@ -29,7 +29,7 @@
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxcursor.h" #include "lyxcursor.h"
#include "CutAndPaste.h" #include "CutAndPaste.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "LColor.h" #include "LColor.h"
#include "lyxrow.h" #include "lyxrow.h"
#include "lyxrc.h" #include "lyxrc.h"
@ -1808,8 +1808,8 @@ void InsetText::toggleInsetCursor(BufferView * bv)
LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv))); LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
if (isCursorVisible()) if (isCursorVisible())
bv->hideLockedInsetCursor(); bv->hideLockedInsetCursor();
@ -1829,8 +1829,8 @@ void InsetText::showInsetCursor(BufferView * bv, bool show)
LyXFont const font = LyXFont const font =
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)); getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc); bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
if (show) if (show)
@ -1860,8 +1860,8 @@ void InsetText::fitInsetCursor(BufferView * bv) const
LyXFont const font = LyXFont const font =
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)); getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = font_metrics::maxDescent(font);
if (bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc)) if (bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc))
need_update |= FULL; need_update |= FULL;

View File

@ -1,3 +1,12 @@
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* formulabase.C:
* formulamacro.C:
* math_charinset.C:
* math_funcinset.C:
* math_support.C:
* math_unknowninset.C: new name for font metrics
2002-05-24 Lars Gullik Bjønnes <larsbj@birdstep.com> 2002-05-24 Lars Gullik Bjønnes <larsbj@birdstep.com>
* math_autocorrect.C: include vector and add a using statement. * math_autocorrect.C: include vector and add a using statement.
@ -8,7 +17,6 @@
* math_cursor.[Ch]: subsequent changes * math_cursor.[Ch]: subsequent changes
* math_parser.C: somewhat better error reporting * math_parser.C: somewhat better error reporting
2002-05-23 John Levon <moz@compsoc.man.ac.uk> 2002-05-23 John Levon <moz@compsoc.man.ac.uk>
* formula.C: * formula.C:

View File

@ -35,7 +35,7 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "Lsstream.h" #include "Lsstream.h"
#include "math_arrayinset.h" #include "math_arrayinset.h"
#include "math_charinset.h" #include "math_charinset.h"

View File

@ -28,7 +28,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "gettext.h" #include "gettext.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "debug.h" #include "debug.h"
@ -136,7 +136,7 @@ int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
{ {
metrics(bv, f); metrics(bv, f);
return 10 + lyxfont::width(prefix(), f) + par()->width(); return 10 + font_metrics::width(prefix(), f) + par()->width();
} }
@ -189,7 +189,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
pain.text(x + 2, y, prefix(), font); pain.text(x + 2, y, prefix(), font);
// formula // formula
par()->draw(pain, x + lyxfont::width(prefix(), f) + 5, y); par()->draw(pain, x + font_metrics::width(prefix(), f) + 5, y);
xx += w + 2; xx += w + 2;
xo_ = x; xo_ = x;
yo_ = y; yo_ = y;

View File

@ -7,8 +7,8 @@
#include "math_charinset.h" #include "math_charinset.h"
#include "LColor.h" #include "LColor.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/font_metrics.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "font.h"
#include "debug.h" #include "debug.h"
#include "math_support.h" #include "math_support.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
@ -67,7 +67,7 @@ void MathCharInset::metrics(MathMetricsInfo const & mi) const
whichFont(font_, code_, mi); whichFont(font_, code_, mi);
mathed_char_dim(font_, char_, ascent_, descent_, width_); mathed_char_dim(font_, char_, ascent_, descent_, width_);
if (isBinaryOp(char_, code_)) if (isBinaryOp(char_, code_))
width_ += 2 * lyxfont::width(' ', font_); width_ += 2 * font_metrics::width(' ', font_);
} }
@ -75,7 +75,7 @@ void MathCharInset::draw(Painter & pain, int x, int y) const
{ {
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl; //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
if (isBinaryOp(char_, code_)) if (isBinaryOp(char_, code_))
x += lyxfont::width(' ', font_); x += font_metrics::width(' ', font_);
drawChar(pain, font_, x, y, char_); drawChar(pain, font_, x, y, char_);
} }

View File

@ -5,7 +5,7 @@
#endif #endif
#include "math_funcinset.h" #include "math_funcinset.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "math_support.h" #include "math_support.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"

View File

@ -5,7 +5,7 @@
#include "math_support.h" #include "math_support.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "FontLoader.h" #include "FontLoader.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "math_cursor.h" #include "math_cursor.h"
#include "math_defs.h" #include "math_defs.h"
#include "math_inset.h" #include "math_inset.h"
@ -559,27 +559,27 @@ deco_struct const * search_deco(string const & name)
void mathed_char_dim(LyXFont const & font, void mathed_char_dim(LyXFont const & font,
unsigned char c, int & asc, int & des, int & wid) unsigned char c, int & asc, int & des, int & wid)
{ {
des = lyxfont::descent(c, font); des = font_metrics::descent(c, font);
asc = lyxfont::ascent(c, font); asc = font_metrics::ascent(c, font);
wid = mathed_char_width(font, c); wid = mathed_char_width(font, c);
} }
int mathed_char_ascent(LyXFont const & font, unsigned char c) int mathed_char_ascent(LyXFont const & font, unsigned char c)
{ {
return lyxfont::ascent(c, font); return font_metrics::ascent(c, font);
} }
int mathed_char_descent(LyXFont const & font, unsigned char c) int mathed_char_descent(LyXFont const & font, unsigned char c)
{ {
return lyxfont::descent(c, font); return font_metrics::descent(c, font);
} }
int mathed_char_width(LyXFont const & font, unsigned char c) int mathed_char_width(LyXFont const & font, unsigned char c)
{ {
return lyxfont::width(c, font); return font_metrics::width(c, font);
} }
@ -588,16 +588,16 @@ void mathed_string_dim(LyXFont const & font,
{ {
asc = des = 0; asc = des = 0;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) { for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
des = max(des, lyxfont::descent(*it, font)); des = max(des, font_metrics::descent(*it, font));
asc = max(asc, lyxfont::ascent(*it, font)); asc = max(asc, font_metrics::ascent(*it, font));
} }
wid = lyxfont::width(s, font); wid = font_metrics::width(s, font);
} }
int mathed_string_width(LyXFont const & font, string const & s) int mathed_string_width(LyXFont const & font, string const & s)
{ {
return lyxfont::width(s, font); return font_metrics::width(s, font);
} }
@ -605,7 +605,7 @@ int mathed_string_ascent(LyXFont const & font, string const & s)
{ {
int asc = 0; int asc = 0;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) for (string::const_iterator it = s.begin(); it != s.end(); ++it)
asc = max(asc, lyxfont::ascent(*it, font)); asc = max(asc, font_metrics::ascent(*it, font));
return asc; return asc;
} }
@ -614,7 +614,7 @@ int mathed_string_descent(LyXFont const & font, string const & s)
{ {
int des = 0; int des = 0;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) for (string::const_iterator it = s.begin(); it != s.end(); ++it)
des = max(des, lyxfont::descent(*it, font)); des = max(des, font_metrics::descent(*it, font));
return des; return des;
} }
@ -734,8 +734,8 @@ void smallerStyleFrac(MathMetricsInfo & st)
void math_font_max_dim(LyXFont const & font, int & asc, int & des) void math_font_max_dim(LyXFont const & font, int & asc, int & des)
{ {
asc = lyxfont::maxAscent(font); asc = font_metrics::maxAscent(font);
des = lyxfont::maxDescent(font); des = font_metrics::maxDescent(font);
} }

View File

@ -5,7 +5,6 @@
#endif #endif
#include "math_unknowninset.h" #include "math_unknowninset.h"
#include "font.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "math_support.h" #include "math_support.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"

View File

@ -19,18 +19,16 @@
#include "buffer.h" #include "buffer.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "encoding.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/font_metrics.h"
#include "frontends/screen.h" #include "frontends/screen.h"
#include "tracer.h"
#include "font.h"
#include "encoding.h"
#include "bufferview_funcs.h" #include "bufferview_funcs.h"
#include "BufferView.h" #include "BufferView.h"
#include "language.h" #include "language.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "undo_funcs.h" #include "undo_funcs.h"
#include "font.h"
#include "insets/insetbib.h" #include "insets/insetbib.h"
#include "insets/insettext.h" #include "insets/insettext.h"
@ -214,7 +212,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
Encodings::IsComposeChar_hebrew(c)) Encodings::IsComposeChar_hebrew(c))
return 0; return 0;
} }
return lyxfont::width(c, font); return font_metrics::width(c, font);
} else if (IsHfillChar(c)) { } else if (IsHfillChar(c)) {
return 3; /* Because of the representation return 3; /* Because of the representation
@ -236,7 +234,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
c = ' '; c = ' ';
else if (IsNewlineChar(c)) else if (IsNewlineChar(c))
c = 'n'; c = 'n';
return lyxfont::width(c, font); return font_metrics::width(c, font);
} }
@ -440,8 +438,8 @@ void LyXText::drawNewline(DrawRowParams & p, pos_type const pos)
{ {
// Draw end-of-line marker // Draw end-of-line marker
LyXFont const font = getFont(p.bv->buffer(), p.row->par(), pos); LyXFont const font = getFont(p.bv->buffer(), p.row->par(), pos);
int const wid = lyxfont::width('n', font); int const wid = font_metrics::width('n', font);
int const asc = lyxfont::maxAscent(font); int const asc = font_metrics::maxAscent(font);
int const y = p.yo + p.row->baseline(); int const y = p.yo + p.row->baseline();
int xp[3]; int xp[3];
int yp[3]; int yp[3];
@ -548,7 +546,7 @@ void LyXText::drawHebrewComposeChar(DrawRowParams & p, pos_type & vpos)
++vpos; ++vpos;
LyXFont const & font = getFont(p.bv->buffer(), p.row->par(), pos); LyXFont const & font = getFont(p.bv->buffer(), p.row->par(), pos);
int const width = lyxfont::width(c, font); int const width = font_metrics::width(c, font);
int dx = 0; int dx = 0;
for (pos_type i = pos-1; i >= 0; --i) { for (pos_type i = pos-1; i >= 0; --i) {
@ -583,7 +581,7 @@ void LyXText::drawArabicComposeChar(DrawRowParams & p, pos_type & vpos)
++vpos; ++vpos;
LyXFont const & font = getFont(p.bv->buffer(), p.row->par(), pos); LyXFont const & font = getFont(p.bv->buffer(), p.row->par(), pos);
int const width = lyxfont::width(c, font); int const width = font_metrics::width(c, font);
int dx = 0; int dx = 0;
for (pos_type i = pos-1; i >= 0; --i) { for (pos_type i = pos-1; i >= 0; --i) {
@ -639,7 +637,7 @@ void LyXText::drawChars(DrawRowParams & p, pos_type & vpos,
// Draw text and set the new x position // Draw text and set the new x position
p.pain->text(int(p.x), p.yo + p.row->baseline(), str, orig_font); p.pain->text(int(p.x), p.yo + p.row->baseline(), str, orig_font);
p.x += lyxfont::width(str, orig_font); p.x += font_metrics::width(str, orig_font);
} }
@ -719,7 +717,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
int x = LYX_PAPER_MARGIN; int x = LYX_PAPER_MARGIN;
x += lyxfont::signedWidth(tclass.leftmargin(), tclass.defaultfont()); x += font_metrics::signedWidth(tclass.leftmargin(), tclass.defaultfont());
// this is the way, LyX handles the LaTeX-Environments. // this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a // I have had this idea very late, so it seems to be a
@ -769,38 +767,38 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
switch (layout.margintype) { switch (layout.margintype) {
case MARGIN_DYNAMIC: case MARGIN_DYNAMIC:
if (!layout.leftmargin.empty()) { if (!layout.leftmargin.empty()) {
x += lyxfont::signedWidth(layout.leftmargin, x += font_metrics::signedWidth(layout.leftmargin,
tclass.defaultfont()); tclass.defaultfont());
} }
if (!row->par()->getLabelstring().empty()) { if (!row->par()->getLabelstring().empty()) {
x += lyxfont::signedWidth(layout.labelindent, x += font_metrics::signedWidth(layout.labelindent,
labelfont); labelfont);
x += lyxfont::width(row->par()->getLabelstring(), x += font_metrics::width(row->par()->getLabelstring(),
labelfont); labelfont);
x += lyxfont::width(layout.labelsep, labelfont); x += font_metrics::width(layout.labelsep, labelfont);
} }
break; break;
case MARGIN_MANUAL: case MARGIN_MANUAL:
x += lyxfont::signedWidth(layout.labelindent, labelfont); x += font_metrics::signedWidth(layout.labelindent, labelfont);
if (row->pos() >= beginningOfMainBody(bview->buffer(), row->par())) { if (row->pos() >= beginningOfMainBody(bview->buffer(), row->par())) {
if (!row->par()->getLabelWidthString().empty()) { if (!row->par()->getLabelWidthString().empty()) {
x += lyxfont::width(row->par()->getLabelWidthString(), x += font_metrics::width(row->par()->getLabelWidthString(),
labelfont); labelfont);
x += lyxfont::width(layout.labelsep, labelfont); x += font_metrics::width(layout.labelsep, labelfont);
} }
} }
break; break;
case MARGIN_STATIC: case MARGIN_STATIC:
x += lyxfont::signedWidth(layout.leftmargin, tclass.defaultfont()) * 4 x += font_metrics::signedWidth(layout.leftmargin, tclass.defaultfont()) * 4
/ (row->par()->getDepth() + 4); / (row->par()->getDepth() + 4);
break; break;
case MARGIN_FIRST_DYNAMIC: case MARGIN_FIRST_DYNAMIC:
if (layout.labeltype == LABEL_MANUAL) { if (layout.labeltype == LABEL_MANUAL) {
if (row->pos() >= beginningOfMainBody(bview->buffer(), row->par())) { if (row->pos() >= beginningOfMainBody(bview->buffer(), row->par())) {
x += lyxfont::signedWidth(layout.leftmargin, x += font_metrics::signedWidth(layout.leftmargin,
labelfont); labelfont);
} else { } else {
x += lyxfont::signedWidth(layout.labelindent, x += font_metrics::signedWidth(layout.labelindent,
labelfont); labelfont);
} }
} else if (row->pos() } else if (row->pos()
@ -809,16 +807,16 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|| (layout.labeltype == LABEL_STATIC || (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT && layout.latextype == LATEX_ENVIRONMENT
&& ! row->par()->isFirstInSequence())) { && ! row->par()->isFirstInSequence())) {
x += lyxfont::signedWidth(layout.leftmargin, x += font_metrics::signedWidth(layout.leftmargin,
labelfont); labelfont);
} else if (layout.labeltype != LABEL_TOP_ENVIRONMENT } else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
&& layout.labeltype != LABEL_BIBLIO && layout.labeltype != LABEL_BIBLIO
&& layout.labeltype != && layout.labeltype !=
LABEL_CENTERED_TOP_ENVIRONMENT) { LABEL_CENTERED_TOP_ENVIRONMENT) {
x += lyxfont::signedWidth(layout.labelindent, x += font_metrics::signedWidth(layout.labelindent,
labelfont); labelfont);
x += lyxfont::width(layout.labelsep, labelfont); x += font_metrics::width(layout.labelsep, labelfont);
x += lyxfont::width(row->par()->getLabelstring(), x += font_metrics::width(row->par()->getLabelstring(),
labelfont); labelfont);
} }
break; break;
@ -842,8 +840,8 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
minfill = tmprow->fill(); minfill = tmprow->fill();
} }
x += lyxfont::signedWidth(layout.leftmargin, x += font_metrics::signedWidth(layout.leftmargin,
tclass.defaultfont()); tclass.defaultfont());
x += minfill; x += minfill;
} }
break; break;
@ -882,7 +880,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
&& (row->par()->layout() != tclass.defaultLayoutName() || && (row->par()->layout() != tclass.defaultLayoutName() ||
bview->buffer()->params.paragraph_separation == bview->buffer()->params.paragraph_separation ==
BufferParams::PARSEP_INDENT)) { BufferParams::PARSEP_INDENT)) {
x += lyxfont::signedWidth(parindent, x += font_metrics::signedWidth(parindent,
tclass.defaultfont()); tclass.defaultfont());
} else if (layout.labeltype == LABEL_BIBLIO) { } else if (layout.labeltype == LABEL_BIBLIO) {
// ale970405 Right width for bibitems // ale970405 Right width for bibitems
@ -906,7 +904,7 @@ int LyXText::rightMargin(Buffer const * buf, Row const * row) const
LyXLayout const & layout = tclass[row->par()->layout()]; LyXLayout const & layout = tclass[row->par()->layout()];
int x = LYX_PAPER_MARGIN int x = LYX_PAPER_MARGIN
+ lyxfont::signedWidth(tclass.rightmargin(), + font_metrics::signedWidth(tclass.rightmargin(),
tclass.defaultfont()); tclass.defaultfont());
// this is the way, LyX handles the LaTeX-Environments. // this is the way, LyX handles the LaTeX-Environments.
@ -940,7 +938,7 @@ int LyXText::rightMargin(Buffer const * buf, Row const * row) const
} }
//lyxerr << "rightmargin: " << layout->rightmargin << endl; //lyxerr << "rightmargin: " << layout->rightmargin << endl;
x += lyxfont::signedWidth(layout.rightmargin, tclass.defaultfont()) x += font_metrics::signedWidth(layout.rightmargin, tclass.defaultfont())
* 4 / (row->par()->getDepth() + 4); * 4 / (row->par()->getDepth() + 4);
return x; return x;
} }
@ -1057,7 +1055,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
} }
++i; ++i;
if (i == main_body) { if (i == main_body) {
x += lyxfont::width(layout.labelsep, x += font_metrics::width(layout.labelsep,
getLabelFont(bview->buffer(), par)); getLabelFont(bview->buffer(), par));
if (par->isLineSeparator(i - 1)) if (par->isLineSeparator(i - 1))
x-= singleWidth(bview, par, i - 1); x-= singleWidth(bview, par, i - 1);
@ -1117,7 +1115,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
while (i <= last) { while (i <= last) {
if (main_body > 0 && i == main_body) { if (main_body > 0 && i == main_body) {
w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par())); w += font_metrics::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(i - 1)) if (row->par()->isLineSeparator(i - 1))
w -= singleWidth(bview, row->par(), i - 1); w -= singleWidth(bview, row->par(), i - 1);
int left_margin = labelEnd(bview, row); int left_margin = labelEnd(bview, row);
@ -1128,7 +1126,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
++i; ++i;
} }
if (main_body > 0 && main_body > last) { if (main_body > 0 && main_body > last) {
w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par())); w += font_metrics::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
if (last >= 0 && row->par()->isLineSeparator(last)) if (last >= 0 && row->par()->isLineSeparator(last))
w -= singleWidth(bview, row->par(), last); w -= singleWidth(bview, row->par(), last);
int const left_margin = labelEnd(bview, row); int const left_margin = labelEnd(bview, row);
@ -1168,7 +1166,7 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
int fill = 0; int fill = 0;
if (!row->par()->params().labelWidthString().empty()) { if (!row->par()->params().labelWidthString().empty()) {
fill = max(lyxfont::width(row->par()->params().labelWidthString(), fill = max(font_metrics::width(row->par()->params().labelWidthString(),
getLabelFont(bview->buffer(), row->par())) - w, getLabelFont(bview->buffer(), row->par())) - w,
0); 0);
} }
@ -1339,12 +1337,13 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
} }
//lyxerr << "spacing_val = " << spacing_val << endl; //lyxerr << "spacing_val = " << spacing_val << endl;
int maxasc = int(lyxfont::maxAscent(font) * int maxasc = int(font_metrics::maxAscent(font) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val); spacing_val);
int maxdesc = int(lyxfont::maxDescent(font) * int maxdesc = int(font_metrics::maxDescent(font) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val); spacing_val);
pos_type const pos_end = rowLast(row_ptr); pos_type const pos_end = rowLast(row_ptr);
int labeladdon = 0; int labeladdon = 0;
int maxwidth = 0; int maxwidth = 0;
@ -1377,8 +1376,8 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
if (maxsize > font.size()) { if (maxsize > font.size()) {
font.setSize(maxsize); font.setSize(maxsize);
asc = lyxfont::maxAscent(font); asc = font_metrics::maxAscent(font);
desc = lyxfont::maxDescent(font); desc = font_metrics::maxDescent(font);
if (asc > maxasc) if (asc > maxasc)
maxasc = asc; maxasc = asc;
if (desc > maxdesc) if (desc > maxdesc)
@ -1422,9 +1421,9 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
// do not forget the DTP-lines! // do not forget the DTP-lines!
// there height depends on the font of the nearest character // there height depends on the font of the nearest character
if (firstpar->params().lineTop()) if (firstpar->params().lineTop())
maxasc += 2 * lyxfont::ascent('x', getFont(bview->buffer(),
firstpar, 0));
maxasc += 2 * font_metrics::ascent('x', getFont(bview->buffer(),
firstpar, 0));
// and now the pagebreaks // and now the pagebreaks
if (firstpar->params().pagebreakTop()) if (firstpar->params().pagebreakTop())
maxasc += 3 * defaultHeight(); maxasc += 3 * defaultHeight();
@ -1441,10 +1440,10 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
spacing_val = bview->buffer()->params.spacing.getValue(); spacing_val = bview->buffer()->params.spacing.getValue();
} }
labeladdon = int(lyxfont::maxDescent(labelfont) * labeladdon = int(font_metrics::maxDescent(labelfont) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val) spacing_val)
+ int(lyxfont::maxAscent(labelfont) * + int(font_metrics::maxAscent(labelfont) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val); spacing_val);
} }
@ -1464,10 +1463,10 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
} }
labeladdon = int( labeladdon = int(
(lyxfont::maxAscent(labelfont) * (font_metrics::maxAscent(labelfont) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val) spacing_val)
+(lyxfont::maxDescent(labelfont) * +(font_metrics::maxDescent(labelfont) *
layout.spacing.getValue() * layout.spacing.getValue() *
spacing_val) spacing_val)
+ layout.topsep * defaultHeight() + layout.topsep * defaultHeight()
@ -1532,8 +1531,8 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
// do not forget the DTP-lines! // do not forget the DTP-lines!
// there height depends on the font of the nearest character // there height depends on the font of the nearest character
if (firstpar->params().lineBottom()) if (firstpar->params().lineBottom())
maxdesc += 2 * lyxfont::ascent('x', maxdesc += 2 * font_metrics::ascent('x',
getFont(bview->buffer(), getFont(bview->buffer(),
par, par,
max(pos_type(0), par->size() - 1))); max(pos_type(0), par->size() - 1)));
@ -2219,7 +2218,7 @@ void LyXText::prepareToPrint(BufferView * bview,
if (main_body > 0 && if (main_body > 0 &&
(main_body - 1 > last || (main_body - 1 > last ||
!row->par()->isLineSeparator(main_body - 1))) { !row->par()->isLineSeparator(main_body - 1))) {
x += lyxfont::width(layout.labelsep, x += font_metrics::width(layout.labelsep,
getLabelFont(bview->buffer(), row->par())); getLabelFont(bview->buffer(), row->par()));
if (main_body - 1 <= last) if (main_body - 1 <= last)
x += fill_label_hfill; x += fill_label_hfill;
@ -3161,8 +3160,7 @@ void LyXText::paintRowSelection(DrawRowParams & p)
[par->layout()]; [par->layout()];
LyXFont const lfont = getLabelFont(buffer, par); LyXFont const lfont = getLabelFont(buffer, par);
tmpx += p.label_hfill + font_metrics::width(layout.labelsep, lfont);
tmpx += p.label_hfill + lyxfont::width(layout.labelsep, lfont);
if (par->isLineSeparator(main_body - 1)) if (par->isLineSeparator(main_body - 1))
tmpx -= singleWidth(p.bv, par, main_body - 1); tmpx -= singleWidth(p.bv, par, main_body - 1);
@ -3258,8 +3256,8 @@ int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const
LyXFont font; LyXFont font;
font.decSize(); font.decSize();
int const min_size = max(3 * arrow_size, int const min_size = max(3 * arrow_size,
lyxfont::maxAscent(font) font_metrics::maxAscent(font)
+ lyxfont::maxDescent(font)); + font_metrics::maxDescent(font));
if (vsp.length().len().value() < 0.0) if (vsp.length().len().value() < 0.0)
return min_size; return min_size;
@ -3314,7 +3312,7 @@ int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
LyXFont font; LyXFont font;
font.setColor(LColor::added_space).decSize(); font.setColor(LColor::added_space).decSize();
lyxfont::rectText(str, font, w, a, d); font_metrics::rectText(str, font, w, a, d);
p.pain->rectText(leftx + 2 * arrow_size + 5, p.pain->rectText(leftx + 2 * arrow_size + 5,
start + ((end - start) / 2) + d, start + ((end - start) / 2) + d,
@ -3365,7 +3363,7 @@ void LyXText::paintFirstRow(DrawRowParams & p)
LyXFont pb_font; LyXFont pb_font;
pb_font.setColor(LColor::pagebreak).decSize(); pb_font.setColor(LColor::pagebreak).decSize();
lyxfont::rectText(_("Page Break (top)"), pb_font, w, a, d); font_metrics::rectText(_("Page Break (top)"), pb_font, w, a, d);
p.pain->rectText((p.width - w)/2, y + d, p.pain->rectText((p.width - w)/2, y + d,
_("Page Break (top)"), pb_font, _("Page Break (top)"), pb_font,
backgroundColor(), backgroundColor(),
@ -3406,7 +3404,7 @@ void LyXText::paintFirstRow(DrawRowParams & p)
// draw a top line // draw a top line
if (parparams.lineTop()) { if (parparams.lineTop()) {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
int const asc = lyxfont::ascent('x', getFont(buffer, par, 0)); int const asc = font_metrics::ascent('x', getFont(buffer, par, 0));
y_top += asc; y_top += asc;
@ -3445,12 +3443,12 @@ void LyXText::paintFirstRow(DrawRowParams & p)
} }
int const maxdesc = int const maxdesc =
int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val) int(font_metrics::maxDescent(font) * layout.spacing.getValue() * spacing_val)
+ int(layout.parsep) * defaultHeight(); + int(layout.parsep) * defaultHeight();
if (is_rtl) { if (is_rtl) {
x = ww - leftMargin(p.bv, p.row) - x = ww - leftMargin(p.bv, p.row) -
lyxfont::width(str, font); font_metrics::width(str, font);
} }
p.pain->text(int(x), p.pain->text(int(x),
@ -3461,10 +3459,10 @@ void LyXText::paintFirstRow(DrawRowParams & p)
} else { } else {
if (is_rtl) { if (is_rtl) {
x = ww - leftMargin(p.bv, p.row) x = ww - leftMargin(p.bv, p.row)
+ lyxfont::width(layout.labelsep, font); + font_metrics::width(layout.labelsep, font);
} else { } else {
x = p.x - lyxfont::width(layout.labelsep, font) x = p.x - font_metrics::width(layout.labelsep, font)
- lyxfont::width(str, font); - font_metrics::width(str, font);
} }
p.pain->text(int(x), p.yo + p.row->baseline(), str, font); p.pain->text(int(x), p.yo + p.row->baseline(), str, font);
@ -3487,17 +3485,17 @@ void LyXText::paintFirstRow(DrawRowParams & p)
} }
int maxdesc = int maxdesc =
int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val int(font_metrics::maxDescent(font) * layout.spacing.getValue() * spacing_val
+ (layout.labelbottomsep * defaultHeight())); + (layout.labelbottomsep * defaultHeight()));
float x = p.x; float x = p.x;
if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) { if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
x = ((is_rtl ? leftMargin(p.bv, p.row) : p.x) x = ((is_rtl ? leftMargin(p.bv, p.row) : p.x)
+ ww - rightMargin(buffer, p.row)) / 2; + ww - rightMargin(buffer, p.row)) / 2;
x -= lyxfont::width(str, font) / 2; x -= font_metrics::width(str, font) / 2;
} else if (is_rtl) { } else if (is_rtl) {
x = ww - leftMargin(p.bv, p.row) - x = ww - leftMargin(p.bv, p.row) -
lyxfont::width(str, font); font_metrics::width(str, font);
} }
p.pain->text(int(x), p.yo + p.row->baseline() p.pain->text(int(x), p.yo + p.row->baseline()
- p.row->ascent_of_text() - maxdesc, - p.row->ascent_of_text() - maxdesc,
@ -3510,9 +3508,9 @@ void LyXText::paintFirstRow(DrawRowParams & p)
float x; float x;
if (is_rtl) { if (is_rtl) {
x = ww - leftMargin(p.bv, p.row) x = ww - leftMargin(p.bv, p.row)
+ lyxfont::width(layout.labelsep, font); + font_metrics::width(layout.labelsep, font);
} else { } else {
x = p.x - lyxfont::width(layout.labelsep, font) x = p.x - font_metrics::width(layout.labelsep, font)
- par->bibkey->width(p.bv, font); - par->bibkey->width(p.bv, font);
} }
par->bibkey->draw(p.bv, font, p.yo + p.row->baseline(), x, p.cleared); par->bibkey->draw(p.bv, font, p.yo + p.row->baseline(), x, p.cleared);
@ -3544,7 +3542,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
int w = 0; int w = 0;
int a = 0; int a = 0;
int d = 0; int d = 0;
lyxfont::rectText(_("Page Break (bottom)"), pb_font, w, a, d); font_metrics::rectText(_("Page Break (bottom)"), pb_font, w, a, d);
p.pain->rectText((ww - w) / 2, y + d, p.pain->rectText((ww - w) / 2, y + d,
_("Page Break (bottom)"), _("Page Break (bottom)"),
pb_font, backgroundColor(), backgroundColor()); pb_font, backgroundColor(), backgroundColor());
@ -3564,7 +3562,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
// draw a bottom line // draw a bottom line
if (parparams.lineBottom()) { if (parparams.lineBottom()) {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
int const asc = lyxfont::ascent('x', int const asc = font_metrics::ascent('x',
getFont(buffer, par, getFont(buffer, par,
max(pos_type(0), par->size() - 1))); max(pos_type(0), par->size() - 1)));
@ -3588,7 +3586,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
case END_LABEL_FILLED_BOX: case END_LABEL_FILLED_BOX:
{ {
LyXFont const font = getLabelFont(buffer, par); LyXFont const font = getLabelFont(buffer, par);
int const size = int(0.75 * lyxfont::maxAscent(font)); int const size = int(0.75 * font_metrics::maxAscent(font));
int const y = (p.yo + p.row->baseline()) - size; int const y = (p.yo + p.row->baseline()) - size;
int x = is_rtl ? LYX_PAPER_MARGIN : ww - LYX_PAPER_MARGIN - size; int x = is_rtl ? LYX_PAPER_MARGIN : ww - LYX_PAPER_MARGIN - size;
@ -3610,7 +3608,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
string const str = textclasslist[buffer->params.textclass][layout].endlabelstring(); string const str = textclasslist[buffer->params.textclass][layout].endlabelstring();
font = getLabelFont(buffer, par); font = getLabelFont(buffer, par);
int const x = is_rtl ? int const x = is_rtl ?
int(p.x) - lyxfont::width(str, font) int(p.x) - font_metrics::width(str, font)
: ww - rightMargin(buffer, p.row) - p.row->fill(); : ww - rightMargin(buffer, p.row) - p.row->fill();
p.pain->text(x, p.yo + p.row->baseline(), str, font); p.pain->text(x, p.yo + p.row->baseline(), str, font);
break; break;
@ -3648,7 +3646,7 @@ void LyXText::paintRowText(DrawRowParams & p)
continue; continue;
} }
if (main_body > 0 && pos == main_body - 1) { if (main_body > 0 && pos == main_body - 1) {
int const lwidth = lyxfont::width(layout.labelsep, int const lwidth = font_metrics::width(layout.labelsep,
getLabelFont(buffer, par)); getLabelFont(buffer, par));
p.x += p.label_hfill + lwidth p.x += p.label_hfill + lwidth
@ -3758,7 +3756,7 @@ void LyXText::getVisibleRow(BufferView * bv, int y_offset, int x_offset,
int LyXText::defaultHeight() const int LyXText::defaultHeight() const
{ {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
return int(lyxfont::maxAscent(font) + lyxfont::maxDescent(font) * 1.5); return int(font_metrics::maxAscent(font) + font_metrics::maxDescent(font) * 1.5);
} }
@ -3797,7 +3795,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
last_tmpx = tmpx; last_tmpx = tmpx;
if (main_body > 0 && c == main_body-1) { if (main_body > 0 && c == main_body-1) {
tmpx += fill_label_hfill + tmpx += fill_label_hfill +
lyxfont::width(layout.labelsep, font_metrics::width(layout.labelsep,
getLabelFont(bview->buffer(), row->par())); getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(main_body - 1)) if (row->par()->isLineSeparator(main_body - 1))
tmpx -= singleWidth(bview, row->par(), main_body-1); tmpx -= singleWidth(bview, row->par(), main_body-1);

View File

@ -26,7 +26,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "CutAndPaste.h" #include "CutAndPaste.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "font.h" #include "frontends/font_metrics.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxrow.h" #include "lyxrow.h"
@ -2145,7 +2145,7 @@ float LyXText::getCursorX(BufferView * bview, Row * row,
pos_type pos = vis2log(vpos); pos_type pos = vis2log(vpos);
if (main_body > 0 && pos == main_body - 1) { if (main_body > 0 && pos == main_body - 1) {
x += fill_label_hfill + x += fill_label_hfill +
lyxfont::width(textclasslist[ font_metrics::width(textclasslist[
bview->buffer()->params.textclass][ bview->buffer()->params.textclass][
row->par()->layout()] row->par()->layout()]
.labelsep, .labelsep,