Changeset 561 for trunk/src/gui/text/qfontengine_qpf.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/qfontengine_qpf.cpp
r2 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 ** … … 52 52 #include "private/qfontengine_ft_p.h" 53 53 #endif 54 #include "private/qcore_unix_p.h" // overrides QT_OPEN 54 55 55 56 // for mmap … … 66 67 #ifndef QT_NO_QWS_QPF2 67 68 69 #include "qpfutil.cpp" 70 68 71 QT_BEGIN_INCLUDE_NAMESPACE 69 #include "qpfutil.cpp"70 72 71 73 #if defined(Q_WS_QWS) … … 253 255 const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i])); 254 256 255 int fd = ::open(fileName.constData(), O_RDONLY);257 int fd = QT_OPEN(fileName.constData(), O_RDONLY, 0); 256 258 if (fd >= 0) { 257 259 void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); … … 266 268 ::munmap(header, sizeof(QFontEngineQPF::Header)); 267 269 } 268 ::close(fd);270 QT_CLOSE(fd); 269 271 } 270 272 } … … 309 311 310 312 #if defined(DEBUG_FONTENGINE) 311 qDebug() << "QFontEngineQPF::QFontEngineQPF( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ")";313 qDebug() << "QFontEngineQPF::QFontEngineQPF( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ')'; 312 314 #endif 313 315 … … 317 319 return; 318 320 319 fileName = fontDef.family.toLower() + QLatin1 String("_")321 fileName = fontDef.family.toLower() + QLatin1Char('_') 320 322 + QString::number(fontDef.pixelSize) 321 + QLatin1 String("_") + QString::number(fontDef.weight)323 + QLatin1Char('_') + QString::number(fontDef.weight) 322 324 + (fontDef.style != QFont::StyleNormal ? 323 325 QLatin1String("_italic") : QLatin1String("")) … … 326 328 fileName.prepend(qws_fontCacheDir()); 327 329 328 const QByteArray encodedName = QFile::encodeName(fileName);329 if (::access(encoded Name, F_OK) == 0) {330 encodedFileName = QFile::encodeName(fileName); 331 if (::access(encodedFileName, F_OK) == 0) { 330 332 #if defined(DEBUG_FONTENGINE) 331 333 qDebug() << "found existing qpf:" << fileName; 332 334 #endif 333 if (::access(encodedName, W_OK | R_OK) == 0) 334 fd = ::open(encodedName, O_RDWR); 335 else if (::access(encodedName, R_OK) == 0) 336 fd = ::open(encodedName, O_RDONLY); 335 if (::access(encodedFileName, W_OK | R_OK) == 0) { 336 fd = QT_OPEN(encodedFileName, O_RDWR); 337 } 338 // read-write access failed - try read-only access 339 if (fd == -1 && ::access(encodedFileName, R_OK) == 0) { 340 fd = QT_OPEN(encodedFileName, O_RDONLY); 341 if (fd == -1) { 342 #if defined(DEBUG_FONTENGINE) 343 qErrnoWarning("QFontEngineQPF: unable to open %s", encodedName.constData()); 344 #endif 345 return; 346 } 347 } 348 if (fd == -1) { 349 #if defined(DEBUG_FONTENGINE) 350 qWarning("QFontEngineQPF: insufficient access rights to %s", encodedName.constData()); 351 #endif 352 return; 353 } 337 354 } else { 338 355 #if defined(DEBUG_FONTENGINE) … … 340 357 #endif 341 358 if (::access(QFile::encodeName(qws_fontCacheDir()), W_OK) == 0) { 342 fd = ::open(encodedName, O_RDWR | O_EXCL | O_CREAT, 0644); 359 fd = QT_OPEN(encodedFileName, O_RDWR | O_EXCL | O_CREAT, 0644); 360 if (fd == -1) { 361 #if defined(DEBUG_FONTENGINE) 362 qErrnoWarning(errno, "QFontEngineQPF: open() failed for %s", encodedName.constData()); 363 #endif 364 return; 365 } 343 366 344 367 QBuffer buffer; … … 348 371 buffer.close(); 349 372 const QByteArray &data = buffer.data(); 350 ::write(fd, data.constData(), data.size()); 373 if (QT_WRITE(fd, data.constData(), data.size()) == -1) { 374 #if defined(DEBUG_FONTENGINE) 375 qErrnoWarning(errno, "QFontEngineQPF: write() failed for %s", encodedName.constData()); 376 #endif 377 return; 378 } 379 } else { 380 #if defined(DEBUG_FONTENGINE) 381 qErrnoWarning(errno, "QFontEngineQPF: access() failed for %s", qPrintable(qws_fontCacheDir())); 382 #endif 383 return; 351 384 } 352 385 } … … 356 389 if (QT_FSTAT(fd, &st)) { 357 390 #if defined(DEBUG_FONTENGINE) 358 q Debug() << "stat failed!";391 qErrnoWarning(errno, "QFontEngineQPF: fstat failed!"); 359 392 #endif 360 393 return; … … 475 508 #if defined(Q_WS_QWS) 476 509 if (isValid() && renderingFontEngine) 477 qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, QFile::encodeName(fileName));510 qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, encodedFileName); 478 511 #endif 479 512 } … … 482 515 { 483 516 #if defined(Q_WS_QWS) 484 if (isValid() && renderingFontEngine) 485 qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, QFile::encodeName(fileName)); 517 if (isValid() && renderingFontEngine) { 518 QT_TRY { 519 qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, encodedFileName); 520 } QT_CATCH(...) { 521 qDebug("QFontEngineQPF::~QFontEngineQPF: Out of memory"); 522 // ignore. 523 } 524 } 486 525 #endif 487 526 delete renderingFontEngine; 488 if (fontData) 489 munmap((void *)fontData, dataSize); 527 if (fontData) { 528 if (munmap((void *)fontData, dataSize) == -1) { 529 #if defined(DEBUG_FONTENGINE) 530 qErrnoWarning(errno, "~QFontEngineQPF: Unable to munmap"); 531 #endif 532 } 533 } 490 534 if (fd != -1) 491 535 ::close(fd); … … 551 595 QChar c(uc); 552 596 if (!findGlyph(glyphs[glyph_pos].glyph) && !seenGlyphs.contains(c)) 553 qDebug() << "glyph for character" << c << "/"<< hex << uc << "is" << dec << glyphs[glyph_pos].glyph;597 qDebug() << "glyph for character" << c << '/' << hex << uc << "is" << dec << glyphs[glyph_pos].glyph; 554 598 555 599 seenGlyphs.insert(c); … … 585 629 const Glyph *glyph = findGlyph(g); 586 630 if (!glyph) 587 QImage();631 return QImage(); 588 632 589 633 const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph); … … 591 635 QImage image(glyph->width, glyph->height, QImage::Format_Indexed8); 592 636 for (int j=0; j<256; ++j) 593 image.setColor(j, 0xff000000 | j | (j<<8) | (j<<16));637 image.setColor(j, qRgba(0, 0, 0, j)); 594 638 595 639 for (int i=0; i<glyph->height; ++i) { … … 776 820 777 821 // ### not perfect 778 const int ysize = fontDef.pixelSize << 6;822 const int ysize = qRound(fontDef.pixelSize * qreal(64)); 779 823 const int xsize = ysize; 780 824 … … 894 938 g.advance = qRound(metrics.xoff); 895 939 896 ::write(fd, &g, sizeof(g));897 ::write(fd, img.bits(), img.numBytes());940 QT_WRITE(fd, &g, sizeof(g)); 941 QT_WRITE(fd, img.bits(), img.byteCount()); 898 942 899 943 glyphPos = oldSize - glyphDataOffset; … … 905 949 gmap[glyph] = qToBigEndian(glyphPos); 906 950 907 glyphDataSize = glyphPos + sizeof(g) + img. numBytes();951 glyphDataSize = glyphPos + sizeof(g) + img.byteCount(); 908 952 quint32 *blockSizePtr = (quint32 *)(fontData + glyphDataOffset - 4); 909 953 *blockSizePtr = qToBigEndian(glyphDataSize); … … 1129 1173 #endif // QT_NO_QWS_QPF2 1130 1174 1175 /* 1176 Creates a new multi qws engine. 1177 1178 This function takes ownership of the QFontEngine, increasing it's refcount. 1179 */ 1131 1180 QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks) 1132 1181 : QFontEngineMulti(fallbacks.size() + 1),
Note:
See TracChangeset
for help on using the changeset viewer.