Diffstat (limited to 'noncore/apps/opie-reader/FontControl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/FontControl.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index f0ed98b..e03bf64 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,37 +1,60 @@ | |||
1 | #include "opie.h" | 1 | #include "opie.h" |
2 | #include "useqpe.h" | ||
2 | #include "FontControl.h" | 3 | #include "FontControl.h" |
3 | 4 | ||
5 | int FontControl::gzoom() | ||
6 | { | ||
7 | int ret; | ||
8 | if (m_size == g_size) | ||
9 | { | ||
10 | ret = m_fontsizes[m_size]*m_basesize; | ||
11 | } | ||
12 | else if (g_size < 0) | ||
13 | { | ||
14 | int f = -g_size; | ||
15 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); | ||
16 | if (f%2) ret = (2*ret/3); | ||
17 | } | ||
18 | else | ||
19 | { | ||
20 | int f = g_size - m_maxsize + 1; | ||
21 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); | ||
22 | if (f%2) ret = (3*ret/2); | ||
23 | } | ||
24 | return ret; | ||
25 | } | ||
26 | |||
4 | bool FontControl::ChangeFont(QString& n, int tgt) | 27 | bool FontControl::ChangeFont(QString& n, int tgt) |
5 | { | 28 | { |
6 | QValueList<int>::Iterator it; | 29 | QValueList<int>::Iterator it; |
7 | QFontDatabase fdb; | 30 | QFontDatabase fdb; |
8 | QValueList<int> sizes = fdb.pointSizes(n); | 31 | QValueList<int> sizes = fdb.pointSizes(n); |
9 | if (sizes.count() == 0) | 32 | if (sizes.count() == 0) |
10 | { | 33 | { |
11 | return false; | 34 | return false; |
12 | } | 35 | } |
13 | else | 36 | else |
14 | { | 37 | { |
15 | m_fontname = n; | 38 | m_fontname = n; |
16 | m_maxsize = sizes.count(); | 39 | m_maxsize = sizes.count(); |
17 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 40 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
18 | m_fontsizes = new int[m_maxsize]; | 41 | m_fontsizes = new int[m_maxsize]; |
19 | uint i = 0; | 42 | uint i = 0; |
20 | uint best = 0; | 43 | uint best = 0; |
21 | for (it = sizes.begin(); it != sizes.end(); it++) | 44 | for (it = sizes.begin(); it != sizes.end(); it++) |
22 | { | 45 | { |
23 | #ifdef OPIE | 46 | #if defined(OPIE) || !defined(USEQPE) |
24 | m_fontsizes[i] = (*it); | 47 | m_fontsizes[i] = (*it); |
25 | #else | 48 | #else |
26 | m_fontsizes[i] = (*it)/10; | 49 | m_fontsizes[i] = (*it)/10; |
27 | #endif | 50 | #endif |
28 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | 51 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) |
29 | { | 52 | { |
30 | best = i; | 53 | best = i; |
31 | } | 54 | } |
32 | i++; | 55 | i++; |
33 | } | 56 | } |
34 | m_size = best; | 57 | g_size = m_size = best; |
35 | } | 58 | } |
36 | return true; | 59 | return true; |
37 | } | 60 | } |