summaryrefslogtreecommitdiffstats
path: root/src/gui/text
Commit message (Collapse)AuthorAgeFilesLines
* Fix possible crash/assertion in qt_fontHasNarrowOutlines()Konstantin Ritt2012-11-211-4/+10
| | | | | | | | | 1. cloneWithSize() may return 0 1bis. QRawFont::setPixelSize() may ivalidate the font (due to 1.) 2. using the data obtained from a temporary QString is never safe! Change-Id: I0cd5f807d8077ef5112704e475f1904bd6fc4b1b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fixed rendering artifacts when drawing cursor.Samuel Rødal2012-11-201-1/+1
| | | | | | | | Get rid of the + 1 in addition to the ascent and descent. Task-number: QTBUG-27658 Change-Id: I8721226a034099ebe348cad3c49ac711c7fe44b9 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix conditional jump based on an uninitialized variable.Jędrzej Nowacki2012-11-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | Valgrind warns about the jump in qfontconfigdatabase.cpp:522 based on uint QFondDef::hintingPreference:2 property. Surprising thing is that the property is initialized in the default constructor, so there should not be an issue. The warning disappear if the property is _not_ placed on a boundary of a two words, or if bit field is fully initialized. So I suspect that only one bit of the two was initialized properly. I decide to implement both solutions because of a potential minor performance improvement, during reading the property. I still fail to say why the value was uninitialized, I believe that this patch simply workarounds gcc bug or valgrind bug. Change-Id: I2e87738f66a435ef6e30b3d2db6baa73da025426 Reviewed-by: Jiang Jiang <gzjjgod@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Pixel-align vertical metrics in QTextLayout againEskil Abrahamsen Blomfeldt2012-10-301-2/+2
| | | | | | | | | | | | | | | | | | | To avoid regressing due to de58eb64bc564fcb8af61a45576783e432d2380c, we need to return a pixel aligned height in QTextLine::height() and also use pixel aligned heights when calculating the position of lines as well as the bounding rect of the layout. Later, we can add a QTextLine::naturalHeight() or something like that which gives the fractional value, but until then, we need to access private API in QPainter to get the correct alignment, since we still don't want to align the height of the last line in the layout, we only want to align the origin of each line. Task-number: QTBUG-27740 Change-Id: I12325f07d33aaf1a1b967e0a11492759d0f565d9 Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* QSyntaxHighlighter: minor code de-duplicationKonstantin Ritt2012-10-291-25/+4
| | | | | | | | The (r.start != -1) case is equal to (i == formatChanges.count()) case in the loop; no need to exit the loop just to do exactly what it did. Change-Id: I4129d8012399895c2fce70b26716ca5aeadee79c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* QFontEngineMulti: Fix possible crash in stringToCMap()Konstantin Ritt2012-10-291-3/+4
| | | | | | | | | in case when the layout is partially initialized. We shouldn't access any data except of indices if GlyphIndicesOnly flag has been passed in. Change-Id: I264689b498e0f9de8b5c040d47dbae4f6ef391c4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* QTextEngine: Support SMP code points when case changingKonstantin Ritt2012-10-251-4/+16
| | | | | | | Semi-related to QTBUG-17337 Change-Id: I6b42c0f7e588bbeab27bf410fcdfa1a6f80e4ac2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Revert hacks in text rendering code pathEskil Abrahamsen Blomfeldt2012-10-252-4/+13
| | | | | | | | | | | | | | There are a lot of hacks here and there in Qt trying to align the text in a correct way which caused regressions to appear once the default coordinate system changed. We need to remove these hacks to get a more consistent and maintainable base. This also fixes the regression introduced by changing the aliased coordinate system. Task-number: QTBUG-27667 Change-Id: I620db2ca23b7ff6c912f3a51e86e7e36bbef81f0 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* Fix crash due to memory access violationKonstantin Ritt2012-10-221-0/+1
| | | | | | | | The font engine has been re-used without increasing it's reference counter Task-number: QTBUG-27596 Change-Id: Icd4c3ca131446255ad4a27da8aa9a6c69177212e Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QFont: Don't invalidate engine unless request has been changedKonstantin Ritt2012-10-192-7/+29
| | | | | | | | | | This makes QFont do a "light" detach when the font attributes data has been changed. The new test clearly shows that the engine is now shared between two font instances after changing the kerning attribute. Change-Id: I59db822f459f02d111686dba7101b98e361fada9 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove Qt3 compat leftoversKonstantin Ritt2012-10-191-12/+2
| | | | | Change-Id: I91c3d26125168998d6279bddb0671cfb68eac2f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use the right properties when checking the frame's marginsAndy Shaw2012-10-181-4/+4
| | | | | | | | | Changed it to check the Frame*Margin property instead of the Block*Margin property as this was incorrect for a QTextFrameFormat. Task-number: QTBUG-22173 Change-Id: I2c3066165fb592ed034874b1180593822859f933 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of unused memberKonstantin Ritt2012-10-161-2/+0
| | | | | | Change-Id: Ic6d207cacf02f2e6837f9f35020be7728ec60706 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* QTextBlock: Handle surrogates in textDirection()Konstantin Ritt2012-10-161-2/+9
| | | | | | | just like QString does. Change-Id: I002827d9ec93fb19ef2c0198b5fcd4dae15c5c34 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* QFont: Don't detach unless value has really changedKonstantin Ritt2012-10-161-6/+46
| | | | | | Change-Id: I496b0102853d04652322bf8751e5824aaa0725b7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QRawFont: improve performance and safety of glyphIndexesForString()Konstantin Ritt2012-10-152-39/+41
| | | | | | | | | | | As of 98c1eb1750498cdff9d3b26658e5e5be9c026c92, partially initialized QGlyphLayout is ok for stringToCMap() if GlyphIndicesOnly flag is set, thus we can use the glyphIndexes buffer directly and avoid copying. Also add some checks to guarantee we're not falling into an undefined behavior for the empty text or NULL buffer. Change-Id: I662953703e4c65edbebabbe4b753972417d963f3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Use constFind()/constEnd() for const_iterator-sKonstantin Ritt2012-10-133-7/+7
| | | | | | | to make the strict iterators happy. Change-Id: Ief4ec309b815f18dc4b2017d4f34c063db510c31 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* QFont: Fix build with QFONTCACHE_DEBUGKonstantin Ritt2012-10-131-1/+1
| | | | | | Change-Id: Ifc89af71cdf6a5f9e4114266030cf265042db626 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QGlyphRun: Fix isEmpty() and boundingRect() didn't work after setRawData()Konstantin Ritt2012-10-131-5/+5
| | | | | Change-Id: I44a347ef24961493d6b8353abbb215c713ccce52 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Update/fix QTextBoundaryFinder simple usage cases in qtbaseKonstantin Ritt2012-10-131-10/+10
| | | | | | Change-Id: I4d3000558bce86e2de3c32247915868ba18fc8b7 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Revert "Handle additional format ranges when itemizing."Pierre Rossi2012-10-101-40/+23
| | | | | | | | | | | This reverts commit 101d04681f4ceb7410681eae684534a206a9d90a. That change seems to have introduced a few regressions, and Creator hits an assertion that it introduced because it assumes the additionalFormats consists of well-formed ranges (QTCREATORBUG-7995). Change-Id: Ic4ae761e6e7f6df8a6b5ca565ceb250647420c15 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Handle additional format ranges when itemizing.Pierre Rossi2012-10-081-23/+40
| | | | | | | | | | | | | | This is useful when the additional formats are used on a text layout using a raw font. It can also come in handy for input methods operating on a QTextDocument. We now consider all format range edges to generate the associated items. The capitalization can be overridden via the additionnal formats mechanism. Adds an autotest that checks that this works with font capitalization. Change-Id: I782d2c48d05b0dfbad480a9ca77198465292b358 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* fixing typo in compile fix for MSVC 2008Thomas Hartmann2012-10-081-1/+1
| | | | | | Change-Id: If1955395d9c476a49e6d6f2ae14e6ad6c63a7da7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* compile fix for MSVC 2008 and std::upper_boundThomas Hartmann2012-10-042-1/+24
| | | | | | | | | | | | qUpperBound was replaced by std::upper_bound. Unfortunately the STL of MSVC 2008 enforces the definition of the operator in both directions. Change-Id: I3e0f775c23e43332d106e0847d3611e488da6c06 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Fixed instances of "to to" in qtbase.Samuel Rødal2012-09-241-1/+1
| | | | | | | Really it should just be "to". Change-Id: I7d0fff334bac3f0ac78adb8131e3bf3df1f1b242 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-2289-2137/+2137
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* A step out from Harfbuzz (reduce dependency)Konstantin Ritt2012-09-224-64/+45
| | | | | | | | | | | | | | | | | Introduce QCharAttributes and use it instead of HB_CharAttributes everywhere in Qt (in Harfbuzz, the HB_CharAttributes is only used in the text segmentation algorithm which has been moved from HB to Qt (well, most of it)). Rename some members to better reflect their meaning, remember to keep HB_CharAttributes in sync with QCharAttributes. Also replace HB_ScriptItem with a (temporary) QUnicodeTools::ScriptItem struct that will be replaced with a more efficient/friendly solution a bit later. The soft hyphen and the mandatory break detection has been factored out of the default text breaking algorithm to a higher level in order to refactor the QCharAttributes bitfields and to optimize the implementation for the common case. Change-Id: Ieb365623ae954430f1c8b2dfcd65c82973143eec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove qUpperBound usages from qtbaseGiuseppe D'Angelo2012-09-193-5/+6
| | | | | | | | | Replace them with std::upper_bound; this allows for deprecation of qUpperBound. Change-Id: Idef01d2228b9a70eee3d52931d7aedb5bb6ba902 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Remove qLowerBound usages from qtbaseGiuseppe D'Angelo2012-09-193-9/+14
| | | | | | | | | Replace them with std::lower_bound; this allows for deprecation of qLowerBound. Change-Id: I536e7338eb85ea6c7c1a5bf23121292767927e0b Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* gui/opengl: Fix missing or improper include guard in headersSergio Ahumada2012-09-152-7/+7
| | | | | | | | Use an include guard in headers to ensure the header is not included more than once. Make the header guard match its file name. Change-Id: I29b41e9d33e4ea17165f44c49de0a963574dd809 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Mark (non-public API's) ctor's as explicitSergio Ahumada2012-09-144-4/+4
| | | | | | | | | Make C++ class constructors that can be used with only one required argument 'explicit' to minimize wrong use of the class. Change-Id: I12ad5b6eb1794108c6b7464a2573e84068733b03 Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix regression in QTextDocument::toHtml() with font pixel sizeEskil Abrahamsen Blomfeldt2012-09-121-0/+1
| | | | | | | | | | | | Introduced by 2e0003eda4783f69a40fb4b31e7084c761d9640d. We were missing a attributesEmitted=true which caused the output from toHtml() to sometimes be invalid when using pixel sizes to specify the font size. Task-number: QTBUG-25778 Change-Id: Ied61fcaef425a590d71c0b52292ac676cb88ba52 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Jiang Jiang <gzjjgod@gmail.com>
* Removing duplicate includesSergio Ahumada2012-09-091-1/+0
| | | | | | | Do not include a header more than once Change-Id: Ia2e5d66e72988ad833cf5177a3f8aa988bf510e9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix crash when QTextLayout::setAdditionalFormats is called with ranges with ↵Olivier Goffart2012-09-071-2/+4
| | | | | | | | | | negative length That can be reproduced in Qt Creator when deleting code. Task-number: QTBUG-27140 Change-Id: Ida7177612653f10e5d866bf9a422c71c632f4eb3 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Move enums that was part of the Qt namespace to qnamespace.hJan-Arve Saether2012-09-071-8/+0
| | | | | | | | | | | | | | | | | This caused some headache wrt documentation, since in order to generate the proper documentation for the qt namespace qdoc also needed to parse the headers of gui, which breaks cross-module linking. (This is because qdoc will actually generate two almost identical nodes in the code tree; one from the header files from gui and another from the index file of gui). The best fix would maybe be to make it part of QAbstractTextDocumentLayout, but that will break source compat. Change-Id: I34e94d05fa4bec3034778d1f1cc0e53d0625e1ab Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Optimize QTextLayout/QTextEngine usage outside of QTextDocument.Milian Wolff2012-09-052-15/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QTextLayout is used in a QTextDocument, many code paths use special caches and thus greatly outperform the raw QTextLayout version that operates directly on a QString. This patch brings some of these optimizations also to the raw version. We now also use a QFormatCollection in such cases and enable the functionality of QTextEngine::indexAdditionalFormats() and QTextEngine::resolveAdditionalFormats(). Thanks to that, we can greatly speed up QTextEngine::format(), which now uses an amort O(1) hash table lookup instead of a O(N) linear search. The added benchmark shows a gain in the order of one magnitude: ./tst_bench_QText formattedLayout:long-many before applying the patch: 378.19 msecs per iteration (total: 37,820, iterations: 100) after applying the patch: 25.80 msecs per iteration (total: 2,580, iterations: 100) Note: This change is source-incompatible for applications using the private QTextEngine API. Task-number: QTBUG-8389 Change-Id: Ifcf7a8902a394428979ea06a6d955f886ee739c7 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Harfbuzz: fix build with NO_OPENTYPE macro definedKonstantin Ritt2012-08-291-1/+0
| | | | | | | | Remove `DEFINES += QT_NO_OPENTYPE` since there are no QT_NO_OPENTYPE guards and I'm not sure defining NO_OPENTYPE won't break some things. Change-Id: I7b36d3f200408aee99db73c56baa9b4a21cb54f9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Make letter spacing APIs in QTextFormat more consistentEskil Abrahamsen Blomfeldt2012-08-272-34/+48
| | | | | | | | | | | | Change d060b6f04f956ab3a6358f826dc6928b3353f5f7 introduced some new properties to QTextFormat which were unfinished and did not match the documentation in the same change. I've updated the API and docs to use the regular QFont enum for letter spacing type instead of introducing bools (which inhibits expansions later) or mutually exclusive properties in the text format. Change-Id: Ife44993b6746c413e421fdaf92ebaaab6ba95977 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* doc: Fix doc warnings for qtextlayout.cppEskil Abrahamsen Blomfeldt2012-08-251-3/+7
| | | | | | | | | \Auml for a with umlaut doesn't seem to work with qdoc anymore, so replace this with the unicode value instead. Also, add reference to arguments in glyphRuns() function. Change-Id: I31861b384b822d1fbdcafbeeac07ea68a0e5fd07 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* doc: Fix several text-related qdoc warningsEskil Abrahamsen Blomfeldt2012-08-258-24/+26
| | | | | | | | | Also adds a new snippet which is just copy-pasted from the old documentation, because the snippet-file previously referenced seems to have disappeared. Change-Id: I0180715544321e076acda769cbdcbf19d50a971b Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Speed up QTextEngine::setBoundaryOlivier Goffart2012-08-231-6/+14
| | | | | | | | | | | | | | Before, setBoundary was O(N), now it is O(log N) assuming the boundaries are added in order. (splitItem might still be linear because of the call to QVector::insert) This speeds up a lot QTextEngine::addRequiredBoundaries when there is a lot of addFormats. (For example if there is a very long line with syntax highlighting) Task-number: QTBUG-8389 Change-Id: I10c9fca72343f46db24b1d4f519f7747188d4009 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Speed up QTextEngine::resolveAdditionalFormatsOlivier Goffart2012-08-231-2/+65
| | | | | | | | | Don't call the linear QTextEngine::format in the loop. Instead, keep track of the current formats by indexing their start and end position. Task-number: QTBUG-8389 Change-Id: I89c18b804111edfab6254442cbee33da39d1a273 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* doc: Remove documentation for removed functionEskil Abrahamsen Blomfeldt2012-08-231-12/+0
| | | | | | | | Function was removed in 1582407fc782c0befd0760633324dd5c206524a1, but the documentation was left behind. Change-Id: Ib59197221e3be0e13db958ab3efdcc95b7c52452 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Move Qt::CursorMoveStyle docs to the right file.Frederik Gladhorn2012-08-231-15/+0
| | | | | | Change-Id: I26cc7336b33495a2649285cfeddeadec62e94d83 Reviewed-by: J-P Nurmi <j-p.nurmi@nokia.com> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
* Fix docs for QRawFont.Jason Barron2012-08-211-2/+2
| | | | | | | Use correct function name for 'swap' and replace QGlyphs -> QGlyphRun. Change-Id: I4997a59ef643c688e8084a2013208fb760a2784a Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
* Doc: Small addition to QAbstractTextDocumentLayout::registerHandler()Geir Vattekar2012-08-181-0/+2
| | | | | | | Task-number: QTBUG-23345 Change-Id: I6f768472aaef95f5dd88cf896ef3e635d223b635 Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@nokia.com> Reviewed-by: Geir Vattekar <geir.vattekar@nokia.com>
* Register QTextDocument* as a meta type to fix QTextEdit::document typeJ-P Nurmi2012-08-182-1/+3
| | | | | | Change-Id: I666845049749bfa6f88b764eefaefb0dcf05cb3f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QtGui: collapse two qgetenv() on the same variableMarc Mutz2012-08-071-1/+2
| | | | | | | | | | Store the result in a temporary QByteArray and continue working with that one. Change-Id: I24bc243f0f3dfb37d840faf7592b3383bd37c7e2 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* change \img to \image in docsJeremy Katz2012-08-013-5/+5
| | | | | | | | \img was a macro defined in macros.qdocconf. This collection of macros is being phased out. Use the full command instead. Change-Id: Ia55212f87bb46349d61359d40568e0aa33882596 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Correct method name referred to in QFont's detailed description.Mitch Curtis2012-07-271-1/+1
| | | | | | | | | | The detailed description of the QFont class reference contains the wrong method name (and link) setPointSizeFloat(). This change replaces it with the correct name: setPointSizeF(). Task-number: QTBUG-15536 Change-Id: Ieb2e398b8e1d0b637a6bac16a3ec48522c5dddc1 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>