HAVE_XFT is no longer defined since the commit below

------------------------------------------------------------------------

r10426 | cannam | 2009-06-24 12:38:09 +0200 (Wed, 24 Jun 2009) | 4 lines

* Default to Qt font rendering, now it seems to work
* Remove feta pixmaps -- having tried this option again, it looks too awful

------------------------------------------------------------------------

Can I delete the code inside #ifdef HAVE_XFT, to keep the codebase clean
and less confusing to newcomers?


-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
diff --git a/Doxyfile b/Doxyfile
index a5584c9..56d1a72 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -1510,7 +1510,7 @@ INCLUDE_FILE_PATTERNS  =
 # instead of the = operator.
 
 PREDEFINED             = HAVE_ALSA HAVE_LIBJACK HAVE_DSSI HAVE_LADSPA \
-                         HAVE_LIBLO HAVE_LIBLRDF HAVE_XFT HAVE_LIRC
+                         HAVE_LIBLO HAVE_LIBLRDF HAVE_LIRC
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be expanded.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0ce6665..73684ed 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -246,7 +246,6 @@ set(rg_CPPS
   gui/editors/notation/NoteRestInserter.cpp
   gui/editors/notation/NoteStyleFactory.cpp
   gui/editors/notation/NoteStyleFileReader.cpp
-  gui/editors/notation/SystemFontXft.cpp
   gui/editors/notation/NotationTool.cpp
   gui/editors/notation/NotationProperties.cpp
   gui/editors/notation/NoteFontViewer.cpp
diff --git a/src/gui/configuration/NotationConfigurationPage.cpp b/src/gui/configuration/NotationConfigurationPage.cpp
index 43566ee..9e61ee5 100644
--- a/src/gui/configuration/NotationConfigurationPage.cpp
+++ b/src/gui/configuration/NotationConfigurationPage.cpp
@@ -453,22 +453,12 @@ NotationConfigurationPage::NotationConfigurationPage(QWidget *parent) :
     layout = new QGridLayout(frame);
     layout->setSpacing(5);
 
-    m_viewButton = 0;
-
     layout->addWidget(new QLabel(tr("Notation font"), frame), 0, 0);
 
     m_font = new QComboBox(frame);
     connect(m_font, SIGNAL(activated(int)), this, SLOT(slotModified()));
 
-#ifdef HAVE_XFT
-    m_viewButton = new QPushButton(tr("View"), frame);
-    layout->addWidget(m_font, row, 1, 1, 2);
-    layout->addWidget(m_viewButton, row, 3);
-    QObject::connect(m_viewButton, SIGNAL(clicked()),
-                     this, SLOT(slotViewButtonPressed()));
-#else
     layout->addWidget(m_font, row, 1, 1, 3);
-#endif
     m_font->setEditable(false);
     QObject::connect(m_font, SIGNAL(activated(int)),
                      this, SLOT(slotFontComboChanged(int)));
@@ -651,31 +641,6 @@ NotationConfigurationPage::NotationConfigurationPage(QWidget *parent) :
 }
 
 void
-NotationConfigurationPage::slotViewButtonPressed()
-{
-#ifdef HAVE_XFT
-    QString fontName = m_untranslatedFont[m_font->currentIndex()];
-
-    try {
-        NoteFont *noteFont = NoteFontFactory::getFont
-            (fontName, NoteFontFactory::getDefaultSize(fontName));
-        const NoteFontMap &map(noteFont->getNoteFontMap());
-        QStringList systemFontNames(map.getSystemFontNames());
-        if (systemFontNames.count() == 0) {
-            m_viewButton->setEnabled(false); // oops
-        } else {
-            NoteFontViewer *viewer =
-                new NoteFontViewer(0, m_untranslatedFont[m_font->currentIndex()],
-                                   systemFontNames, 24);
-            (void)viewer->exec(); // no return value
-        }
-    } catch (Exception f) {
-        QMessageBox::critical(0, tr("Rosegarden"), tr(f.getMessage().c_str()));
-    }
-#endif
-}
-
-void
 NotationConfigurationPage::slotPopulateFontCombo(bool rescan)
 {
     QSettings settings;
@@ -746,9 +711,6 @@ NotationConfigurationPage::slotFontComboChanged(int index)
         } else {
             m_fontTypeLabel->setText(tr("%1 (jaggy)").arg(tr(map.getType().toStdString().c_str())));
         }
-        if (m_viewButton) {
-            m_viewButton->setEnabled(map.getSystemFontNames().count() > 0);
-        }
     } catch (Exception f) {
         QMessageBox::critical(0, tr("Rosegarden"), strtoqstr(f.getMessage()));
     }
diff --git a/src/gui/configuration/NotationConfigurationPage.h b/src/gui/configuration/NotationConfigurationPage.h
index cea433e..4ba8425 100644
--- a/src/gui/configuration/NotationConfigurationPage.h
+++ b/src/gui/configuration/NotationConfigurationPage.h
@@ -56,7 +56,6 @@ public:
 protected slots:
     void slotFontComboChanged(int);
     void slotPopulateFontCombo(bool rescan);
-    void slotViewButtonPressed();
 
 protected:
 
@@ -68,7 +67,6 @@ protected:
     FontRequester* m_textFont;
     FontRequester* m_sansFont;
     FontRequester* m_timeSigFont;
-    QPushButton *m_viewButton;
     QLabel *m_fontOriginLabel;
     QLabel *m_fontCopyrightLabel;
     QLabel *m_fontMappedByLabel;
diff --git a/src/gui/editors/notation/FontViewFrame.cpp b/src/gui/editors/notation/FontViewFrame.cpp
index 13ea436..729de0d 100644
--- a/src/gui/editors/notation/FontViewFrame.cpp
+++ b/src/gui/editors/notation/FontViewFrame.cpp
@@ -30,14 +30,6 @@
 
 #include "misc/Strings.h"
 
-#ifdef HAVE_XFT
-#include <ft2build.h>
-#include FT_FREETYPE_H 
-#include FT_OUTLINE_H
-#include FT_GLYPH_H
-#include <X11/Xft/Xft.h>
-#endif
-
 #include <iostream>
 
 namespace Rosegarden
@@ -58,7 +50,7 @@ FontViewFrame::FontViewFrame( int pixelSize, QWidget* parent) :
 
 FontViewFrame::~FontViewFrame()
 {
-    // empty
+    delete m_tableFont;
 }
 
 void
@@ -72,49 +64,7 @@ FontViewFrame::setFont(QString font)
 void
 FontViewFrame::loadFont()
 {
-#ifdef HAVE_XFT
-    if (m_tableFont) {
-        XftFontClose(x11AppDisplay(), (XftFont *)m_tableFont);
-    }
-    m_tableFont = 0;
-
-    static bool haveDir = false;
-    if (!haveDir) {
-        FcConfigAppFontAddDir(FcConfigGetCurrent(),
-                              (const FcChar8 *)"/opt/kde3/share/apps/rosegarden/fonts");
-        haveDir = true;
-    }
-
-    FcPattern *pattern = FcPatternCreate();
-    FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *)m_fontName.toLatin1().data());
-    FcPatternAddInteger(pattern, FC_PIXEL_SIZE, m_fontSize);
-
-    FcConfigSubstitute(FcConfigGetCurrent(), pattern, FcMatchPattern);
-
-    FcResult result = FcResultMatch;
-    FcPattern *match = FcFontMatch(FcConfigGetCurrent(), pattern, &result);
-    FcPatternDestroy(pattern);
-
-    if (!match || result != FcResultMatch) {
-        QMessageBox::critical(this, tr("Rosegarden"), tr("Error: Unable to match font name %1", m_fontName));
-        return ;
-    }
-
-    FcChar8 *matchFamily;
-    FcPatternGetString(match, FC_FAMILY, 0, &matchFamily);
-
-    if (QString((const char *)matchFamily).toLower() != m_fontName.toLower()) {
-        QMessageBox::warning(this, tr("Rosegarden"), tr("Warning: No good match for font name %1 (best is %2)")
-                           .arg(m_fontName).arg(QString((const char *)matchFamily)) );
-        m_fontName = (const char *)matchFamily;
-    }
-
-    m_tableFont = XftFontOpenPattern(x11AppDisplay(), match);
-    if (!m_tableFont) {
-        QMessageBox::critical(this, tr("Rosegarden"), tr("Error: Unable to open best-match font %1")
-                           .arg(QString((const char *)matchFamily)));
-    }
-#else
+    delete m_tableFont;
     QFont *qf = new QFont(m_fontName);
     qf->setPixelSize(m_fontSize);
     qf->setWeight(QFont::Normal);
@@ -122,7 +72,6 @@ FontViewFrame::loadFont()
     QFontInfo fi(*qf);
     std::cerr << "Loaded Qt font \"" << fi.family() << "\" (exactMatch = " << (fi.exactMatch() ? "true" : "false") << ")" << std::endl;
     m_tableFont = qf;
-#endif
 
     m_ascent = QFontMetrics(font()).ascent(); // ascent of numbering font, not notation font
 }
@@ -171,20 +120,6 @@ void FontViewFrame::paintEvent( QPaintEvent* e )
     if ( !cell.width() || !cell.height() )
         return ;
 
-#ifdef HAVE_XFT
-    Drawable drawable = (Drawable)handle();
-    XftDraw *draw = XftDrawCreate(x11AppDisplay(), drawable,
-                                  (Visual *)x11Visual(), x11Colormap());
-
-    QColor pen(QColor(Qt::black));
-    XftColor col;
-    col.color.red = pen.red () | pen.red() << 8;
-    col.color.green = pen.green () | pen.green() << 8;
-    col.color.blue = pen.blue () | pen.blue() << 8;
-    col.color.alpha = 0xffff;
-    col.pixel = pen.pixel();
-#endif
-
     p.setPen(Qt::black);
 
     for (int j = 0; j <= 16; j++) {
@@ -218,31 +153,7 @@ void FontViewFrame::paintEvent( QPaintEvent* e )
         }
     }
 
-#ifdef HAVE_XFT
-    p.end();
-
-    for (int j = 1; j <= 16; j++) {
-        for (int i = 1; i <= 16; i++) {
-
-            int x = i * cell.width();
-            int y = j * cell.height();
-
-            x += ml;
-            y += mt;
-
-            if (m_glyphs) {
-                FT_UInt ui = m_row * 256 + (j - 1) * 16 + i - 1;
-                XftDrawGlyphs(draw, &col, (XftFont *)m_tableFont, x, y, &ui, 1);
-            } else {
-                FcChar32 ch = m_row * 256 + (j - 1) * 16 + i - 1;
-                if (XftCharExists(x11AppDisplay(), (XftFont *)m_tableFont, ch)) {
-                    XftDrawString32(draw, &col, (XftFont *)m_tableFont, x, y, &ch, 1);
-                }
-            }
-        }
-    }
-#else
-    p.setFont(*(QFont *)m_tableFont);
+    p.setFont(*m_tableFont);
 
     for (int j = 1; j <= 16; j++) {
         for (int i = 1; i <= 16; i++) {
@@ -257,29 +168,12 @@ void FontViewFrame::paintEvent( QPaintEvent* e )
             p.drawText(x, y, QString(c));
         }
     }
-
-    p.end();
-#endif
 }
 
 bool
 FontViewFrame::hasRow(int r) const
 {
-#ifdef HAVE_XFT
-    if (m_glyphs) {
-        if (r < 256) return true;
-    } else {
-
-        for (int c = 0; c < 256; ++c) {
-            FcChar32 ch = r * 256 + c;
-            if (XftCharExists(x11AppDisplay(), (XftFont *)m_tableFont, ch)) {
-                return true;
-            }
-        }
-    }
-#else
     if (r < 256) return true;
-#endif
     return false;
 }
 
diff --git a/src/gui/editors/notation/FontViewFrame.h b/src/gui/editors/notation/FontViewFrame.h
index 939b96d..8ecba36 100644
--- a/src/gui/editors/notation/FontViewFrame.h
+++ b/src/gui/editors/notation/FontViewFrame.h
@@ -56,7 +56,7 @@ protected:
 private:
     QString m_fontName;
     int m_fontSize;
-    void *m_tableFont;
+    QFont *m_tableFont;
     int m_ascent;
     int m_row;
     bool m_glyphs;
diff --git a/src/gui/editors/notation/SystemFont.cpp b/src/gui/editors/notation/SystemFont.cpp
index 58c5d16..7800a01 100644
--- a/src/gui/editors/notation/SystemFont.cpp
+++ b/src/gui/editors/notation/SystemFont.cpp
@@ -37,7 +37,6 @@
 
 #include "SystemFont.h"
 #include "SystemFontQt.h"
-#include "SystemFontXft.h"
 
 #include <iostream>
 
@@ -70,66 +69,6 @@ SystemFont::loadSystemFont(const SystemFontSpec &spec)
         haveFonts = true;
     }
 
-#ifdef HAVE_XFT
-
-    FcPattern *pattern, *match;
-    FcResult result;
-    FcChar8 *matchFamily;
-    XftFont *xfont = 0;
-
-    Display *dpy = QPaintDevice::x11AppDisplay();
-
-    if (!dpy) {
-        std::cerr << "SystemFont::loadSystemFont[Xft]: Xft support requested but no X11 display available!" << std::endl;
-        goto qfont;
-    }
-	
-    pattern = FcPatternCreate();
-    FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *)name.toLatin1().data());
-    FcPatternAddInteger(pattern, FC_PIXEL_SIZE, size);
-    FcConfigSubstitute(FcConfigGetCurrent(), pattern, FcMatchPattern);
-
-    result = FcResultMatch;
-    match = FcFontMatch(FcConfigGetCurrent(), pattern, &result);
-    FcPatternDestroy(pattern);
-
-    if (!match || result != FcResultMatch) {
-        NOTATION_DEBUG << "SystemFont::loadSystemFont[Xft]: No match for font "
-        << name << " (result is " << result
-        << "), falling back on QFont";
-        if (match)
-            FcPatternDestroy(match);
-        goto qfont;
-    }
-
-    FcPatternGetString(match, FC_FAMILY, 0, &matchFamily);
-    NOTATION_DEBUG << "SystemFont::loadSystemFont[Xft]: match family is "
-    << (char *)matchFamily;
-
-    if (QString((char *)matchFamily).toLower() != name.toLower()) {
-        NOTATION_DEBUG << "SystemFont::loadSystemFont[Xft]: Wrong family returned, falling back on QFont";
-        FcPatternDestroy(match);
-        goto qfont;
-    }
-
-    xfont = XftFontOpenPattern(dpy, match);
-    if (!xfont) {
-        FcPatternDestroy(match);
-        NOTATION_DEBUG << "SystemFont::loadSystemFont[Xft]: Unable to load font "
-        << name << " via Xft, falling back on QFont";
-        goto qfont;
-    }
-
-    NOTATION_DEBUG << "SystemFont::loadSystemFont[Xft]: successfully loaded font "
-                   << name << " through Xft";
-
-    return new SystemFontXft(dpy, xfont);
-
-
-qfont:
-
-#endif
-
     static QHash<QString, QFont *> qFontMap;
 
     if (qFontMap.contains(name)) {
@@ -194,18 +133,8 @@ SystemFont::unbundleFonts()
 void
 SystemFont::addFont(QString fileName)
 {
-#ifdef HAVE_XFT
-    if (!FcConfigAppFontAddFile
-        (FcConfigGetCurrent(),
-         (const FcChar8 *)fileName.toLocal8Bit().data())) {
-        NOTATION_DEBUG << "SystemFont::addFont[Xft]: Failed to add font file " << fileName << " to fontconfig, continuing without it";
-    } else {
-        NOTATION_DEBUG << "Added font file \"" << fileName << "\" to fontconfig";
-    }
-#else
     QFontDatabase::addApplicationFont(fileName);
     NOTATION_DEBUG << "Added font file \"" << fileName << "\" to Qt font database";
-#endif
 }
 
 }
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@lists.sourceforge.net - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to