summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-10-12 12:18:54 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-10-12 12:19:47 (GMT)
commitea5281e6cd1ebc63e080f7232d4eb28f1610539e (patch)
tree169f5e70749bd42d87c51e3a400fc6741e7835ba
parentab057be7228d20d909246183505b72e821cc440f (diff)
downloadQt-ea5281e6cd1ebc63e080f7232d4eb28f1610539e.zip
Qt-ea5281e6cd1ebc63e080f7232d4eb28f1610539e.tar.gz
Qt-ea5281e6cd1ebc63e080f7232d4eb28f1610539e.tar.bz2
Implement QFontEngineS60::emSquareSize()
Some glyph position tweaks during the shaping phase require the "Units per Em" information for the font. QFontEngineS60 did not reimplement emSquareSize(), therefore, some combined glyphs were rendered incorrectly (see QTBUG-10725) This patch implements QFontEngineS60::emSquareSize() Since Symbian does not provide the "Units per Em" via public Api, we have to pick that out of the 'head' font table. The value is cached per font. Task-Number: QTBUG-10725 Reviewed-by: Eskil Abrahamsen Blomfeldt
-rw-r--r--src/gui/text/qfontengine_s60.cpp26
-rw-r--r--src/gui/text/qfontengine_s60_p.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index 32fcb82..824a8e2 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -41,6 +41,7 @@
#include "qfontengine_s60_p.h"
#include "qtextengine_p.h"
+#include "qendian.h"
#include "qglobal.h"
#include <private/qapplication_p.h>
#include "qimage.h"
@@ -176,6 +177,24 @@ CFont *QSymbianTypeFaceExtras::fontOwner() const
return m_cFont;
}
+QFixed QSymbianTypeFaceExtras::unitsPerEm() const
+{
+ if (m_unitsPerEm.value() != 0)
+ return m_unitsPerEm;
+ const QByteArray head = getSfntTable(MAKE_TAG('h', 'e', 'a', 'd'));
+ const int unitsPerEmOffset = 18;
+ if (head.size() > unitsPerEmOffset + sizeof(quint16)) {
+ const uchar* tableData = reinterpret_cast<const uchar*>(head.constData());
+ const uchar* unitsPerEm = tableData + unitsPerEmOffset;
+ m_unitsPerEm = qFromBigEndian<quint16>(unitsPerEm);
+ } else {
+ // Bitmap font? Corrupt font?
+ // We return -1 and let the QFontEngineS60 return the pixel size.
+ m_unitsPerEm = -1;
+ }
+ return m_unitsPerEm;
+}
+
// duplicated from qfontengine_xyz.cpp
static inline unsigned int getChar(const QChar *str, int &i, const int len)
{
@@ -248,6 +267,13 @@ QFontEngineS60::~QFontEngineS60()
releaseFont(m_scaledFont);
}
+QFixed QFontEngineS60::emSquareSize() const
+{
+ const QFixed unitsPerEm = m_extras->unitsPerEm();
+ return unitsPerEm.toInt() == -1 ?
+ QFixed::fromReal(m_originalFontSizeInPixels) : unitsPerEm;
+}
+
bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
{
if (*nglyphs < len) {
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index d05c23c..c65ce55 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -82,11 +82,13 @@ public:
const uchar *cmap() const;
CFont *fontOwner() const;
bool isSymbolCMap() const;
+ QFixed unitsPerEm() const;
private:
CFont* m_cFont;
mutable bool m_symbolCMap;
mutable QByteArray m_cmapTable;
+ mutable QFixed m_unitsPerEm;
#ifndef Q_SYMBIAN_HAS_FONTTABLE_API
COpenFont *m_openFont;
mutable MOpenFontTrueTypeExtension *m_trueTypeExtension;
@@ -99,6 +101,7 @@ public:
QFontEngineS60(const QFontDef &fontDef, const QSymbianTypeFaceExtras *extras);
~QFontEngineS60();
+ QFixed emSquareSize() const;
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;