#include "commandtags.h"
#include "lyxfunc.h"
#include "debug.h"
-#include "font.h"
#include "bufferview_funcs.h"
#include "TextCache.h"
#include "bufferlist.h"
+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
#pragma implementation
#endif
-#include <X11/Xlib.h>
-
#include "debug.h"
#include "LColor.h"
#include "support/LAssert.h"
encoding.h \
exporter.C \
exporter.h \
- font.C \
- font.h \
gettext.C \
gettext.h \
importer.C \
+++ /dev/null
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "support/lstrings.h"
-#include "font.h"
-#include "FontLoader.h"
-#include "lyxrc.h"
-#include "encoding.h"
-#include "language.h"
-
-#include <boost/scoped_array.hpp>
-
-namespace {
-
-inline
-XFontStruct * getXFontstruct(LyXFont const & f)
-{
- return fontloader.load(f.family(), f.series(),
- f.realShape(), f.size());
-}
-
-
-inline
-XID getFontID(LyXFont const & f)
-{
- return getXFontstruct(f)->fid;
-}
-
-} // namespace anon
-
-int lyxfont::maxAscent(LyXFont const & f)
-{
- return getXFontstruct(f)->ascent;
-}
-
-
-int lyxfont::maxDescent(LyXFont const & f)
-{
- return getXFontstruct(f)->descent;
-}
-
-
-int lyxfont::ascent(char c, LyXFont const & f)
-{
- XFontStruct * finfo = getXFontstruct(f);
- unsigned int uc = static_cast<unsigned char>(c);
- if (finfo->per_char
- && uc >= finfo->min_char_or_byte2
- && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
- return finfo->per_char[uc - finfo->min_char_or_byte2].ascent;
- else
- return finfo->ascent;
-}
-
-
-int lyxfont::descent(char c, LyXFont const & f)
-{
- XFontStruct * finfo = getXFontstruct(f);
- unsigned int uc = static_cast<unsigned char>(c);
- if (finfo->per_char
- && uc >= finfo->min_char_or_byte2
- && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
- return finfo->per_char[uc - finfo->min_char_or_byte2].descent;
- else
- return finfo->descent;
-}
-
-
-int lyxfont::lbearing(char c, LyXFont const & f)
-{
- XFontStruct * finfo = getXFontstruct(f);
- unsigned int uc = static_cast<unsigned char>(c);
- if (finfo->per_char
- && uc >= finfo->min_char_or_byte2
- && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
- return finfo->per_char[uc - finfo->min_char_or_byte2].lbearing;
- else
- return 0;
-}
-
-
-int lyxfont::rbearing(char c, LyXFont const & f)
-{
- XFontStruct * finfo = getXFontstruct(f);
- unsigned int uc = static_cast<unsigned char>(c);
- if (finfo->per_char
- && uc >= finfo->min_char_or_byte2
- && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
- return finfo->per_char[uc - finfo->min_char_or_byte2].rbearing;
- else
- return width(c, f);
-}
-
-
-int lyxfont::width(char const * s, size_t n, LyXFont const & f)
-{
- if (!lyxrc.use_gui)
- return n;
-
- if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
- boost::scoped_array<XChar2b> xs(new XChar2b[n]);
- Encoding const * encoding = f.language()->encoding();
- LyXFont font(f);
- if (f.isSymbolFont()) {
-#ifdef USE_UNICODE_FOR_SYMBOLS
- font.setFamily(LyXFont::ROMAN_FAMILY);
- font.setShape(LyXFont::UP_SHAPE);
-#endif
- encoding = encodings.symbol_encoding();
- }
- for (size_t i = 0; i < n; ++i) {
- Uchar c = encoding->ucs(s[i]);
- xs[i].byte1 = c >> 8;
- xs[i].byte2 = c & 0xff;
- }
- int result = width(xs.get(), n, font);
- return result;
- }
-
- if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
- return ::XTextWidth(getXFontstruct(f), s, n);
- } else {
- // emulate smallcaps since X doesn't support this
- unsigned int result = 0;
- LyXFont smallfont(f);
- smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
- for (size_t i = 0; i < n; ++i) {
- char const c = uppercase(s[i]);
- if (c != s[i]) {
- result += ::XTextWidth(getXFontstruct(smallfont), &c, 1);
- } else {
- result += ::XTextWidth(getXFontstruct(f), &c, 1);
- }
- }
- return result;
- }
-}
-
-
-int lyxfont::signedWidth(string const & s, LyXFont const & f)
-{
- if (s.empty())
- return 0;
- if (s[0] == '-')
- return -width(s.substr(1, s.length() - 1), f);
- else
- return width(s, f);
-}
-
-
-//int lyxfont::width(wstring const & s, int n, LyXFont const & f)
-int lyxfont::width(XChar2b const * s, int n, LyXFont const & f)
-{
- if (!lyxrc.use_gui)
- return n;
-
- if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
- return ::XTextWidth16(getXFontstruct(f), s, n);
- } else {
- // emulate smallcaps since X doesn't support this
- unsigned int result = 0;
- static XChar2b c;
- LyXFont smallfont(f);
- smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
- for (int i = 0; i < n; ++i) {
- if (s[i].byte1)
- c = s[i];
- else {
- c.byte1 = s[i].byte1;
- c.byte2 = uppercase(s[i].byte2);
- }
- if (c.byte2 != s[i].byte2) {
- result += ::XTextWidth16(getXFontstruct(smallfont), &c, 1);
- } else {
- result += ::XTextWidth16(getXFontstruct(f), &s[i], 1);
- }
- }
- return result;
- }
-}
-
-int lyxfont::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)
-{
- return ::XTextWidth16(getXFontstruct(f), str, count);
-}
-
-
-void lyxfont::XSetFont(Display * display, GC gc, LyXFont const & f)
-{
- ::XSetFont(display, gc, getFontID(f));
-}
-
-
-void lyxfont::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;
-}
-
-
-
-void lyxfont::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;
-}
-
-
-//} // end of namespace font
-//} // end of namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
-
-#ifndef FONT_H
-#define FONT_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <X11/Xlib.h>
-
-#include "LString.h"
-
-class LyXFont;
-
-//namespace lyx {
-//namespace font {
-///
-struct 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);
- }
- ///
- //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
-
-// import into namespace lyx
-//using font::maxAscent;
-//using font::maxDescent;
-//using font::ascent;
-//using font::descent;
-//using font::lbearing;
-//using font::rbearing;
-//using font::width;
-//using font::signedWidth;
-//using font::XTextWidth;
-//using font::XSetFont;
-
-//} // end of namespace lyx
-
-#endif
+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:
LyXView.h \
WorkArea.C \
WorkArea.h \
+ font_metrics.h \
screen.C \
screen.h
#include "Painter.h"
#include "lyxfont.h"
#include "WorkArea.h"
-#include "font.h"
+#include "font_metrics.h"
int PainterBase::paperMargin() const
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);
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;
--- /dev/null
+//// temporary
+
+#include "xforms/xfont_metrics.h"
#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"
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);
}
}
+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)
XFormsView.h \
XPainter.C \
XPainter.h \
+ xfont_metrics.C \
+ xfont_metrics.h \
xforms_helpers.C \
xforms_helpers.h \
xforms_resize.C \
#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"
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);
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;
{
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);
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;
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
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "support/lstrings.h"
+#include "xfont_metrics.h"
+#include "FontLoader.h"
+#include "lyxrc.h"
+#include "encoding.h"
+#include "language.h"
+
+#include <boost/scoped_array.hpp>
+
+namespace {
+
+inline
+XFontStruct * getXFontstruct(LyXFont const & f)
+{
+ return fontloader.load(f.family(), f.series(),
+ f.realShape(), f.size());
+}
+
+
+inline
+XID getFontID(LyXFont const & f)
+{
+ return getXFontstruct(f)->fid;
+}
+
+} // namespace anon
+
+int font_metrics::maxAscent(LyXFont const & f)
+{
+ return getXFontstruct(f)->ascent;
+}
+
+
+int font_metrics::maxDescent(LyXFont const & f)
+{
+ return getXFontstruct(f)->descent;
+}
+
+
+int font_metrics::ascent(char c, LyXFont const & f)
+{
+ XFontStruct * finfo = getXFontstruct(f);
+ unsigned int uc = static_cast<unsigned char>(c);
+ if (finfo->per_char
+ && uc >= finfo->min_char_or_byte2
+ && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
+ return finfo->per_char[uc - finfo->min_char_or_byte2].ascent;
+ else
+ return finfo->ascent;
+}
+
+
+int font_metrics::descent(char c, LyXFont const & f)
+{
+ XFontStruct * finfo = getXFontstruct(f);
+ unsigned int uc = static_cast<unsigned char>(c);
+ if (finfo->per_char
+ && uc >= finfo->min_char_or_byte2
+ && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
+ return finfo->per_char[uc - finfo->min_char_or_byte2].descent;
+ else
+ return finfo->descent;
+}
+
+
+int font_metrics::lbearing(char c, LyXFont const & f)
+{
+ XFontStruct * finfo = getXFontstruct(f);
+ unsigned int uc = static_cast<unsigned char>(c);
+ if (finfo->per_char
+ && uc >= finfo->min_char_or_byte2
+ && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
+ return finfo->per_char[uc - finfo->min_char_or_byte2].lbearing;
+ else
+ return 0;
+}
+
+
+int font_metrics::rbearing(char c, LyXFont const & f)
+{
+ XFontStruct * finfo = getXFontstruct(f);
+ unsigned int uc = static_cast<unsigned char>(c);
+ if (finfo->per_char
+ && uc >= finfo->min_char_or_byte2
+ && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
+ return finfo->per_char[uc - finfo->min_char_or_byte2].rbearing;
+ else
+ return width(c, 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;
+
+ if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
+ boost::scoped_array<XChar2b> xs(new XChar2b[n]);
+ Encoding const * encoding = f.language()->encoding();
+ LyXFont font(f);
+ if (f.isSymbolFont()) {
+#ifdef USE_UNICODE_FOR_SYMBOLS
+ font.setFamily(LyXFont::ROMAN_FAMILY);
+ font.setShape(LyXFont::UP_SHAPE);
+#endif
+ encoding = encodings.symbol_encoding();
+ }
+ for (size_t i = 0; i < n; ++i) {
+ Uchar c = encoding->ucs(s[i]);
+ xs[i].byte1 = c >> 8;
+ xs[i].byte2 = c & 0xff;
+ }
+ int result = width(xs.get(), n, font);
+ return result;
+ }
+
+ if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+ return ::XTextWidth(getXFontstruct(f), s, n);
+ } else {
+ // emulate smallcaps since X doesn't support this
+ unsigned int result = 0;
+ LyXFont smallfont(f);
+ smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+ for (size_t i = 0; i < n; ++i) {
+ char const c = uppercase(s[i]);
+ if (c != s[i]) {
+ result += ::XTextWidth(getXFontstruct(smallfont), &c, 1);
+ } else {
+ result += ::XTextWidth(getXFontstruct(f), &c, 1);
+ }
+ }
+ return result;
+ }
+}
+
+
+int font_metrics::signedWidth(string const & s, LyXFont const & f)
+{
+ if (s.empty())
+ return 0;
+ if (s[0] == '-')
+ return -width(s.substr(1, s.length() - 1), f);
+ else
+ return width(s, 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;
+
+ if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+ return ::XTextWidth16(getXFontstruct(f), s, n);
+ } else {
+ // emulate smallcaps since X doesn't support this
+ unsigned int result = 0;
+ static XChar2b c;
+ LyXFont smallfont(f);
+ smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+ for (int i = 0; i < n; ++i) {
+ if (s[i].byte1)
+ c = s[i];
+ else {
+ c.byte1 = s[i].byte1;
+ c.byte2 = uppercase(s[i].byte2);
+ }
+ if (c.byte2 != s[i].byte2) {
+ result += ::XTextWidth16(getXFontstruct(smallfont), &c, 1);
+ } else {
+ result += ::XTextWidth16(getXFontstruct(f), &s[i], 1);
+ }
+ }
+ return result;
+ }
+}
+
+int font_metrics::XTextWidth(LyXFont const & f, char const * str, int count)
+{
+ return ::XTextWidth(getXFontstruct(f), str, count);
+}
+
+
+int font_metrics::XTextWidth16(LyXFont const & f, XChar2b const * str, int count)
+{
+ return ::XTextWidth16(getXFontstruct(f), str, count);
+}
+
+
+void font_metrics::XSetFont(Display * display, GC gc, LyXFont const & f)
+{
+ ::XSetFont(display, gc, getFontID(f));
+}
+
+
+void font_metrics::rectText(string const & str, LyXFont const & font,
+ int & width, int & ascent, int & descent)
+{
+ static int const d = 2;
+ width = font_metrics::width(str, font) + d * 2 + 2;
+ ascent = font_metrics::maxAscent(font) + d;
+ descent = font_metrics::maxDescent(font) + d;
+}
+
+
+
+void font_metrics::buttonText(string const & str, LyXFont const & font,
+ int & width, int & ascent, int & descent)
+{
+ static int const d = 3;
+
+ width = font_metrics::width(str, font) + d * 2 + 2;
+ ascent = font_metrics::maxAscent(font) + d;
+ descent = font_metrics::maxDescent(font) + d;
+}
+
+
+//} // end of namespace font
+//} // end of namespace lyx
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifndef FONT_H
+#define FONT_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <X11/Xlib.h>
+
+#include "LString.h"
+
+class LyXFont;
+
+namespace font_metrics {
+//namespace lyx {
+//namespace font {
+///
+//istruct lyxfont {
+ ///
+ int maxAscent(LyXFont const & f);
+ ///
+ int maxDescent(LyXFont const & f);
+ ///
+ int ascent(char c, LyXFont const & f);
+ ///
+ int descent(char c, LyXFont const & f);
+ ///
+ int lbearing(char c, LyXFont const & f);
+ ///
+ int rbearing(char c, LyXFont const & f);
+ ///
+ int width(char const * s, size_t n, LyXFont const & 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);
+ //}
+ ///
+ int signedWidth(string const & s, LyXFont const & f);
+ ///
+ int XTextWidth(LyXFont const & f, char const * str, int count);
+ ///
+ int width(XChar2b const * s, int n, LyXFont const & f);
+ ///
+ int XTextWidth16(LyXFont const & f, XChar2b const * str, int count);
+ ///
+ void XSetFont(Display * display, GC gc, LyXFont const & f);
+ // A couple of more high-level metrics
+ ///
+ void rectText(string const & str, LyXFont const & font,
+ int & width, int & ascent, int & descent);
+ ///
+ void buttonText(string const & str, LyXFont const & font,
+ int & width, int & ascent, int & descent);
+//};
+}
+
+//} // end of namespace font
+
+// import into namespace lyx
+//using font::maxAscent;
+//using font::maxDescent;
+//using font::ascent;
+//using font::descent;
+//using font::lbearing;
+//using font::rbearing;
+//using font::width;
+//using font::signedWidth;
+//using font::XTextWidth;
+//using font::XSetFont;
+
+//} // end of namespace lyx
+
+#endif
+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)
#include "gettext.h"
#include "lyxtext.h"
#include "lyxrc.h"
-#include "font.h"
+#include "frontends/font_metrics.h"
#include "frontends/LyXView.h"
#include "lyxtextclasslist.h"
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;
#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;
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;
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;
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;
#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"
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;
#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"
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;
}
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;
}
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);
}
#endif
#include "BufferView.h"
-#include "font.h"
+#include "frontends/font_metrics.h"
#include "lyxfont.h"
#include "gettext.h"
#include "inseterror.h"
{
LyXFont efont;
efont.setSize(font.size()).decSize();
- return lyxfont::maxAscent(efont) + 1;
+ return font_metrics::maxAscent(efont) + 1;
}
{
LyXFont efont;
efont.setSize(font.size()).decSize();
- return lyxfont::maxDescent(efont) + 1;
+ return font_metrics::maxDescent(efont) + 1;
}
{
LyXFont efont;
efont.setSize(font.size()).decSize();
- return 6 + lyxfont::width(_("Error"), efont);
+ return 6 + font_metrics::width(_("Error"), efont);
}
#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"
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);
}
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);
}
#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;
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;
}
{
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;
}
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);
}
int y;
if (plusasc) {
// mark at the top
- hg = lyxfont::maxDescent(font);
+ hg = font_metrics::maxDescent(font);
y = baseline - asc;
if (font.shape() == LyXFont::ITALIC_SHAPE)
pain.text(int(x), baseline, ic, font);
if (remdot) {
- int tmpvar = baseline - lyxfont::ascent('i', font);
+ int tmpvar = baseline - font_metrics::ascent('i', font);
float tmpx = 0;
if (font.shape() == LyXFont::ITALIC_SHAPE)
tmpx += (8.0 * hg) / 10.0; // italic
lyxerr[Debug::KEY] << "Removing dot." << endl;
// remove the dot first
pain.fillRectangle(int(x + tmpx), tmpvar, wid,
- lyxfont::ascent('i', font) -
- lyxfont::ascent('x', font) - 1,
+ font_metrics::ascent('i', font) -
+ font_metrics::ascent('x', font) - 1,
backgroundColor());
// the five lines below is a simple hack to
// make the display of accent 'i' and 'j'
// 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;
}
{
LyXFont tmpf(font);
tmpf.decSize().decSize();
- pain.text(int(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0),
- int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0),
+ pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
+ int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
char(0xB0), tmpf);
break;
}
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
- pain.text(int(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font))),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
pain.text(int(x2),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
break;
}
case UMLAUT: // umlaut
{
- pain.text(int(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2),
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - (lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
+ pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
+ baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
'¨', font);
break;
}
{
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
- pain.text(int(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2),
- int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0),
+ pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
+ int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
char(0x5E), tmpf);
break;
}
#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"
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);
}
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;
#include "LaTeXFeatures.h"
#include "BufferView.h"
#include "frontends/Painter.h"
-#include "font.h"
+#include "frontends/font_metrics.h"
#include "lyxlex.h"
#include "lyxfont.h"
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);
}
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);
}
}
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;
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);
#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"
}
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
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);
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;
}
#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"
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
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)
}
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;
+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.
* math_cursor.[Ch]: subsequent changes
* math_parser.C: somewhat better error reporting
-
2002-05-23 John Levon <moz@compsoc.man.ac.uk>
* formula.C:
#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"
#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"
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();
}
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;
#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"
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_);
}
{
//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_);
}
#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"
#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"
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);
}
{
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);
}
{
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;
}
{
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;
}
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);
}
#endif
#include "math_unknowninset.h"
-#include "font.h"
#include "frontends/Painter.h"
#include "math_support.h"
#include "math_mathmlstream.h"
#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"
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
c = ' ';
else if (IsNewlineChar(c))
c = 'n';
- return lyxfont::width(c, font);
+ return font_metrics::width(c, font);
}
{
// 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];
++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) {
++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) {
// 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);
}
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
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()
|| (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;
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;
&& (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
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.
}
//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;
}
}
++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);
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);
++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);
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);
}
}
//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;
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)
// 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();
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);
}
}
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()
// 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)));
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;
[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);
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;
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,
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(),
// 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;
}
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),
} 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);
}
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,
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);
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());
// 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)));
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;
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;
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
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);
}
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);
#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"
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,