summaryrefslogtreecommitdiff
path: root/library/fontdatabase.cpp
authorzecke <zecke>2002-09-10 12:09:49 (UTC)
committer zecke <zecke>2002-09-10 12:09:49 (UTC)
commit6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (side-by-side diff)
tree6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/fontdatabase.cpp
parentd10cddb3c9ce75bc90b14add14bc133737fe35aa (diff)
downloadopie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2
Qtopia1-6 merge
still to test bic changes to be resolved more changes to be made?
Diffstat (limited to 'library/fontdatabase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/fontdatabase.cpp39
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,39 +1,41 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "qpeapplication.h"
#include "fontfactoryinterface.h"
#include "fontdatabase.h"
#include <qpe/qlibrary.h>
+#ifdef QWS
#include <qfontmanager_qws.h>
+#endif
#include <qdir.h>
#include <qdict.h>
#include <stdio.h>
#include <stdlib.h>
static QString fontDir()
{
QString qtdir = getenv("QTDIR");
if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded";
return qtdir+"/lib/fonts/";
}
@@ -49,54 +51,52 @@ static QString fontFamily( const QString& key )
//bool italic = key.mid(u2-1,1) == "i";
// #### ignores _t and _I fields
return family;
}
#endif
QValueList<FontFactory> *FontDatabase::factoryList = 0;
/*!
\class FontDatabase fontdatabase.h
\brief The FontDatabase class provides information about available fonts.
- Provides information about available fonts.
-
- FontDatabase provides information about the available fonts of the
- underlying window system.
+ Most often you will simply want to query the database for the
+ available font families().
- Most often you will simply want to query the database for all font
- families(), and their respective pointSizes(), styles() and charSets().
+ Use FontDatabase rather than QFontDatabase when you may need access
+ to fonts that are not normally available. For example, if the
+ freetype library and the Qtopia freetype plugin are installed,
+ TrueType fonts will be available to your application. Font renderer
+ plugins have greater resource requirements than system fonts so they
+ should be used only when necessary. You can force the loading of
+ font renderer plugins with loadRenderers().
- Use FontDatabase rather than QFontDatabase when you may need access to
- fonts not normally available. For example, if the freetype library and
- Qtopia freetype plugin are installed TrueType fonts will be available
- to your application. Font renderer plugins have greater resource
- requirements than the system fonts so they should be used only when
- necessary.
+ \ingroup qtopiaemb
*/
/*!
- Constructs the FontDatabase class.
+ Constructs a FontDatabase object.
*/
FontDatabase::FontDatabase()
#ifndef QT_NO_FONTDATABASE
: QFontDatabase()
#endif
{
if ( !factoryList )
loadRenderers();
}
/*!
- Returns a list of names of all available font families.
+ Returns a list of names of all the available font families.
*/
QStringList FontDatabase::families() const
{
#ifndef QT_NO_FONTDATABASE
return QFontDatabase::families();
#else
QStringList list;
QDict<void> familyDict;
QDiskFont *qdf;
for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0;
qdf=qt_fontmanager->diskfonts.next()) {
QString familyname = qdf->name;
@@ -132,26 +132,26 @@ QValueList<int> FontDatabase::standardSizes()
if ( first ) {
first = FALSE;
int i = 0;
while( s[i] )
sList.append( s[i++] );
}
return sList;
}
#endif
/*!
- Load any font renderer plugins that are available and make fonts that
- the plugins can read available.
+ Load any font renderer plugins that are available and make the fonts
+ that the plugins can read available.
*/
void FontDatabase::loadRenderers()
{
#ifndef QT_NO_COMPONENT
if ( !factoryList )
factoryList = new QValueList<FontFactory>;
QValueList<FontFactory>::Iterator mit;
for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) {
qt_fontmanager->factories.setAutoDelete( false );
qt_fontmanager->factories.removeRef( (*mit).factory );
qt_fontmanager->factories.setAutoDelete( true );
@@ -179,25 +179,24 @@ void FontDatabase::loadRenderers()
} else {
delete lib;
}
}
#endif
}
/*!
\internal
*/
void FontDatabase::readFonts( QFontFactory *factory )
{
-
// Load in font definition file
QString fn = fontDir() + "fontdir";
FILE* fontdef=fopen(fn.local8Bit(),"r");
if(!fontdef) {
QCString temp=fn.local8Bit();
qWarning("Cannot find font definition file %s - is $QTDIR set correctly?",
temp.data());
return;
}
char buf[200]="";
char name[200]="";
char render[200]="";
@@ -211,25 +210,23 @@ void FontDatabase::readFonts( QFontFactory *factory )
int size=0;
flags[0]=0;
sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags);
QString filename;
if ( file[0] != '/' )
filename = fontDir();
filename += file;
if ( QFile::exists(filename) ) {
if( factory->name() == render ) {
QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y',
weight,size,flags,filename);
qt_fontmanager->diskfonts.append(qdf);
-#ifndef QT_NO_FONTDATABASE
#if QT_VERSION >= 232
QFontDatabase::qwsAddDiskFont( qdf );
#endif
-#endif
}
}
}
fgets(buf,200,fontdef);
}
fclose(fontdef);
}