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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.