1 #ifndef __KXFTCONFIG_H__
2 #define __KXFTCONFIG_H__
5 Copyright (c) 2002 Craig Drummond <craig@kde.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #include <config-workspace.h>
25 #ifdef HAVE_FONTCONFIG
27 #include <QStringList>
31 #include <QtXml/QtXml>
46 static const int constStyleSettings
=SubPixelType
|ExcludeRange
|AntiAlias
|HintStyle
;
50 Item(QDomNode
&n
) : node(n
), toBeRemoved(false) {}
51 Item() : toBeRemoved(false) {}
52 virtual void reset() { node
.clear(); toBeRemoved
=false; }
53 bool added() { return node
.isNull(); }
61 struct ListItem
: public Item
63 ListItem(const QString
&st
, QDomNode
&n
) : Item(n
), str(st
) {}
64 ListItem(const QString
&st
) : str(st
) {}
69 struct SubPixel
: public Item
80 SubPixel(Type t
, QDomNode
&n
) : Item(n
), type(t
) {}
81 SubPixel(Type t
=None
) : type(t
) {}
83 void reset() { Item::reset(); type
=None
; }
88 struct Exclude
: public Item
90 Exclude(double f
, double t
, QDomNode
&n
) : Item(n
), from(f
), to(t
) {}
91 Exclude(double f
=0, double t
=0) : from(f
), to(t
) {}
93 void reset() { Item::reset(); from
=to
=0; }
99 struct Hint
: public Item
110 Hint(Style s
, QDomNode
&n
) : Item(n
), style(s
) {}
111 Hint(Style s
=NotSet
) : style(s
) {}
113 void reset() { Item::reset(); style
=NotSet
; }
118 struct Hinting
: public Item
120 Hinting(bool s
, QDomNode
&n
) : Item(n
), set(s
) {}
121 Hinting(bool s
=true) : set(s
) {}
123 void reset() { Item::reset(); set
=true; }
128 struct AntiAliasing
: public Item
130 AntiAliasing(bool s
, QDomNode
&n
) : Item(n
), set(s
) {}
131 AntiAliasing(bool s
=true) : set(s
) {}
133 void reset() { Item::reset(); set
=true; }
140 static QString
contractHome(QString path
);
141 static QString
expandHome(QString path
);
145 // required - This should be a bitmask of 'RequiredData', and indicates the data to be
146 // read/written to the config file. It is intended that the 'fonts' KControl
147 // module will use KXftConfig::SubPixelType|KXftConfig::ExcludeRange, and the
148 // font installer will use KXftConfig::Dirs
150 // system - Indicates if the system-wide config file, or the users ~/.xftconfig file
151 // should be used. Only the font-installer should access the system file (and then
152 // only if run as root.
153 explicit KXftConfig(int required
, bool system
=false);
155 virtual ~KXftConfig();
159 bool getSubPixelType(SubPixel::Type
&type
);
160 void setSubPixelType(SubPixel::Type type
); // SubPixel::None => turn off sub-pixel rendering
161 bool getExcludeRange(double &from
, double &to
);
162 void setExcludeRange(double from
, double to
); // from:0, to:0 => turn off exclude range
163 void addDir(const QString
&d
);
164 void removeDir(const QString
&d
);
165 bool getHintStyle(Hint::Style
&style
);
166 void setHintStyle(Hint::Style style
);
167 void setAntiAliasing(bool set
);
168 bool getAntiAliasing() const;
169 bool changed() { return m_madeChanges
; }
170 static QString
description(SubPixel::Type t
);
171 static const char * toStr(SubPixel::Type t
);
172 static QString
description(Hint::Style s
);
173 static const char * toStr(Hint::Style s
);
174 bool hasDir(const QString
&d
);
178 QStringList
getDirList();
181 void applySubPixelType();
182 void applyHintStyle();
183 void applyAntiAliasing();
184 void setHinting(bool set
);
186 void applyExcludeRange(bool pixel
);
192 Exclude m_excludeRange
,
196 AntiAliasing m_antiAliasing
;
197 bool aliasingEnabled();
199 QList
<ListItem
> m_dirs
;