This one prepares for GUII font metrics stuff, so ignore the weird
forwarding of frontends/font_metrics.h for now

I got very confused when first looking at font stuff, I think
font_metrics is a much better name for the namespace

OK to apply ?

The good news: there is only the unsigned int ->event_states::button
change to go then insets/ and mathed/ are almost entirely done (this
is a good indication of how far GUII had already got without anybody
noticing)

thanks
john

-- 
"This is playing, not work, therefore it's not a waste of time."
        - Zath
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.241
diff -u -r1.241 BufferView_pimpl.C
--- src/BufferView_pimpl.C      23 May 2002 15:43:25 -0000      1.241
+++ src/BufferView_pimpl.C      23 May 2002 17:40:58 -0000
@@ -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"
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.721
diff -u -r1.721 ChangeLog
--- src/ChangeLog       23 May 2002 15:48:42 -0000      1.721
+++ src/ChangeLog       23 May 2002 17:41:17 -0000
@@ -1,5 +1,16 @@
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
+       * 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-23  John Levon  <[EMAIL PROTECTED]>
+
        * BufferView_pimpl.C:
        * BufferView_pimpl.h:
        * Makefile.am:
Index: src/LColor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LColor.C,v
retrieving revision 1.31
diff -u -r1.31 LColor.C
--- src/LColor.C        21 Mar 2002 17:25:07 -0000      1.31
+++ src/LColor.C        23 May 2002 17:41:17 -0000
@@ -13,8 +13,6 @@
 #pragma implementation
 #endif
 
-#include <X11/Xlib.h>
-
 #include "debug.h"
 #include "LColor.h"
 #include "support/LAssert.h"
Index: src/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.124
diff -u -r1.124 Makefile.am
--- src/Makefile.am     23 May 2002 15:43:25 -0000      1.124
+++ src/Makefile.am     23 May 2002 17:41:20 -0000
@@ -114,8 +114,6 @@
        encoding.h \
        exporter.C \
        exporter.h \
-       font.C \
-       font.h \
        gettext.C \
        gettext.h \
        importer.C \
diff -N src/font.C
--- src/font.C  22 May 2002 01:16:35 -0000      1.23
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,236 +0,0 @@
-/* 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
Index: src/font.h
===================================================================
RCS file: src/font.h
diff -N src/font.h
--- src/font.h  21 Mar 2002 17:25:09 -0000      1.11
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-// -*- 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
diff -u -r1.251 text.C
--- src/text.C  23 May 2002 15:43:23 -0000      1.251
+++ src/text.C  23 May 2002 17:41:48 -0000
@@ -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 @@
                                 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 @@
                c = ' ';
        else if (IsNewlineChar(c))
                c = 'n';
-       return lyxfont::width(c, font);
+       return font_metrics::width(c, font);
 }
 
 
@@ -440,8 +438,8 @@
 {
        // 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 @@
        ++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 @@
        ++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 @@
 
        // 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 @@
        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 @@
        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 @@
                           || (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 @@
                        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 @@
                    && (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 @@
        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 @@
        }
 
        //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 @@
                        }
                        ++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 @@
 
        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 @@
                ++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 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 @@
        }
        //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 @@
        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 @@
                // 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 @@
                                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 @@
                        }
 
                        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 @@
                // 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 @@
                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 @@
                                [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 @@
        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 @@
 
        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 @@
 
                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 @@
        // 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 @@
                                        }
 
                                        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 @@
                        } 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 @@
                        }
 
                        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 @@
                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 @@
                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 @@
        // 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 @@
        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 @@
                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 @@
                        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 @@
 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 @@
                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);
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.230
diff -u -r1.230 text2.C
--- src/text2.C 23 May 2002 12:08:39 -0000      1.230
+++ src/text2.C 23 May 2002 17:41:53 -0000
@@ -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 @@
                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,
diff -u -r1.62 ChangeLog
--- src/frontends/ChangeLog     23 May 2002 15:43:23 -0000      1.62
+++ src/frontends/ChangeLog     23 May 2002 17:41:59 -0000
@@ -1,5 +1,13 @@
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
+       * Makefile.am:
+       * font_metrics.h: add placeholder
+ 
+       * Painter.C:
+       * screen.C: use placeholder
+ 
+2002-05-23  John Levon  <[EMAIL PROTECTED]>
+
        * WorkArea.h:
        * WorkArea.C:
        * Makefile.am: move here
Index: src/frontends/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Makefile.am,v
retrieving revision 1.36
diff -u -r1.36 Makefile.am
--- src/frontends/Makefile.am   23 May 2002 15:43:23 -0000      1.36
+++ src/frontends/Makefile.am   23 May 2002 17:41:59 -0000
@@ -36,5 +36,6 @@
        LyXView.h \
        WorkArea.C \
        WorkArea.h \
+       font_metrics.h \
        screen.C \
        screen.h
Index: src/frontends/Painter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Painter.C,v
retrieving revision 1.1
diff -u -r1.1 Painter.C
--- src/frontends/Painter.C     23 May 2002 09:21:27 -0000      1.1
+++ src/frontends/Painter.C     23 May 2002 17:41:59 -0000
@@ -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 @@
        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 @@
        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;
Index: src/frontends/font_metrics.h
===================================================================
RCS file: src/frontends/font_metrics.h
diff -N src/frontends/font_metrics.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/font_metrics.h        23 May 2002 17:41:59 -0000
@@ -0,0 +1,3 @@
+//// temporary
+
+#include "xforms/xfont_metrics.h"
Index: src/frontends/screen.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v
retrieving revision 1.1
diff -u -r1.1 screen.C
--- src/frontends/screen.C      23 May 2002 15:43:23 -0000      1.1
+++ src/frontends/screen.C      23 May 2002 17:41:59 -0000
@@ -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 @@
                        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);
        }
 }
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.386
diff -u -r1.386 ChangeLog
--- src/frontends/xforms/ChangeLog      23 May 2002 15:43:23 -0000      1.386
+++ src/frontends/xforms/ChangeLog      23 May 2002 17:42:33 -0000
@@ -1,5 +1,12 @@
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
+       * Makefile.am:
+       * XPainter.C:
+       * xfont_metrics.h:
+       * xfont_metrics.C: moved font metrics code
+ 
+2002-05-23  John Levon  <[EMAIL PROTECTED]>
+
        * XFormsView.C:
        * lyxlookup.h:
        * lyxlookup.C:
diff -u -r1.67 Makefile.am
--- src/frontends/xforms/Makefile.am    23 May 2002 15:43:23 -0000      1.67
+++ src/frontends/xforms/Makefile.am    23 May 2002 17:42:36 -0000
@@ -214,6 +214,8 @@
        XFormsView.h \
        XPainter.C \
        XPainter.h \
+       xfont_metrics.C \
+       xfont_metrics.h \
        xforms_helpers.C \
        xforms_helpers.h \
        xforms_resize.C \
Index: src/frontends/xforms/XPainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XPainter.C,v
retrieving revision 1.1
diff -u -r1.1 XPainter.C
--- src/frontends/xforms/XPainter.C     23 May 2002 09:21:27 -0000      1.1
+++ src/frontends/xforms/XPainter.C     23 May 2002 17:42:36 -0000
@@ -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 @@
 
        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 @@
                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 @@
 {
        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 @@
                                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 @@
 
 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
Index: src/frontends/xforms/xfont_metrics.C
===================================================================
RCS file: src/frontends/xforms/xfont_metrics.C
diff -N src/frontends/xforms/xfont_metrics.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/xfont_metrics.C        23 May 2002 17:42:36 -0000
@@ -0,0 +1,249 @@
+/* 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
Index: src/frontends/xforms/xfont_metrics.h
===================================================================
RCS file: src/frontends/xforms/xfont_metrics.h
diff -N src/frontends/xforms/xfont_metrics.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/xfont_metrics.h        23 May 2002 17:42:36 -0000
@@ -0,0 +1,89 @@
+// -*- 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
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.427
diff -u -r1.427 ChangeLog
--- src/insets/ChangeLog        23 May 2002 15:43:22 -0000      1.427
+++ src/insets/ChangeLog        23 May 2002 17:42:47 -0000
@@ -1,5 +1,19 @@
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
+       * 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-23  John Levon  <[EMAIL PROTECTED]>
+
        * insettext.C: screen moved
  
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
Index: src/insets/insetbib.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbib.C,v
retrieving revision 1.86
diff -u -r1.86 insetbib.C
--- src/insets/insetbib.C       23 May 2002 12:08:43 -0000      1.86
+++ src/insets/insetbib.C       23 May 2002 17:42:47 -0000
@@ -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 @@
        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;
Index: src/insets/insetbutton.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbutton.C,v
retrieving revision 1.17
diff -u -r1.17 insetbutton.C
--- src/insets/insetbutton.C    23 May 2002 09:21:28 -0000      1.17
+++ src/insets/insetbutton.C    23 May 2002 17:42:47 -0000
@@ -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 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 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 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;
Index: src/insets/insetcaption.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcaption.C,v
retrieving revision 1.15
diff -u -r1.15 insetcaption.C
--- src/insets/insetcaption.C   23 May 2002 09:21:28 -0000      1.15
+++ src/insets/insetcaption.C   23 May 2002 17:42:47 -0000
@@ -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 @@
        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;
 
Index: src/insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.108
diff -u -r1.108 insetcollapsable.C
--- src/insets/insetcollapsable.C       23 May 2002 09:21:28 -0000      1.108
+++ src/insets/insetcollapsable.C       23 May 2002 17:42:50 -0000
@@ -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 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 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 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);
 }
 
Index: src/insets/inseterror.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inseterror.C,v
retrieving revision 1.41
diff -u -r1.41 inseterror.C
--- src/insets/inseterror.C     23 May 2002 12:08:44 -0000      1.41
+++ src/insets/inseterror.C     23 May 2002 17:42:50 -0000
@@ -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 @@
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return lyxfont::maxAscent(efont) + 1;
+       return font_metrics::maxAscent(efont) + 1;
 }
 
 
@@ -44,7 +44,7 @@
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return lyxfont::maxDescent(efont) + 1;
+       return font_metrics::maxDescent(efont) + 1;
 }
 
 
@@ -52,7 +52,7 @@
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return 6 + lyxfont::width(_("Error"), efont);
+       return 6 + font_metrics::width(_("Error"), efont);
 }
 
 
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.112
diff -u -r1.112 insetgraphics.C
--- src/insets/insetgraphics.C  23 May 2002 12:08:44 -0000      1.112
+++ src/insets/insetgraphics.C  23 May 2002 17:42:53 -0000
@@ -88,7 +88,7 @@
 #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 @@
                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 @@
                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);
                }
 
Index: src/insets/insetlatexaccent.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.C,v
retrieving revision 1.52
diff -u -r1.52 insetlatexaccent.C
--- src/insets/insetlatexaccent.C       23 May 2002 09:21:28 -0000      1.52
+++ src/insets/insetlatexaccent.C       23 May 2002 17:42:53 -0000
@@ -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 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 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::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 @@
                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 @@
                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 @@
                // 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 @@
                {
                        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 @@
                }
                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 @@
                {
                        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;
                }
Index: src/insets/insetquotes.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.C,v
retrieving revision 1.65
diff -u -r1.65 insetquotes.C
--- src/insets/insetquotes.C    23 May 2002 09:21:28 -0000      1.65
+++ src/insets/insetquotes.C    23 May 2002 17:42:57 -0000
@@ -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 @@
 
 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 @@
 
        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;
Index: src/insets/insetspecialchar.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspecialchar.C,v
retrieving revision 1.49
diff -u -r1.49 insetspecialchar.C
--- src/insets/insetspecialchar.C       23 May 2002 09:21:28 -0000      1.49
+++ src/insets/insetspecialchar.C       23 May 2002 17:42:57 -0000
@@ -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 @@
 
 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 @@
        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 @@
        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 @@
        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);
Index: src/insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.203
diff -u -r1.203 insettabular.C
--- src/insets/insettabular.C   23 May 2002 12:08:44 -0000      1.203
+++ src/insets/insettabular.C   23 May 2002 17:43:08 -0000
@@ -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 @@
        }
 
        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 @@
                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 @@
                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;
 }
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.297
diff -u -r1.297 insettext.C
--- src/insets/insettext.C      23 May 2002 15:43:22 -0000      1.297
+++ src/insets/insettext.C      23 May 2002 17:43:13 -0000
@@ -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 @@
 
        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 @@
        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 @@
        }
        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;
Index: src/mathed/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.231
diff -u -r1.231 ChangeLog
--- src/mathed/ChangeLog        23 May 2002 12:08:47 -0000      1.231
+++ src/mathed/ChangeLog        23 May 2002 17:43:18 -0000
@@ -1,5 +1,14 @@
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
+       * formulabase.C:
+       * formulamacro.C:
+       * math_charinset.C:
+       * math_funcinset.C:
+       * math_support.C:
+       * math_unknowninset.C: new name for font metrics
+ 
+2002-05-23  John Levon  <[EMAIL PROTECTED]>
+
        * formula.C:
        * formulabase.C: LyXView moved into frontends/
  
Index: src/mathed/formulabase.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v
retrieving revision 1.156
diff -u -r1.156 formulabase.C
--- src/mathed/formulabase.C    23 May 2002 12:08:45 -0000      1.156
+++ src/mathed/formulabase.C    23 May 2002 17:43:18 -0000
@@ -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"
Index: src/mathed/formulamacro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v
retrieving revision 1.96
diff -u -r1.96 formulamacro.C
--- src/mathed/formulamacro.C   23 May 2002 09:21:30 -0000      1.96
+++ src/mathed/formulamacro.C   23 May 2002 17:43:24 -0000
@@ -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::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 @@
        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;
Index: src/mathed/math_charinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_charinset.C,v
retrieving revision 1.39
diff -u -r1.39 math_charinset.C
--- src/mathed/math_charinset.C 23 May 2002 09:21:30 -0000      1.39
+++ src/mathed/math_charinset.C 23 May 2002 17:43:24 -0000
@@ -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 @@
        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 @@
 {
        //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_);
 }
 
Index: src/mathed/math_funcinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.C,v
retrieving revision 1.38
diff -u -r1.38 math_funcinset.C
--- src/mathed/math_funcinset.C 23 May 2002 09:21:31 -0000      1.38
+++ src/mathed/math_funcinset.C 23 May 2002 17:43:24 -0000
@@ -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"
Index: src/mathed/math_support.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_support.C,v
retrieving revision 1.32
diff -u -r1.32 math_support.C
--- src/mathed/math_support.C   23 May 2002 09:21:32 -0000      1.32
+++ src/mathed/math_support.C   23 May 2002 17:43:24 -0000
@@ -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 @@
 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 @@
 {
        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 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 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 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);
 }
 
 
Index: src/mathed/math_unknowninset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_unknowninset.C,v
retrieving revision 1.6
diff -u -r1.6 math_unknowninset.C
--- src/mathed/math_unknowninset.C      23 May 2002 09:21:32 -0000      1.6
+++ src/mathed/math_unknowninset.C      23 May 2002 17:43:24 -0000
@@ -5,7 +5,6 @@
 #endif
 
 #include "math_unknowninset.h"
-#include "font.h"
 #include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"

Reply via email to