summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/FontControl.h
authorllornkcor <llornkcor>2002-12-20 01:35:01 (UTC)
committer llornkcor <llornkcor>2002-12-20 01:35:01 (UTC)
commit876e1a4724a7bd75dc642e295de354241096e028 (patch) (side-by-side diff)
treea37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/FontControl.h
parent5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff)
downloadopie-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.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/FontControl.h47
1 files changed, 15 insertions, 32 deletions
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h
index d427680..02049d0 100644
--- a/noncore/apps/opie-reader/FontControl.h
+++ b/noncore/apps/opie-reader/FontControl.h
@@ -11,10 +11,11 @@ class FontControl
int m_size;
QString m_fontname;
int m_maxsize;
+ bool m_hasCourier;
public:
FontControl(QString n = "helvetica", int size = 10)
:
- m_fontsizes(NULL)
+ m_fontsizes(NULL), m_hasCourier(false)
{
ChangeFont(n, size);
}
@@ -22,11 +23,22 @@ class FontControl
{
if (m_fontsizes != NULL) delete [] m_fontsizes;
}
+ void hasCourier(bool _b) { m_hasCourier = _b; }
+ bool hasCourier() { return m_hasCourier; }
QString name() { return m_fontname; }
int currentsize() { return m_fontsizes[m_size]; }
int getsize(CStyle size)
{
- return m_fontsizes[m_size+size.getFontSize()];
+ int tgt = m_size+size.getFontSize();
+ if (tgt < 0)
+ {
+ tgt = 0;
+ }
+ if (tgt >= m_maxsize)
+ {
+ tgt = m_maxsize - 1;
+ }
+ return m_fontsizes[tgt];
}
int ascent()
{
@@ -86,36 +98,7 @@ class FontControl
{
return ChangeFont(n, currentsize());
}
- bool 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++)
- {
- m_fontsizes[i] = (*it);
- if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best]))
- {
- best = i;
- }
- i++;
- }
- m_size = best;
- }
- return true;
- }
+ bool ChangeFont(QString& n, int tgt);
};
#endif