Diffstat (limited to 'noncore/apps/opie-reader/FontControl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/FontControl.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp new file mode 100644 index 0000000..f0ed98b --- a/dev/null +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -0,0 +1,37 @@ | |||
1 | #include "opie.h" | ||
2 | #include "FontControl.h" | ||
3 | |||
4 | bool FontControl::ChangeFont(QString& n, int tgt) | ||
5 | { | ||
6 | QValueList<int>::Iterator it; | ||
7 | QFontDatabase fdb; | ||
8 | QValueList<int> sizes = fdb.pointSizes(n); | ||
9 | if (sizes.count() == 0) | ||
10 | { | ||
11 | return false; | ||
12 | } | ||
13 | else | ||
14 | { | ||
15 | m_fontname = n; | ||
16 | m_maxsize = sizes.count(); | ||
17 | if (m_fontsizes != NULL) delete [] m_fontsizes; | ||
18 | m_fontsizes = new int[m_maxsize]; | ||
19 | uint i = 0; | ||
20 | uint best = 0; | ||
21 | for (it = sizes.begin(); it != sizes.end(); it++) | ||
22 | { | ||
23 | #ifdef OPIE | ||
24 | m_fontsizes[i] = (*it); | ||
25 | #else | ||
26 | m_fontsizes[i] = (*it)/10; | ||
27 | #endif | ||
28 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | ||
29 | { | ||
30 | best = i; | ||
31 | } | ||
32 | i++; | ||
33 | } | ||
34 | m_size = best; | ||
35 | } | ||
36 | return true; | ||
37 | } | ||