-int LyXFont::textWidth(char const * s, int n) const
-{
- if (!lyxrc.use_gui)
- return n;
-
- if (realShape() != LyXFont::SMALLCAPS_SHAPE){
- return XTextWidth(getXFontstruct(), s, n);
- } else {
- // emulate smallcaps since X doesn't support this
- unsigned int result = 0;
- char c;
- LyXFont smallfont = *this;
- smallfont.decSize();
- smallfont.decSize();
- smallfont.setShape(LyXFont::UP_SHAPE);
- for (int 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);
- result += XTextWidth(smallfont.getXFontstruct(), &c, 1);
- } else {
- result += XTextWidth(getXFontstruct(), &c, 1);
- }
- }
- return result;
- }
-}
-
-
-int LyXFont::stringWidth(string const & s) const
-{
- if (s.empty()) return 0;
- return textWidth(s.c_str(), s.length());
-}
-
-
-int LyXFont::signedStringWidth(string const & s) const
-{
- if (s.empty()) return 0;
- if (s.c_str()[0] == '-')
- return -textWidth(s.c_str()+1, s.length()-1);
- else
- return textWidth(s.c_str(), s.length());
-}
-
-
-int LyXFont::drawText(char const * s, int n, Pixmap,
- int, int x) const
-{
- if (realShape() != LyXFont::SMALLCAPS_SHAPE) {
- /* XDrawString(fl_display,
- pm,
- getGC(),
- x, baseline,
- s, n);
- XFlush(fl_display); */
- return XTextWidth(getXFontstruct(), s, n);
-
- } else {
- // emulate smallcaps since X doesn't support this
- char c;
- int sx = x;
- LyXFont smallfont = *this;
- smallfont.decSize();
- smallfont.decSize();
- smallfont.setShape(LyXFont::UP_SHAPE);
- for (int i = 0; i < n; ++i) {
- c = s[i];
- if (islower(static_cast<unsigned char>(c))){
- c = toupper(c);
- /* XDrawString(fl_display,
- pm,
- smallfont.getGC(),
- x, baseline,
- &c, 1); */
- x += XTextWidth(smallfont.getXFontstruct(),
- &c, 1);
- //XFlush(fl_display);
- } else {
- /* XDrawString(fl_display,
- pm,
- getGC(),
- x, baseline,
- &c, 1);*/
- x += XTextWidth(getXFontstruct(), &c, 1);
- //XFlush(fl_display);
- }
- }
- return x - sx;
- }
-}
-
-
-int LyXFont::drawString(string const & s, Pixmap pm, int baseline, int x) const
-{
- return drawText(s.c_str(), s.length(), pm, baseline, x);
-}
-
-
-bool LyXFont::equalExceptLatex(LyXFont const & f) const
-{
- LyXFont f1 = *this;
- f1.setLatex(f.latex());
- return f1 == f;
-}
-
-ostream & operator<<(ostream & o, LyXFont::FONT_MISC_STATE fms)