File indexing completed on 2024-05-05 12:17:07

0001 /**
0002  * This file is part of the KDE project
0003  *
0004  * Copyright (C) 2003 Stephan Kulow (coolo@kde.org)
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  */
0022 
0023 #include "ecma/kjs_proxy.h"
0024 
0025 #define QT_NO_FONTCONFIG 1
0026 #define QT_NO_FREETYPE   1
0027 #include <private/qfontengine_p.h>
0028 #pragma message ("Port to Qt5")
0029 #if 0
0030 #  include <private/qfontengine_x11_p.h>
0031 #endif
0032 #include <QFontDatabase>
0033 #include <QFont>
0034 #include "khtml_settings.h"
0035 #include <QImage>
0036 #include <assert.h>
0037 #include <QX11Info>
0038 #include <QPainter>
0039 #if HAVE_X11
0040 #include <fixx11h.h>
0041 #endif
0042 #include <QtGlobal>
0043 
0044 struct MetricsInfo {
0045     const char *name;
0046     int ascent;
0047     int descent;
0048     int leading;
0049 };
0050 
0051 typedef QFixed QtFontDim;
0052 
0053 static int dimToInt(QtFontDim dim)
0054 {
0055     return dim.toInt();
0056 }
0057 
0058 static const MetricsInfo compatMetrics[] = {
0059     {"-Adobe-Courier-Medium-R-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0060     {"-Adobe-Courier-Medium-O-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0061     {"-Adobe-Courier-Bold-R-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0062     {"-Adobe-Courier-Bold-O-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0063     {"-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0064     {"-Adobe-Courier-Medium-O-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0065     {"-Adobe-Courier-Bold-R-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0066     {"-Adobe-Courier-Bold-O-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0067     {"-Adobe-Courier-Medium-R-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0068     {"-Adobe-Courier-Medium-O-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0069     {"-Adobe-Courier-Bold-R-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0070     {"-Adobe-Courier-Bold-O-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0071     {"-Adobe-Courier-Medium-R-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0072     {"-Adobe-Courier-Medium-O-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0073     {"-Adobe-Courier-Bold-R-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0074     {"-Adobe-Courier-Bold-O-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0075     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0076     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0077     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0078     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0079     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0080     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0081     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0082     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0083     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0084     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0085     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0086     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0087     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0088     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0089     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0090     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0091     {"-Adobe-Helvetica-Medium-R-Normal--10-100-75-75-P-56-ISO10646-1", 10, 1, 2},
0092     {"-Adobe-Helvetica-Medium-O-Normal--10-100-75-75-P-57-ISO10646-1", 10, 1, 2},
0093     {"-Adobe-Helvetica-Bold-R-Normal--10-100-75-75-P-60-ISO10646-1", 10, 1, 2},
0094     {"-Adobe-Helvetica-Bold-O-Normal--10-100-75-75-P-60-ISO10646-1", 10, 1, 2},
0095     {"-Adobe-Helvetica-Medium-R-Normal--12-120-75-75-P-67-ISO10646-1", 11, 2, 2},
0096     {"-Adobe-Helvetica-Medium-O-Normal--12-120-75-75-P-67-ISO10646-1", 11, 2, 2},
0097     {"-Adobe-Helvetica-Bold-R-Normal--12-120-75-75-P-70-ISO10646-1", 11, 2, 2},
0098     {"-Adobe-Helvetica-Bold-O-Normal--12-120-75-75-P-69-ISO10646-1", 11, 2, 2},
0099     {"-Adobe-Helvetica-Medium-R-Normal--18-180-75-75-P-98-ISO10646-1", 16, 4, 3},
0100     {"-Adobe-Helvetica-Medium-O-Normal--18-180-75-75-P-98-ISO10646-1", 16, 4, 3},
0101     {"-Adobe-Helvetica-Bold-R-Normal--18-180-75-75-P-103-ISO10646-1", 16, 4, 3},
0102     {"-Adobe-Helvetica-Bold-O-Normal--18-180-75-75-P-104-ISO10646-1", 16, 4, 3},
0103     {"-Adobe-Helvetica-Medium-R-Normal--24-240-75-75-P-130-ISO10646-1", 22, 4, 4},
0104     {"-Adobe-Helvetica-Medium-O-Normal--24-240-75-75-P-130-ISO10646-1", 22, 4, 4},
0105     {"-Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-138-ISO10646-1", 22, 4, 4},
0106     {"-Adobe-Helvetica-Bold-O-Normal--24-240-75-75-P-138-ISO10646-1", 22, 4, 4},
0107     {"-Adobe-Courier-Medium-R-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0108     {"-Adobe-Courier-Medium-O-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0109     {"-Adobe-Courier-Bold-R-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0110     {"-Adobe-Courier-Bold-O-Normal--10-100-75-75-M-60-ISO10646-1", 8, 1, 2},
0111     {"-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0112     {"-Adobe-Courier-Medium-O-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0113     {"-Adobe-Courier-Bold-R-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0114     {"-Adobe-Courier-Bold-O-Normal--12-120-75-75-M-70-ISO10646-1", 10, 2, 2},
0115     {"-Adobe-Courier-Medium-R-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0116     {"-Adobe-Courier-Medium-O-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0117     {"-Adobe-Courier-Bold-R-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0118     {"-Adobe-Courier-Bold-O-Normal--18-180-75-75-M-110-ISO10646-1", 14, 3, 3},
0119     {"-Adobe-Courier-Medium-R-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0120     {"-Adobe-Courier-Medium-O-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0121     {"-Adobe-Courier-Bold-R-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0122     {"-Adobe-Courier-Bold-O-Normal--24-240-75-75-M-150-ISO10646-1", 19, 4, 4},
0123     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0124     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0125     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0126     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0127     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0128     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0129     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0130     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0131     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0132     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0133     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0134     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0135     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0136     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0137     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0138     {"-Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO10646-1", 7, 1, 1},
0139     {"-Adobe-Helvetica-Medium-R-Normal--10-100-75-75-P-56-ISO10646-1", 10, 1, 2},
0140     {"-Adobe-Helvetica-Medium-O-Normal--10-100-75-75-P-57-ISO10646-1", 10, 1, 2},
0141     {"-Adobe-Helvetica-Bold-R-Normal--10-100-75-75-P-60-ISO10646-1", 10, 1, 2},
0142     {"-Adobe-Helvetica-Bold-O-Normal--10-100-75-75-P-60-ISO10646-1", 10, 1, 2},
0143     {"-Adobe-Helvetica-Medium-R-Normal--12-120-75-75-P-67-ISO10646-1", 11, 2, 2},
0144     {"-Adobe-Helvetica-Medium-O-Normal--12-120-75-75-P-67-ISO10646-1", 11, 2, 2},
0145     {"-Adobe-Helvetica-Bold-R-Normal--12-120-75-75-P-70-ISO10646-1", 11, 2, 2},
0146     {"-Adobe-Helvetica-Bold-O-Normal--12-120-75-75-P-69-ISO10646-1", 11, 2, 2},
0147     {"-Adobe-Helvetica-Medium-R-Normal--18-180-75-75-P-98-ISO10646-1", 16, 4, 3},
0148     {"-Adobe-Helvetica-Medium-O-Normal--18-180-75-75-P-98-ISO10646-1", 16, 4, 3},
0149     {"-Adobe-Helvetica-Bold-R-Normal--18-180-75-75-P-103-ISO10646-1", 16, 4, 3},
0150     {"-Adobe-Helvetica-Bold-O-Normal--18-180-75-75-P-104-ISO10646-1", 16, 4, 3},
0151     {"-Adobe-Helvetica-Medium-R-Normal--24-240-75-75-P-130-ISO10646-1", 22, 4, 4},
0152     {"-Adobe-Helvetica-Medium-O-Normal--24-240-75-75-P-130-ISO10646-1", 22, 4, 4},
0153     {"-Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-138-ISO10646-1", 22, 4, 4},
0154     {"-Adobe-Helvetica-Bold-O-Normal--24-240-75-75-P-138-ISO10646-1", 22, 4, 4},
0155     {0, 0, 0, 0}
0156 };
0157 
0158 static const MetricsInfo *grabMetrics(const QString &name)
0159 {
0160     for (int pos = 0; compatMetrics[pos].name; ++pos)
0161         if (name == QLatin1String(compatMetrics[pos].name)) {
0162             return &compatMetrics[pos];
0163         }
0164     return 0;
0165 }
0166 
0167 class QFakeFontEngine : public QFontEngineXLFD
0168 {
0169 public:
0170     QString name;
0171 
0172     QFakeFontEngine(XFontStruct *fs, const char *name, int size);
0173     ~QFakeFontEngine();
0174 
0175     bool  haveMetrics;
0176     QtFontDim m_ascent, m_descent, m_leading;
0177     bool  ahem;
0178     int   pixS;
0179     XFontStruct *xfs;
0180 
0181     QtFontDim fallBackWidth() const
0182     {
0183         QtFontDim fbw = xfs->min_bounds.width;
0184         if (xfs->per_char) {
0185             if (haveMetrics) {
0186                 fbw = m_ascent;    //### we really should get rid of these and regen..
0187             } else {
0188                 fbw = xfs->ascent;
0189             }
0190         }
0191         return fbw;
0192     }
0193 
0194     void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
0195     {
0196         QFontEngineXLFD::recalcAdvances(glyphs, flags);
0197 
0198         // Go through the glyhs with glyph 0 and fix up their x advance
0199         // to make sense (or at least match Qt3)
0200         QtFontDim fbw = fallBackWidth();
0201 
0202         for (int c = 0; c < glyphs->numGlyphs; ++c) {
0203             if (glyphs->glyphs[c] == 0x200B) { // ZERO WIDTH SPACE
0204                 glyphs->advances_x[c] = 0;
0205             } else if (!glyphs->glyphs[c]) {
0206                 glyphs->advances_x[c] = fbw;
0207             }
0208         }
0209     }
0210 
0211     Type type() const
0212     {
0213         if (ahem) {
0214             return QFontEngine::Freetype;
0215         } else {
0216             return QFontEngine::XLFD;
0217         }
0218     }
0219 
0220     QtFontDim ascent() const
0221     {
0222         if (haveMetrics) {
0223             return m_ascent;
0224         } else {
0225             return QFontEngineXLFD::ascent();
0226         }
0227     }
0228 
0229     QtFontDim descent() const
0230     {
0231         if (haveMetrics) {
0232             return m_descent;
0233         } else {
0234             return QFontEngineXLFD::descent();
0235         }
0236     }
0237 
0238     QtFontDim leading() const
0239     {
0240         if (ahem) {
0241             return 0;
0242         } else if (haveMetrics) {
0243             return m_leading;
0244         } else {
0245             return QFontEngineXLFD::leading();
0246         }
0247     }
0248 
0249     bool canRender(const QChar *string,  int len);
0250 };
0251 
0252 //OK. This is evil. Since we don't use Xft, we hijack the FreeType painting hook in the X11 engine
0253 //for ahem, as unfortunately the drawing is in the paint engine, and not the font engine in Qt4
0254 class Q_DECL_EXPORT QX11PaintEngine: public QPaintEngine
0255 {
0256     void drawFreetype(const QPointF &p, const QTextItemInt &si);
0257 };
0258 
0259 void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &si)
0260 {
0261     int cnt = si.glyphs.numGlyphs;
0262 
0263     if (!cnt) {
0264         return;
0265     }
0266 
0267     QFakeFontEngine *eng = static_cast<QFakeFontEngine *>(si.fontEngine);
0268 
0269     int x       = int(p.x());
0270     int y       = int(p.y());
0271     int pixS    = int(eng->pixS);
0272     int advance = pixS;
0273     int ascent  = dimToInt(eng->ascent());
0274     int descent = dimToInt(eng->descent());
0275 
0276     if (si.flags & QTextItem::RightToLeft) {
0277         x       = x + advance * (cnt - 1);
0278         advance = -advance;
0279     }
0280 
0281     for (int pos = 0; pos < cnt; ++pos) {
0282         QRect rect;
0283 
0284         switch (si.chars[pos].unicode()) {
0285         case ' ':
0286         case 0x00A0: // NON-BREAKING SPACE
0287             rect = QRect();
0288             break;
0289         case 0x200B: // ZERO WIDTH SPACE
0290             continue;
0291         case 'p':
0292             //Below the baseline, including it
0293             rect = QRect(x, y, pixS, descent + 1);
0294             break;
0295         case 0xC9:
0296             //Above the baseline
0297             rect = QRect(x, y - ascent, pixS, ascent);
0298             break;
0299         default:
0300             //Whole block
0301             rect = QRect(x, y - ascent, pixS, pixS);
0302         }
0303 
0304         QPainter *p = painter();
0305         p->fillRect(rect, p->pen().color());
0306 
0307         x += advance;
0308     }
0309 }
0310 
0311 QFakeFontEngine::QFakeFontEngine(XFontStruct *fs, const char *name, int size)
0312     : QFontEngineXLFD(fs,  name,  0)
0313 {
0314     xfs = fs;
0315     pixS = size;
0316     this->name = QLatin1String(name);
0317     ahem = this->name.contains("ahem");
0318 
0319     const MetricsInfo *metrics = grabMetrics(name);
0320     if (metrics) {
0321         haveMetrics = true;
0322         m_ascent  = metrics->ascent;
0323         m_descent = metrics->descent;
0324         m_leading = metrics->leading;
0325     } else {
0326         haveMetrics = false;
0327     }
0328 }
0329 
0330 QFakeFontEngine::~QFakeFontEngine()
0331 {
0332 }
0333 
0334 bool QFakeFontEngine::canRender(const QChar *, int)
0335 {
0336     return true;
0337 }
0338 
0339 static QString courier_pickxlfd(int pixelsize, bool italic, bool bold)
0340 {
0341     if (pixelsize >= 24) {
0342         pixelsize = 24;
0343     } else if (pixelsize >= 18) {
0344         pixelsize = 18;
0345     } else if (pixelsize >= 12) {
0346         pixelsize = 12;
0347     } else {
0348         pixelsize = 10;
0349     }
0350 
0351     return QString("-adobe-courier-%1-%2-normal--%3-*-75-75-m-*-iso10646-1").arg(bold ? "bold" : "medium").arg(italic ? "o" : "r").arg(pixelsize);
0352 }
0353 
0354 static QString ahem_pickxlfd(int pixelsize)
0355 {
0356     return QString("-misc-ahem-medium-r-normal--%1-*-100-100-c-*-iso10646-1").arg(pixelsize);
0357 }
0358 
0359 static QString helv_pickxlfd(int pixelsize, bool italic, bool bold)
0360 {
0361     if (pixelsize >= 24) {
0362         pixelsize = 24;
0363     } else if (pixelsize >= 18) {
0364         pixelsize = 18;
0365     } else if (pixelsize >= 12) {
0366         pixelsize = 12;
0367     } else {
0368         pixelsize = 10;
0369     }
0370 
0371     return QString("-adobe-helvetica-%1-%2-normal--%3-*-75-75-p-*-iso10646-1").arg(bold ? "bold" : "medium").arg(italic ? "o" : "r").arg(pixelsize);
0372 
0373 }
0374 
0375 static QFontEngine *loadFont(const QFontDef &request)
0376 {
0377     QString xlfd;
0378     QStringList flist = request.family.toLower().split(",");
0379     foreach (QString family, flist) {
0380         if (!KHTMLSettings::availableFamilies().contains("," + family + ",", Qt::CaseInsensitive)) {
0381             continue;
0382         }
0383 
0384         if (family == "adobe courier" || family == "courier" || family == "fixed") {
0385             xlfd = courier_pickxlfd(request.pixelSize, request.style == QFont::StyleItalic, request.weight > 50);
0386         } else if (family == "times new roman" || family == "times") {
0387             xlfd = "-adobe-times-medium-r-normal--8-80-75-75-p-44-iso10646-1";
0388         } else if (family == "ahem") {
0389             xlfd = ahem_pickxlfd(request.pixelSize);
0390         } else {
0391             xlfd = helv_pickxlfd(request.pixelSize,  request.style == QFont::StyleItalic, request.weight > 50);
0392         }
0393         break;
0394     }
0395     if (xlfd.isEmpty()) {
0396         xlfd = helv_pickxlfd(request.pixelSize,  request.style == QFont::StyleItalic, request.weight > 50);
0397     }
0398 
0399     QFontEngine *fe = 0;
0400 
0401     XFontStruct *xfs;
0402     xfs = XLoadQueryFont(QX11Info::display(), xlfd.toLatin1());
0403     if (!xfs) { // as long as you don't do screenshots, it's maybe fine
0404         qFatal("we need some fonts. So make sure you have %s installed.", qPrintable(xlfd));
0405     }
0406 
0407     unsigned long value;
0408     if (!XGetFontProperty(xfs, XA_FONT, &value)) {
0409         return 0;
0410     }
0411 
0412     char *n = XGetAtomName(QX11Info::display(), value);
0413     xlfd = n;
0414     if (n) {
0415         XFree(n);
0416     }
0417 
0418     fe = new QFakeFontEngine(xfs, xlfd.toLatin1(), request.pixelSize);
0419     return fe;
0420 }
0421 
0422 Q_DECL_EXPORT
0423 QFontEngine *QFontDatabase::loadXlfd(int /* screen */, int /* script */,
0424                                      const QFontDef &request, int /* force_encoding_id */)
0425 {
0426     return loadFont(request);
0427 }
0428 
0429 extern "C" Q_DECL_EXPORT int FcInit()
0430 {
0431     /* Make sure Qt uses the Xlfd path, which we intercept */
0432     return 0;
0433 }
0434 
0435 Q_DECL_EXPORT bool QFontDatabase::isBitmapScalable(const QString &,
0436         const QString &) const
0437 {
0438     return true;
0439 }
0440 
0441 Q_DECL_EXPORT bool  QFontDatabase::isSmoothlyScalable(const QString &,
0442         const QString &) const
0443 {
0444     return true;
0445 }
0446 
0447 const QString &KHTMLSettings::availableFamilies()
0448 {
0449     if (!avFamilies) {
0450         avFamilies = new QString;
0451         *avFamilies = ",Adobe Courier,Arial,Comic Sans MS,Courier,Helvetica,Times,Times New Roman,Utopia,Fixed,Ahem,";
0452     }
0453 
0454     return *avFamilies;
0455 }
0456 
0457 bool KHTMLSettings::unfinishedImageFrame() const
0458 {
0459     return false;
0460 }
0461 
0462 Q_DECL_EXPORT int QX11Info::appDpiY(int)
0463 {
0464     return 100;
0465 }
0466 
0467 Q_DECL_EXPORT int QX11Info::appDpiX(int)
0468 {
0469     return 100;
0470 }
0471 
0472 Q_DECL_EXPORT void QFont::insertSubstitution(const QString &,
0473         const QString &)
0474 {
0475 }
0476 
0477 Q_DECL_EXPORT void QFont::insertSubstitutions(const QString &,
0478         const QStringList &)
0479 {
0480 }
0481 
0482 #include <kprotocolinfo.h>
0483 bool KProtocolInfo::isKnownProtocol(const QString &_protocol)
0484 {
0485     return (_protocol == "file");
0486 }
0487 
0488 #include <kprotocolinfofactory.h>
0489 
0490 QString KProtocolInfo::exec(const QString &_protocol)
0491 {
0492     if (_protocol != "file") {
0493         return QString();
0494     }
0495 
0496     KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol);
0497     if (!prot) {
0498         return QString();
0499     }
0500 
0501     return prot->m_exec;
0502 }
0503 /*
0504 #include <dcopclient.h>
0505 
0506 bool DCOPClient::attach()
0507 {
0508     return false;
0509 }
0510 
0511 bool DCOPClient::isAttached() const
0512 {
0513     return false;
0514 }
0515 
0516 void DCOPClient::processSocketData( int )
0517 {
0518 }*/
0519 
0520 #include <QApplication>
0521 #include <QPalette>
0522 
0523 #if 0
0524 Q_DECL_EXPORT void QApplication::setPalette(const QPalette &, bool,
0525         const char *)
0526 {
0527     static bool done = false;
0528     if (done) {
0529         return;
0530     }
0531     QString xlfd = AHEM;
0532     XFontStruct *xfs;
0533     xfs = XLoadQueryFont(QPaintDevice::x11AppDisplay(), xlfd.toLatin1().constData());
0534     if (!xfs) { // as long as you don't do screenshots, it's maybe fine
0535         qFatal("We will need some fonts. So make sure you have %s installed.", xlfd.toLatin1().constData());
0536     }
0537     XFreeFont(QPaintDevice::x11AppDisplay(), xfs);
0538     done = true;
0539 }
0540 #endif
0541 
0542 #include <kparts/historyprovider.h>
0543 
0544 bool KParts::HistoryProvider::contains(const QString &t) const
0545 {
0546     return (t == "http://www.kde.org/" || t == "http://www.google.com/");
0547 }
0548 
0549 #include <ksslsettings.h>
0550 
0551 bool KSSLSettings::warnOnEnter() const
0552 {
0553     return false;
0554 }
0555 bool KSSLSettings::warnOnUnencrypted() const
0556 {
0557     return false;
0558 }
0559 bool KSSLSettings::warnOnLeave() const
0560 {
0561     return false;
0562 }
0563 
0564 #include <kparts/plugin.h>
0565 
0566 KParts::Plugin *KParts::Plugin::loadPlugin(QObject * /* parent */, const char * /* libname */)
0567 {
0568     return 0;
0569 }
0570 
0571 #include <klineedit.h>
0572 
0573 void KLineEdit::setClearButtonEnabled(bool /*show*/)
0574 {}