qfontdatabase.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QFONTDATABASE_H
00043 #define QFONTDATABASE_H
00044 
00045 #include <QtGui/qwindowdefs.h>
00046 #include <QtCore/qstring.h>
00047 #include <QtGui/qfont.h>
00048 #ifdef QT3_SUPPORT
00049 #include <QtCore/qstringlist.h>
00050 #include <QtCore/qlist.h>
00051 #endif
00052 
00053 QT_BEGIN_HEADER
00054 
00055 QT_BEGIN_NAMESPACE
00056 
00057 QT_MODULE(Gui)
00058 
00059 class QStringList;
00060 template <class T> class QList;
00061 struct QFontDef;
00062 class QFontEngine;
00063 
00064 class QFontDatabasePrivate;
00065 
00066 class Q_GUI_EXPORT QFontDatabase
00067 {
00068     Q_GADGET
00069     Q_ENUMS(WritingSystem)
00070 public:
00071     // do not re-order or delete entries from this enum without updating the
00072     // QPF2 format and makeqpf!!
00073     enum WritingSystem {
00074         Any,
00075 
00076         Latin,
00077         Greek,
00078         Cyrillic,
00079         Armenian,
00080         Hebrew,
00081         Arabic,
00082         Syriac,
00083         Thaana,
00084         Devanagari,
00085         Bengali,
00086         Gurmukhi,
00087         Gujarati,
00088         Oriya,
00089         Tamil,
00090         Telugu,
00091         Kannada,
00092         Malayalam,
00093         Sinhala,
00094         Thai,
00095         Lao,
00096         Tibetan,
00097         Myanmar,
00098         Georgian,
00099         Khmer,
00100         SimplifiedChinese,
00101         TraditionalChinese,
00102         Japanese,
00103         Korean,
00104         Vietnamese,
00105 
00106         Symbol,
00107         Other = Symbol,
00108 
00109         Ogham,
00110         Runic,
00111         Nko,
00112 
00113         WritingSystemsCount
00114     };
00115 
00116     static QList<int> standardSizes();
00117 
00118     QFontDatabase();
00119 
00120     QList<WritingSystem> writingSystems() const;
00121     QList<WritingSystem> writingSystems(const QString &family) const;
00122 
00123     QStringList families(WritingSystem writingSystem = Any) const;
00124     QStringList styles(const QString &family) const;
00125     QList<int> pointSizes(const QString &family, const QString &style = QString());
00126     QList<int> smoothSizes(const QString &family, const QString &style);
00127     QString styleString(const QFont &font);
00128     QString styleString(const QFontInfo &fontInfo);
00129 
00130     QFont font(const QString &family, const QString &style, int pointSize) const;
00131 
00132     bool isBitmapScalable(const QString &family, const QString &style = QString()) const;
00133     bool isSmoothlyScalable(const QString &family, const QString &style = QString()) const;
00134     bool isScalable(const QString &family, const QString &style = QString()) const;
00135     bool isFixedPitch(const QString &family, const QString &style = QString()) const;
00136 
00137     bool italic(const QString &family, const QString &style) const;
00138     bool bold(const QString &family, const QString &style) const;
00139     int weight(const QString &family, const QString &style) const;
00140 
00141     static QString writingSystemName(WritingSystem writingSystem);
00142     static QString writingSystemSample(WritingSystem writingSystem);
00143 
00144     static int addApplicationFont(const QString &fileName);
00145     static int addApplicationFontFromData(const QByteArray &fontData);
00146     static QStringList applicationFontFamilies(int id);
00147     static bool removeApplicationFont(int id);
00148     static bool removeAllApplicationFonts();
00149 
00150     static bool supportsThreadedFontRendering();
00151 
00152 private:
00153     static void createDatabase();
00154     static void parseFontName(const QString &name, QString &foundry, QString &family);
00155 #if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
00156     static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request);
00157 #endif
00158     static void load(const QFontPrivate *d, int script);
00159 #ifdef Q_WS_X11
00160     static QFontEngine *loadXlfd(int screen, int script, const QFontDef &request, int force_encoding_id = -1);
00161 #endif
00162 
00163     friend struct QFontDef;
00164     friend class QFontPrivate;
00165     friend class QFontDialog;
00166     friend class QFontDialogPrivate;
00167     friend class QFontEngineMultiXLFD;
00168     friend class QFontEngineMultiQWS;
00169     friend class QFontEngineMultiS60;
00170 
00171     QFontDatabasePrivate *d;
00172 };
00173 
00174 QT_END_NAMESPACE
00175 
00176 QT_END_HEADER
00177 
00178 #endif // QFONTDATABASE_H