author | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
commit | 876e1a4724a7bd75dc642e295de354241096e028 (patch) (unidiff) | |
tree | a37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/FontControl.cpp | |
parent | 5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff) | |
download | opie-876e1a4724a7bd75dc642e295de354241096e028.zip opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2 |
update - sorry it took so long. hope this works correctly
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 | } | ||