Changeset 561 for trunk/src/gui/text/qfont.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qfont.cpp
r124 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 76 76 #include "qfontengine_qpf_p.h" 77 77 #endif 78 #endif 79 #ifdef Q_OS_SYMBIAN 80 #include "qt_s60_p.h" 78 81 #endif 79 82 … … 180 183 screen = subScreens.at(0); 181 184 dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); 185 #elif defined(Q_OS_SYMBIAN) 186 dpi = S60->defaultDpiX; 182 187 #endif // Q_WS_X11 183 188 … … 212 217 screen = subScreens.at(0); 213 218 dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); 219 #elif defined(Q_OS_SYMBIAN) 220 dpi = S60->defaultDpiY; 214 221 #endif // Q_WS_X11 215 222 … … 227 234 capital(0), letterSpacingIsAbsolute(false), scFont(0) 228 235 { 229 ref = 1;230 236 #ifdef Q_WS_X11 231 237 if (QX11Info::display()) … … 247 253 scFont(other.scFont) 248 254 { 249 ref = 1;250 255 #ifdef Q_WS_WIN 251 256 hdc = other.hdc; … … 324 329 else 325 330 font.setPixelSize((font.pixelSize() * 7 + 5) / 10); 326 scFont = font.d ;331 scFont = font.d.data(); 327 332 if (scFont != this) 328 333 scFont->ref.ref(); … … 425 430 \brief The QFont class specifies a font used for drawing text. 426 431 427 \ingroup multimedia432 \ingroup painting 428 433 \ingroup appearance 429 434 \ingroup shared 430 \ingroup text431 \mainclass 435 \ingroup richtext-processing 436 432 437 433 438 When you create a QFont object you specify various attributes that … … 735 740 d->screen = screen; 736 741 } else { 737 d = font.d; 738 d->ref.ref(); 742 d = font.d.data(); 739 743 } 740 744 #ifdef Q_WS_WIN … … 748 752 */ 749 753 QFont::QFont(QFontPrivate *data) 750 : resolve_mask(QFont::AllPropertiesResolved) 751 { 752 d = data; 753 d->ref.ref(); 754 : d(data), resolve_mask(QFont::AllPropertiesResolved) 755 { 754 756 } 755 757 … … 763 765 d->engineData->ref.deref(); 764 766 d->engineData = 0; 765 if (d->scFont && d->scFont != d )767 if (d->scFont && d->scFont != d.data()) 766 768 d->scFont->ref.deref(); 767 769 d->scFont = 0; … … 769 771 } 770 772 771 qAtomicDetach(d);773 d.detach(); 772 774 } 773 775 … … 778 780 */ 779 781 QFont::QFont() 780 :d(QApplication::font().d), resolve_mask(0) 781 { 782 d->ref.ref(); 782 : d(QApplication::font().d.data()), resolve_mask(0) 783 { 783 784 } 784 785 … … 787 788 pointSize, \a weight and \a italic settings. 788 789 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. 790 793 791 794 The \a family name may optionally also include a foundry name, … … 800 803 */ 801 804 QFont::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 { 806 807 if (pointSize <= 0) { 808 #ifdef Q_OS_SYMBIAN 809 pointSize = 7; 810 #else 807 811 pointSize = 12; 812 #endif 808 813 } else { 809 814 resolve_mask |= QFont::SizeResolved; … … 827 832 */ 828 833 QFont::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 { 833 836 } 834 837 … … 838 841 QFont::~QFont() 839 842 { 840 if (!d->ref.deref())841 delete d;842 843 } 843 844 … … 847 848 QFont &QFont::operator=(const QFont &font) 848 849 { 849 qAtomicAssign(d, font.d);850 d = font.d.data(); 850 851 resolve_mask = font.resolve_mask; 851 852 return *this; … … 907 908 void QFont::setPointSize(int pointSize) 908 909 { 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 } 910 914 911 915 detach(); … … 926 930 void QFont::setPointSizeF(qreal pointSize) 927 931 { 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 } 929 936 930 937 detach(); … … 1623 1630 && f.d->overline == d->overline 1624 1631 && f.d->strikeOut == d->strikeOut 1625 && f.d->kerning == d->kerning)); 1632 && f.d->kerning == d->kerning 1633 && f.d->capital == d->capital)); 1626 1634 } 1627 1635 … … 1655 1663 if (r1.addStyle != r2.addStyle) return r1.addStyle < r2.addStyle; 1656 1664 #endif // Q_WS_X11 1665 if (f.d->capital != d->capital) return f.d->capital < d->capital; 1657 1666 1658 1667 int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning; … … 1724 1733 QFont font(*this); 1725 1734 font.detach(); 1726 font.d->resolve(resolve_mask, other.d );1735 font.d->resolve(resolve_mask, other.d.data()); 1727 1736 1728 1737 return font; … … 1788 1797 { 1789 1798 // default substitutions 1790 static const char * initTbl[] = {1799 static const char * const initTbl[] = { 1791 1800 1792 1801 #if defined(Q_WS_X11) … … 1820 1829 } 1821 1830 1822 1823 1831 /*! 1824 1832 Returns the first family name to be used whenever \a familyName is … … 1907 1915 } 1908 1916 } 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 */ 1909 1931 1910 1932 // ### mark: should be called removeSubstitutions() … … 2163 2185 s << (quint8) 0 2164 2186 << (quint8) font.d->request.weight 2165 << get_font_bits(s.version(), font.d );2187 << get_font_bits(s.version(), font.d.data()); 2166 2188 if (s.version() >= QDataStream::Qt_4_3) 2167 2189 s << (quint16)font.d->request.stretch; 2168 2190 if (s.version() >= QDataStream::Qt_4_4) 2169 s << get_extended_font_bits(font.d );2191 s << get_extended_font_bits(font.d.data()); 2170 2192 if (s.version() >= QDataStream::Qt_4_5) { 2171 2193 s << font.d->letterSpacing.value(); … … 2186 2208 QDataStream &operator>>(QDataStream &s, QFont &font) 2187 2209 { 2188 if (!font.d->ref.deref())2189 delete font.d;2190 2191 2210 font.d = new QFontPrivate; 2192 2211 font.resolve_mask = QFont::AllPropertiesResolved; … … 2230 2249 font.d->request.weight = weight; 2231 2250 2232 set_font_bits(s.version(), bits, font.d );2251 set_font_bits(s.version(), bits, font.d.data()); 2233 2252 2234 2253 if (s.version() >= QDataStream::Qt_4_3) { … … 2241 2260 quint8 extendedBits; 2242 2261 s >> extendedBits; 2243 set_extended_font_bits(extendedBits, font.d );2262 set_extended_font_bits(extendedBits, font.d.data()); 2244 2263 } 2245 2264 if (s.version() >= QDataStream::Qt_4_5) { … … 2267 2286 \brief The QFontInfo class provides general information about fonts. 2268 2287 2269 \ingroup multimedia2288 \ingroup appearance 2270 2289 \ingroup shared 2271 \ingroup text2272 2290 2273 2291 The QFontInfo class provides the same access functions as QFont, … … 2323 2341 */ 2324 2342 QFontInfo::QFontInfo(const QFont &font) 2325 : d(font.d) 2326 { d->ref.ref(); } 2343 : d(font.d.data()) 2344 { 2345 } 2327 2346 2328 2347 /*! … … 2330 2349 */ 2331 2350 QFontInfo::QFontInfo(const QFontInfo &fi) 2332 : d(fi.d) 2333 { d->ref.ref(); } 2351 : d(fi.d.data()) 2352 { 2353 } 2334 2354 2335 2355 /*! … … 2338 2358 QFontInfo::~QFontInfo() 2339 2359 { 2340 if (!d->ref.deref())2341 delete d;2342 2360 } 2343 2361 … … 2347 2365 QFontInfo &QFontInfo::operator=(const QFontInfo &fi) 2348 2366 { 2349 qAtomicAssign(d, fi.d);2367 d = fi.d.data(); 2350 2368 return *this; 2351 2369 } … … 2596 2614 void QFontCache::cleanup() 2597 2615 { 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); 2599 2624 } 2600 2625 #endif // QT_NO_THREAD … … 2609 2634 { 2610 2635 { 2611 EngineDataCache:: Iterator it = engineDataCache.begin(),2612 end = engineDataCache. end();2636 EngineDataCache::ConstIterator it = engineDataCache.constBegin(), 2637 end = engineDataCache.constEnd(); 2613 2638 while (it != end) { 2614 2639 if (it.value()->ref == 0) … … 2620 2645 } 2621 2646 } 2622 EngineCache:: Iterator it = engineCache.begin(),2623 end = engineCache. end();2647 EngineCache::ConstIterator it = engineCache.constBegin(), 2648 end = engineCache.constEnd(); 2624 2649 while (it != end) { 2625 2650 if (--it.value().data->cache_count == 0) { 2626 2651 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)", 2628 2653 it.value().data, it.key().script, it.key().def.pointSize, 2629 2654 it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
Note:
See TracChangeset
for help on using the changeset viewer.