-rw-r--r-- | library/fontdatabase.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index 50dcf3d..c64e645 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -19,17 +19,19 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qpeapplication.h" | 21 | #include "qpeapplication.h" |
22 | #include "fontfactoryinterface.h" | 22 | #include "fontfactoryinterface.h" |
23 | #include "fontdatabase.h" | 23 | #include "fontdatabase.h" |
24 | 24 | ||
25 | #include <qpe/qlibrary.h> | 25 | #include <qpe/qlibrary.h> |
26 | 26 | ||
27 | #ifdef QWS | ||
27 | #include <qfontmanager_qws.h> | 28 | #include <qfontmanager_qws.h> |
29 | #endif | ||
28 | #include <qdir.h> | 30 | #include <qdir.h> |
29 | #include <qdict.h> | 31 | #include <qdict.h> |
30 | #include <stdio.h> | 32 | #include <stdio.h> |
31 | #include <stdlib.h> | 33 | #include <stdlib.h> |
32 | 34 | ||
33 | static QString fontDir() | 35 | static QString fontDir() |
34 | { | 36 | { |
35 | QString qtdir = getenv("QTDIR"); | 37 | QString qtdir = getenv("QTDIR"); |
@@ -53,46 +55,44 @@ static QString fontFamily( const QString& key ) | |||
53 | #endif | 55 | #endif |
54 | 56 | ||
55 | QValueList<FontFactory> *FontDatabase::factoryList = 0; | 57 | QValueList<FontFactory> *FontDatabase::factoryList = 0; |
56 | 58 | ||
57 | /*! | 59 | /*! |
58 | \class FontDatabase fontdatabase.h | 60 | \class FontDatabase fontdatabase.h |
59 | \brief The FontDatabase class provides information about available fonts. | 61 | \brief The FontDatabase class provides information about available fonts. |
60 | 62 | ||
61 | Provides information about available fonts. | 63 | Most often you will simply want to query the database for the |
62 | 64 | available font families(). | |
63 | FontDatabase provides information about the available fonts of the | ||
64 | underlying window system. | ||
65 | 65 | ||
66 | Most often you will simply want to query the database for all font | 66 | Use FontDatabase rather than QFontDatabase when you may need access |
67 | families(), and their respective pointSizes(), styles() and charSets(). | 67 | to fonts that are not normally available. For example, if the |
68 | freetype library and the Qtopia freetype plugin are installed, | ||
69 | TrueType fonts will be available to your application. Font renderer | ||
70 | plugins have greater resource requirements than system fonts so they | ||
71 | should be used only when necessary. You can force the loading of | ||
72 | font renderer plugins with loadRenderers(). | ||
68 | 73 | ||
69 | Use FontDatabase rather than QFontDatabase when you may need access to | 74 | \ingroup qtopiaemb |
70 | fonts not normally available. For example, if the freetype library and | ||
71 | Qtopia freetype plugin are installed TrueType fonts will be available | ||
72 | to your application. Font renderer plugins have greater resource | ||
73 | requirements than the system fonts so they should be used only when | ||
74 | necessary. | ||
75 | */ | 75 | */ |
76 | 76 | ||
77 | /*! | 77 | /*! |
78 | Constructs the FontDatabase class. | 78 | Constructs a FontDatabase object. |
79 | */ | 79 | */ |
80 | FontDatabase::FontDatabase() | 80 | FontDatabase::FontDatabase() |
81 | #ifndef QT_NO_FONTDATABASE | 81 | #ifndef QT_NO_FONTDATABASE |
82 | : QFontDatabase() | 82 | : QFontDatabase() |
83 | #endif | 83 | #endif |
84 | { | 84 | { |
85 | if ( !factoryList ) | 85 | if ( !factoryList ) |
86 | loadRenderers(); | 86 | loadRenderers(); |
87 | } | 87 | } |
88 | 88 | ||
89 | /*! | 89 | /*! |
90 | Returns a list of names of all available font families. | 90 | Returns a list of names of all the available font families. |
91 | */ | 91 | */ |
92 | QStringList FontDatabase::families() const | 92 | QStringList FontDatabase::families() const |
93 | { | 93 | { |
94 | #ifndef QT_NO_FONTDATABASE | 94 | #ifndef QT_NO_FONTDATABASE |
95 | return QFontDatabase::families(); | 95 | return QFontDatabase::families(); |
96 | #else | 96 | #else |
97 | QStringList list; | 97 | QStringList list; |
98 | QDict<void> familyDict; | 98 | QDict<void> familyDict; |
@@ -136,18 +136,18 @@ QValueList<int> FontDatabase::standardSizes() | |||
136 | sList.append( s[i++] ); | 136 | sList.append( s[i++] ); |
137 | } | 137 | } |
138 | return sList; | 138 | return sList; |
139 | } | 139 | } |
140 | 140 | ||
141 | #endif | 141 | #endif |
142 | 142 | ||
143 | /*! | 143 | /*! |
144 | Load any font renderer plugins that are available and make fonts that | 144 | Load any font renderer plugins that are available and make the fonts |
145 | the plugins can read available. | 145 | that the plugins can read available. |
146 | */ | 146 | */ |
147 | void FontDatabase::loadRenderers() | 147 | void FontDatabase::loadRenderers() |
148 | { | 148 | { |
149 | #ifndef QT_NO_COMPONENT | 149 | #ifndef QT_NO_COMPONENT |
150 | if ( !factoryList ) | 150 | if ( !factoryList ) |
151 | factoryList = new QValueList<FontFactory>; | 151 | factoryList = new QValueList<FontFactory>; |
152 | 152 | ||
153 | QValueList<FontFactory>::Iterator mit; | 153 | QValueList<FontFactory>::Iterator mit; |
@@ -183,17 +183,16 @@ void FontDatabase::loadRenderers() | |||
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | 185 | ||
186 | /*! | 186 | /*! |
187 | \internal | 187 | \internal |
188 | */ | 188 | */ |
189 | void FontDatabase::readFonts( QFontFactory *factory ) | 189 | void FontDatabase::readFonts( QFontFactory *factory ) |
190 | { | 190 | { |
191 | |||
192 | // Load in font definition file | 191 | // Load in font definition file |
193 | QString fn = fontDir() + "fontdir"; | 192 | QString fn = fontDir() + "fontdir"; |
194 | FILE* fontdef=fopen(fn.local8Bit(),"r"); | 193 | FILE* fontdef=fopen(fn.local8Bit(),"r"); |
195 | if(!fontdef) { | 194 | if(!fontdef) { |
196 | QCString temp=fn.local8Bit(); | 195 | QCString temp=fn.local8Bit(); |
197 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", | 196 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", |
198 | temp.data()); | 197 | temp.data()); |
199 | return; | 198 | return; |
@@ -215,21 +214,19 @@ void FontDatabase::readFonts( QFontFactory *factory ) | |||
215 | if ( file[0] != '/' ) | 214 | if ( file[0] != '/' ) |
216 | filename = fontDir(); | 215 | filename = fontDir(); |
217 | filename += file; | 216 | filename += file; |
218 | if ( QFile::exists(filename) ) { | 217 | if ( QFile::exists(filename) ) { |
219 | if( factory->name() == render ) { | 218 | if( factory->name() == render ) { |
220 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', | 219 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', |
221 | weight,size,flags,filename); | 220 | weight,size,flags,filename); |
222 | qt_fontmanager->diskfonts.append(qdf); | 221 | qt_fontmanager->diskfonts.append(qdf); |
223 | #ifndef QT_NO_FONTDATABASE | ||
224 | #if QT_VERSION >= 232 | 222 | #if QT_VERSION >= 232 |
225 | QFontDatabase::qwsAddDiskFont( qdf ); | 223 | QFontDatabase::qwsAddDiskFont( qdf ); |
226 | #endif | 224 | #endif |
227 | #endif | ||
228 | } | 225 | } |
229 | } | 226 | } |
230 | } | 227 | } |
231 | fgets(buf,200,fontdef); | 228 | fgets(buf,200,fontdef); |
232 | } | 229 | } |
233 | fclose(fontdef); | 230 | fclose(fontdef); |
234 | } | 231 | } |
235 | 232 | ||