/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#pragma implementation
#endif
+#include "support/lstrings.h"
#include "font.h"
#include "FontLoader.h"
#include "lyxrc.h"
#include <boost/smart_ptr.hpp>
-#include <cctype>
namespace {
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);
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;
}
} else {
// emulate smallcaps since X doesn't support this
unsigned int result = 0;
- char c;
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
for (size_t i = 0; i < n; ++i) {
- c = s[i];
- // when islower is a macro, the cast is needed (JMarc)
- if (islower(static_cast<unsigned char>(c))) {
- c = toupper(c);
+ char const c = uppercase(s[i]);
+ if (c != s[i]) {
result += ::XTextWidth(getXFontstruct(smallfont), &c, 1);
} else {
result += ::XTextWidth(getXFontstruct(f), &c, 1);
int lyxfont::signedWidth(string const & s, LyXFont const & f)
{
- if (s.empty()) return 0;
+ if (s.empty())
+ return 0;
if (s[0] == '-')
return -width(s.substr(1, s.length() - 1), f);
else
{
if (!lyxrc.use_gui)
return n;
-
+
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
return ::XTextWidth16(getXFontstruct(f), s, n);
} else {
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
for (int i = 0; i < n; ++i) {
- if (s[i].byte1 == 0 && islower(s[i].byte2)) {
- c.byte2 = toupper(s[i].byte2);
+ 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);
}
-void lyxfont::XSetFont(Display * display, GC gc, LyXFont const & f)
+void lyxfont::XSetFont(Display * display, GC gc, LyXFont const & f)
{
::XSetFont(display, gc, getFontID(f));
}
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;