diff -r b72c6db6890b -r 5dc02b23752f src/gui/text/qfontengine_s60.cpp --- a/src/gui/text/qfontengine_s60.cpp Wed Jun 23 19:07:03 2010 +0300 +++ b/src/gui/text/qfontengine_s60.cpp Tue Jul 06 15:10:48 2010 +0300 @@ -50,73 +50,21 @@ #include #include #include -#ifdef Q_SYMBIAN_HAS_FONTTABLE_API -#include -#endif // Q_SYMBIAN_HAS_FONTTABLE_API QT_BEGIN_NAMESPACE -#ifdef Q_SYMBIAN_HAS_FONTTABLE_API -QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* cFont, COpenFont *openFont) - : m_cFont(cFont) +QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font) + : m_font(font) + , m_cmap(0) , m_symbolCMap(false) -{ - Q_UNUSED(openFont) -} - -QSymbianTypeFaceExtras::~QSymbianTypeFaceExtras() -{ - QS60Data::screenDevice()->ReleaseFont(m_cFont); -} - -QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const -{ - RFontTable fontTable; - if (fontTable.Open(*m_cFont, tag) != KErrNone) - return QByteArray(); - const QByteArray byteArray(reinterpret_cast - (fontTable.TableContent()),fontTable.TableLength()); - fontTable.Close(); - return byteArray; -} - -bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *length) const -{ - RFontTable fontTable; - if (fontTable.Open(*m_cFont, tag) != KErrNone) - return false; - - bool result = true; - const TInt tableByteLength = fontTable.TableLength(); - - if (*length > 0 && *length < tableByteLength) { - result = false; // Caller did not allocate enough memory - } else { - *length = tableByteLength; - if (buffer) - qMemCopy(buffer, fontTable.TableContent(), tableByteLength); - } - - fontTable.Close(); - return result; -} - -#else // Q_SYMBIAN_HAS_FONTTABLE_API -QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* cFont, COpenFont *openFont) - : m_cFont(cFont) - , m_symbolCMap(false) - , m_openFont(openFont) + , m_fontOwner(fontOwner) { TAny *trueTypeExtension = NULL; - m_openFont->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension); + m_font->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension); m_trueTypeExtension = static_cast(trueTypeExtension); Q_ASSERT(m_trueTypeExtension); } -QSymbianTypeFaceExtras::~QSymbianTypeFaceExtras() -{ -} - QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const { Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag)); @@ -152,25 +100,23 @@ m_trueTypeExtension->ReleaseTrueTypeTable(table); return result; } -#endif // Q_SYMBIAN_HAS_FONTTABLE_API -const uchar *QSymbianTypeFaceExtras::cmap() const +const unsigned char *QSymbianTypeFaceExtras::cmap() const { - if (m_cmapTable.isNull()) { - const QByteArray cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); + if (!m_cmap) { + m_cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); int size = 0; - const uchar *cmap = QFontEngine::getCMap(reinterpret_cast - (cmapTable.constData()), cmapTable.size(), &m_symbolCMap, &size); - m_cmapTable = QByteArray(reinterpret_cast(cmap), size); + m_cmap = QFontEngineS60::getCMap(reinterpret_cast(m_cmapTable.constData()), m_cmapTable.size(), &m_symbolCMap, &size); } - return reinterpret_cast(m_cmapTable.constData()); + return m_cmap; } CFont *QSymbianTypeFaceExtras::fontOwner() const { - return m_cFont; + return m_fontOwner; } + // duplicated from qfontengine_xyz.cpp static inline unsigned int getChar(const QChar *str, int &i, const int len) {