Changeset 769 for trunk/src/gui/text
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/text/qcssparser.cpp
r651 r769 896 896 *width = lengthValueFromData(data.width, f); 897 897 *style = data.style; 898 *color = brushFromData(data.color, pal);898 *color = data.color.type != BrushData::Invalid ? brushFromData(data.color, pal) : QBrush(QColor()); 899 899 return; 900 900 } -
trunk/src/gui/text/qfont.cpp
r651 r769 646 646 Returns the name of the font within the underlying window system. 647 647 648 Only on X11 when Qt was built without FontConfig support the XLFD (X Logical Font Description) 649 is returned; otherwise an empty string. 648 On X11, this function will return an empty string if Qt is built with 649 FontConfig support; otherwise the XLFD (X Logical Font Description) is 650 returned. 650 651 651 652 Using the return value of this function is usually \e not \e … … 820 821 resolve_mask |= QFont::WeightResolved | QFont::StyleResolved; 821 822 } 823 824 if (italic) 825 resolve_mask |= QFont::StyleResolved; 822 826 823 827 d->request.family = family; … … 2641 2645 QFontCache::~QFontCache() 2642 2646 { 2647 clear(); 2643 2648 { 2644 2649 EngineDataCache::ConstIterator it = engineDataCache.constBegin(), -
trunk/src/gui/text/qfontdatabase.cpp
r651 r769 87 87 #define SMOOTH_SCALABLE 0xffff 88 88 89 extern int qt_defaultDpiY(); // in qfont.cpp89 Q_GUI_EXPORT extern int qt_defaultDpiY(); // in qfont.cpp 90 90 91 91 bool qt_enable_test_font = false; … … 611 611 #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) 612 612 // class with virtual destructor, derived in qfontdatabase_s60.cpp 613 class Q FontDatabaseS60Store613 class QSymbianFontDatabaseExtras 614 614 { 615 615 public: 616 virtual ~Q FontDatabaseS60Store() {}616 virtual ~QSymbianFontDatabaseExtras() {} 617 617 }; 618 618 #endif … … 630 630 #endif 631 631 #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) 632 , s 60Store(0)632 , symbianExtras(0) 633 633 #endif 634 634 { } … … 644 644 count = 0; 645 645 #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) 646 if (s 60Store) {647 delete s 60Store;648 s 60Store= 0;646 if (symbianExtras) { 647 delete symbianExtras; 648 symbianExtras = 0; 649 649 } 650 650 #endif … … 691 691 QStringList fallbackFamilies; 692 692 #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) 693 const Q FontDatabaseS60Store *s60Store;693 const QSymbianFontDatabaseExtras *symbianExtras; 694 694 #endif 695 695 -
trunk/src/gui/text/qfontdatabase_s60.cpp
r651 r769 51 51 #include <private/qcore_symbian_p.h> 52 52 #if defined(QT_NO_FREETYPE) 53 #include < OPENFONT.H>53 #include <openfont.h> 54 54 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS 55 55 #include <graphics/openfontrasterizer.h> // COpenFontRasterizer has moved to a new header file … … 93 93 94 94 #if defined(QT_NO_FREETYPE) 95 class Q FontDatabaseS60StoreImplementation : public QFontDatabaseS60Store95 class QSymbianFontDatabaseExtrasImplementation : public QSymbianFontDatabaseExtras 96 96 { 97 97 public: 98 Q FontDatabaseS60StoreImplementation();99 ~Q FontDatabaseS60StoreImplementation();100 101 const Q FontEngineS60Extensions *extension(const QString &typeface) const;98 QSymbianFontDatabaseExtrasImplementation(); 99 ~QSymbianFontDatabaseExtrasImplementation(); 100 101 const QSymbianTypeFaceExtras *extras(const QString &typeface, bool bold, bool italic) const; 102 102 103 103 private: … … 105 105 CFontStore *m_store; 106 106 COpenFontRasterizer *m_rasterizer; 107 mutable QHash<QString, const QFontEngineS60Extensions *> m_extensions; 107 mutable QList<const QSymbianTypeFaceExtras *> m_extras; 108 mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extrasHash; 108 109 }; 109 110 110 QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() 111 { 112 m_heap = User::ChunkHeap(NULL, 0x1000, 0x100000); 111 QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementation() 112 { 113 QStringList filters; 114 filters.append(QLatin1String("*.ttf")); 115 filters.append(QLatin1String("*.ccc")); 116 filters.append(QLatin1String("*.ltt")); 117 const QFileInfoList fontFiles = alternativeFilePaths(QLatin1String("resource\\Fonts"), filters); 118 119 const TInt heapMinLength = 0x1000; 120 const TInt heapMaxLength = qMax(0x20000 * fontFiles.count(), heapMinLength); 121 m_heap = User::ChunkHeap(NULL, heapMinLength, heapMaxLength); 113 122 QT_TRAP_THROWING( 114 123 m_store = CFontStore::NewL(m_heap); … … 118 127 CleanupStack::Pop(m_rasterizer);); 119 128 120 QStringList filters;121 filters.append(QString::fromLatin1("*.ttf"));122 filters.append(QString::fromLatin1("*.ccc"));123 const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters);124 129 foreach (const QFileInfo &fontFileInfo, fontFiles) { 125 130 const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath()); … … 128 133 } 129 134 } 130 QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() 131 { 132 typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator; 133 for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) { 135 136 QSymbianFontDatabaseExtrasImplementation::~QSymbianFontDatabaseExtrasImplementation() 137 { 138 typedef QList<const QSymbianTypeFaceExtras *>::iterator iterator; 139 for (iterator p = m_extras.begin(); p != m_extras.end(); ++p) { 134 140 m_store->ReleaseFont((*p)->fontOwner()); 135 141 delete *p; … … 157 163 #endif // FNTSTORE_H_INLINES_SUPPORT_FMM 158 164 159 const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const 160 { 161 if (!m_extensions.contains(typeface)) { 165 const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface, 166 bool bold, bool italic) const 167 { 168 const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic)); 169 if (!m_extrasHash.contains(searchKey)) { 162 170 CFont* font = NULL; 163 TFontSpec spec(qt_QString2TPtrC(typeface), 1); 164 spec.iHeight = 1; 165 const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); 171 TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1); 172 if (bold) 173 searchSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); 174 if (italic) 175 searchSpec.iFontStyle.SetPosture(EPostureItalic); 176 const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, searchSpec); 166 177 Q_ASSERT(err == KErrNone && font); 167 178 const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); … … 172 183 OpenFontFromBitmapFont(bitmapFont); 173 184 #endif // FNTSTORE_H_INLINES_SUPPORT_FMM 174 m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont)); 175 } 176 return m_extensions.value(typeface); 185 const TOpenFontFaceAttrib* const attrib = openFont->FaceAttrib(); 186 const QString foundKey = 187 QString((const QChar*)attrib->FullName().Ptr(), attrib->FullName().Length()); 188 if (!m_extrasHash.contains(foundKey)) { 189 QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font, openFont); 190 m_extras.append(extras); 191 m_extrasHash.insert(searchKey, extras); 192 m_extrasHash.insert(foundKey, extras); 193 } else { 194 m_store->ReleaseFont(font); 195 m_extrasHash.insert(searchKey, m_extrasHash.value(foundKey)); 196 } 197 } 198 return m_extrasHash.value(searchKey); 177 199 } 178 200 #else … … 241 263 242 264 #if defined(QT_NO_FREETYPE) 243 if (!db->s 60Store)244 db->s 60Store = new QFontDatabaseS60StoreImplementation;265 if (!db->symbianExtras) 266 db->symbianExtras = new QSymbianFontDatabaseExtrasImplementation; 245 267 246 268 QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); 247 269 248 270 const int numTypeFaces = QS60Data::screenDevice()->NumTypefaces(); 249 const Q FontDatabaseS60StoreImplementation *store=250 static_cast<const Q FontDatabaseS60StoreImplementation*>(db->s60Store);271 const QSymbianFontDatabaseExtrasImplementation *dbExtras = 272 static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); 251 273 bool fontAdded = false; 252 274 for (int i = 0; i < numTypeFaces; i++) { … … 274 296 style->pixelSize(0, true); 275 297 276 const QFontEngineS60Extensions *extension = store->extension(familyName); 277 const QByteArray os2Table = extension->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); 298 const QSymbianTypeFaceExtras *typeFaceExtras = 299 dbExtras->extras(familyName, faceAttrib.IsBold(), faceAttrib.IsItalic()); 300 const QByteArray os2Table = typeFaceExtras->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); 278 301 const unsigned char* data = reinterpret_cast<const unsigned char*>(os2Table.constData()); 279 302 const unsigned char* ulUnicodeRange = data + 42; … … 333 356 } 334 357 358 bool QFontDatabase::removeAllApplicationFonts() 359 { 360 return false; 361 } 362 335 363 bool QFontDatabase::supportsThreadedFontRendering() 336 364 { … … 390 418 request.family = fontFamily; 391 419 #if defined(QT_NO_FREETYPE) 392 const QFontDatabaseS60StoreImplementation *store = 393 static_cast<const QFontDatabaseS60StoreImplementation*>(db->s60Store); 394 const QFontEngineS60Extensions *extension = store->extension(fontFamily); 395 fe = new QFontEngineS60(request, extension); 420 const QSymbianFontDatabaseExtrasImplementation *dbExtras = 421 static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); 422 const QSymbianTypeFaceExtras *typeFaceExtras = 423 dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); 424 fe = new QFontEngineS60(request, typeFaceExtras); 396 425 #else 397 426 QFontEngine::FaceId faceId; -
trunk/src/gui/text/qfontdatabase_win.cpp
r651 r769 337 337 }; 338 338 QList<QFontDatabase::WritingSystem> systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); 339 for (int i = 0; i < systems.count(); ++i) 340 family->writingSystems[systems.at(i)] = QtFontFamily::Supported; 339 340 for (int i = 0; i < systems.count(); ++i) { 341 QFontDatabase::WritingSystem writingSystem = systems.at(i); 342 343 // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains 344 // the symbol for Baht, and Windows thus reports that it supports the Thai script. 345 // Since it's the default UI font on this platform, most widgets will be unable to 346 // display Thai text by default. As a temporary work around, we special case Segoe UI 347 // and remove the Thai script from its list of supported writing systems. 348 if (writingSystem != QFontDatabase::Thai || familyName != QLatin1String("Segoe UI")) 349 family->writingSystems[writingSystem] = QtFontFamily::Supported; 350 } 341 351 } else if (!family->writingSystemCheck) { 342 352 //qDebug("family='%s' script=%s", family->name.latin1(), script.latin1()); -
trunk/src/gui/text/qfontengine.cpp
r651 r769 358 358 } 359 359 } else { 360 positions.resize(glyphs.numGlyphs);361 glyphs_out.resize(glyphs.numGlyphs);362 int i = 0;363 360 while (i < glyphs.numGlyphs) { 364 361 if (!glyphs.attributes[i].dontPrint) { … … 383 380 } 384 381 382 void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) 383 { 384 glyph_metrics_t gi = boundingBox(glyph); 385 bool isValid = gi.isValid(); 386 if (leftBearing != 0) 387 *leftBearing = isValid ? gi.x.toReal() : 0.0; 388 if (rightBearing != 0) 389 *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : 0.0; 390 } 385 391 386 392 glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs) … … 1389 1395 } 1390 1396 1397 void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) 1398 { 1399 int which = highByte(glyph); 1400 engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing); 1401 } 1402 1391 1403 void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, 1392 1404 QPainterPath *path, QTextItem::RenderFlags flags) -
trunk/src/gui/text/qfontengine_p.h
r651 r769 207 207 virtual qreal minRightBearing() const { return qreal(); } 208 208 209 virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); 210 209 211 virtual const char *name() const = 0; 210 212 … … 375 377 virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const; 376 378 virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags); 379 virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); 377 380 378 381 virtual QFixed ascent() const; -
trunk/src/gui/text/qfontengine_s60.cpp
r651 r769 45 45 #include <private/qapplication_p.h> 46 46 #include "qimage.h" 47 #include "qt_s60_p.h"47 #include <private/qt_s60_p.h> 48 48 49 49 #include <e32base.h> … … 54 54 QT_BEGIN_NAMESPACE 55 55 56 Q FontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font)56 QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font) 57 57 : m_font(font) 58 58 , m_cmap(0) … … 60 60 , m_fontOwner(fontOwner) 61 61 { 62 TAny *shapingExtension = NULL;63 m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension);64 m_shapingExtension = static_cast<MOpenFontShapingExtension*>(shapingExtension);65 62 TAny *trueTypeExtension = NULL; 66 63 m_font->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension); 67 64 m_trueTypeExtension = static_cast<MOpenFontTrueTypeExtension*>(trueTypeExtension); 68 Q_ASSERT(m_ shapingExtension && m_trueTypeExtension);69 } 70 71 QByteArray Q FontEngineS60Extensions::getSfntTable(uint tag) const65 Q_ASSERT(m_trueTypeExtension); 66 } 67 68 QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const 72 69 { 73 70 Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag)); … … 80 77 } 81 78 82 const unsigned char *QFontEngineS60Extensions::cmap() const 79 bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *length) const 80 { 81 if (!m_trueTypeExtension->HasTrueTypeTable(tag)) 82 return false; 83 84 bool result = true; 85 TInt error = KErrNone; 86 TInt tableByteLength; 87 TAny *table = 88 q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength)); 89 90 if (error != KErrNone) { 91 return false; 92 } else if (*length > 0 && *length < tableByteLength) { 93 result = false; // Caller did not allocate enough memory 94 } else { 95 *length = tableByteLength; 96 if (buffer) 97 qMemCopy(buffer, table, tableByteLength); 98 } 99 100 m_trueTypeExtension->ReleaseTrueTypeTable(table); 101 return result; 102 } 103 104 const unsigned char *QSymbianTypeFaceExtras::cmap() const 83 105 { 84 106 if (!m_cmap) { … … 90 112 } 91 113 92 QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const 93 { 94 QPainterPath result; 95 QPolygonF polygon; 96 TInt glyphIndex = glyph; 97 TInt pointNumber = 0; 98 TInt x, y; 99 while (m_shapingExtension->GlyphPointInFontUnits(glyphIndex, pointNumber++, x, y)) { 100 const QPointF point(qreal(x) / 0xffff, qreal(y) / 0xffff); 101 if (polygon.contains(point)) { 102 result.addPolygon(polygon); 103 result.closeSubpath(); 104 polygon.clear(); 105 } else { 106 polygon.append(point); 107 } 108 } 109 return result; 110 } 111 112 CFont *QFontEngineS60Extensions::fontOwner() const 114 CFont *QSymbianTypeFaceExtras::fontOwner() const 113 115 { 114 116 return m_fontOwner; … … 168 170 } 169 171 170 QFontEngineS60::QFontEngineS60(const QFontDef &request, const Q FontEngineS60Extensions *extensions)171 : m_ext ensions(extensions)172 QFontEngineS60::QFontEngineS60(const QFontDef &request, const QSymbianTypeFaceExtras *extras) 173 : m_extras(extras) 172 174 , m_originalFont(0) 173 175 , m_originalFontSizeInPixels((request.pixelSize >= 0)? … … 196 198 197 199 HB_Glyph *g = glyphs->glyphs; 198 const unsigned char* cmap = m_extensions->cmap(); 200 const unsigned char* cmap = m_extras->cmap(); 201 const bool isRtl = (flags & QTextEngine::RightToLeft); 199 202 for (int i = 0; i < len; ++i) { 200 203 const unsigned int uc = getChar(characters, i, len); 201 *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, uc); 204 *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, 205 isRtl ? QChar::mirroredChar(uc) : uc); 202 206 } 203 207 … … 217 221 for (int i = 0; i < glyphs->numGlyphs; i++) { 218 222 const glyph_metrics_t bbox = boundingBox_const(glyphs->glyphs[i]); 219 glyphs->advances_x[i] = glyphs->offsets[i].x =bbox.xoff;220 glyphs->advances_y[i] = glyphs->offsets[i].y =bbox.yoff;223 glyphs->advances_x[i] = bbox.xoff; 224 glyphs->advances_y[i] = bbox.yoff; 221 225 } 222 226 } … … 313 317 bool QFontEngineS60::canRender(const QChar *string, int len) 314 318 { 315 const unsigned char *cmap = m_ext ensions->cmap();319 const unsigned char *cmap = m_extras->cmap(); 316 320 for (int i = 0; i < len; ++i) { 317 321 const unsigned int uc = getChar(string, i, len); … … 324 328 QByteArray QFontEngineS60::getSfntTable(uint tag) const 325 329 { 326 return m_extensions->getSfntTable(tag); 330 return m_extras->getSfntTable(tag); 331 } 332 333 bool QFontEngineS60::getSfntTableData(uint tag, uchar *buffer, uint *length) const 334 { 335 return m_extras->getSfntTableData(tag, buffer, length); 327 336 } 328 337 -
trunk/src/gui/text/qfontengine_s60_p.h
r651 r769 57 57 #include "qfontengine_p.h" 58 58 #include "qsize.h" 59 #include < OPENFONT.H>59 #include <openfont.h> 60 60 61 class CFbsBitmap;62 class CFbsBitmapDevice;63 class CFbsBitGc;64 61 class CFont; 65 62 66 63 QT_BEGIN_NAMESPACE 67 64 68 // ..gives us access to truetype tables , UTF-16<->GlyphID mapping, and glyph outlines69 class Q FontEngineS60Extensions65 // ..gives us access to truetype tables 66 class QSymbianTypeFaceExtras 70 67 { 71 68 public: 72 Q FontEngineS60Extensions(CFont* fontOwner, COpenFont *font);69 QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font); 73 70 74 71 QByteArray getSfntTable(uint tag) const; 72 bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; 75 73 const unsigned char *cmap() const; 76 QPainterPath glyphOutline(glyph_t glyph) const;77 74 CFont *fontOwner() const; 78 75 79 76 private: 80 77 COpenFont *m_font; 81 const MOpenFontShapingExtension *m_shapingExtension;82 78 mutable MOpenFontTrueTypeExtension *m_trueTypeExtension; 83 79 mutable const unsigned char *m_cmap; … … 90 86 { 91 87 public: 92 QFontEngineS60(const QFontDef &fontDef, const Q FontEngineS60Extensions *extensions);88 QFontEngineS60(const QFontDef &fontDef, const QSymbianTypeFaceExtras *extras); 93 89 ~QFontEngineS60(); 94 90 … … 110 106 111 107 QByteArray getSfntTable(uint tag) const; 108 bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; 112 109 113 110 static qreal pixelsToPoints(qreal pixels, Qt::Orientation orientation = Qt::Horizontal); … … 130 127 static void releaseFont(CFont *&font); 131 128 132 const Q FontEngineS60Extensions *m_extensions;129 const QSymbianTypeFaceExtras *m_extras; 133 130 CFont* m_originalFont; 134 131 const qreal m_originalFontSizeInPixels; -
trunk/src/gui/text/qfontengine_win.cpp
r651 r769 40 40 ****************************************************************************/ 41 41 42 #if _WIN32_WINNT < 0x0500 43 #undef _WIN32_WINNT 44 #define _WIN32_WINNT 0x0500 45 #endif 46 42 47 #include "qfontengine_p.h" 43 48 #include "qtextengine_p.h" … … 650 655 static const int char_table_entries = sizeof(char_table)/sizeof(ushort); 651 656 657 #ifndef Q_CC_MINGW 658 void QFontEngineWin::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) 659 { 660 HDC hdc = shared_dc(); 661 SelectObject(hdc, hfont); 662 663 #ifndef Q_WS_WINCE 664 if (ttf) 665 #endif 666 667 { 668 ABC abcWidths; 669 GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths); 670 if (leftBearing) 671 *leftBearing = abcWidths.abcA; 672 if (rightBearing) 673 *rightBearing = abcWidths.abcC; 674 } 675 676 #ifndef Q_WS_WINCE 677 else { 678 QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing); 679 } 680 #endif 681 } 682 #endif // Q_CC_MINGW 652 683 653 684 qreal QFontEngineWin::minLeftBearing() const -
trunk/src/gui/text/qfontengine_win_p.h
r651 r769 107 107 virtual QImage alphaRGBMapForGlyph(glyph_t t, int margin, const QTransform &xform); 108 108 109 #ifndef Q_CC_MINGW 110 virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); 111 #endif 112 109 113 int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const; 110 114 void getCMap(); -
trunk/src/gui/text/qfontmetrics.cpp
r651 r769 64 64 int tabStops, int *tabArray, int tabArrayLen, 65 65 QPainter *painter); 66 extern int qt_defaultDpi();66 Q_GUI_EXPORT extern int qt_defaultDpi(); 67 67 68 68 /***************************************************************************** … … 473 473 engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); 474 474 // ### can nglyphs != 1 happen at all? Not currently I think 475 glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); 476 return qRound(gi.x); 475 qreal lb; 476 engine->getGlyphBearings(glyphs.glyphs[0], &lb); 477 return qRound(lb); 477 478 } 478 479 … … 507 508 engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); 508 509 // ### can nglyphs != 1 happen at all? Not currently I think 509 glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); 510 return qRound(gi.xoff - gi.x - gi.width); 510 qreal rb; 511 engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb); 512 return qRound(rb); 511 513 } 512 514 … … 1318 1320 engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); 1319 1321 // ### can nglyphs != 1 happen at all? Not currently I think 1320 glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); 1321 return gi.x.toReal(); 1322 qreal lb; 1323 engine->getGlyphBearings(glyphs.glyphs[0], &lb); 1324 return lb; 1322 1325 } 1323 1326 … … 1352 1355 engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); 1353 1356 // ### can nglyphs != 1 happen at all? Not currently I think 1354 glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); 1355 return (gi.xoff - gi.x - gi.width).toReal(); 1357 qreal rb; 1358 engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb); 1359 return rb; 1360 1356 1361 } 1357 1362 -
trunk/src/gui/text/qtextcontrol.cpp
r651 r769 1200 1200 cursor.setBlockFormat(blockFmt); 1201 1201 } else { 1202 cursor.deletePreviousChar(); 1202 QTextCursor localCursor = cursor; 1203 localCursor.deletePreviousChar(); 1203 1204 } 1204 1205 goto accept; … … 1233 1234 #endif 1234 1235 else if (e == QKeySequence::Delete) { 1235 cursor.deleteChar(); 1236 QTextCursor localCursor = cursor; 1237 localCursor.deleteChar(); 1236 1238 } 1237 1239 else if (e == QKeySequence::DeleteEndOfWord) { -
trunk/src/gui/text/qtextdocument.cpp
r651 r769 1632 1632 } 1633 1633 1634 extern int qt_defaultDpi();1634 Q_GUI_EXPORT extern int qt_defaultDpi(); 1635 1635 1636 1636 /*! … … 1680 1680 1681 1681 const QTextDocument *doc = this; 1682 Q TextDocument *clonedDoc = 0;1682 QScopedPointer<QTextDocument> clonedDoc; 1683 1683 (void)doc->documentLayout(); // make sure that there is a layout 1684 1684 … … 1713 1713 } else { 1714 1714 doc = clone(const_cast<QTextDocument *>(this)); 1715 clonedDoc = const_cast<QTextDocument *>(doc);1715 clonedDoc.reset(const_cast<QTextDocument *>(doc)); 1716 1716 1717 1717 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); … … 1788 1788 if (printer->printerState() == QPrinter::Aborted 1789 1789 || printer->printerState() == QPrinter::Error) 1790 goto UserCanceled;1790 return; 1791 1791 printPage(page, &p, doc, body, pageNumberPos); 1792 1792 if (j < pageCopies - 1) … … 1808 1808 printer->newPage(); 1809 1809 } 1810 1811 UserCanceled:1812 delete clonedDoc;1813 1810 } 1814 1811 #endif -
trunk/src/gui/text/qtextdocumentlayout.cpp
r651 r769 76 76 QT_BEGIN_NAMESPACE 77 77 78 extern int qt_defaultDpi();78 Q_GUI_EXPORT extern int qt_defaultDpi(); 79 79 80 80 // ################ should probably add frameFormatChange notification! -
trunk/src/gui/text/qtextengine.cpp
r651 r769 82 82 { 83 83 if ((int)caps == (int)QFont::SmallCaps) 84 generateScriptItemsSmallCaps( m_string.utf16(), start, length);84 generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length); 85 85 else if(caps == QFont::Capitalize) 86 86 generateScriptItemsCapitalize(start, length); … … 857 857 } 858 858 859 extern int qt_defaultDpiY(); // in qfont.cpp859 Q_GUI_EXPORT extern int qt_defaultDpiY(); // in qfont.cpp 860 860 861 861 void QTextEngine::shapeText(int item) const … … 1435 1435 } 1436 1436 1437 const ushort *unicode = layoutData->string.utf16(); 1438 // correctly assign script, isTab and isObject to the script analysis 1439 const ushort *uc = unicode; 1437 const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode()); 1440 1438 const ushort *e = uc + length; 1441 1439 int lastScript = QUnicodeTables::Common; … … 1651 1649 } 1652 1650 1653 glyph_t glyph = glyphs.glyphs[logClusters[ pos +ilen - 1]];1651 glyph_t glyph = glyphs.glyphs[logClusters[ilen - 1]]; 1654 1652 glyph_metrics_t gi = fe->boundingBox(glyph); 1655 1653 if (gi.isValid()) … … 2498 2496 } 2499 2497 2500 extern int qt_defaultDpiY();2498 Q_GUI_EXPORT extern int qt_defaultDpiY(); 2501 2499 2502 2500 QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const -
trunk/src/gui/text/qtextengine_p.h
r651 r769 383 383 QFixed width; 384 384 QFixed textWidth; 385 QFixed textAdvance; 385 386 int from; 386 387 signed int length : 29; -
trunk/src/gui/text/qtextformat.cpp
r651 r769 3086 3086 f.d->resolveFont(defaultFnt); 3087 3087 3088 hashes.insert(hash, idx); 3088 if (!hashes.contains(hash, idx)) 3089 hashes.insert(hash, idx); 3089 3090 3090 3091 } QT_CATCH(...) { -
trunk/src/gui/text/qtextimagehandler.cpp
r651 r769 124 124 QPaintDevice *pdev = doc->documentLayout()->paintDevice(); 125 125 if (pdev) { 126 extern int qt_defaultDpi();126 Q_GUI_EXPORT extern int qt_defaultDpi(); 127 127 if (pm.isNull()) 128 128 pm = getPixmap(doc, format); -
trunk/src/gui/text/qtextlayout.cpp
r651 r769 90 90 align = Qt::AlignRight; 91 91 if (align & Qt::AlignRight) 92 x = line.width - (line.text Width+ leadingSpaceWidth(eng, line));92 x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line)); 93 93 else if (align & Qt::AlignHCenter) 94 x = (line.width - line.text Width)/2;94 x = (line.width - line.textAdvance)/2; 95 95 } 96 96 return x; … … 1332 1332 const QScriptLine &sl = d->lines[line]; 1333 1333 1334 constqreal x = position.x() + l.cursorToX(cursorPosition);1334 qreal x = position.x() + l.cursorToX(cursorPosition); 1335 1335 1336 1336 int itm = d->findItem(cursorPosition - 1); … … 1351 1351 if (toggleAntialiasing) 1352 1352 p->setRenderHint(QPainter::Antialiasing); 1353 #if defined(QT_MAC_USE_COCOA) 1354 // Always draw the cursor aligned to pixel boundary. 1355 x = qRound(x); 1356 #endif 1353 1357 p->fillRect(QRectF(x, y, qreal(width), (base + descent + 1).toReal()), p->pen().brush()); 1354 1358 if (toggleAntialiasing) … … 1641 1645 struct LineBreakHelper 1642 1646 { 1643 LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {} 1647 LineBreakHelper() 1648 : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0), 1649 manualWrap(false) 1650 { 1651 } 1652 1644 1653 1645 1654 QScriptLine tmpData; 1646 1655 QScriptLine spaceData; 1647 1656 1657 QGlyphLayout glyphs; 1658 1648 1659 int glyphCount; 1649 1660 int maxGlyphs; 1661 int currentPosition; 1650 1662 1651 1663 QFixed minw; 1652 1664 QFixed softHyphenWidth; 1653 1665 QFixed rightBearing; 1666 QFixed minimumRightBearing; 1667 1668 QFontEngine *fontEngine; 1669 const unsigned short *logClusters; 1654 1670 1655 1671 bool manualWrap; 1656 1672 1657 1673 bool checkFullOtherwiseExtend(QScriptLine &line); 1674 1675 QFixed calculateNewWidth(const QScriptLine &line) const { 1676 return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth 1677 - qMin(rightBearing, QFixed()); 1678 } 1679 1680 inline glyph_t currentGlyph() const 1681 { 1682 Q_ASSERT(currentPosition > 0); 1683 return glyphs.glyphs[logClusters[currentPosition - 1]]; 1684 } 1685 1686 inline void adjustRightBearing() 1687 { 1688 if (currentPosition <= 0) 1689 return; 1690 1691 qreal rb; 1692 fontEngine->getGlyphBearings(currentGlyph(), 0, &rb); 1693 rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); 1694 } 1695 1696 inline void resetRightBearing() 1697 { 1698 rightBearing = QFixed(1); // Any positive number is defined as invalid since only 1699 // negative right bearings are interesting to us. 1700 } 1658 1701 }; 1659 1702 … … 1662 1705 LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); 1663 1706 1664 QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing;1707 QFixed newWidth = calculateNewWidth(line); 1665 1708 if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs)) 1666 1709 return true; … … 1738 1781 1739 1782 const HB_CharAttributes *attributes = eng->attributes(); 1740 int pos= line.from;1783 lbh.currentPosition = line.from; 1741 1784 int end = 0; 1742 QGlyphLayout glyphs; 1743 const unsigned short *logClusters = eng->layoutData->logClustersPtr; 1785 lbh.logClusters = eng->layoutData->logClustersPtr; 1744 1786 1745 1787 while (newItem < eng->layoutData->items.size()) { 1746 lbh.r ightBearing = 0;1788 lbh.resetRightBearing(); 1747 1789 lbh.softHyphenWidth = 0; 1748 1790 if (newItem != item) { … … 1752 1794 eng->shape(item); 1753 1795 attributes = eng->attributes(); 1754 l ogClusters = eng->layoutData->logClustersPtr;1796 lbh.logClusters = eng->layoutData->logClustersPtr; 1755 1797 } 1756 pos= qMax(line.from, current.position);1798 lbh.currentPosition = qMax(line.from, current.position); 1757 1799 end = current.position + eng->length(item); 1758 glyphs = eng->shapedGlyphs(¤t);1800 lbh.glyphs = eng->shapedGlyphs(¤t); 1759 1801 } 1760 1802 const QScriptItem ¤t = eng->layoutData->items[item]; 1803 QFontEngine *fontEngine = eng->fontEngine(current); 1804 if (lbh.fontEngine != fontEngine) { 1805 lbh.fontEngine = fontEngine; 1806 lbh.minimumRightBearing = qMin(QFixed(), 1807 QFixed::fromReal(fontEngine->minRightBearing())); 1808 } 1761 1809 1762 1810 lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent, … … 1788 1836 line.setDefaultHeight(eng); 1789 1837 if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) { 1790 addNextCluster( pos, end, lbh.tmpData, lbh.glyphCount,1791 current, l ogClusters,glyphs);1838 addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, 1839 current, lbh.logClusters, lbh.glyphs); 1792 1840 } else { 1793 1841 lbh.tmpData.length++; … … 1808 1856 if (lbh.checkFullOtherwiseExtend(line)) 1809 1857 goto found; 1810 } else if (attributes[ pos].whiteSpace) {1811 while ( pos < end && attributes[pos].whiteSpace)1812 addNextCluster( pos, end, lbh.spaceData, lbh.glyphCount,1813 current, l ogClusters,glyphs);1858 } else if (attributes[lbh.currentPosition].whiteSpace) { 1859 while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace) 1860 addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount, 1861 current, lbh.logClusters, lbh.glyphs); 1814 1862 1815 1863 if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) { … … 1820 1868 bool sb_or_ws = false; 1821 1869 do { 1822 addNextCluster( pos, end, lbh.tmpData, lbh.glyphCount,1823 current, l ogClusters,glyphs);1824 1825 if (attributes[ pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) {1870 addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, 1871 current, lbh.logClusters, lbh.glyphs); 1872 1873 if (attributes[lbh.currentPosition].whiteSpace || attributes[lbh.currentPosition-1].lineBreakType != HB_NoBreak) { 1826 1874 sb_or_ws = true; 1827 1875 break; 1828 } else if (breakany && attributes[ pos].charStop) {1876 } else if (breakany && attributes[lbh.currentPosition].charStop) { 1829 1877 break; 1830 1878 } 1831 } while ( pos< end);1879 } while (lbh.currentPosition < end); 1832 1880 lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw); 1833 1881 1834 if ( pos && attributes[pos- 1].lineBreakType == HB_SoftHyphen) {1882 if (lbh.currentPosition && attributes[lbh.currentPosition - 1].lineBreakType == HB_SoftHyphen) { 1835 1883 // if we are splitting up a word because of 1836 1884 // a soft hyphen then we ... … … 1850 1898 // 1851 1899 if (line.length) 1852 lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos- 1]];1900 lbh.softHyphenWidth = lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; 1853 1901 else if (breakany) 1854 lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos- 1]];1902 lbh.tmpData.textWidth += lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; 1855 1903 } 1856 1904 … … 1859 1907 // of the advance of the glyph, the bearing will be negative. We flip the sign 1860 1908 // for the code to be more readable. Logic borrowed from qfontmetrics.cpp. 1861 if (pos) { 1862 QFontEngine *fontEngine = eng->fontEngine(current); 1863 glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]]; 1864 glyph_metrics_t gi = fontEngine->boundingBox(glyph); 1865 if (gi.isValid()) 1866 lbh.rightBearing = qMax(QFixed(), -(gi.xoff - gi.x - gi.width)); 1909 // We ignore the right bearing if the minimum negative bearing is too little to 1910 // expand the text beyond the edge. 1911 if (sb_or_ws|breakany) { 1912 if (lbh.calculateNewWidth(line) + lbh.minimumRightBearing > line.width) 1913 lbh.adjustRightBearing(); 1914 if (lbh.checkFullOtherwiseExtend(line)) { 1915 if (!breakany) { 1916 line.textWidth += lbh.softHyphenWidth; 1917 } 1918 1919 goto found; 1920 } 1867 1921 } 1868 1869 if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) { 1870 if (!breakany) { 1871 line.textWidth += lbh.softHyphenWidth; 1872 } 1873 1874 line.textWidth += lbh.rightBearing; 1875 1876 goto found; 1877 } 1878 } 1879 if (pos == end) 1922 } 1923 if (lbh.currentPosition == end) 1880 1924 newItem = item + 1; 1881 1925 } 1882 1926 LB_DEBUG("reached end of line"); 1883 1927 lbh.checkFullOtherwiseExtend(line); 1884 line.textWidth += lbh.rightBearing;1885 1886 1928 found: 1929 if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted 1930 lbh.adjustRightBearing(); 1931 line.textAdvance = line.textWidth; 1932 line.textWidth -= qMin(QFixed(), lbh.rightBearing); 1933 1887 1934 if (line.length == 0) { 1888 1935 LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", -
trunk/src/gui/text/qzip.cpp
r651 r769 55 55 56 56 #if defined(Q_OS_WIN) 57 #undef S_IFREG 58 #define S_IFREG 0100000 57 # undef S_IFREG 58 # define S_IFREG 0100000 59 # ifndef S_IFDIR 60 # define S_IFDIR 0040000 61 # endif 59 62 # ifndef S_ISDIR 60 # define S_ISDIR(x) ((x) & 0040000) > 063 # define S_ISDIR(x) ((x) & S_IFDIR) > 0 61 64 # endif 62 65 # ifndef S_ISREG -
trunk/src/gui/text/qzipreader_p.h
r651 r769 50 50 // 51 51 // This file is not part of the Qt API. It exists for the convenience 52 // of the Q Libraryclass. This header file may change from52 // of the QZipReader class. This header file may change from 53 53 // version to version without notice, or even be removed. 54 54 // -
trunk/src/gui/text/qzipwriter_p.h
r651 r769 48 48 // 49 49 // This file is not part of the Qt API. It exists for the convenience 50 // of the Q Libraryclass. This header file may change from50 // of the QZipWriter class. This header file may change from 51 51 // version to version without notice, or even be removed. 52 52 //
Note:
See TracChangeset
for help on using the changeset viewer.