mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
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:
parent
86a566a27d
commit
2dabaa33de
@ -14,7 +14,6 @@
|
||||
#include "commandtags.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "debug.h"
|
||||
#include "font.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "TextCache.h"
|
||||
#include "bufferlist.h"
|
||||
|
@ -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>
|
||||
|
||||
* undo_funcs.C (textHandleUndo): fix the cursor selection after
|
||||
|
@ -13,8 +13,6 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "LColor.h"
|
||||
#include "support/LAssert.h"
|
||||
|
@ -114,8 +114,6 @@ lyx_SOURCES = \
|
||||
encoding.h \
|
||||
exporter.C \
|
||||
exporter.h \
|
||||
font.C \
|
||||
font.h \
|
||||
gettext.C \
|
||||
gettext.h \
|
||||
importer.C \
|
||||
|
@ -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>
|
||||
|
||||
* WorkArea.h:
|
||||
|
@ -36,5 +36,6 @@ libfrontends_la_SOURCES = \
|
||||
LyXView.h \
|
||||
WorkArea.C \
|
||||
WorkArea.h \
|
||||
font_metrics.h \
|
||||
screen.C \
|
||||
screen.h
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "Painter.h"
|
||||
#include "lyxfont.h"
|
||||
#include "WorkArea.h"
|
||||
#include "font.h"
|
||||
#include "font_metrics.h"
|
||||
|
||||
|
||||
int PainterBase::paperMargin() const
|
||||
@ -97,7 +97,7 @@ PainterBase & PainterBase::rectText(int x, int baseline,
|
||||
int ascent;
|
||||
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);
|
||||
fillRectangle(x + 1, baseline - ascent + 1, width - 1,
|
||||
ascent + descent - 1, back);
|
||||
@ -114,7 +114,7 @@ PainterBase & PainterBase::buttonText(int x, int baseline,
|
||||
int ascent;
|
||||
int descent;
|
||||
|
||||
lyxfont::buttonText(str, font, width, ascent, descent);
|
||||
font_metrics::buttonText(str, font, width, ascent, descent);
|
||||
button(x, baseline - ascent, width, descent + ascent);
|
||||
text(x + 4, baseline, str, font);
|
||||
return *this;
|
||||
|
3
src/frontends/font_metrics.h
Normal file
3
src/frontends/font_metrics.h
Normal file
@ -0,0 +1,3 @@
|
||||
//// temporary
|
||||
|
||||
#include "xforms/xfont_metrics.h"
|
@ -23,7 +23,7 @@
|
||||
#include "frontends/WorkArea.h"
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "font.h"
|
||||
#include "font_metrics.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "ColorHandler.h"
|
||||
#include "language.h"
|
||||
@ -241,8 +241,8 @@ void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
|
||||
shape = (text->real_current_font.isVisibleRightToLeft())
|
||||
? REVERSED_L_SHAPE : L_SHAPE;
|
||||
showManualCursor(text, text->cursor.x(), text->cursor.y(),
|
||||
lyxfont::maxAscent(text->real_current_font),
|
||||
lyxfont::maxDescent(text->real_current_font),
|
||||
font_metrics::maxAscent(text->real_current_font),
|
||||
font_metrics::maxDescent(text->real_current_font),
|
||||
shape);
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
* FormMathsBitmap.C: include local includes first (selfcontainment)
|
||||
|
@ -214,6 +214,8 @@ libxforms_la_SOURCES = \
|
||||
XFormsView.h \
|
||||
XPainter.C \
|
||||
XPainter.h \
|
||||
xfont_metrics.C \
|
||||
xfont_metrics.h \
|
||||
xforms_helpers.C \
|
||||
xforms_helpers.h \
|
||||
xforms_resize.C \
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "debug.h"
|
||||
#include "lyxfont.h"
|
||||
#include "WorkArea.h"
|
||||
#include "font.h"
|
||||
#include "xfont_metrics.h"
|
||||
#include "ColorHandler.h"
|
||||
#include "lyxrc.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());
|
||||
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);
|
||||
} else {
|
||||
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) {
|
||||
char const c = uppercase(s[i]);
|
||||
if (c != s[i]) {
|
||||
lyxfont::XSetFont(display(), gc, smallfont);
|
||||
font_metrics::XSetFont(display(), gc, smallfont);
|
||||
XDrawString(display(), owner.getPixmap(), gc,
|
||||
tmpx, y, &c, 1);
|
||||
tmpx += lyxfont::XTextWidth(smallfont, &c, 1);
|
||||
tmpx += font_metrics::XTextWidth(smallfont, &c, 1);
|
||||
} else {
|
||||
lyxfont::XSetFont(display(), gc, f);
|
||||
font_metrics::XSetFont(display(), gc, f);
|
||||
XDrawString(display(), owner.getPixmap(), gc,
|
||||
tmpx, y, &c, 1);
|
||||
tmpx += lyxfont::XTextWidth(f, &c, 1);
|
||||
tmpx += font_metrics::XTextWidth(f, &c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -255,7 +255,7 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
|
||||
{
|
||||
GC gc = lyxColorHandler->getGCForeground(f.realColor());
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
if (c.byte2 != s[i].byte2) {
|
||||
lyxfont::XSetFont(display(), gc, smallfont);
|
||||
font_metrics::XSetFont(display(), gc, smallfont);
|
||||
XDrawString16(display(), owner.getPixmap(), gc,
|
||||
tmpx, y, &c, 1);
|
||||
tmpx += lyxfont::XTextWidth16(smallfont, &c, 1);
|
||||
tmpx += font_metrics::XTextWidth16(smallfont, &c, 1);
|
||||
} else {
|
||||
lyxfont::XSetFont(display(), gc, f);
|
||||
font_metrics::XSetFont(display(), gc, f);
|
||||
XDrawString16(display(), owner.getPixmap(), gc,
|
||||
tmpx, y, &c, 1);
|
||||
tmpx += lyxfont::XTextWidth16(f, &c, 1);
|
||||
tmpx += font_metrics::XTextWidth16(f, &c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -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)
|
||||
{
|
||||
int const below = max(lyxfont::maxDescent(f) / 2, 2);
|
||||
int const height = max((lyxfont::maxDescent(f) / 4) - 1, 1);
|
||||
int const below = max(font_metrics::maxDescent(f) / 2, 2);
|
||||
int const height = max((font_metrics::maxDescent(f) / 4) - 1, 1);
|
||||
if (height < 2)
|
||||
line(x, y + below, x + width, y + below, f.color());
|
||||
else
|
||||
|
@ -15,7 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "font.h"
|
||||
#include "xfont_metrics.h"
|
||||
#include "FontLoader.h"
|
||||
#include "lyxrc.h"
|
||||
#include "encoding.h"
|
||||
@ -41,19 +41,19 @@ XID getFontID(LyXFont const & f)
|
||||
|
||||
} // namespace anon
|
||||
|
||||
int lyxfont::maxAscent(LyXFont const & f)
|
||||
int font_metrics::maxAscent(LyXFont const & f)
|
||||
{
|
||||
return getXFontstruct(f)->ascent;
|
||||
}
|
||||
|
||||
|
||||
int lyxfont::maxDescent(LyXFont const & f)
|
||||
int font_metrics::maxDescent(LyXFont const & f)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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)
|
||||
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())
|
||||
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 lyxfont::width(XChar2b const * s, int n, LyXFont const & f)
|
||||
//int font_metrics::width(wstring const & s, int n, LyXFont const & f)
|
||||
int font_metrics::width(XChar2b const * s, int n, LyXFont const & f)
|
||||
{
|
||||
if (!lyxrc.use_gui)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
static int const d = 2;
|
||||
width = lyxfont::width(str, font) + d * 2 + 2;
|
||||
ascent = lyxfont::maxAscent(font) + d;
|
||||
descent = lyxfont::maxDescent(font) + d;
|
||||
width = font_metrics::width(str, font) + d * 2 + 2;
|
||||
ascent = font_metrics::maxAscent(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)
|
||||
{
|
||||
static int const d = 3;
|
||||
|
||||
width = lyxfont::width(str, font) + d * 2 + 2;
|
||||
ascent = lyxfont::maxAscent(font) + d;
|
||||
descent = lyxfont::maxDescent(font) + d;
|
||||
width = font_metrics::width(str, font) + d * 2 + 2;
|
||||
ascent = font_metrics::maxAscent(font) + d;
|
||||
descent = font_metrics::maxDescent(font) + d;
|
||||
}
|
||||
|
||||
|
@ -22,72 +22,53 @@
|
||||
|
||||
class LyXFont;
|
||||
|
||||
namespace font_metrics {
|
||||
//namespace lyx {
|
||||
//namespace font {
|
||||
///
|
||||
struct lyxfont {
|
||||
//istruct lyxfont {
|
||||
///
|
||||
static
|
||||
int maxAscent(LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int maxDescent(LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int ascent(char c, LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int descent(char c, LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int lbearing(char c, LyXFont const & f);
|
||||
///
|
||||
static
|
||||
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);
|
||||
///
|
||||
static
|
||||
int width(string const & s, LyXFont const & f) {
|
||||
if (s.empty()) return 0;
|
||||
return width(s.data(), s.length(), f);
|
||||
}
|
||||
int width(char c, LyXFont const & f);
|
||||
///
|
||||
int width(string const & s, LyXFont const & f);
|
||||
///
|
||||
//static
|
||||
//int width(char const * s, LyXFont const & f) {
|
||||
// return width(s, strlen(s), f);
|
||||
//}
|
||||
///
|
||||
static
|
||||
int signedWidth(string const & s, LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int XTextWidth(LyXFont const & f, char const * str, int count);
|
||||
///
|
||||
static
|
||||
int width(XChar2b const * s, int n, LyXFont const & f);
|
||||
///
|
||||
static
|
||||
int XTextWidth16(LyXFont const & f, XChar2b const * str, int count);
|
||||
///
|
||||
static
|
||||
void XSetFont(Display * display, GC gc, LyXFont const & f);
|
||||
// A couple of more high-level metrics
|
||||
///
|
||||
static
|
||||
void rectText(string const & str, LyXFont const & font,
|
||||
int & width, int & ascent, int & descent);
|
||||
///
|
||||
static
|
||||
void buttonText(string const & str, LyXFont const & font,
|
||||
int & width, int & ascent, int & descent);
|
||||
};
|
||||
//};
|
||||
}
|
||||
|
||||
//} // end of namespace font
|
||||
|
@ -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>
|
||||
|
||||
* insetgraphics.h: include inset.h first (for LString.h)
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "gettext.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxrc.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
@ -353,7 +353,7 @@ string const bibitemWidest(Buffer const * buffer)
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
int const wx =
|
||||
lyxfont::width(par->bibkey->getBibLabel(),
|
||||
font_metrics::width(par->bibkey->getBibLabel(),
|
||||
font);
|
||||
if (wx > w) {
|
||||
w = wx;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "lyxfont.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
@ -38,10 +38,10 @@ int InsetButton::ascent(BufferView * bv, LyXFont const &) const
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
lyxfont::buttonText(s, font, width, ascent, descent);
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
lyxfont::rectText(s, font, width, ascent, descent);
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return ascent;
|
||||
@ -60,10 +60,10 @@ int InsetButton::descent(BufferView * bv, LyXFont const &) const
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
lyxfont::buttonText(s, font, width, ascent, descent);
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
lyxfont::rectText(s, font, width, ascent, descent);
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return descent;
|
||||
@ -82,10 +82,10 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
lyxfont::buttonText(s, font, width, ascent, descent);
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
lyxfont::rectText(s, font, width, ascent, descent);
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return width + 4;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "insetcaption.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "BufferView.h"
|
||||
#include "FloatList.h"
|
||||
#include "insets/insetfloat.h"
|
||||
@ -89,7 +89,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
||||
string const label = _(fl) + " " + num + ":";
|
||||
|
||||
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);
|
||||
x += w;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
#include "debug.h"
|
||||
#include "lyxtext.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "insets/insettext.h"
|
||||
@ -113,7 +113,7 @@ int InsetCollapsable::ascent_collapsed() const
|
||||
int width = 0;
|
||||
int ascent = 0;
|
||||
int descent = 0;
|
||||
lyxfont::buttonText(label, labelfont, width, ascent, descent);
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return ascent;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ int InsetCollapsable::descent_collapsed() const
|
||||
int width = 0;
|
||||
int ascent = 0;
|
||||
int descent = 0;
|
||||
lyxfont::buttonText(label, labelfont, width, ascent, descent);
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return descent;
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ int InsetCollapsable::width_collapsed() const
|
||||
int width;
|
||||
int ascent;
|
||||
int descent;
|
||||
lyxfont::buttonText(label, labelfont, width, ascent, descent);
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return width + (2*TEXT_TO_INSET_OFFSET);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxfont.h"
|
||||
#include "gettext.h"
|
||||
#include "inseterror.h"
|
||||
@ -36,7 +36,7 @@ int InsetError::ascent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
LyXFont efont;
|
||||
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;
|
||||
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;
|
||||
efont.setSize(font.size()).decSize();
|
||||
return 6 + lyxfont::width(_("Error"), efont);
|
||||
return 6 + font_metrics::width(_("Error"), efont);
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ TODO Before initial production release:
|
||||
#include "converter.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "lyxrc.h"
|
||||
#include "font.h" // For the lyxfont class.
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
@ -263,13 +263,13 @@ int InsetGraphics::width(BufferView *, LyXFont const & font) const
|
||||
string const justname = OnlyFilename (params().filename);
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||
font_width = lyxfont::width(justname, msgFont);
|
||||
font_width = font_metrics::width(justname, msgFont);
|
||||
}
|
||||
|
||||
string const msg = statusMessage();
|
||||
if (!msg.empty()) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -328,8 +328,8 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
||||
string const justname = OnlyFilename (params().filename);
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||
paint.text(old_x + 8,
|
||||
baseline - lyxfont::maxAscent(msgFont) - 4,
|
||||
paint.text(old_x + 8,
|
||||
baseline - font_metrics::maxAscent(msgFont) - 4,
|
||||
justname, msgFont);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "BufferView.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "language.h"
|
||||
|
||||
using std::ostream;
|
||||
@ -270,13 +270,13 @@ int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
|
||||
int max;
|
||||
if (candisp) {
|
||||
if (ic == ' ')
|
||||
max = lyxfont::ascent('a', font);
|
||||
max = font_metrics::ascent('a', font);
|
||||
else
|
||||
max = lyxfont::ascent(ic, font);
|
||||
if (plusasc)
|
||||
max += (lyxfont::maxAscent(font) + 3) / 3;
|
||||
max = font_metrics::ascent(ic, font);
|
||||
if (plusasc)
|
||||
max += (font_metrics::maxAscent(font) + 3) / 3;
|
||||
} else
|
||||
max = lyxfont::maxAscent(font) + 4;
|
||||
max = font_metrics::maxAscent(font) + 4;
|
||||
return max;
|
||||
}
|
||||
|
||||
@ -285,14 +285,14 @@ int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
int max;
|
||||
if (candisp) {
|
||||
if (ic == ' ')
|
||||
max = lyxfont::descent('a', font);
|
||||
else
|
||||
max = lyxfont::descent(ic, font);
|
||||
if (plusdesc)
|
||||
max += 3;
|
||||
if (ic == ' ')
|
||||
max = font_metrics::descent('a', font);
|
||||
else
|
||||
max = font_metrics::descent(ic, font);
|
||||
if (plusdesc)
|
||||
max += 3;
|
||||
} else
|
||||
max = lyxfont::maxDescent(font) + 4;
|
||||
max = font_metrics::maxDescent(font) + 4;
|
||||
return max;
|
||||
}
|
||||
|
||||
@ -300,21 +300,21 @@ int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
|
||||
int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
if (candisp)
|
||||
return lyxfont::width(ic, font);
|
||||
else
|
||||
return lyxfont::width(contents, font) + 4;
|
||||
return font_metrics::width(ic, font);
|
||||
else
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -388,7 +388,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
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)
|
||||
@ -406,15 +406,15 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
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'
|
||||
@ -429,58 +429,58 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
// now the rest - draw within (x, y, x+wid, y+hg)
|
||||
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;
|
||||
}
|
||||
@ -489,8 +489,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -537,18 +537,18 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -556,8 +556,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "language.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxrc.h"
|
||||
@ -186,13 +186,13 @@ string const InsetQuotes::dispString(Language const * loclang) 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
|
||||
{
|
||||
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) {
|
||||
if (text[i] == ' ')
|
||||
w += lyxfont::width('i', font);
|
||||
w += font_metrics::width('i', font);
|
||||
else if (i == 0 || text[i] != text[i-1])
|
||||
w += lyxfont::width(text[i], font);
|
||||
w += font_metrics::width(text[i], font);
|
||||
else
|
||||
w += lyxfont::width(',', font);
|
||||
w += font_metrics::width(',', font);
|
||||
}
|
||||
|
||||
return w;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "BufferView.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxfont.h"
|
||||
|
||||
@ -37,13 +37,13 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() 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
|
||||
{
|
||||
return lyxfont::maxDescent(font);
|
||||
return font_metrics::maxDescent(font);
|
||||
}
|
||||
|
||||
|
||||
@ -52,30 +52,30 @@ int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
|
||||
switch (kind_) {
|
||||
case HYPHENATION:
|
||||
{
|
||||
int w = lyxfont::width('-', font);
|
||||
if (w > 5)
|
||||
int w = font_metrics::width('-', font);
|
||||
if (w > 5)
|
||||
w -= 2; // to make it look shorter
|
||||
return w;
|
||||
}
|
||||
case LIGATURE_BREAK:
|
||||
{
|
||||
return lyxfont::width('|', font);
|
||||
return font_metrics::width('|', font);
|
||||
}
|
||||
case END_OF_SENTENCE:
|
||||
{
|
||||
return lyxfont::width('.', font);
|
||||
return font_metrics::width('.', font);
|
||||
}
|
||||
case LDOTS:
|
||||
{
|
||||
return lyxfont::width(". . .", font);
|
||||
return font_metrics::width(". . .", font);
|
||||
}
|
||||
case MENU_SEPARATOR:
|
||||
{
|
||||
return lyxfont::width(" x ", font);
|
||||
return font_metrics::width(" x ", font);
|
||||
}
|
||||
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:
|
||||
{
|
||||
// A triangle the width and height of an 'x'
|
||||
int w = lyxfont::width('x', font);
|
||||
int ox = lyxfont::width(' ', font) + int(x);
|
||||
int h = lyxfont::ascent('x', font);
|
||||
int w = font_metrics::width('x', font);
|
||||
int ox = font_metrics::width(' ', font) + int(x);
|
||||
int h = font_metrics::ascent('x', font);
|
||||
int xp[4], yp[4];
|
||||
|
||||
xp[0] = ox; yp[0] = baseline;
|
||||
@ -138,7 +138,7 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
|
||||
case PROTECTED_SEPARATOR:
|
||||
{
|
||||
float w = width(bv, font);
|
||||
int h = lyxfont::ascent('x', font);
|
||||
int h = font_metrics::ascent('x', font);
|
||||
int xp[4], yp[4];
|
||||
|
||||
xp[0] = int(x);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "debug.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxtext.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "insets/insettext.h"
|
||||
@ -1428,10 +1428,10 @@ void InsetTabular::toggleInsetCursor(BufferView * bv)
|
||||
}
|
||||
|
||||
LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
|
||||
if (isCursorVisible())
|
||||
bv->hideLockedInsetCursor();
|
||||
else
|
||||
@ -1446,9 +1446,9 @@ void InsetTabular::showInsetCursor(BufferView * bv, bool show)
|
||||
return;
|
||||
if (!isCursorVisible()) {
|
||||
LyXFont font; // = GetFont(par, cursor.pos);
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
|
||||
if (show)
|
||||
bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
|
||||
@ -1476,10 +1476,11 @@ void InsetTabular::fitInsetCursor(BufferView * bv) const
|
||||
return;
|
||||
}
|
||||
LyXFont font;
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
resetPos(bv);
|
||||
|
||||
if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
|
||||
need_update = FULL;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "lyxtext.h"
|
||||
#include "lyxcursor.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "LColor.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxrc.h"
|
||||
@ -1808,9 +1808,9 @@ void InsetText::toggleInsetCursor(BufferView * bv)
|
||||
|
||||
LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
|
||||
if (isCursorVisible())
|
||||
bv->hideLockedInsetCursor();
|
||||
else
|
||||
@ -1828,9 +1828,9 @@ void InsetText::showInsetCursor(BufferView * bv, bool show)
|
||||
if (!isCursorVisible()) {
|
||||
LyXFont const font =
|
||||
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
|
||||
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
|
||||
if (show)
|
||||
@ -1859,9 +1859,9 @@ void InsetText::fitInsetCursor(BufferView * bv) const
|
||||
}
|
||||
LyXFont const font =
|
||||
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
|
||||
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const desc = lyxfont::maxDescent(font);
|
||||
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const desc = font_metrics::maxDescent(font);
|
||||
|
||||
if (bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc))
|
||||
need_update |= FULL;
|
||||
|
@ -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>
|
||||
|
||||
* math_autocorrect.C: include vector and add a using statement.
|
||||
@ -8,7 +17,6 @@
|
||||
* math_cursor.[Ch]: subsequent changes
|
||||
* math_parser.C: somewhat better error reporting
|
||||
|
||||
|
||||
2002-05-23 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* formula.C:
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "Lsstream.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_charinset.h"
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "gettext.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "debug.h"
|
||||
@ -136,7 +136,7 @@ int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
|
||||
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
|
||||
{
|
||||
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);
|
||||
|
||||
// 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;
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "math_charinset.h"
|
||||
#include "LColor.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "font.h"
|
||||
#include "debug.h"
|
||||
#include "math_support.h"
|
||||
#include "math_mathmlstream.h"
|
||||
@ -67,7 +67,7 @@ void MathCharInset::metrics(MathMetricsInfo const & mi) const
|
||||
whichFont(font_, code_, mi);
|
||||
mathed_char_dim(font_, char_, ascent_, descent_, width_);
|
||||
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;
|
||||
if (isBinaryOp(char_, code_))
|
||||
x += lyxfont::width(' ', font_);
|
||||
x += font_metrics::width(' ', font_);
|
||||
drawChar(pain, font_, x, y, char_);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#endif
|
||||
|
||||
#include "math_funcinset.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "math_support.h"
|
||||
#include "math_mathmlstream.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "math_support.h"
|
||||
#include "lyxfont.h"
|
||||
#include "FontLoader.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "math_cursor.h"
|
||||
#include "math_defs.h"
|
||||
#include "math_inset.h"
|
||||
@ -559,27 +559,27 @@ deco_struct const * search_deco(string const & name)
|
||||
void mathed_char_dim(LyXFont const & font,
|
||||
unsigned char c, int & asc, int & des, int & wid)
|
||||
{
|
||||
des = lyxfont::descent(c, font);
|
||||
asc = lyxfont::ascent(c, font);
|
||||
des = font_metrics::descent(c, font);
|
||||
asc = font_metrics::ascent(c, font);
|
||||
wid = mathed_char_width(font, 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)
|
||||
{
|
||||
return lyxfont::descent(c, font);
|
||||
return font_metrics::descent(c, font);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||
des = max(des, lyxfont::descent(*it, font));
|
||||
asc = max(asc, lyxfont::ascent(*it, font));
|
||||
des = max(des, font_metrics::descent(*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)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ int mathed_string_descent(LyXFont const & font, string const & s)
|
||||
{
|
||||
int des = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -734,8 +734,8 @@ void smallerStyleFrac(MathMetricsInfo & st)
|
||||
|
||||
void math_font_max_dim(LyXFont const & font, int & asc, int & des)
|
||||
{
|
||||
asc = lyxfont::maxAscent(font);
|
||||
des = lyxfont::maxDescent(font);
|
||||
asc = font_metrics::maxAscent(font);
|
||||
des = font_metrics::maxDescent(font);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#endif
|
||||
|
||||
#include "math_unknowninset.h"
|
||||
#include "font.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "math_support.h"
|
||||
#include "math_mathmlstream.h"
|
||||
|
158
src/text.C
158
src/text.C
@ -19,18 +19,16 @@
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
#include "lyxrc.h"
|
||||
#include "encoding.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/screen.h"
|
||||
#include "tracer.h"
|
||||
#include "font.h"
|
||||
#include "encoding.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "BufferView.h"
|
||||
#include "language.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "font.h"
|
||||
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
@ -214,7 +212,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
|
||||
Encodings::IsComposeChar_hebrew(c))
|
||||
return 0;
|
||||
}
|
||||
return lyxfont::width(c, font);
|
||||
return font_metrics::width(c, font);
|
||||
|
||||
} else if (IsHfillChar(c)) {
|
||||
return 3; /* Because of the representation
|
||||
@ -236,7 +234,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
|
||||
c = ' ';
|
||||
else if (IsNewlineChar(c))
|
||||
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
|
||||
LyXFont const font = getFont(p.bv->buffer(), p.row->par(), pos);
|
||||
int const wid = lyxfont::width('n', font);
|
||||
int const asc = lyxfont::maxAscent(font);
|
||||
int const wid = font_metrics::width('n', font);
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const y = p.yo + p.row->baseline();
|
||||
int xp[3];
|
||||
int yp[3];
|
||||
@ -548,7 +546,7 @@ void LyXText::drawHebrewComposeChar(DrawRowParams & p, pos_type & vpos)
|
||||
++vpos;
|
||||
|
||||
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;
|
||||
|
||||
for (pos_type i = pos-1; i >= 0; --i) {
|
||||
@ -583,7 +581,7 @@ void LyXText::drawArabicComposeChar(DrawRowParams & p, pos_type & vpos)
|
||||
++vpos;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -718,8 +716,8 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
string parindent = layout.parindent;
|
||||
|
||||
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.
|
||||
// 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) {
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout.leftmargin.empty()) {
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
x += font_metrics::signedWidth(layout.leftmargin,
|
||||
tclass.defaultfont());
|
||||
}
|
||||
if (!row->par()->getLabelstring().empty()) {
|
||||
x += lyxfont::signedWidth(layout.labelindent,
|
||||
x += font_metrics::signedWidth(layout.labelindent,
|
||||
labelfont);
|
||||
x += lyxfont::width(row->par()->getLabelstring(),
|
||||
x += font_metrics::width(row->par()->getLabelstring(),
|
||||
labelfont);
|
||||
x += lyxfont::width(layout.labelsep, labelfont);
|
||||
x += font_metrics::width(layout.labelsep, labelfont);
|
||||
}
|
||||
break;
|
||||
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->par()->getLabelWidthString().empty()) {
|
||||
x += lyxfont::width(row->par()->getLabelWidthString(),
|
||||
x += font_metrics::width(row->par()->getLabelWidthString(),
|
||||
labelfont);
|
||||
x += lyxfont::width(layout.labelsep, labelfont);
|
||||
x += font_metrics::width(layout.labelsep, labelfont);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MARGIN_STATIC:
|
||||
x += lyxfont::signedWidth(layout.leftmargin, tclass.defaultfont()) * 4
|
||||
x += font_metrics::signedWidth(layout.leftmargin, tclass.defaultfont()) * 4
|
||||
/ (row->par()->getDepth() + 4);
|
||||
break;
|
||||
case MARGIN_FIRST_DYNAMIC:
|
||||
if (layout.labeltype == LABEL_MANUAL) {
|
||||
if (row->pos() >= beginningOfMainBody(bview->buffer(), row->par())) {
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
x += font_metrics::signedWidth(layout.leftmargin,
|
||||
labelfont);
|
||||
} else {
|
||||
x += lyxfont::signedWidth(layout.labelindent,
|
||||
x += font_metrics::signedWidth(layout.labelindent,
|
||||
labelfont);
|
||||
}
|
||||
} else if (row->pos()
|
||||
@ -809,16 +807,16 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
|| (layout.labeltype == LABEL_STATIC
|
||||
&& layout.latextype == LATEX_ENVIRONMENT
|
||||
&& ! row->par()->isFirstInSequence())) {
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
x += font_metrics::signedWidth(layout.leftmargin,
|
||||
labelfont);
|
||||
} else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
|
||||
&& layout.labeltype != LABEL_BIBLIO
|
||||
&& layout.labeltype !=
|
||||
LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
x += lyxfont::signedWidth(layout.labelindent,
|
||||
x += font_metrics::signedWidth(layout.labelindent,
|
||||
labelfont);
|
||||
x += lyxfont::width(layout.labelsep, labelfont);
|
||||
x += lyxfont::width(row->par()->getLabelstring(),
|
||||
x += font_metrics::width(layout.labelsep, labelfont);
|
||||
x += font_metrics::width(row->par()->getLabelstring(),
|
||||
labelfont);
|
||||
}
|
||||
break;
|
||||
@ -841,9 +839,9 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
if (tmprow->fill() < minfill)
|
||||
minfill = tmprow->fill();
|
||||
}
|
||||
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
tclass.defaultfont());
|
||||
|
||||
x += font_metrics::signedWidth(layout.leftmargin,
|
||||
tclass.defaultfont());
|
||||
x += minfill;
|
||||
}
|
||||
break;
|
||||
@ -882,7 +880,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
&& (row->par()->layout() != tclass.defaultLayoutName() ||
|
||||
bview->buffer()->params.paragraph_separation ==
|
||||
BufferParams::PARSEP_INDENT)) {
|
||||
x += lyxfont::signedWidth(parindent,
|
||||
x += font_metrics::signedWidth(parindent,
|
||||
tclass.defaultfont());
|
||||
} else if (layout.labeltype == LABEL_BIBLIO) {
|
||||
// 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()];
|
||||
|
||||
int x = LYX_PAPER_MARGIN
|
||||
+ lyxfont::signedWidth(tclass.rightmargin(),
|
||||
+ font_metrics::signedWidth(tclass.rightmargin(),
|
||||
tclass.defaultfont());
|
||||
|
||||
// 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;
|
||||
x += lyxfont::signedWidth(layout.rightmargin, tclass.defaultfont())
|
||||
x += font_metrics::signedWidth(layout.rightmargin, tclass.defaultfont())
|
||||
* 4 / (row->par()->getDepth() + 4);
|
||||
return x;
|
||||
}
|
||||
@ -1057,7 +1055,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
|
||||
}
|
||||
++i;
|
||||
if (i == main_body) {
|
||||
x += lyxfont::width(layout.labelsep,
|
||||
x += font_metrics::width(layout.labelsep,
|
||||
getLabelFont(bview->buffer(), par));
|
||||
if (par->isLineSeparator(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) {
|
||||
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))
|
||||
w -= singleWidth(bview, row->par(), i - 1);
|
||||
int left_margin = labelEnd(bview, row);
|
||||
@ -1128,7 +1126,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
|
||||
++i;
|
||||
}
|
||||
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))
|
||||
w -= singleWidth(bview, row->par(), last);
|
||||
int const left_margin = labelEnd(bview, row);
|
||||
@ -1168,7 +1166,7 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
|
||||
|
||||
int fill = 0;
|
||||
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,
|
||||
0);
|
||||
}
|
||||
@ -1339,12 +1337,13 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
}
|
||||
//lyxerr << "spacing_val = " << spacing_val << endl;
|
||||
|
||||
int maxasc = int(lyxfont::maxAscent(font) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
int maxdesc = int(lyxfont::maxDescent(font) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
int maxasc = int(font_metrics::maxAscent(font) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
int maxdesc = int(font_metrics::maxDescent(font) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
|
||||
pos_type const pos_end = rowLast(row_ptr);
|
||||
int labeladdon = 0;
|
||||
int maxwidth = 0;
|
||||
@ -1377,8 +1376,8 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
if (maxsize > font.size()) {
|
||||
font.setSize(maxsize);
|
||||
|
||||
asc = lyxfont::maxAscent(font);
|
||||
desc = lyxfont::maxDescent(font);
|
||||
asc = font_metrics::maxAscent(font);
|
||||
desc = font_metrics::maxDescent(font);
|
||||
if (asc > maxasc)
|
||||
maxasc = asc;
|
||||
if (desc > maxdesc)
|
||||
@ -1422,9 +1421,9 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
// do not forget the DTP-lines!
|
||||
// there height depends on the font of the nearest character
|
||||
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
|
||||
if (firstpar->params().pagebreakTop())
|
||||
maxasc += 3 * defaultHeight();
|
||||
@ -1441,10 +1440,10 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
spacing_val = bview->buffer()->params.spacing.getValue();
|
||||
}
|
||||
|
||||
labeladdon = int(lyxfont::maxDescent(labelfont) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val)
|
||||
+ int(lyxfont::maxAscent(labelfont) *
|
||||
labeladdon = int(font_metrics::maxDescent(labelfont) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val)
|
||||
+ int(font_metrics::maxAscent(labelfont) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
}
|
||||
@ -1464,10 +1463,10 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
}
|
||||
|
||||
labeladdon = int(
|
||||
(lyxfont::maxAscent(labelfont) *
|
||||
(font_metrics::maxAscent(labelfont) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val)
|
||||
+(lyxfont::maxDescent(labelfont) *
|
||||
+(font_metrics::maxDescent(labelfont) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val)
|
||||
+ layout.topsep * defaultHeight()
|
||||
@ -1532,8 +1531,8 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
// do not forget the DTP-lines!
|
||||
// there height depends on the font of the nearest character
|
||||
if (firstpar->params().lineBottom())
|
||||
maxdesc += 2 * lyxfont::ascent('x',
|
||||
getFont(bview->buffer(),
|
||||
maxdesc += 2 * font_metrics::ascent('x',
|
||||
getFont(bview->buffer(),
|
||||
par,
|
||||
max(pos_type(0), par->size() - 1)));
|
||||
|
||||
@ -2219,7 +2218,7 @@ void LyXText::prepareToPrint(BufferView * bview,
|
||||
if (main_body > 0 &&
|
||||
(main_body - 1 > last ||
|
||||
!row->par()->isLineSeparator(main_body - 1))) {
|
||||
x += lyxfont::width(layout.labelsep,
|
||||
x += font_metrics::width(layout.labelsep,
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (main_body - 1 <= last)
|
||||
x += fill_label_hfill;
|
||||
@ -3161,8 +3160,7 @@ void LyXText::paintRowSelection(DrawRowParams & p)
|
||||
[par->layout()];
|
||||
LyXFont const lfont = getLabelFont(buffer, par);
|
||||
|
||||
|
||||
tmpx += p.label_hfill + lyxfont::width(layout.labelsep, lfont);
|
||||
tmpx += p.label_hfill + font_metrics::width(layout.labelsep, lfont);
|
||||
|
||||
if (par->isLineSeparator(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;
|
||||
font.decSize();
|
||||
int const min_size = max(3 * arrow_size,
|
||||
lyxfont::maxAscent(font)
|
||||
+ lyxfont::maxDescent(font));
|
||||
font_metrics::maxAscent(font)
|
||||
+ font_metrics::maxDescent(font));
|
||||
|
||||
if (vsp.length().len().value() < 0.0)
|
||||
return min_size;
|
||||
@ -3314,7 +3312,7 @@ int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
|
||||
|
||||
LyXFont font;
|
||||
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,
|
||||
start + ((end - start) / 2) + d,
|
||||
@ -3365,7 +3363,7 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
||||
|
||||
LyXFont pb_font;
|
||||
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,
|
||||
_("Page Break (top)"), pb_font,
|
||||
backgroundColor(),
|
||||
@ -3406,7 +3404,7 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
||||
// draw a top line
|
||||
if (parparams.lineTop()) {
|
||||
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;
|
||||
|
||||
@ -3445,12 +3443,12 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if (is_rtl) {
|
||||
x = ww - leftMargin(p.bv, p.row) -
|
||||
lyxfont::width(str, font);
|
||||
font_metrics::width(str, font);
|
||||
}
|
||||
|
||||
p.pain->text(int(x),
|
||||
@ -3461,10 +3459,10 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
||||
} else {
|
||||
if (is_rtl) {
|
||||
x = ww - leftMargin(p.bv, p.row)
|
||||
+ lyxfont::width(layout.labelsep, font);
|
||||
+ font_metrics::width(layout.labelsep, font);
|
||||
} else {
|
||||
x = p.x - lyxfont::width(layout.labelsep, font)
|
||||
- lyxfont::width(str, font);
|
||||
x = p.x - font_metrics::width(layout.labelsep, font)
|
||||
- font_metrics::width(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(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val
|
||||
int(font_metrics::maxDescent(font) * layout.spacing.getValue() * spacing_val
|
||||
+ (layout.labelbottomsep * defaultHeight()));
|
||||
|
||||
float x = p.x;
|
||||
if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
x = ((is_rtl ? leftMargin(p.bv, p.row) : p.x)
|
||||
+ ww - rightMargin(buffer, p.row)) / 2;
|
||||
x -= lyxfont::width(str, font) / 2;
|
||||
x -= font_metrics::width(str, font) / 2;
|
||||
} else if (is_rtl) {
|
||||
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.row->ascent_of_text() - maxdesc,
|
||||
@ -3510,9 +3508,9 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
||||
float x;
|
||||
if (is_rtl) {
|
||||
x = ww - leftMargin(p.bv, p.row)
|
||||
+ lyxfont::width(layout.labelsep, font);
|
||||
+ font_metrics::width(layout.labelsep, font);
|
||||
} 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->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 a = 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,
|
||||
_("Page Break (bottom)"),
|
||||
pb_font, backgroundColor(), backgroundColor());
|
||||
@ -3564,7 +3562,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
|
||||
// draw a bottom line
|
||||
if (parparams.lineBottom()) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int const asc = lyxfont::ascent('x',
|
||||
int const asc = font_metrics::ascent('x',
|
||||
getFont(buffer, par,
|
||||
max(pos_type(0), par->size() - 1)));
|
||||
|
||||
@ -3588,7 +3586,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
|
||||
case END_LABEL_FILLED_BOX:
|
||||
{
|
||||
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 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();
|
||||
font = getLabelFont(buffer, par);
|
||||
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();
|
||||
p.pain->text(x, p.yo + p.row->baseline(), str, font);
|
||||
break;
|
||||
@ -3648,7 +3646,7 @@ void LyXText::paintRowText(DrawRowParams & p)
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
if (main_body > 0 && c == main_body-1) {
|
||||
tmpx += fill_label_hfill +
|
||||
lyxfont::width(layout.labelsep,
|
||||
font_metrics::width(layout.labelsep,
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(main_body - 1))
|
||||
tmpx -= singleWidth(bview, row->par(), main_body-1);
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "font.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "debug.h"
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
@ -2145,7 +2145,7 @@ float LyXText::getCursorX(BufferView * bview, Row * row,
|
||||
pos_type pos = vis2log(vpos);
|
||||
if (main_body > 0 && pos == main_body - 1) {
|
||||
x += fill_label_hfill +
|
||||
lyxfont::width(textclasslist[
|
||||
font_metrics::width(textclasslist[
|
||||
bview->buffer()->params.textclass][
|
||||
row->par()->layout()]
|
||||
.labelsep,
|
||||
|
Loading…
Reference in New Issue
Block a user