* Licence details can be found in the file COPYING.
*
* \author unknown
- * \author John Levon
+ * \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 "frontends/lyx_gui.h"
#include "xfont_metrics.h"
#include "xfont_loader.h"
#include "lyxrc.h"
} // namespace anon
-
+
namespace font_metrics {
-
+
int maxAscent(LyXFont const & f)
{
return getXFontstruct(f)->ascent;
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;
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;
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;
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);
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) {
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;
}
void rectText(string const & str, LyXFont const & font,
- int & width,
- int & ascent,
+ int & width,
+ int & ascent,
int & descent)
{
static int const d = 2;
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 {
return result;
}
}
-
+
int XTextWidth(LyXFont const & f, char 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