OSDN Git Service

Version 0.5
[fontmanager/fontmanager.git] / installedfontinfo.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Takumi Asaki
4 ** All rights reserved.
5 ** Contact: Takumi Asaki (takumi.asaki@gmail.com)
6 **
7 ** This file is part of the fontmanager application.
8 **
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ****************************************************************************/
38
39 #ifndef INSTALLEDFONTINFO_H
40 #define INSTALLEDFONTINFO_H
41
42 #include <QObject>
43 #include <QStringList>
44
45 class FontsConfigProperties;
46
47 class InstalledFontInfo : public QObject
48 {
49     Q_OBJECT
50     Q_PROPERTY(QStringList family READ family NOTIFY detailsChanged)
51     Q_PROPERTY(QStringList familylang READ familylang NOTIFY detailsChanged)
52     Q_PROPERTY(QStringList style READ style NOTIFY detailsChanged)
53     Q_PROPERTY(QStringList stylelang READ stylelang NOTIFY detailsChanged)
54     Q_PROPERTY(QStringList fullname READ fullname NOTIFY detailsChanged)
55     Q_PROPERTY(QStringList fullnamelang READ fullnamelang NOTIFY detailsChanged)
56
57     Q_PROPERTY(QString localefamily READ localefamily NOTIFY detailsChanged)
58     Q_PROPERTY(QString localestyle READ localestyle NOTIFY detailsChanged)
59     Q_PROPERTY(QString localefullname READ localefullname NOTIFY detailsChanged)
60
61     Q_PROPERTY(QString enfamily READ enfamily NOTIFY detailsChanged)
62     Q_PROPERTY(QString enstyle READ enstyle NOTIFY detailsChanged)
63     Q_PROPERTY(QString enfullname READ enfullname NOTIFY detailsChanged)
64
65     Q_PROPERTY(QString foundry READ foundry NOTIFY detailsChanged)
66     Q_PROPERTY(QString file READ file NOTIFY detailsChanged)
67     Q_PROPERTY(QStringList lang READ lang NOTIFY detailsChanged)
68     Q_PROPERTY(bool outline READ outline NOTIFY detailsChanged)
69     Q_PROPERTY(bool scalable READ scalable NOTIFY detailsChanged)
70     Q_PROPERTY(int slant READ slant NOTIFY detailsChanged)
71     Q_PROPERTY(int weight READ weight NOTIFY detailsChanged)
72     Q_PROPERTY(int width READ width NOTIFY detailsChanged)
73
74     Q_PROPERTY(bool systemFont READ systemFont NOTIFY detailsChanged)
75
76 public:
77     explicit InstalledFontInfo(const QByteArray buf, const QString &localFontPath, QObject *parent = 0);
78     
79     bool isValid();
80
81     QStringList family() const;
82     QStringList familylang() const;
83     QStringList style() const;
84     QStringList stylelang() const;
85     QStringList fullname() const;
86     QStringList fullnamelang() const;
87     QString foundry() const;
88     QString file() const;
89     QStringList lang() const;
90     bool outline() const;
91     bool scalable() const;
92     int slant() const;
93     int weight() const;
94     int width() const;
95
96     QString localefamily() const;
97     QString localestyle() const;
98     QString localefullname() const;
99
100     QString enfamily() const;
101     QString enstyle() const;
102     QString enfullname() const;
103
104     QString locale() const;
105     void setLocale(const QString &loc);
106
107     bool systemFont() const;
108
109     QString localeString(const QStringList &strlist, const QStringList &langlist, const QString &lang) const;
110
111     Q_INVOKABLE FontsConfigProperties *fontProperty() const;
112     void setFontProperty(FontsConfigProperties *prop);
113
114     static bool compare(const InstalledFontInfo *info1, InstalledFontInfo *info2);
115
116 signals:
117     void detailsChanged();
118
119 public slots:
120
121 private:
122     bool analyze(const QByteArray &buf, const QString &localFontPath);
123
124     static QString toString(const QString &value);
125     static QStringList toStringList(const QString &value);
126     static int toInt(const QString &value);
127     static bool toBool(const QString &value);
128
129 private:
130     bool mValid;
131
132     QStringList mFamily;
133     QStringList mFamilylang;
134     QStringList mStyle;
135     QStringList mStylelang;
136     QStringList mFullname;
137     QStringList mFullnamelang;
138     QString mFoundry;
139     QString mFile;
140     QStringList mLang;
141     bool mOutline;
142     bool mScalable;
143     int mSlant;
144     int mWeight;
145     int mWidth;
146
147     bool mSystemFont;
148
149     QString mLocale;
150
151     FontsConfigProperties *mFontProperty;
152 };
153
154 #endif // INSTALLEDFONTINFO_H