summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/FontControl.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h
index ed6c33f..d427680 100644
--- a/noncore/apps/opie-reader/FontControl.h
+++ b/noncore/apps/opie-reader/FontControl.h
@@ -12,110 +12,110 @@ class FontControl
12 QString m_fontname; 12 QString m_fontname;
13 int m_maxsize; 13 int m_maxsize;
14 public: 14 public:
15 FontControl(QString n = "helvetica", int size = 10) 15 FontControl(QString n = "helvetica", int size = 10)
16 : 16 :
17 m_fontsizes(NULL) 17 m_fontsizes(NULL)
18 { 18 {
19 ChangeFont(n, size); 19 ChangeFont(n, size);
20 } 20 }
21 ~FontControl() 21 ~FontControl()
22 { 22 {
23 if (m_fontsizes != NULL) delete [] m_fontsizes; 23 if (m_fontsizes != NULL) delete [] m_fontsizes;
24 } 24 }
25 QString name() { return m_fontname; } 25 QString name() { return m_fontname; }
26 int currentsize() { return m_fontsizes[m_size]; } 26 int currentsize() { return m_fontsizes[m_size]; }
27 int getsize(CStyle size) 27 int getsize(CStyle size)
28 { 28 {
29 return m_fontsizes[m_size+size.getFontSize()]; 29 return m_fontsizes[m_size+size.getFontSize()];
30 } 30 }
31 int ascent() 31 int ascent()
32 { 32 {
33 QFont f(name(), currentsize()); 33 QFont f(name(), currentsize());
34 QFontMetrics fm(f); 34 QFontMetrics fm(f);
35 return fm.ascent(); 35 return fm.ascent();
36 } 36 }
37 int ascent(CStyle ch) 37 int ascent(CStyle ch)
38 { 38 {
39 QFont f(name(), getsize(ch)); 39 QFont f(name(), getsize(ch));
40 QFontMetrics fm(f); 40 QFontMetrics fm(f);
41 return fm.ascent(); 41 return fm.ascent();
42 } 42 }
43 int descent() 43 int descent()
44 { 44 {
45 QFont f(name(), currentsize()); 45 QFont f(name(), currentsize());
46 QFontMetrics fm(f); 46 QFontMetrics fm(f);
47 return fm.descent(); 47 return fm.descent();
48 } 48 }
49 int descent(CStyle ch) 49 int descent(CStyle ch)
50 { 50 {
51 QFont f(name(), getsize(ch)); 51 QFont f(name(), getsize(ch));
52 QFontMetrics fm(f); 52 QFontMetrics fm(f);
53 return fm.descent(); 53 return fm.descent();
54 } 54 }
55 int lineSpacing() 55 int lineSpacing()
56 { 56 {
57 QFont f(name(), currentsize()); 57 QFont f(name(), currentsize());
58 QFontMetrics fm(f); 58 QFontMetrics fm(f);
59 return fm.lineSpacing(); 59 return fm.lineSpacing();
60 } 60 }
61 int lineSpacing(CStyle ch) 61 int lineSpacing(CStyle ch)
62 { 62 {
63 QFont f(name(), getsize(ch)); 63 QFont f(name(), getsize(ch));
64 QFontMetrics fm(f); 64 QFontMetrics fm(f);
65 return fm.lineSpacing(); 65 return fm.lineSpacing();
66 } 66 }
67 bool decreasesize() 67 bool decreasesize()
68 { 68 {
69 if (--m_size < 0) 69 if (--m_size < 0)
70 { 70 {
71 m_size = 0; 71 m_size = 0;
72 return false; 72 return false;
73 } 73 }
74 else return true; 74 else return true;
75 } 75 }
76 bool increasesize() 76 bool increasesize()
77 { 77 {
78 if (++m_size >= m_maxsize) 78 if (++m_size >= m_maxsize)
79 { 79 {
80 m_size = m_maxsize - 1; 80 m_size = m_maxsize - 1;
81 return false; 81 return false;
82 } 82 }
83 else return true; 83 else return true;
84 } 84 }
85 bool ChangeFont(QString& n) 85 bool ChangeFont(QString& n)
86 { 86 {
87 return ChangeFont(n, currentsize()); 87 return ChangeFont(n, currentsize());
88 } 88 }
89 bool ChangeFont(QString& n, int tgt) 89 bool ChangeFont(QString& n, int tgt)
90 { 90 {
91 QValueList<int>::Iterator it; 91 QValueList<int>::Iterator it;
92 QFontDatabase fdb; 92 QFontDatabase fdb;
93 QValueList<int> sizes = fdb.pointSizes(n); 93 QValueList<int> sizes = fdb.pointSizes(n);
94 if (sizes.count() == 0) 94 if (sizes.count() == 0)
95 { 95 {
96 return false; 96 return false;
97 } 97 }
98 else 98 else
99 { 99 {
100 m_fontname = n; 100 m_fontname = n;
101 m_maxsize = sizes.count(); 101 m_maxsize = sizes.count();
102 if (m_fontsizes != NULL) delete [] m_fontsizes; 102 if (m_fontsizes != NULL) delete [] m_fontsizes;
103 m_fontsizes = new int[m_maxsize]; 103 m_fontsizes = new int[m_maxsize];
104 uint i = 0; 104 uint i = 0;
105 uint best = 0; 105 uint best = 0;
106 for (it = sizes.begin(); it != sizes.end(); it++) 106 for (it = sizes.begin(); it != sizes.end(); it++)
107 { 107 {
108 m_fontsizes[i] = (*it)/10; 108 m_fontsizes[i] = (*it);
109 if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) 109 if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best]))
110 { 110 {
111 best = i; 111 best = i;
112 } 112 }
113 i++; 113 i++;
114 } 114 }
115 m_size = best; 115 m_size = best;
116 } 116 }
117 return true; 117 return true;
118 } 118 }
119}; 119};
120 120
121#endif 121#endif