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 @@ +#include "opie.h" +#include "FontControl.h" + +bool FontControl::ChangeFont(QString& n, int tgt) +{ + QValueList<int>::Iterator it; + QFontDatabase fdb; + QValueList<int> sizes = fdb.pointSizes(n); + if (sizes.count() == 0) + { + return false; + } + else + { + m_fontname = n; + m_maxsize = sizes.count(); + if (m_fontsizes != NULL) delete [] m_fontsizes; + m_fontsizes = new int[m_maxsize]; + uint i = 0; + uint best = 0; + for (it = sizes.begin(); it != sizes.end(); it++) + { +#ifdef OPIE + m_fontsizes[i] = (*it); +#else + m_fontsizes[i] = (*it)/10; +#endif + if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) + { + best = i; + } + i++; + } + m_size = best; + } + return true; +} |