summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use maximum ascent/descent/leading from fallback fonts in shapingJiang Jiang2011-04-271-0/+4
| | | | | | | | | | | | | | | When shaping a QScriptItem with a multi font engine, currently we only take the ascent/descent/leading from the primary (first) font engine in that multi font engine, however, subsequent engines used during shaping may have larger ascent/descent/leading, disregarding them may cause clipping issues in some cases. It's fixed by checking each font engine used in the shaping process and take the maximum value instead of the first one. On ATSUI we merely make it compile. Task-number: QTBUG-16719 Reviewed-by: Eskil
* Make sure layoutData exist before checking for string directionJiang Jiang2011-04-271-0/+2
| | | | | | Otherwise accessing that through QTextEngine::alignLine may cause crash. Reviewed-by: Samuel Rødal
* Take leading space width into account for painting and selectionJiang Jiang2011-04-261-1/+3
| | | | | | | | | When painting horizontally centered RTL text and selection with trailing spaces, we need to take that space width into account because line.textAdvance doesn't include it. Task-number: QTBUG-18612 Reviewed-by: Eskil
* Turn on HarfBuzz support for Mac/CocoaJiang Jiang2011-04-191-1/+33
| | | | | | | | | | | | | | | | | | | | It's possible to enable HarfBuzz text layout on Mac by either: - Set QT_ENABLE_HARFBUZZ environment variable when running a Qt app. - configure with -harfbuzz to build Qt, then HarfBuzz support will be turned on by default. HarfBuzz will only be used when the font explicitly requested is supported by HarfBuzz (aka. TrueType/OpenType font), other fonts (AAT fonts) will still be handled by Core Text. Using HarfBuzz for text layout will hopefully solve most tricky complex text shaping bugs on Mac. Task-number: QTBUG-17728 Reviewed-by: Eskil
* Support visual cursor movement for BIDI textJiang Jiang2011-04-191-0/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bidi input can in some contexts be more intuitive if the cursor works in visual way: pressing left arrow key always make cursor move one character to the left regardless the language of text, pressing right arrow key always make cursor move to the right. It is also the behavior of Mac OS X. Based on the above reason and requests from Symbian we implemented this support for visual movement in BIDI text. 3 public properties are added to QTextDocument, QTextLayout and QLineEdit respectively: - QTextDocument::defaultCursorMoveStyle can be used to control the cursor behavior in all widgets based on QTextDocument, like QTextEdit, QPlainTextEdit, etc. When set to QTextCursor:: Visual, it will enable visual movement for all the cursors in the corresponding text edit. Default is QTextCursor::Logical. - QTextLayout::cursorMoveStyle is used for low-level cursor manipulation. When set to Visual, it will enable visual movement behavior for all the cursor related methods, including cursorToX, xToCursor and drawCursor. Default is Logical. - QLineEdit::cursorMoveStyle is used to control cursor movement behavior in QLineEdit. Default is Logical.: Task-number: QTBUG-13859 Reviewed-by: Eskil
* Put all the declarations of qt_defaultDpi{,X,Y}() in one placeJiang Jiang2011-04-051-4/+0
| | | | Reviewed-by: Samuel Rødal
* Fix horizontal centered text drawing without word wrapJiang Jiang2011-03-311-0/+16
| | | | | | | | In this case we can't use line width to align the text, we have to use the rectangle width given in QPainter::drawText for alignment instead. Reviewed-by: Eskil
* Check engine existence before increasing reference countJiang Jiang2011-02-231-3/+6
| | | | Reviewed-by: TrustMe
* Keep reference count for cached font engines in QTextEngineJiang Jiang2011-02-231-0/+15
| | | | | | | | So that if these font engines are deallocated elsewhere (by QFontCache for instance), we can still access them in QTextEngine. Task-number: QTBUG-17603 Reviewed-by: Eskil
* Merge remote branch 'origin/4.7' into qt-master-from-4.7Olivier Goffart2011-01-171-9/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/webkit/imageanalyzer/imageanalyzer.h examples/webkit/imageanalyzer/mainwindow.h mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h src/corelib/io/qfsfileengine_iterator_unix.cpp src/corelib/io/qfsfileengine_iterator_win.cpp src/corelib/kernel/qcoreapplication.cpp src/network/access/qnetworkaccessdatabackend.cpp src/plugins/bearer/connman/qconnmanservice_linux.cpp src/plugins/platforms/openvglite/qwindowsurface_vglite.h src/s60installs/bwins/QtCoreu.def src/s60installs/eabi/QtCoreu.def src/s60installs/s60installs.pro tools/assistant/tools/assistant/helpviewer_qwv.h tools/qdoc3/test/qt-html-templates.qdocconf
| * Update copyright year to 2011.Jason McDonald2011-01-101-1/+1
| | | | | | | | Reviewed-by: Trust Me
| * Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into ↵Qt Continuous Integration System2011-01-071-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | 4.7-integration * '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixes crash in QGraphicsItem's destructor. Doc: Fixing typo
| | * Doc: Fixing typoSergio Ahumada2011-01-071-1/+1
| | |
| * | improve performance of QTextEngine, esp. setBoundary by using non-detaching ↵Milian Wolff2010-12-231-7/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operator[] Improves scrolling in testfile content.xml attached to QTBUG-9549. According to callgrind, the improvement is nearly 35% (comparing total incl. cost of QTextEngine::setBoundary) total incl cost / calls to setBoundary = before: 6.0883269E9 / 46520 = approx. 130875.47 after: 2.4834313E9 / 29370 = approx. 84556.733 in relation this gives us: 84556.733 / 130875.47 = approx. 0.64608542 Merge-request: 975 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
* | Make sure num_glyphs pass to HarfBuzz is large enoughJiang Jiang2010-12-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we only pass the num_glyphs for the run to HB_ShapeItem, but it can be less then the string length for this run because of Unicode surrogates. Thus, we need to pass at least the length of that run as num_glyphs to HB (given that we have enough space allocated because for the entire string), if that's still not enough, we will do ensureSpace again according to the num_glyphs returned by HB and move remaining glyphs backwards. Task-number: QTBUG-15679 Reviewed-by: Lars Knoll
* | Fix cursor position of one digit after RTL textJiang Jiang2010-11-151-1/+1
| | | | | | | | | | | | | | | | | | A single digit after RTL text will be considered as RTL because it was treated as Other Neutral (DirON), it can be solved by changing it to DirAN. Task-number: QTBUG-2795 Reviewed-by: Lars Knoll
* | Merge branch 4.7 into qt-master-from-4.7Qt Continuous Integration System2010-10-091-6/+10
|\ \ | |/
| * Fix infinite loop when justifying undisplayable Arabic textEskil Abrahamsen Blomfeldt2010-10-081-6/+10
| | | | | | | | | | | | | | | | | | | | | | If the Arabic text is for some reason undisplayable, e.g. because of QTBUG-13132, the font engine will be unable to find the tatweel character and the kashida width may be returned as 0. This would potentially cause an infinite loop, as "need" would remain >= minKashida forever because x - 0 is still >= 0. Task-number: QTBUG-13130 Reviewed-by: Lars
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Olivier Goffart2010-09-101-2/+9
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: bin/syncqt demos/declarative/snake/content/snake.js demos/declarative/snake/snake.qml doc/src/development/qmake-manual.qdoc src/corelib/plugin/plugin.pri src/gui/kernel/qapplication_win.cpp src/gui/kernel/qdesktopwidget_win.cpp src/gui/painting/qdrawhelper.cpp tests/auto/qdir/tst_qdir.cpp tools/qdoc3/test/assistant.qdocconf tools/qdoc3/test/designer.qdocconf tools/qdoc3/test/linguist.qdocconf
| * Recognize @, #, $ and ` as word separatorsThorbjørn Lindeijer2010-09-031-0/+4
| | | | | | | | | | | | | | | | The behavior of Qt with these characters was different than other toolkits, which annoys some people. Task-number: QTCREATORBUG-2241 Reviewed-by: mae
| * QTextEngine::LayoutData::reallocate musn't corrupt memoryJoão Abecasis2010-08-311-2/+5
| | | | | | | | | | | | | | | | | | ... on re-allocation failure. So, let's actually check the returned pointer and fail, instead of using Q_CHECK_PTR. Task-number: QT-3785 Reviewed-by: Peter Hartmann Reviewed-by: Samuel Rødal
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Olivier Goffart2010-08-301-6/+1
|\ \ | |/ | | | | | | | | | | Conflicts: qmake/generators/win32/msbuild_objectmodel.cpp qmake/generators/win32/msvc_vcxproj.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp
| * Correct last right bearing in boundingBox(glyphs)Jiang Jiang2010-08-271-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 07880542ecc479807c23c5646d263135240822ff introduced regression to QFontMetrics::boundingRect and QTextEngine::boundingBox on FT, XLFD and QPF font engine. Because on these platforms, rightBearing of the last glyphs is already removed from the width returned in glyph_metrics_t. Subtracting that rightBearing twice will cause the resulting boundingBox smaller than expected. This patch fix this by removing last right bearing accounting code from generic QTextEngine::boundingBox, instead, we put it into font engines that need them: QFontEngineWin, QCoreTextFontEngine, QFontEngineMac, QFontEngineS60 and QFontEngineQWS. So that the resulting width should be correct on all platforms without introducing any performance penalties. Task-number: QTBUG-6854, QTBUG-12950 Reviewed-by: Eskil
| * Use binarysort to find items.Gunnar Sletta2010-08-241-7/+12
| | | | | | | | | | Task: http://bugreports.qt.nokia.com/browse/QTBUG-231 Reviwed-by: Eskil
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Olivier Goffart2010-08-131-24/+62
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/painting/qpainter.cpp src/gui/text/qtextengine.cpp tests/auto/qimage/tst_qimage.cpp tests/auto/qpainter/tst_qpainter.cpp tools/qdoc3/test/assistant.qdocconf tools/qdoc3/test/designer.qdocconf tools/qdoc3/test/linguist.qdocconf tools/qdoc3/test/qmake.qdocconf tools/qdoc3/test/qt-build-docs.qdocconf tools/qdoc3/test/qt-html-templates.qdocconf tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf tools/qdoc3/test/qt.qdocconf
| * Fix QTextEngine overflow caused by extremely long textJiang Jiang2010-08-051-24/+63
| | | | | | | | | | | | | | | | | | | | | | | | Internally, QTextEngine use int to calculate most of the layout data required. If a string longer than 2^24 is passed into either QTextEngine or classes using it (QStackTextEngine, QPainter, QFontMetrics, etc.), overflow will happen because the memory size required to allocate for layout will become too large for int to handle. This patch will prevent these cases and add error handling mechanism for relevant code. Task-number: QT-3658 Reviewed-by: Eskil Abrahamsen Blomfeldt
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Thiago Macieira2010-07-151-2/+2
|\ \ | |/ | | | | | | Conflicts: src/gui/kernel/qapplication.h
| * Made -graphicssystem trace work with Qt::TextBypassShaping flag.Samuel Rødal2010-06-291-2/+2
| | | | | | | | | | | | The QPaintBuffer gets the text from the text item in order to stream it. Reviewed-by: Jocelyn Turcotte
* | Optimize text layout.Michael Brasser2010-07-091-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When laying out text, a significant amount of time was being spent querying for the font engine. This patch: * changes the layout to only query for the engine when a new script item is encountered. * adds an internal cache of the previous result to QTextEngine::fontEngine(). This catches the important case of multiline text with few font engine changes. With these changes layout costs are now approximately 60% of what they were previously, as measured by the text layout benchmarks. Reviewed-by: Eskil Abrahamsen Blomfeldt
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Thiago Macieira2010-07-011-4/+24
|\ \ | |/ | | | | | | | | | | | | | | Conflicts: bin/syncqt src/gui/text/qtextlayout.cpp tools/assistant/tools/assistant/helpviewer_qwv.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/configure/configureapp.cpp
| * Fix compiler warnings in QtGui (text,painting).Friedemann Kleint2010-06-211-1/+1
| | | | | | | | Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
| * consistent handling of directionality in QTextLayoutLars Knoll2010-06-091-12/+19
| | | | | | | | | | | | | | | | Make sure we use the same method to determine RTL/LTR for the layout everywhere. Task-number: Part of QT-3292 Reviewed-by: Simon Hausmann
| * correctly initialize the bidi level in the text engineLars Knoll2010-06-091-2/+15
| | | | | | | | | | | | | | If the text options doesn't specify the layout direction, determine it from the content. Reviewed-by: Simon Hausmann
* | nano optimizationsRitt Konstantin2010-06-281-6/+6
| | | | | | | | | | Merge-request: 685 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
* | Merge remote branch 'origin/4.7' into qt-master-from-4.7Olivier Goffart2010-06-081-1/+7
|\ \ | |/ | | | | | | Conflicts: tools/qdoc3/test/qt-html-templates.qdocconf
| * Add the Qt::TextBypassShaping flag.Jocelyn Turcotte2010-05-311-0/+6
| | | | | | | | | | | | | | | | | | | | This allows quick layouting especially with Windows fonts which contain heavy OpenType logic. On regular latin text the visual compromize is the loss of kerning, justification, capitalization, word spacing and letter spacing support. Reviewed-by: Simon Hausmann Reviewed-by: Eskil
| * QTextEngine: skip an unnecessary call to GetDeviceCaps on Windows.Jocelyn Turcotte2010-05-311-1/+1
| | | | | | | | Reviewed-by: Simon Hausmann
* | Use binarysort to find items.Gunnar Sletta2010-05-211-7/+12
|/ | | | | Task: http://bugreports.qt.nokia.com/browse/QTBUG-231 Reviwed-by: Eskil
* Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Olivier Goffart2010-04-161-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/3rdparty/webkit/VERSION src/3rdparty/webkit/WebCore/ChangeLog src/3rdparty/webkit/WebCore/page/FrameView.cpp src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def src/s60installs/bwins/QtCoreu.def src/s60installs/bwins/QtGuiu.def src/s60installs/bwins/QtNetworku.def src/s60installs/eabi/QtGuiu.def tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
| * Symbol visibility fixes for RVCT4 on SymbianIain2010-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | RVCT 4 is far more strict with regards to symbol visiblity that RVCT 2.2, and will hide symbols unless all references have default visibility in the object files. Update the various places in Qt code where the symbol visibility was set incorrectly for DLL-based platforms (those that use __declspec(dllimport) and (dllexport). Note: QtWebkit and QtScript are fixed in different commits. Task-number: QTBUG-9903 Reviewed-by: Jason Barron
* | Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Thiago Macieira2010-04-091-1/+1
|\ \ | |/ | | | | | | Conflicts: src/multimedia/audio/qaudioinput_win32_p.h
| * Fix crash for multiscript text in QTextEngine::boundingBox()Eskil Abrahamsen Blomfeldt2010-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The logClusters pointer is already adjusted for the item, so it should be indexed relative to the item, hence from 0 to itemLength-1. Adding pos to the index would give us a random value for all script items > 0. Thus this would sometimes crash for text that spanned several scripts, since we would sometimes get a value back which was outside the bounds of the glyph array. Task-number: QTBUG-9374 Reviewed-by: Samuel
| * Avoid QString reallocation in QTextEngineAndreas Kling2010-03-041-4/+2
| | | | | | | | | | | | | | | | Calling QString::utf16() will cause reallocation (for null-termination) if the string was created via fromRawData(). Reviewed-by: Benjamin Poulain Reviewed-by: Simon Hausmann
* | Merge remote branch 'origin/4.7' into HEADThiago Macieira2010-03-241-3/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | Four-way merge: take the qt-qml.git#4.7 branch version (which uses fromUtf8). I used QLatin1String, Thierry used QString::fromLatin1. Conflicts: src/declarative/qml/qdeclarativecompiler.cpp
| * | compile fix for mingw (also removes some warnings)Thierry Bastian2010-03-231-3/+2
| | |
* | | Make QStackTextEngine cheaper to constructAndreas Kling2010-03-221-5/+4
|/ / | | | | | | | | | | | | Default-constructing the QFont member of QTextEngine meant getting the QApplication::font() which is a waste of time. Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
* | Avoid QString reallocation for smallcaps fonts in Itemizer::generate()Andreas Kling2010-03-041-1/+1
| | | | | | | | Reviewed-by: Simon Hausmann
* | Avoid QString reallocation in QTextEngine::itemize()Andreas Kling2010-03-031-3/+1
|/ | | | | | | Calling QString::utf16() will cause reallocation (for null-termination) if the string was created via fromRawData(). Reviewed-by: Benjamin Poulain
* Update copyright year to 2010Jason McDonald2010-01-061-1/+1
| | | | Reviewed-by: Trust Me
* Line spacing fixesJoerg Bornemann2009-10-231-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QTextEdit (via QTextLayout) and QPlainTextEdit in Qt used to ignore any font leading but added one extra pixel in QFontMetrics. With many freetype fonts, this resulted in a "spacy" text layout. The necessary fixes on X11 and Windows were to take (positive) leading into account, to make the font database convert point sizes to pixel sizes without rounding to plain integer values, and to subtract the extra pixel from QFontMetrics from the font engines' descent value. The change also fixes several places in styles and widgets, where QFontMetrics::lineSpacing() was wrongly used instead of QFontMetrics::height(). Ideally we should also handle negative leading, which would require additional and bigger code changes in QTextLayout and QPlainTextEdit. In addition, all other editors we have tested seem to ignore leading on X11. If we choose to believe the values provided by freetype, our text layout would be one pixel smaller than everybody else's. On the Mac, this change does nothing. There our layout is still too spacy, and for smaller fonts quite ugly compared to native Mac applications. Done with mae. Reviewed-by: mae