-rw-r--r-- | library/fontdatabase.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index c7a5211..2ad8e95 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -109,129 +109,133 @@ QStringList FontDatabase::families() const | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | QDir dir(fontDir(),"*.qpf"); | 112 | QDir dir(fontDir(),"*.qpf"); |
113 | for (int i=0; i<(int)dir.count(); i++) { | 113 | for (int i=0; i<(int)dir.count(); i++) { |
114 | QString familyname = fontFamily(dir[i]); | 114 | QString familyname = fontFamily(dir[i]); |
115 | if ( !familyDict.find( familyname ) ) { | 115 | if ( !familyDict.find( familyname ) ) { |
116 | familyDict.insert( familyname, (void *)1 ); | 116 | familyDict.insert( familyname, (void *)1 ); |
117 | list.append( familyname ); | 117 | list.append( familyname ); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | return list; | 121 | return list; |
122 | #endif | 122 | #endif |
123 | #endif | 123 | #endif |
124 | } | 124 | } |
125 | 125 | ||
126 | #ifdef QT_NO_FONTDATABASE | 126 | #ifdef QT_NO_FONTDATABASE |
127 | /*! | 127 | /*! |
128 | Returns a list of standard fontsizes. | 128 | Returns a list of standard fontsizes. |
129 | */ | 129 | */ |
130 | QValueList<int> FontDatabase::standardSizes() | 130 | QValueList<int> FontDatabase::standardSizes() |
131 | { | 131 | { |
132 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, | 132 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, |
133 | 36, 48, 72, 0 }; | 133 | 36, 48, 72, 0 }; |
134 | static bool first = TRUE; | 134 | static bool first = TRUE; |
135 | static QValueList<int> sList; | 135 | static QValueList<int> sList; |
136 | if ( first ) { | 136 | if ( first ) { |
137 | first = FALSE; | 137 | first = FALSE; |
138 | int i = 0; | 138 | int i = 0; |
139 | while( s[i] ) | 139 | while( s[i] ) |
140 | sList.append( s[i++] ); | 140 | sList.append( s[i++] ); |
141 | } | 141 | } |
142 | return sList; | 142 | return sList; |
143 | } | 143 | } |
144 | 144 | ||
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | /*! | 147 | /*! |
148 | Load any font renderer plugins that are available and make the fonts | 148 | Load any font renderer plugins that are available and make the fonts |
149 | that the plugins can read available. | 149 | that the plugins can read available. |
150 | */ | 150 | */ |
151 | void FontDatabase::loadRenderers() | 151 | void FontDatabase::loadRenderers() |
152 | { | 152 | { |
153 | #ifndef QWS | 153 | #ifndef QWS |
154 | return; | 154 | return; |
155 | #else | 155 | #else |
156 | 156 | ||
157 | #ifndef QT_NO_COMPONENT | 157 | #ifndef QT_NO_COMPONENT |
158 | if ( !factoryList ) | 158 | if ( !factoryList ) |
159 | factoryList = new QValueList<FontFactory>; | 159 | factoryList = new QValueList<FontFactory>; |
160 | 160 | ||
161 | QValueList<FontFactory>::Iterator mit; | 161 | QValueList<FontFactory>::Iterator mit; |
162 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { | 162 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { |
163 | qt_fontmanager->factories.setAutoDelete( false ); | 163 | qt_fontmanager->factories.setAutoDelete( false ); |
164 | qt_fontmanager->factories.removeRef( (*mit).factory ); | 164 | qt_fontmanager->factories.removeRef( (*mit).factory ); |
165 | qt_fontmanager->factories.setAutoDelete( true ); | 165 | qt_fontmanager->factories.setAutoDelete( true ); |
166 | (*mit).interface->release(); | 166 | (*mit).interface->release(); |
167 | (*mit).library->unload(); | 167 | (*mit).library->unload(); |
168 | delete (*mit).library; | 168 | delete (*mit).library; |
169 | } | 169 | } |
170 | factoryList->clear(); | 170 | factoryList->clear(); |
171 | 171 | ||
172 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; | 172 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; |
173 | #ifdef Q_OS_MACX | ||
174 | QDir dir( path, "lib*.dylib" ); | ||
175 | #else | ||
173 | QDir dir( path, "lib*.so" ); | 176 | QDir dir( path, "lib*.so" ); |
177 | #endif | ||
174 | 178 | ||
175 | if ( !dir.exists()) | 179 | if ( !dir.exists()) |
176 | return; | 180 | return; |
177 | 181 | ||
178 | QStringList list = dir.entryList(); | 182 | QStringList list = dir.entryList(); |
179 | QStringList::Iterator it; | 183 | QStringList::Iterator it; |
180 | for ( it = list.begin(); it != list.end(); ++it ) { | 184 | for ( it = list.begin(); it != list.end(); ++it ) { |
181 | FontFactoryInterface *iface = 0; | 185 | FontFactoryInterface *iface = 0; |
182 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 186 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
183 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { | 187 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { |
184 | FontFactory factory; | 188 | FontFactory factory; |
185 | factory.library = lib; | 189 | factory.library = lib; |
186 | factory.interface = iface; | 190 | factory.interface = iface; |
187 | factory.factory = factory.interface->fontFactory(); | 191 | factory.factory = factory.interface->fontFactory(); |
188 | factoryList->append( factory ); | 192 | factoryList->append( factory ); |
189 | qt_fontmanager->factories.append( factory.factory ); | 193 | qt_fontmanager->factories.append( factory.factory ); |
190 | readFonts( factory.factory ); | 194 | readFonts( factory.factory ); |
191 | } else { | 195 | } else { |
192 | delete lib; | 196 | delete lib; |
193 | } | 197 | } |
194 | } | 198 | } |
195 | #endif | 199 | #endif |
196 | #endif | 200 | #endif |
197 | } | 201 | } |
198 | 202 | ||
199 | /*! | 203 | /*! |
200 | \internal | 204 | \internal |
201 | */ | 205 | */ |
202 | void FontDatabase::readFonts( QFontFactory *factory ) | 206 | void FontDatabase::readFonts( QFontFactory *factory ) |
203 | { | 207 | { |
204 | #ifndef QWS | 208 | #ifndef QWS |
205 | return; | 209 | return; |
206 | #else | 210 | #else |
207 | // Load in font definition file | 211 | // Load in font definition file |
208 | QString fn = fontDir() + "fontdir"; | 212 | QString fn = fontDir() + "fontdir"; |
209 | FILE* fontdef=fopen(fn.local8Bit(),"r"); | 213 | FILE* fontdef=fopen(fn.local8Bit(),"r"); |
210 | if(!fontdef) { | 214 | if(!fontdef) { |
211 | QCString temp=fn.local8Bit(); | 215 | QCString temp=fn.local8Bit(); |
212 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", | 216 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", |
213 | temp.data()); | 217 | temp.data()); |
214 | return; | 218 | return; |
215 | } | 219 | } |
216 | char buf[200]=""; | 220 | char buf[200]=""; |
217 | char name[200]=""; | 221 | char name[200]=""; |
218 | char render[200]=""; | 222 | char render[200]=""; |
219 | char file[200]=""; | 223 | char file[200]=""; |
220 | char flags[200]=""; | 224 | char flags[200]=""; |
221 | char isitalic[10]=""; | 225 | char isitalic[10]=""; |
222 | fgets(buf,200,fontdef); | 226 | fgets(buf,200,fontdef); |
223 | while(!feof(fontdef)) { | 227 | while(!feof(fontdef)) { |
224 | if ( buf[0] != '#' ) { | 228 | if ( buf[0] != '#' ) { |
225 | int weight=50; | 229 | int weight=50; |
226 | int size=0; | 230 | int size=0; |
227 | flags[0]=0; | 231 | flags[0]=0; |
228 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); | 232 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); |
229 | QString filename; | 233 | QString filename; |
230 | if ( file[0] != '/' ) | 234 | if ( file[0] != '/' ) |
231 | filename = fontDir(); | 235 | filename = fontDir(); |
232 | filename += file; | 236 | filename += file; |
233 | if ( QFile::exists(filename) ) { | 237 | if ( QFile::exists(filename) ) { |
234 | if( factory->name() == render ) { | 238 | if( factory->name() == render ) { |
235 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', | 239 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', |
236 | weight,size,flags,filename); | 240 | weight,size,flags,filename); |
237 | qt_fontmanager->diskfonts.append(qdf); | 241 | qt_fontmanager->diskfonts.append(qdf); |