src/gui/text/qfontdatabase_s60.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
     9 ** $QT_BEGIN_LICENSE:LGPL$
     9 ** $QT_BEGIN_LICENSE:LGPL$
    10 ** No Commercial Usage
    10 ** No Commercial Usage
    11 ** This file contains pre-release code and may not be distributed.
    11 ** This file contains pre-release code and may not be distributed.
    12 ** You may use this file in accordance with the terms and conditions
    12 ** You may use this file in accordance with the terms and conditions
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #include <private/qapplication_p.h>
    42 #include <private/qapplication_p.h>
    43 /* :QTP:JKOO-7XPHCJ:resolve header split problem */
       
    44 #include "qglobal.h"
       
    45 #include "qdir.h"
    43 #include "qdir.h"
    46 #include "qfont_p.h"
    44 #include "qfont_p.h"
    47 #include "qfontengine_s60_p.h"
    45 #include "qfontengine_s60_p.h"
    48 #include "qabstractfileengine.h"
    46 #include "qabstractfileengine.h"
    49 #include "qdesktopservices.h"
    47 #include "qdesktopservices.h"
    50 #include "qpixmap_s60_p.h"
    48 #include "qpixmap_s60_p.h"
    51 #include "qt_s60_p.h"
    49 #include "qt_s60_p.h"
    52 #include "qendian.h"
    50 #include "qendian.h"
    53 #include <private/qcore_symbian_p.h>
    51 #include <private/qcore_symbian_p.h>
    54 #if defined(QT_NO_FREETYPE)
    52 #if defined(QT_NO_FREETYPE)
    55 #include <OPENFONT.H>
    53 #include <openfont.h>
    56 #include <graphics/openfontrasterizer.h>
    54 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    55 #include <graphics/openfontrasterizer.h> // COpenFontRasterizer has moved to a new header file
       
    56 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS
    57 #endif
    57 #endif
    58 
    58 
    59 QT_BEGIN_NAMESPACE
    59 QT_BEGIN_NAMESPACE
    60 
    60 
    61 QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters,
    61 QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters,
   137 
   137 
   138     delete m_store;
   138     delete m_store;
   139     m_heap->Close();
   139     m_heap->Close();
   140 }
   140 }
   141 
   141 
       
   142 #ifndef FNTSTORE_H_INLINES_SUPPORT_FMM
       
   143 /*
       
   144  Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()'
       
   145  that returns a private data member. The header will change between SDKs. But Qt has
       
   146  to build on any SDK version and run on other versions of Symbian OS.
       
   147  This function performs the needed pointer arithmetic to get the right COpenFont*
       
   148 */
       
   149 COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont)
       
   150 {
       
   151     const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private
       
   152     const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont);
       
   153     return (valueIOpenFont & 1) ?
       
   154             (COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset
       
   155             (COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer
       
   156 }
       
   157 #endif // FNTSTORE_H_INLINES_SUPPORT_FMM
       
   158 
   142 const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const
   159 const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const
   143 {
   160 {
   144     if (!m_extensions.contains(typeface)) {
   161     if (!m_extensions.contains(typeface)) {
   145         CFont* font = NULL;
   162         CFont* font = NULL;
   146         TFontSpec spec(qt_QString2TPtrC(typeface), 1);
   163         TFontSpec spec(qt_QString2TPtrC(typeface), 1);
   147         spec.iHeight = 1;
   164         spec.iHeight = 1;
   148         const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec);
   165         const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec);
   149         Q_ASSERT(err == KErrNone && font);
   166         Q_ASSERT(err == KErrNone && font);
   150         CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
   167         const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
   151         m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont()));
   168         COpenFont *openFont =
       
   169 #ifdef FNTSTORE_H_INLINES_SUPPORT_FMM
       
   170             bitmapFont->openFont();
       
   171 #else
       
   172             OpenFontFromBitmapFont(bitmapFont);
       
   173 #endif // FNTSTORE_H_INLINES_SUPPORT_FMM
       
   174         m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont));
   152     }
   175     }
   153     return m_extensions.value(typeface);
   176     return m_extensions.value(typeface);
   154 }
   177 }
   155 #else
   178 #else
   156 class QFontEngineFTS60 : public QFontEngineFT
   179 class QFontEngineFTS60 : public QFontEngineFT