summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/fontdatabase.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp
index 147134c..899d5cf 100644
--- a/library/fontdatabase.cpp
+++ b/library/fontdatabase.cpp
@@ -68,163 +68,167 @@ QValueList<FontFactory> *FontDatabase::factoryList = 0;
68 plugins have greater resource requirements than system fonts so they 68 plugins have greater resource requirements than system fonts so they
69 should be used only when necessary. You can force the loading of 69 should be used only when necessary. You can force the loading of
70 font renderer plugins with loadRenderers(). 70 font renderer plugins with loadRenderers().
71 71
72 \ingroup qtopiaemb 72 \ingroup qtopiaemb
73*/ 73*/
74 74
75/*! 75/*!
76 Constructs a FontDatabase object. 76 Constructs a FontDatabase object.
77*/ 77*/
78FontDatabase::FontDatabase() 78FontDatabase::FontDatabase()
79#ifndef QT_NO_FONTDATABASE 79#ifndef QT_NO_FONTDATABASE
80 : QFontDatabase() 80 : QFontDatabase()
81#endif 81#endif
82{ 82{
83 if ( !factoryList ) 83 if ( !factoryList )
84 loadRenderers(); 84 loadRenderers();
85} 85}
86 86
87/*! 87/*!
88 Returns a list of names of all the available font families. 88 Returns a list of names of all the available font families.
89*/ 89*/
90QStringList FontDatabase::families() const 90QStringList FontDatabase::families() const
91{ 91{
92#ifndef QT_NO_FONTDATABASE 92#ifndef QT_NO_FONTDATABASE
93 return QFontDatabase::families(); 93 return QFontDatabase::families();
94#else 94#else
95 QStringList list; 95 QStringList list;
96 QDict<void> familyDict; 96 QDict<void> familyDict;
97 QDiskFont *qdf; 97 QDiskFont *qdf;
98 for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; 98 for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0;
99 qdf=qt_fontmanager->diskfonts.next()) { 99 qdf=qt_fontmanager->diskfonts.next()) {
100 QString familyname = qdf->name; 100 QString familyname = qdf->name;
101 if ( !familyDict.find( familyname ) ) { 101 if ( !familyDict.find( familyname ) ) {
102 familyDict.insert( familyname, (void *)1 ); 102 familyDict.insert( familyname, (void *)1 );
103 list.append( familyname ); 103 list.append( familyname );
104 } 104 }
105 } 105 }
106 106
107 QDir dir(fontDir(),"*.qpf"); 107 QDir dir(fontDir(),"*.qpf");
108 for (int i=0; i<(int)dir.count(); i++) { 108 for (int i=0; i<(int)dir.count(); i++) {
109 QString familyname = fontFamily(dir[i]); 109 QString familyname = fontFamily(dir[i]);
110 if ( !familyDict.find( familyname ) ) { 110 if ( !familyDict.find( familyname ) ) {
111 familyDict.insert( familyname, (void *)1 ); 111 familyDict.insert( familyname, (void *)1 );
112 list.append( familyname ); 112 list.append( familyname );
113 } 113 }
114 } 114 }
115 115
116 return list; 116 return list;
117#endif 117#endif
118} 118}
119 119
120#ifdef QT_NO_FONTDATABASE 120#ifdef QT_NO_FONTDATABASE
121/*! 121/*!
122 Returns a list of standard fontsizes. 122 Returns a list of standard fontsizes.
123*/ 123*/
124QValueList<int> FontDatabase::standardSizes() 124QValueList<int> FontDatabase::standardSizes()
125{ 125{
126 static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 126 static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28,
127 36, 48, 72, 0 }; 127 36, 48, 72, 0 };
128 static bool first = TRUE; 128 static bool first = TRUE;
129 static QValueList<int> sList; 129 static QValueList<int> sList;
130 if ( first ) { 130 if ( first ) {
131 first = FALSE; 131 first = FALSE;
132 int i = 0; 132 int i = 0;
133 while( s[i] ) 133 while( s[i] )
134 sList.append( s[i++] ); 134 sList.append( s[i++] );
135 } 135 }
136 return sList; 136 return sList;
137} 137}
138 138
139#endif 139#endif
140 140
141/*! 141/*!
142 Load any font renderer plugins that are available and make the fonts 142 Load any font renderer plugins that are available and make the fonts
143 that the plugins can read available. 143 that the plugins can read available.
144*/ 144*/
145void FontDatabase::loadRenderers() 145void FontDatabase::loadRenderers()
146{ 146{
147#ifndef QT_NO_COMPONENT 147#ifndef QT_NO_COMPONENT
148 if ( !factoryList ) 148 if ( !factoryList )
149 factoryList = new QValueList<FontFactory>; 149 factoryList = new QValueList<FontFactory>;
150 150
151 QValueList<FontFactory>::Iterator mit; 151 QValueList<FontFactory>::Iterator mit;
152 for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { 152 for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) {
153 qt_fontmanager->factories.setAutoDelete( false ); 153 qt_fontmanager->factories.setAutoDelete( false );
154 qt_fontmanager->factories.removeRef( (*mit).factory ); 154 qt_fontmanager->factories.removeRef( (*mit).factory );
155 qt_fontmanager->factories.setAutoDelete( true ); 155 qt_fontmanager->factories.setAutoDelete( true );
156 (*mit).interface->release(); 156 (*mit).interface->release();
157 (*mit).library->unload(); 157 (*mit).library->unload();
158 delete (*mit).library; 158 delete (*mit).library;
159 } 159 }
160 factoryList->clear(); 160 factoryList->clear();
161 161
162 QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; 162 QString path = QPEApplication::qpeDir() + "/plugins/fontfactories";
163 QDir dir( path, "lib*.so" ); 163 QDir dir( path, "lib*.so" );
164
165 if ( !dir.exists())
166 return;
167
164 QStringList list = dir.entryList(); 168 QStringList list = dir.entryList();
165 QStringList::Iterator it; 169 QStringList::Iterator it;
166 for ( it = list.begin(); it != list.end(); ++it ) { 170 for ( it = list.begin(); it != list.end(); ++it ) {
167 FontFactoryInterface *iface = 0; 171 FontFactoryInterface *iface = 0;
168 QLibrary *lib = new QLibrary( path + "/" + *it ); 172 QLibrary *lib = new QLibrary( path + "/" + *it );
169 if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { 173 if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) {
170 FontFactory factory; 174 FontFactory factory;
171 factory.library = lib; 175 factory.library = lib;
172 factory.interface = iface; 176 factory.interface = iface;
173 factory.factory = factory.interface->fontFactory(); 177 factory.factory = factory.interface->fontFactory();
174 factoryList->append( factory ); 178 factoryList->append( factory );
175 qt_fontmanager->factories.append( factory.factory ); 179 qt_fontmanager->factories.append( factory.factory );
176 readFonts( factory.factory ); 180 readFonts( factory.factory );
177 } else { 181 } else {
178 delete lib; 182 delete lib;
179 } 183 }
180 } 184 }
181#endif 185#endif
182} 186}
183 187
184/*! 188/*!
185 \internal 189 \internal
186*/ 190*/
187void FontDatabase::readFonts( QFontFactory *factory ) 191void FontDatabase::readFonts( QFontFactory *factory )
188{ 192{
189 // Load in font definition file 193 // Load in font definition file
190 QString fn = fontDir() + "fontdir"; 194 QString fn = fontDir() + "fontdir";
191 FILE* fontdef=fopen(fn.local8Bit(),"r"); 195 FILE* fontdef=fopen(fn.local8Bit(),"r");
192 if(!fontdef) { 196 if(!fontdef) {
193 QCString temp=fn.local8Bit(); 197 QCString temp=fn.local8Bit();
194 qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", 198 qWarning("Cannot find font definition file %s - is $QTDIR set correctly?",
195 temp.data()); 199 temp.data());
196 return; 200 return;
197 } 201 }
198 char buf[200]=""; 202 char buf[200]="";
199 char name[200]=""; 203 char name[200]="";
200 char render[200]=""; 204 char render[200]="";
201 char file[200]=""; 205 char file[200]="";
202 char flags[200]=""; 206 char flags[200]="";
203 char isitalic[10]=""; 207 char isitalic[10]="";
204 fgets(buf,200,fontdef); 208 fgets(buf,200,fontdef);
205 while(!feof(fontdef)) { 209 while(!feof(fontdef)) {
206 if ( buf[0] != '#' ) { 210 if ( buf[0] != '#' ) {
207 int weight=50; 211 int weight=50;
208 int size=0; 212 int size=0;
209 flags[0]=0; 213 flags[0]=0;
210 sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); 214 sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags);
211 QString filename; 215 QString filename;
212 if ( file[0] != '/' ) 216 if ( file[0] != '/' )
213 filename = fontDir(); 217 filename = fontDir();
214 filename += file; 218 filename += file;
215 if ( QFile::exists(filename) ) { 219 if ( QFile::exists(filename) ) {
216 if( factory->name() == render ) { 220 if( factory->name() == render ) {
217 QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', 221 QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y',
218 weight,size,flags,filename); 222 weight,size,flags,filename);
219 qt_fontmanager->diskfonts.append(qdf); 223 qt_fontmanager->diskfonts.append(qdf);
220#if QT_VERSION >= 232 224#if QT_VERSION >= 232
221 QFontDatabase::qwsAddDiskFont( qdf ); 225 QFontDatabase::qwsAddDiskFont( qdf );
222#endif 226#endif
223 } 227 }
224 } 228 }
225 } 229 }
226 fgets(buf,200,fontdef); 230 fgets(buf,200,fontdef);
227 } 231 }
228 fclose(fontdef); 232 fclose(fontdef);
229} 233}
230 234