summaryrefslogtreecommitdiff
path: root/library/fontmanager.cpp
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /library/fontmanager.cpp
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'library/fontmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/fontmanager.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/library/fontmanager.cpp b/library/fontmanager.cpp
new file mode 100644
index 0000000..adbe57b
--- a/dev/null
+++ b/library/fontmanager.cpp
@@ -0,0 +1,101 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "fontmanager.h"
22#include <qfile.h>
23#include <stdlib.h>
24#include <qgfx_qws.h>
25
26
27
28/*
29 QFontInfo doesn't work in QWS at the moment,
30 otherwise we would just have used that to check
31 the real values
32
33 For now, there are only two Unicode fonts in
34 the known universe...
35
36*/
37
38bool FontManager::hasUnicodeFont()
39{
40 QString fontDir = getenv("QTDIR") + QString("/lib/fonts/");
41
42 QString suffix;
43 if ( qt_screen->isTransformed() ) {
44 suffix += "_t";
45 QPoint a = qt_screen->mapToDevice(QPoint(0,0),QSize(2,2));
46 QPoint b = qt_screen->mapToDevice(QPoint(1,1),QSize(2,2));
47 suffix += QString::number( a.x()*8+a.y()*4+(1-b.x())*2+(1-b.y()) );
48 }
49 suffix += ".qpf";
50
51 return QFile::exists( fontDir+"cyberbit_120_50"+suffix )
52 || QFile::exists( fontDir+"unifont_160_50"+suffix ) ||
53 QFile::exists( fontDir+"arial_140_50" + suffix );
54}
55
56QFont FontManager::unicodeFont( Spacing sp )
57{
58 QString key;
59 QString fontName;
60 QString fontDir = getenv("QTDIR") + QString("/lib/fonts/");
61
62 int size;
63 if ( sp == Proportional ) {
64 fontName = "Arial";
65 size=14;
66 key = "arial_140_50";
67 } else {
68 fontName = "Unifont";
69 size=16;
70 key = "unifont_160_50";
71 }
72
73 QString suffix;
74 if ( qt_screen->isTransformed() ) {
75 suffix += "_t";
76 QPoint a = qt_screen->mapToDevice(QPoint(0,0),QSize(2,2));
77 QPoint b = qt_screen->mapToDevice(QPoint(1,1),QSize(2,2));
78 suffix += QString::number( a.x()*8+a.y()*4+(1-b.x())*2+(1-b.y()) );
79 }
80 suffix += ".qpf";
81
82 // if we cannot find it, try the other one
83
84 if ( !QFile::exists(fontDir+key+suffix) ) {
85 key = (sp == Fixed ) ? "arial_140_50" : "unifont_160_50";
86 if ( QFile::exists(fontDir+key+suffix) ) {
87 fontName = (sp == Fixed) ? "Arial" : "Unifont";
88 size = (sp == Fixed) ? 14 : 16;
89 } else {
90 key = "cyberbit_120_50";
91 if ( QFile::exists(fontDir+key+suffix) ) {
92 fontName = "Cyberbit";
93 size = 12;
94 } else {
95 fontName = "Helvetica";
96 size = 14;
97 }
98 }
99 }
100 return QFont(fontName,size);
101}