Changeset 124 for trunk/src/gui/text


Ignore:
Timestamp:
Aug 21, 2009, 3:34:10 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented QWidge::metric(). Added using of test (box) font engines on OS/2.

Location:
trunk/src/gui/text
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/text/qfont.cpp

    r2 r124  
    6666#include <private/qt_x11_p.h>
    6767#endif
     68#ifdef Q_WS_PM
     69#include "qt_os2.h"
     70#include "qwindowdefs_pm.h"
     71#endif
    6872#ifdef Q_WS_QWS
    6973#include "qscreen_qws.h"
     
    159163#elif defined(Q_WS_WIN)
    160164    dpi = GetDeviceCaps(shared_dc(),LOGPIXELSX);
     165#elif defined(Q_WS_PM)
     166    LONG ulDpi;
     167    DevQueryCaps(GpiQueryDevice(qt_display_ps()),
     168                 CAPS_HORIZONTAL_FONT_RES, 1, &ulDpi);
     169    Q_ASSERT(ulDpi != 0);
     170    dpi = ulDpi;
    161171#elif defined(Q_WS_MAC)
    162172    extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp
     
    185195#elif defined(Q_WS_WIN)
    186196    dpi = GetDeviceCaps(shared_dc(),LOGPIXELSY);
     197#elif defined(Q_WS_PM)
     198    LONG ulDpi;
     199    DevQueryCaps(GpiQueryDevice(qt_display_ps()),
     200                 CAPS_VERTICAL_FONT_RES, 1, &ulDpi);
     201    Q_ASSERT(ulDpi != 0);
     202    dpi = ulDpi;
    187203#elif defined(Q_WS_MAC)
    188204    extern float qt_mac_defaultDpi_y(); //qpaintdevice_mac.cpp
  • trunk/src/gui/text/qfontdatabase.cpp

    r95 r124  
    815815#endif
    816816
    817 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
     817#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_PM)
    818818static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
    819819{
  • trunk/src/gui/text/qfontdatabase_pm.cpp

    r95 r124  
    6363void QFontDatabase::load(const QFontPrivate *d, int script)
    6464{
    65     // @todo implement
     65    Q_ASSERT(script >= 0 && script < QUnicodeTables::ScriptCount);
     66
     67    // normalize the request to get better caching
     68    QFontDef req = d->request;
     69    if (req.pixelSize <= 0)
     70        req.pixelSize = qMax(1, qRound(req.pointSize * d->dpi / 72.));
     71    req.pointSize = 0;
     72    if (req.weight == 0)
     73        req.weight = QFont::Normal;
     74    if (req.stretch == 0)
     75        req.stretch = 100;
     76
     77    QFontCache::Key key(req, d->rawMode ? QUnicodeTables::Common : script, d->screen);
     78    if (!d->engineData)
     79        getEngineData(d, key);
     80
     81    // the cached engineData could have already loaded the engine we want
     82    if (d->engineData->engines[script])
     83        return;
     84
     85    // set it to the actual pointsize, so QFontInfo will do the right thing
     86    req.pointSize = req.pixelSize * 72. / d->dpi;
     87
     88    QFontEngine *fe = QFontCache::instance()->findEngine(key);
     89
     90    if (!fe) {
     91        if (qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) {
     92            fe = new QTestFontEngine(req.pixelSize);
     93            fe->fontDef = req;
     94        } else {
     95            // @todo initializeDb() and stuff, get the engine
     96        }
     97        if (!fe) {
     98            fe = new QFontEngineBox(req.pixelSize);
     99            fe->fontDef = QFontDef();
     100        }
     101    }
     102    if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
     103        for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
     104            if (!d->engineData->engines[i]) {
     105                d->engineData->engines[i] = fe;
     106                fe->ref.ref();
     107            }
     108        }
     109    } else {
     110        d->engineData->engines[script] = fe;
     111        fe->ref.ref();
     112    }
     113    QFontCache::instance()->insertEngine(key, fe);
    66114}
    67115
  • trunk/src/gui/text/qfontengine_p.h

    r95 r124  
    165165    virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
    166166
    167 #if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
     167#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_PM) && !defined(Q_WS_MAC)
    168168    virtual void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si) = 0;
    169169#endif
Note: See TracChangeset for help on using the changeset viewer.