]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/xfont_metrics.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / xfont_metrics.C
index 92b2f87be177d86e879a88434c7ca9617eeff089..eba8c5f4dac5533577cd26cd69263a21ed038c52 100644 (file)
@@ -1,28 +1,35 @@
 /**
  * \file xfont_metrics.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation "frontends/font_metrics.h"
-#pragma implementation "frontends/xfont_metrics.h"
-#endif
-
-#include "support/lstrings.h"
 #include "xfont_metrics.h"
+#include "font_metrics.h"
 #include "xfont_loader.h"
-#include "lyxrc.h"
+
 #include "encoding.h"
 #include "language.h"
+#include "lyxrc.h"
+
+#include "frontends/lyx_gui.h"
+
+#include "support/lstrings.h"
 
 #include <boost/scoped_array.hpp>
 
+using lyx::support::uppercase;
+
+using std::string;
+
+
 namespace {
 
 inline
@@ -42,9 +49,9 @@ XID getFontID(LyXFont const & f)
 
 } // namespace anon
 
+
 namespace font_metrics {
+
 int maxAscent(LyXFont const & f)
 {
        return getXFontstruct(f)->ascent;
@@ -63,7 +70,7 @@ int ascent(char c, LyXFont const & 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) 
+           && 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;
@@ -76,7 +83,7 @@ int descent(char c, LyXFont const & 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) 
+           && 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;
@@ -89,7 +96,7 @@ int lbearing(char c, LyXFont const & 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) 
+           && uc <= finfo->max_char_or_byte2+256*finfo->max_byte1)
                return finfo->per_char[uc - finfo->min_char_or_byte2].lbearing;
        else
                return 0;
@@ -102,7 +109,7 @@ int rbearing(char c, LyXFont const & 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) 
+           && 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);
@@ -111,7 +118,7 @@ int rbearing(char c, LyXFont const & f)
 
 int width(char const * s, size_t n, LyXFont const & f)
 {
-       if (!lyxrc.use_gui)
+       if (!lyx_gui::use_gui)
                return n;
 
        if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
@@ -129,7 +136,7 @@ int width(char const * s, size_t n, LyXFont const & f)
                        Uchar c = encoding->ucs(s[i]);
                        xs[i].byte1 = c >> 8;
                        xs[i].byte2 = c & 0xff;
-                }
+               }
                int result = xfont_metrics::width(xs.get(), n, font);
                return result;
        }
@@ -166,8 +173,8 @@ int signedWidth(string const & s, LyXFont const & f)
 
 
 void rectText(string const & str, LyXFont const & font,
-       int & width, 
-       int & ascent, 
+       int & width,
+       int & ascent,
        int & descent)
 {
        static int const d = 2;
@@ -179,26 +186,26 @@ void rectText(string const & str, LyXFont const & font,
 
 
 void buttonText(string const & str, LyXFont const & font,
-       int & width, 
-       int & ascent, 
+       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;
 }
 
 } // namespace font_metrics
+
 namespace xfont_metrics {
+
 int width(XChar2b const * s, int n, LyXFont const & f)
 {
-       if (!lyxrc.use_gui)
+       if (!lyx_gui::use_gui)
                return n;
-       
+
        if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
                return ::XTextWidth16(getXFontstruct(f), s, n);
        } else {
@@ -223,7 +230,7 @@ int width(XChar2b const * s, int n, LyXFont const & f)
                return result;
        }
 }
+
 
 int XTextWidth(LyXFont const & f, char const * str, int count)
 {
@@ -238,9 +245,9 @@ int XTextWidth16(LyXFont const & f, XChar2b const * str, int count)
 
 
 /// hmm, not a metric !
-void XSetFont(Display * display, GC gc, LyXFont const & f) 
+void XSetFont(Display * display, GC gc, LyXFont const & f)
 {
        ::XSetFont(display, gc, getFontID(f));
 }
+
 } // namespace xfont_metrics