Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qfont.cpp

    r124 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7676#include "qfontengine_qpf_p.h"
    7777#endif
     78#endif
     79#ifdef Q_OS_SYMBIAN
     80#include "qt_s60_p.h"
    7881#endif
    7982
     
    180183        screen = subScreens.at(0);
    181184    dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
     185#elif defined(Q_OS_SYMBIAN)
     186    dpi = S60->defaultDpiX;
    182187#endif // Q_WS_X11
    183188
     
    212217        screen = subScreens.at(0);
    213218    dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
     219#elif defined(Q_OS_SYMBIAN)
     220    dpi = S60->defaultDpiY;
    214221#endif // Q_WS_X11
    215222
     
    227234      capital(0), letterSpacingIsAbsolute(false), scFont(0)
    228235{
    229     ref = 1;
    230236#ifdef Q_WS_X11
    231237    if (QX11Info::display())
     
    247253      scFont(other.scFont)
    248254{
    249     ref = 1;
    250255#ifdef Q_WS_WIN
    251256    hdc = other.hdc;
     
    324329    else
    325330        font.setPixelSize((font.pixelSize() * 7 + 5) / 10);
    326     scFont = font.d;
     331    scFont = font.d.data();
    327332    if (scFont != this)
    328333        scFont->ref.ref();
     
    425430    \brief The QFont class specifies a font used for drawing text.
    426431
    427     \ingroup multimedia
     432    \ingroup painting
    428433    \ingroup appearance
    429434    \ingroup shared
    430     \ingroup text
    431     \mainclass
     435    \ingroup richtext-processing
     436
    432437
    433438    When you create a QFont object you specify various attributes that
     
    735740        d->screen = screen;
    736741    } else {
    737         d = font.d;
    738         d->ref.ref();
     742        d = font.d.data();
    739743    }
    740744#ifdef Q_WS_WIN
     
    748752*/
    749753QFont::QFont(QFontPrivate *data)
    750     : resolve_mask(QFont::AllPropertiesResolved)
    751 {
    752     d = data;
    753     d->ref.ref();
     754    : d(data), resolve_mask(QFont::AllPropertiesResolved)
     755{
    754756}
    755757
     
    763765            d->engineData->ref.deref();
    764766        d->engineData = 0;
    765         if (d->scFont && d->scFont != d)
     767        if (d->scFont && d->scFont != d.data())
    766768            d->scFont->ref.deref();
    767769        d->scFont = 0;
     
    769771    }
    770772
    771     qAtomicDetach(d);
     773    d.detach();
    772774}
    773775
     
    778780*/
    779781QFont::QFont()
    780     :d(QApplication::font().d), resolve_mask(0)
    781 {
    782     d->ref.ref();
     782    : d(QApplication::font().d.data()), resolve_mask(0)
     783{
    783784}
    784785
     
    787788    pointSize, \a weight and \a italic settings.
    788789
    789     If \a pointSize is <= 0, it is set to 12.
     790    If \a pointSize is zero or negative, the point size of the font
     791    is set to a system-dependent default value. Generally, this is
     792    12 points, except on Symbian where it is 7 points.
    790793
    791794    The \a family name may optionally also include a foundry name,
     
    800803*/
    801804QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
    802     :d(new QFontPrivate)
    803 {
    804     resolve_mask = QFont::FamilyResolved;
    805 
     805    : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved)
     806{
    806807    if (pointSize <= 0) {
     808#ifdef Q_OS_SYMBIAN
     809        pointSize = 7;
     810#else
    807811        pointSize = 12;
     812#endif
    808813    } else {
    809814        resolve_mask |= QFont::SizeResolved;
     
    827832*/
    828833QFont::QFont(const QFont &font)
    829 {
    830     d = font.d;
    831     d->ref.ref();
    832     resolve_mask = font.resolve_mask;
     834    : d(font.d.data()), resolve_mask(font.resolve_mask)
     835{
    833836}
    834837
     
    838841QFont::~QFont()
    839842{
    840     if (!d->ref.deref())
    841         delete d;
    842843}
    843844
     
    847848QFont &QFont::operator=(const QFont &font)
    848849{
    849     qAtomicAssign(d, font.d);
     850    d = font.d.data();
    850851    resolve_mask = font.resolve_mask;
    851852    return *this;
     
    907908void QFont::setPointSize(int pointSize)
    908909{
    909     Q_ASSERT_X (pointSize > 0, "QFont::setPointSize", "point size must be greater than 0");
     910    if (pointSize <= 0) {
     911        qWarning("QFont::setPointSize: Point size <= 0 (%d), must be greater than 0", pointSize);
     912        return;
     913    }
    910914
    911915    detach();
     
    926930void QFont::setPointSizeF(qreal pointSize)
    927931{
    928     Q_ASSERT_X(pointSize > 0.0, "QFont::setPointSizeF", "point size must be greater than 0");
     932    if (pointSize <= 0) {
     933        qWarning("QFont::setPointSizeF: Point size <= 0 (%f), must be greater than 0", pointSize);
     934        return;
     935    }
    929936
    930937    detach();
     
    16231630                && f.d->overline  == d->overline
    16241631                && f.d->strikeOut == d->strikeOut
    1625                 && f.d->kerning == d->kerning));
     1632                && f.d->kerning == d->kerning
     1633                && f.d->capital == d->capital));
    16261634}
    16271635
     
    16551663    if (r1.addStyle != r2.addStyle) return r1.addStyle < r2.addStyle;
    16561664#endif // Q_WS_X11
     1665    if (f.d->capital != d->capital) return f.d->capital < d->capital;
    16571666
    16581667    int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning;
     
    17241733    QFont font(*this);
    17251734    font.detach();
    1726     font.d->resolve(resolve_mask, other.d);
     1735    font.d->resolve(resolve_mask, other.d.data());
    17271736
    17281737    return font;
     
    17881797{
    17891798    // default substitutions
    1790     static const char *initTbl[] = {
     1799    static const char * const initTbl[] = {
    17911800
    17921801#if defined(Q_WS_X11)
     
    18201829}
    18211830
    1822 
    18231831/*!
    18241832    Returns the first family name to be used whenever \a familyName is
     
    19071915    }
    19081916}
     1917
     1918/*! \fn void QFont::initialize()
     1919  \internal
     1920
     1921  Internal function that initializes the font system.  The font cache
     1922  and font dict do not alloc the keys. The key is a QString which is
     1923  shared between QFontPrivate and QXFontName.
     1924*/
     1925
     1926/*! \fn void QFont::cleanup()
     1927  \internal
     1928
     1929  Internal function that cleans up the font system.
     1930*/
    19091931
    19101932// ### mark: should be called removeSubstitutions()
     
    21632185    s << (quint8) 0
    21642186      << (quint8) font.d->request.weight
    2165       << get_font_bits(s.version(), font.d);
     2187      << get_font_bits(s.version(), font.d.data());
    21662188    if (s.version() >= QDataStream::Qt_4_3)
    21672189        s << (quint16)font.d->request.stretch;
    21682190    if (s.version() >= QDataStream::Qt_4_4)
    2169         s << get_extended_font_bits(font.d);
     2191        s << get_extended_font_bits(font.d.data());
    21702192    if (s.version() >= QDataStream::Qt_4_5) {
    21712193        s << font.d->letterSpacing.value();
     
    21862208QDataStream &operator>>(QDataStream &s, QFont &font)
    21872209{
    2188     if (!font.d->ref.deref())
    2189         delete font.d;
    2190 
    21912210    font.d = new QFontPrivate;
    21922211    font.resolve_mask = QFont::AllPropertiesResolved;
     
    22302249    font.d->request.weight = weight;
    22312250
    2232     set_font_bits(s.version(), bits, font.d);
     2251    set_font_bits(s.version(), bits, font.d.data());
    22332252
    22342253    if (s.version() >= QDataStream::Qt_4_3) {
     
    22412260        quint8 extendedBits;
    22422261        s >> extendedBits;
    2243         set_extended_font_bits(extendedBits, font.d);
     2262        set_extended_font_bits(extendedBits, font.d.data());
    22442263    }
    22452264    if (s.version() >= QDataStream::Qt_4_5) {
     
    22672286    \brief The QFontInfo class provides general information about fonts.
    22682287
    2269     \ingroup multimedia
     2288    \ingroup appearance
    22702289    \ingroup shared
    2271     \ingroup text
    22722290
    22732291    The QFontInfo class provides the same access functions as QFont,
     
    23232341*/
    23242342QFontInfo::QFontInfo(const QFont &font)
    2325     : d(font.d)
    2326 { d->ref.ref(); }
     2343    : d(font.d.data())
     2344{
     2345}
    23272346
    23282347/*!
     
    23302349*/
    23312350QFontInfo::QFontInfo(const QFontInfo &fi)
    2332     : d(fi.d)
    2333 { d->ref.ref(); }
     2351    : d(fi.d.data())
     2352{
     2353}
    23342354
    23352355/*!
     
    23382358QFontInfo::~QFontInfo()
    23392359{
    2340     if (!d->ref.deref())
    2341         delete d;
    23422360}
    23432361
     
    23472365QFontInfo &QFontInfo::operator=(const QFontInfo &fi)
    23482366{
    2349     qAtomicAssign(d, fi.d);
     2367    d = fi.d.data();
    23502368    return *this;
    23512369}
     
    25962614void QFontCache::cleanup()
    25972615{
    2598     theFontCache()->setLocalData(0);
     2616    QThreadStorage<QFontCache *> *cache = 0;
     2617    QT_TRY {
     2618        cache = theFontCache();
     2619    } QT_CATCH (const std::bad_alloc &) {
     2620        // no cache - just ignore
     2621    }
     2622    if (cache && cache->hasLocalData())
     2623        cache->setLocalData(0);
    25992624}
    26002625#endif // QT_NO_THREAD
     
    26092634{
    26102635    {
    2611         EngineDataCache::Iterator it = engineDataCache.begin(),
    2612                                  end = engineDataCache.end();
     2636        EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
     2637                                 end = engineDataCache.constEnd();
    26132638        while (it != end) {
    26142639            if (it.value()->ref == 0)
     
    26202645        }
    26212646    }
    2622     EngineCache::Iterator it = engineCache.begin(),
    2623                          end = engineCache.end();
     2647    EngineCache::ConstIterator it = engineCache.constBegin(),
     2648                         end = engineCache.constEnd();
    26242649    while (it != end) {
    26252650        if (--it.value().data->cache_count == 0) {
    26262651            if (it.value().data->ref == 0) {
    2627                 FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %d %d %d %d)",
     2652                FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %g %d %d %d)",
    26282653                         it.value().data, it.key().script, it.key().def.pointSize,
    26292654                         it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
Note: See TracChangeset for help on using the changeset viewer.