2
* KFontInst - KDE Font Installer
4
* Copyright 2003-2007 Craig Drummond <craig@kde.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; see the file COPYING. If not, write to
20
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301, USA.
26
#include <QtCore/QProcess>
33
static int getInt(const QString &str)
35
int rv=KFI_NULL_SETTING,
36
start=str.lastIndexOf(':')+1,
37
end=str.lastIndexOf("(i)(s)");
40
rv=str.mid(start, end-start).trimmed().toInt();
49
void CFcQuery::run(const QString &query)
53
itsFile=itsFont=QString();
54
itsBuffer=QByteArray();
59
itsProc=new QProcess(this);
61
args << "-v" << query;
63
connect(itsProc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(procExited()));
64
connect(itsProc, SIGNAL(readyReadStandardOutput()), SLOT(data()));
66
itsProc->start("fc-match", args);
69
void CFcQuery::procExited()
72
int weight(KFI_NULL_SETTING), slant(KFI_NULL_SETTING), width(KFI_NULL_SETTING);
73
QStringList results(QString::fromUtf8(itsBuffer, itsBuffer.length()).split('\n'));
77
QStringList::ConstIterator it(results.begin()),
82
QString line((*it).trimmed());
84
if(0==line.indexOf("file:")) // file: "Wibble"(s)
86
int endPos=line.indexOf("\"(s)");
89
itsFile=line.mid(7, endPos-7);
91
else if(0==line.indexOf("family:")) // family: "Wibble"(s)
93
int endPos=line.indexOf("\"(s)");
96
family=line.mid(9, endPos-9);
98
else if(0==line.indexOf("slant:")) // slant: 0(i)(s)
100
else if(0==line.indexOf("weight:")) // weight: 0(i)(s)
102
else if(0==line.indexOf("width:")) // width: 0(i)(s)
107
if(!family.isEmpty())
108
itsFont=FC::createName(family, weight, width, slant);
113
void CFcQuery::data()
115
itsBuffer+=itsProc->readAllStandardOutput();
120
#include "FcQuery.moc"