-rw-r--r-- | library/fontdatabase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index c64e645..2b5e0d2 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -1,149 +1,149 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qpeapplication.h" | 21 | #include <qpe/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 | #ifdef QWS |
28 | #include <qfontmanager_qws.h> | 28 | #include <qfontmanager_qws.h> |
29 | #endif | 29 | #endif |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | static QString fontDir() | 35 | static QString fontDir() |
36 | { | 36 | { |
37 | QString qtdir = getenv("QTDIR"); | 37 | QString qtdir = getenv("QTDIR"); |
38 | if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded"; | 38 | if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded"; |
39 | return qtdir+"/lib/fonts/"; | 39 | return qtdir+"/lib/fonts/"; |
40 | } | 40 | } |
41 | 41 | ||
42 | #ifdef QT_NO_FONTDATABASE | 42 | #ifdef QT_NO_FONTDATABASE |
43 | static QString fontFamily( const QString& key ) | 43 | static QString fontFamily( const QString& key ) |
44 | { | 44 | { |
45 | int u0 = key.find('_'); | 45 | int u0 = key.find('_'); |
46 | int u1 = key.find('_',u0+1); | 46 | int u1 = key.find('_',u0+1); |
47 | int u2 = key.find('_',u1+1); | 47 | int u2 = key.find('_',u1+1); |
48 | QString family = key.left(u0); | 48 | QString family = key.left(u0); |
49 | //int pointSize = key.mid(u0+1,u1-u0-1).toInt(); | 49 | //int pointSize = key.mid(u0+1,u1-u0-1).toInt(); |
50 | //int weight = key.mid(u1+1,u2-u1-1).toInt(); | 50 | //int weight = key.mid(u1+1,u2-u1-1).toInt(); |
51 | //bool italic = key.mid(u2-1,1) == "i"; | 51 | //bool italic = key.mid(u2-1,1) == "i"; |
52 | // #### ignores _t and _I fields | 52 | // #### ignores _t and _I fields |
53 | return family; | 53 | return family; |
54 | } | 54 | } |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | QValueList<FontFactory> *FontDatabase::factoryList = 0; | 57 | QValueList<FontFactory> *FontDatabase::factoryList = 0; |
58 | 58 | ||
59 | /*! | 59 | /*! |
60 | \class FontDatabase fontdatabase.h | 60 | \class FontDatabase fontdatabase.h |
61 | \brief The FontDatabase class provides information about available fonts. | 61 | \brief The FontDatabase class provides information about available fonts. |
62 | 62 | ||
63 | Most often you will simply want to query the database for the | 63 | Most often you will simply want to query the database for the |
64 | available font families(). | 64 | available font families(). |
65 | 65 | ||
66 | Use FontDatabase rather than QFontDatabase when you may need access | 66 | Use FontDatabase rather than QFontDatabase when you may need access |
67 | to fonts that are not normally available. For example, if the | 67 | to fonts that are not normally available. For example, if the |
68 | freetype library and the Qtopia freetype plugin are installed, | 68 | freetype library and the Qtopia freetype plugin are installed, |
69 | TrueType fonts will be available to your application. Font renderer | 69 | TrueType fonts will be available to your application. Font renderer |
70 | plugins have greater resource requirements than system fonts so they | 70 | plugins have greater resource requirements than system fonts so they |
71 | should be used only when necessary. You can force the loading of | 71 | should be used only when necessary. You can force the loading of |
72 | font renderer plugins with loadRenderers(). | 72 | font renderer plugins with loadRenderers(). |
73 | 73 | ||
74 | \ingroup qtopiaemb | 74 | \ingroup qtopiaemb |
75 | */ | 75 | */ |
76 | 76 | ||
77 | /*! | 77 | /*! |
78 | Constructs a FontDatabase object. | 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 the 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; |
99 | QDiskFont *qdf; | 99 | QDiskFont *qdf; |
100 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; | 100 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; |
101 | qdf=qt_fontmanager->diskfonts.next()) { | 101 | qdf=qt_fontmanager->diskfonts.next()) { |
102 | QString familyname = qdf->name; | 102 | QString familyname = qdf->name; |
103 | if ( !familyDict.find( familyname ) ) { | 103 | if ( !familyDict.find( familyname ) ) { |
104 | familyDict.insert( familyname, (void *)1 ); | 104 | familyDict.insert( familyname, (void *)1 ); |
105 | list.append( familyname ); | 105 | list.append( familyname ); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | QDir dir(fontDir(),"*.qpf"); | 109 | QDir dir(fontDir(),"*.qpf"); |
110 | for (int i=0; i<(int)dir.count(); i++) { | 110 | for (int i=0; i<(int)dir.count(); i++) { |
111 | QString familyname = fontFamily(dir[i]); | 111 | QString familyname = fontFamily(dir[i]); |
112 | if ( !familyDict.find( familyname ) ) { | 112 | if ( !familyDict.find( familyname ) ) { |
113 | familyDict.insert( familyname, (void *)1 ); | 113 | familyDict.insert( familyname, (void *)1 ); |
114 | list.append( familyname ); | 114 | list.append( familyname ); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | return list; | 118 | return list; |
119 | #endif | 119 | #endif |
120 | } | 120 | } |
121 | 121 | ||
122 | #ifdef QT_NO_FONTDATABASE | 122 | #ifdef QT_NO_FONTDATABASE |
123 | /*! | 123 | /*! |
124 | Returns a list of standard fontsizes. | 124 | Returns a list of standard fontsizes. |
125 | */ | 125 | */ |
126 | QValueList<int> FontDatabase::standardSizes() | 126 | QValueList<int> FontDatabase::standardSizes() |
127 | { | 127 | { |
128 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, | 128 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, |
129 | 36, 48, 72, 0 }; | 129 | 36, 48, 72, 0 }; |
130 | static bool first = TRUE; | 130 | static bool first = TRUE; |
131 | static QValueList<int> sList; | 131 | static QValueList<int> sList; |
132 | if ( first ) { | 132 | if ( first ) { |
133 | first = FALSE; | 133 | first = FALSE; |
134 | int i = 0; | 134 | int i = 0; |
135 | while( s[i] ) | 135 | while( s[i] ) |
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 the fonts | 144 | Load any font renderer plugins that are available and make the fonts |
145 | that 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 |