summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text
Commit message (Collapse)AuthorAgeFilesLines
* QTextDocument: add setLayoutEnabled()David Faure2022-05-261-0/+21
| | | | | | | | | | | | This allows to set up everything first - without paying for the layout calculation at every step - and only then trigger the layout once. Results: 0.065 msecs to create a QGraphicsTextItem with some text (layouted) 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width Change-Id: I138bd1d58941d029bc0a36d2730216778f1fbd97 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Avoid ending Markdown fenced code blocks with gratuitous blank linesShawn Rutledge2022-05-203-6/+6
| | | | | | | | | | | | This caused unnecessary empty <pre> blocks when converting markdown to HTML, made code blocks too large using QSyntaxHighlighter to highlight the whole block, and caused assymmetry when rewriting markdown. Pick-to: 6.3 Fixes: QTBUG-101031 Change-Id: I08016577ccb92edb4afae31d7df3259cb011d5c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Convert <pre> to Markdown ``` and vice-versa with nonBreakableLinesShawn Rutledge2022-05-192-2/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HTML parser calls QTextBlockFormat::setNonBreakableLines(true) when it sees a <pre> tag; so for symmetry, the markdown reader now does the same when it sees a fenced code block, and the markdown writer honors the nonBreakableLines property by writing a fenced code block. This preserves the meaning better when reading HTML and writing markdown or vice-versa, without modifying HTML reading or writing code. Added a test tst_QTextMarkdownImporter::fencedCodeBlocks() which unfortunately also highlights a known bug in the markdown reader: each fenced code block ends with an extra empty block. That can be fixed separately. tst_QTextMarkdownWriter::fromHtml(preformats with embedded backticks) that we re-enabled in 1abaf9d5d6ea9c6554362e851903ddd214a6f659 was not a very useful test: ``` with a space and some words but no newline is not a fence: it's just like a `monospace` span. We have had trouble with those in CI because of missing monospace fonts, or inconsistency when a supposedly mono font's QFontInfo::fixedPitch() returns false. So just test proper <pre>/fence conversion for now. Pick-to: 6.3 Fixes: QTBUG-100515 Fixes: QTBUG-100981 Task-number: QTBUG-101031 Change-Id: I88f0ede0810d8a9480b30eb0cd780e1af67cc5f2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* unblacklist passing tests 2022Anna Wojciechowska2022-05-181-2/+0
| | | | | | Pick-to: 6.2 6.3 Change-Id: I7d37dd58eaede1bd0d1b53fe264b45be83cbca57 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Un-blacklist markdown tests: QSKIP when fonts are scrambledShawn Rutledge2022-05-184-31/+92
| | | | | | | | | | | | | | | | | | | | | On QNX in CI we see system fonts: fixed: monospace 9; general: Sans Serif 9 and "monospace" isn't really a fixed pitch font. On B2Qt arm7 in CI we see system fonts: fixed: monospace 9; general Sans Serif 9 and Sans Serif is actually fixed pitch. So these tests can go wrong both ways; we need to skip them whenever the fonts would lead QTextMarkdownWriter astray. Pick-to: 6.3 6.2 Task-number: QTBUG-89819 Task-number: QTBUG-99676 Task-number: QTBUG-100515 Task-number: QTBUG-103484 Change-Id: I7b9adca967eaf9b8d33d1e03ef2627f70f375196 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1630-810/+60
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add QTextDocFragment::to/fromMarkdown() & QTextCursor::insertMarkdown()Shawn Rutledge2022-05-141-0/+222
| | | | | | | | | | | | | | | | | | | | | Also add the beginnings of an autotest for QTextCursor::insertHtml(), for comparison purposes. We can see that the block to be inserted is merged with an existing block by default rather than being inserted as a new one, with both HTML and Markdown insertions. So now we test for leading and trailing newlines in the markdown to be inserted, to determine whether we need a new block into which to insert, and to "hit enter" at the end of the insertion. QSKIP the toMarkdown() comparisons if GeneralFont is mono. This happens on Boot2Qt systems in CI. Task-number: QTBUG-76105 Task-number: QTBUG-94462 Task-number: QTBUG-100515 Task-number: QTBUG-103484 Change-Id: I51a05c6a7cd0be4f2817f4a922f45fa663982293 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-071-5/+7
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* CI: blacklist fromHtml:preformats with embedded backticks for QNXPasi Petäjäjärvi2022-04-061-0/+2
| | | | | | | Pick-to: 6.2 6.3 Task-number: QTBUG-100515 Change-Id: I82b06ef1d2e275e256f8d811bc70f425c6e6bf7e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* CI: Blacklist mixedScripts for QNXPasi Petäjäjärvi2022-04-051-0/+3
| | | | | | | | | QNX tests are run under QEMU so have the same problem as Ubuntu. Pick-to: 6.2 6.3 Task-number: QTBUG-100928 Change-Id: Id7c7639b743062c777502e2ba8b28f9bb18deb19 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Android: don't QEXPECT_FAIL in tst_QTextDocument::task240325()Assam Boudjelthia2022-03-231-3/+0
| | | | | | | | | | This test doesn't fail on Android anymore, so don't use QEXPECT_FAIL. Pick-to: 6.2 6.3 Task-number: QTBUG-100470 Fixes: QTBUG-69242 Change-Id: I5a96566728a486c701656aede1818e7ab7f019be Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Deprecate {QString, QByteArray}::count()Sona Kurazyan2022-03-121-1/+1
| | | | | | | | | | | | And remove their uses. [ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count() and QByteArray::count() that take no parameters, to avoid confusion with the algorithm overloads of the same name. They can be replaced by size() or length() methods. Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: XFAIL a few in tst_QStaticText on WaylandLiang Qi2022-03-021-0/+23
| | | | | | | Task-number: QTBUG-100982 Pick-to: 6.3 6.2 Change-Id: I18cdb79d9261bac40cc619f9d327d0ef7ed722c4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CI: Blacklist systemFixedFont for QNXPasi Petäjäjärvi2022-03-021-1/+3
| | | | | | | | | | QNX tests are run under QEMU so have the same problem as b2qt Pick-to: 6.2 6.3 Task-number: QTBUG-100948 Change-Id: I2abc8a4bca9e8ba414197721301d493296e7ce0b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Activate tst_qtextdocument for AndroidAndreas Buhr2022-02-241-2/+1
| | | | | | | | | | | | tst_qtextdocument was disabled because it crashed. It does not any more. Task-number: QTBUG-87671 Pick-to: 6.2 6.3 Change-Id: Ie1bd75c21e481c2ecb8607c04ce9370fc6d7b00e Reviewed-by: Samuel Mira <samuel.mira@qt.io> Reviewed-by: Pekka Gehör <pekka.gehor@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Make Droid Sans Mono available as fixed font for all Android stylesAndreas Buhr2022-02-141-3/+0
| | | | | | | Fixes: QTBUG-87405 Change-Id: I54ebc06c82c32acd0383ea5fedf78acce4e11977 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-112-57/+8
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Add BUILTIN_TESTDATA option to qt_internal_add_testAlexey Edelev2022-02-113-40/+24
| | | | | | | | | | | Multiple tests use qt_internal_add_resource that copies the functionality that is already implemented inside the qt_internal_add_test function. Simplify these test by replacing the qt_internal_add_resource call with the new BUILTIN_TESTDATA option. Change-Id: I18475b817d6f87264f0de53817d6c26c5ccab4e2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove QEXPECT_FAIL for test passing on AndroidVolker Hilsheimer2022-01-291-3/+0
| | | | | | | | | | | | The test has been XPASS'ing recently on Android. Reverts 67e209f59fed638e93402bf2eb63fba56195e244. Fixes: QTBUG-69216 Change-Id: Ic629cc28936e0ef27277c243717e97226bf01b1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-177-57/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QCSS: Support Qt 5-style integer property selectorsVolker Hilsheimer2022-01-151-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5 style sheets, objects could be selected by an enum-type property using the integer value of the enum value, e.g QToolButton[popupMode="1"] { ... } In Qt 6, the the new meta type system and QVariant implementation enabled QVariant::toString to return the string representation of the enum value instead for a property containing an enum. Since QStyleSheetStyle's attribute matching is string based, this breaks the Qt 5 style selector, and QCSS code instead needs to use e.g. QToolButton[popupMode=MenuButtonPopup] { ... } While the new syntax is arguably preferable, this is an unintentional change that silently breaks style sheet code (no error or warning at compile- or run-time). To support Qt 5-style selectors, we have to change the StyleSelector interface of the QCssParser API so that we can pass through what type of value the attribute extractor should return; if an integer string "1" is provided, then we need to compare the enum integer value; if the string provided does not represent a number, then we need to compare the name of the enum value. Since the pure virtual attribute() method that needs to be implemented to extract the attribute value of the node is implemented in modules outside qtbase, add a second virtual method that takes the entire QCss::AttributeSelector, which includes the value to match. Extractor implementations can use it to evaluate which type of data to return for an exact match. The default implementation calls the old attribute() method so that existing StyleSelector implementations continue to work. Make the respective change in the QStyleSheetStyleSelector, and simplify the surrounding code. Adjust other StyleSelector implemnentations in qtbase. As a drive-by, remove the superfluous virtual declaration from those overrides. Once submodules are adjusted to override this virtual function instead of the (now no longer pure) virtual attribute() method, that method can be removed. Pick-to: 6.3 6.2 Fixes: QTBUG-99642 Change-Id: I9a2b3498f77bf7cab5e90980b7dab2f621d3d859 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Enable markdown writer 'preformats with embedded backticks' testShawn Rutledge2022-01-121-3/+3
| | | | | | | | It happens to pass now. Pick-to: 6.2 6.3 Change-Id: I0f6132251c3ee4ee2fef5530f8ed6997e3c946ab Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Add a markdown writer test for a checklist item ending with `code`Shawn Rutledge2022-01-121-0/+29
| | | | | | | Task-number: QTBUG-81583 Change-Id: I32540615be66f4e45bb1b3b19e914bea3aacf3e7 Pick-to: 6.3 6.2 5.15 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Use QTextCharFormat::fontFixedPitch to remember Markdown backtick spansShawn Rutledge2022-01-111-2/+5
| | | | | | | | | | | | | | | | | | | | | | If the editing app (like qtbase/examples/widgets/richtext/textedit) has controls only for setting a specific font, and someone uses it to write markdown "from scratch", then we need to detect that they chose Courier or some other fixed-pitch font, and write the backticks, because Markdown has no syntax for selecting a specific font family. If the user loads markdown into such an application, the font is set to QFontDatabase::systemFont(QFontDatabase::FixedFont). Round-trip editing was already working, as long as such a font exists. QTextCharFormat::setFont() calls setFontFixedPitch(font.fixedPitch()), but for the chosen "mono" font, font.fixedPitch() can be false. For semantic completeness and separation of concerns, we now set fontFixedPitch explicitly if a `backtick` span is encountered. As a followup to f1e60de66540b198d696253ab5148de4fcbff319 this should get its autotest passing reliably. Fixes: QTBUG-99676 Pick-to: 6.3 6.2 5.15 Change-Id: I4987a1f0f819f82ec64546bdc3ef53e7d29933de Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QTextMarkdownImporter: don't apply text char format to list item blockShawn Rutledge2022-01-061-0/+29
| | | | | | | | | | | | | | | | | | We want an ordered list item's number to be rendered with default char format, like the others in the same list, even if the list item's text begins with a span that has a different char format. So insert the list item's block with a default char format first, then change the char format of the cursor to suit the text that's about to be inserted. In HTML interpretation, it means the <li> does not have a style, but contains a styled span. Fixes: QTBUG-92445 Task-number: QTBUG-3583 Task-number: QTBUG-99148 Pick-to: 5.15 6.2 6.3 Change-Id: I7eb58a8d1171c16503cac01c8cce109d9f12e1af Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Add QTextDocumentFragment::toRawText()Kai Köhne2022-01-061-0/+9
| | | | | | | | | | | | Like QTextDocument::toRawText(), QTextDocumentFragment::toRawText() does allow access to the raw string without normalizing nbsp, line separator, paragraph separator unicode characters. [ChangeLog][QtGui][Text] Added QTextDocumentFragment::toRawText() function. Task-number: QTBUG-99572 Change-Id: Ia74150a3870ea0e6326fdcda4d9d0410019124ae Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QTextHtmlParser: fix prefix lookahead and html commentsOliver Eftevaag2021-12-221-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | The hasPrefix() function would only use the second 'lookahead' parameter to check if there was more unparsed text after the current character. When it's obvious from the codebase that it should actually look ahead of the current character being processed, and compare againt that future character. Html comments were also not handled quite right. Partially because of the broken hasPrefix() function, but also because it would advance the current index tracker by 3 instead of 2. Remember that the beginning of an html comment is <!-- meaning that there are only supposed to be 2 dashes required, not 3. The result would be that something like this <!----> would not automatically close, because the current index tracker would jump over the first 3 dashes when it begins a comment, and the remaining unprocessed string would be -> Also, because of the broken lookahead in hasPrefix(), a comment could actually be started with just <!- not requiring a second dash at all. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-99147 Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add css media rule support for QTextDocument::setHtml()Ralf Habacker2021-12-151-0/+38
| | | | | | | | | | | | | | | | | CSS styles can contain '@media <rule> {...}' blocks, which were previously ignored for all values except "screen". To use a media rule other than the default "screen" rule, specify it before calling setHtml() with setMetaInformation() and the new info value 'CssMedia'. [ChangeLog][Gui][QTextDocument] Add css media rule support for QTextDocument::setHtml() Pick-to: 6.3 Fixes: QTBUG-98408 Change-Id: Ie05f815a6dedbd970210f467e26b116f6ee3b9ca Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QFontDatabase (Windows): Sanitize font requests earlyMårten Nordheim2021-12-061-0/+31
| | | | | | | | | | | | | | | | | | | After the windows font engine was no longer marking everything as scalable we started limiting the font size of requests to the maximum of Courier when it was requested. This was a regression from 5.8 and not in agreement with our documentation. The problem is that we would only make the switch from Courier to Courier New after having already gone through the foundry-lookup and found a closest-available font size for Courier. With this sanitization step in the backend we can make these changes early enough that we haven't yet adjusted e.g. the font size. Pick-to: 6.2 5.15 Fixes: QTBUG-58995 Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Don't let text table cells shrink below their minimum widthVolker Hilsheimer2021-12-021-1/+60
| | | | | | | | | | | | | | We calculate the minimum width, but then use it only to make sure that the maximum width is at least as large as it. Without setting the layout struct's minimumWidth as well, table cells can be smaller. Add a test case. Fixes: QTBUG-86671 Fixes: QTBUG-97463 Pick-to: 6.2 5.15 Change-Id: Idf4ad015938abb8d3e599e9a58e002f29c0067be Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix overlapping text for Osaka font on macOSEskil Abrahamsen Blomfeldt2021-12-021-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | The Osaka font on macOS has all zeroes in the OS/2 table, probably because it is not intended to be cross-platform. In Qt 6 (since f761ad3cd9ad1252f24b76ae413298dc7bed8af3) we are trying using the same vertical metrics on all platforms, but this only works if they are valid. To work around this issue, we detect the case when ascent/descent values are both 0, since this is very unlikely to be intentional, so we fall back to the system-provided ascent and descent in these cases. Adding the test also revealed that we had missed the check for a macOS-specific bitmap font format when skipping the check for bitmap fonts in 7a18b7e2c2394b2b2cc95833c755f91193d9ba2e. [ChangeLog][macOS][Text] Fixed a problem where using the Osaka font would lead to overlapping text. Pick-to: 6.2 Fixes: QTBUG-96880 Change-Id: Ifea7918641a68829e8f5ef20a4fb61c0a7e5b757 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Don't shrink a column when it spans multiple columnsVolker Hilsheimer2021-12-011-0/+28
| | | | | | | | | | | | | | | | | | If a cell spans multiple columns, then the merged cells' starting column's maximum width should never become smaller than what was calculated from previous rows. Otherwise, we'd distribute the space of the column that has a span across all merged columns, resulting in unnecessary line breaks esp if WrapAnywhere is enabled. Add a test case. Fixes: QTBUG-91691 Fixes: QTBUG-95240 Pick-to: 6.2 5.15 Change-Id: Ic27dbdb128071e50fba049de85c9f23ba2f059b3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QTextDocument: fix an off-by-one in the changed signal for listsEirik Aavitsland2021-11-291-0/+60
| | | | | | | | | | | | | | | | | When blocks are added or removed in block groups, i.e. items added or removed from text lists, the whole group is marked as changed, but the calculation of the before/after group length would be one off. That was reflected in the contentsChange signal. Add unit test. Since the whole group changes when list items are added, text is removed and the change-begin is not where the cursor was when the change was made. Fixes: QTBUG-82455 Pick-to: 6.2 5.15 Change-Id: I99ee2cfef4944fcac8aca492741fd0f3b0de4920 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Properly fix QFontDatabase test on FreetypeEskil Abrahamsen Blomfeldt2021-11-191-1/+3
| | | | | | | | | | | | Amends 4dd5020fbdfdd34f1e4ec54521217e472942a4b4. I messed up the fix for the XFAIL condition, since the font engine type we get from a normal QFont will be QFontEngine::Multi regardless of whether the actual font engines are Freetype or not. Use NoFontMerging to avoid this. Pick-to: 6.2 Task-number: QTBUG-97995 Change-Id: I2298c997e6826e667dbb8e3d004821f296625ef7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix deserializing Qt 5.x fonts through QDataStreamEskil Abrahamsen Blomfeldt2021-11-184-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5, fonts had both singular family and plural families properties, and both were stored separately when streaming through QDataStream. The families list was treated as an extension of family in this case, and the primary font family was always the singular family property. In Qt 6, it has been merged into one and family() is now just a convenience for families().at(0). But when reading files generated with Qt 5, we would ignore the fact that these were previously separated. We would first read the family entry into the families list, and then we would later overwrite this with an empty families list. Instead, we detect streams created with Qt 5.15 or lower and make sure we append the families list instead of overwriting it in this case. In addition, we need to make sure we split up the list again when outputting to Qt 5.x. This adds a file generated with QDataStream in Qt 5.15 to the test to verify. [ChangeLog][Fonts] Fixed a problem deserializing the family of fonts that had been serialized using QDataStream in Qt 5. Pick-to: 6.2 Fixes: QTBUG-97995 Change-Id: Id3c6e13fc2375685643caee5f8e3009c00918ccb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Fix tst_qfontdatabase on Windows with FreetypeEskil Abrahamsen Blomfeldt2021-11-101-1/+5
| | | | | | | | | | | Since e05e3c776256d35798f451f31cd71e809786ed78, the advance test in tst_QFontDatabase::condensedFontMatching() passes with the bundled freetype engine, so the XFAIL causes a failure when running with this configuration. Pick-to: 6.2 Change-Id: Ie6fbccfa0d9c79654563e9e3f19694f252e32fc6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix inconsistencies between advanceWidth and bounding rectsAllan Sandfeld Jensen2021-10-211-0/+18
| | | | | | | | | | | | | | | | Unify the logic in QTextEngine Ensure tightBoundingRect, and the FreeType boundingRect, calculates from the shaped x offset when calculating the max x coordinate for a glyph. Fixes: QTBUG-7768 Task-number: QTBUG-70184 Task-number: QTBUG-85936 Task-number: QTBUG-94023 Change-Id: I6daafb25c79158dc7e777529abb5e8d3a284dac0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix cursor positioning on bidi boundariesVolker Hilsheimer2021-10-181-0/+58
| | | | | | | | | | | | | | | | | When the cursor is positioned between to script items that have different writing directions, prioritise the script item that has the same direction as the paragraph (i.e. the QTextEngine) when deciding where and how to display the cursor. If visual cursor movement is enabled, the behavior is unchanged. As a drive-by, clean up coding style and avoid shadowing of function- local variables. Task-number: QTBUG-88529 Pick-to: 6.2 Change-Id: I15227b10b1469d9caf1235b00e4d6f9f64a8b510 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix cursor placement at left and right ends of bidi textVolker Hilsheimer2021-10-181-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a text line that has a change of direction at either end of the text, the cursor needs to be positioned where the next character is inserted, or where backspace deletes the previous character. In bidi text, this is ambiguous as illustrated by this example: abcشزذ Depending on whether this string was typed in a left-to-right document or in a right-to-left document, it could be first latin, then arabic; or it could be first arabic, then latin. If a general left-to-right context, cursor position 0 should be in front of the 'a', and cursor position 6 should be at the end of the arabic text, in the visual middle of the line. Cursor position 3 can be either after the 'c' if the next character typed would be latin, or at the visual end of the line if the next character will be arabic. Qt calculated the cursor position past the right end of the text as 3 (which is not wrong, but 3 has two visual positions), and placed the cursor at the visual end of the line (favoring the right-to-left alternative). Backspace would then delete the 'c', writing a new latin character would insert a 'd' next to the 'c', writing a new arabic character would insert it also in the middle - none of these operations happen at the visual end of the line, where the cursor was blinking. To fix this, we take into account the general layout of the text, which is typically based on the document, or the user's locale setting and UI translation, and calculate the cursor position accordingly: if we are past the visual end of the document on either side, then the cursor position is either 0 or the last character of the text, depending on the direction of the QTextEngine used. This way, the cursor ends up in the middle of the document when we click beyond the end of the line, which is where characters are removed and inserted. Typing a 'd' at this point will make the cursor jump to the end, where the d is added. There are still corner cases: clicking on the right-most arabic character calculates the cursor position as 3, which is then ambiguous, as it can be either at the visual end of the string, or next to the 'c'. َQt makes the inconsistent choice to place the cursor at the visual end, showing the left-to-right indicator, but pressing a 'd' adds the 'd' after the 'c' in the middle of the text. Fixes: QTBUG-88529 Pick-to: 6.2 Change-Id: Idccd4c4deead2bce0e858189f9aef414857eb8af Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Markdown importer: keep entities in HTML blocks with the HTMLShawn Rutledge2021-10-161-0/+66
| | | | | | | | | | | | If an entity occurs directly in markdown, we parse and insert it directly; but if it occurs in an HTML block, it has to be added to the HTML accumulator string for deferred parsing when the HTML block ends. Pick-to: 6.2 Fixes: QTBUG-91222 Fixes: QTBUG-94245 Change-Id: I0cf586d68d6751892ca035a98f77cd67950d3bc4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Markdown writer: indent fence consistent with code blockShawn Rutledge2021-10-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Under a list item, we've been indenting code blocks: ``` int main() ... ``` - But it's also ok *not* to indent (and github handles that better): ``` int main() ... ``` - There was a bug that when the code is not indented, the fence would be indented anyway: ``` int main() ... ``` and that was not OK, neither for md4c nor for github. Now with this change, either way is rewritable: you can read markdown into QTextDocument, make small edits and write it back out again, with the indentation being preserved (the code block is either part of the list item, thus indented, or else it's outside the list completely). Pick-to: 6.2 Task-number: QTBUG-92445 Change-Id: I5f51899e28ba9f09b88a71e640d9283416cce171 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Support background-color CSS styling on <hr/>Shawn Rutledge2021-10-142-102/+60
| | | | | | | | | [ChangeLog][QtGui][CSS] The background-color style can now be applied to <hr/> to set the rule color. Task-number: QTBUG-74342 Change-Id: Ib960ce4d38caa225f258b6d228fb794cef43e1b7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix caching of parsed border color values in CSS parserVolker Hilsheimer2021-10-121-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When parsing CSS, a border-color value is parsed as four brushes, as css allows assigning up to four values, one for each side. When applying the CSS to the HTML, we accessed it as a color value, which overwrote the parsed value with a QColor. So while we had a valid parsed value (and didn't re-parse), the code accessing that value still expected it to be a list, and thus failed to retrieve the data. There are several ways to fix that, but the cleanest way without introducing any performance penalty from repeatedly parsing (and in fact removing a parse of the string into a color) is to enable colorValue to interpret an already parsed value that is a list without overwriting the parsed value again. To avoid similar issues in the future, add assert that the parsed value has the right type in brushValues. As a drive-by, speed things up further by making use of qMetaTypeId being constexpr, which allows for it to be used in a switch statement. Add a test case. Fixes: QTBUG-96603 Pick-to: 6.2 5.15 Change-Id: Icdbff874daedc91bff497cd0cd1d99e4c713217c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Respect font stretch if set together with font styleAlbert Astals Cid2021-10-041-0/+24
| | | | | | Fixes: QTBUG-77854 Change-Id: I2bf9cea9d5ecd151a9d96bbe93e9477a9159ca1f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QFontCache: don't start cleanup timer if we are not in the main threadVolker Hilsheimer2021-10-011-0/+47
| | | | | | | | | | | | | We can only start timers in threads started via QThread, and even then we cannot assume that the thread runs an event loop. So only start the timer when we are in the main thread. Add a test that verifies that we don't get the warning message. Pick-to: 6.2 Change-Id: I40d7d9ff115720f9ecd3eedaebbade2643daf843 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compile autotests for IntegrityTatiana Borisova2021-09-201-0/+2
| | | | | | | | | - process environment/DNS are OFF for INTEGRITY Task-number: QTBUG-96176 Pick-to: 6.2 Change-Id: I189a97f88c96a428586c31a66b8d250e04482900 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix querying font aliases that share name with other fontsEskil Abrahamsen Blomfeldt2021-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a332f3fabc29f796526202648eddf35a24f1cb67 disabled resolving all fonts on the system for every font lookup, which was a significant startup time improvement. But it also caused a regression: When a font has an alias which shares the name of a proper font, then this would not be resolved correctly. This is fairly typical on Windows/GDI due to backwards-compatibility. Instead of being collected under a shared typographical family, fonts are disambiguated by adding the style name to the family name. The proper typographical name is still available, but this is not enumerated by the system. So "Segoe UI" for instance, will be available as "Segoe UI", "Segoe UI Light", "Segoe UI Bold" etc. When we populate family aliases, we register that "Segoe UI Light" is actually "Segoe UI" with Light weight, and prior to a332f3fabc29f796526202648eddf35a24f1cb67 this would be done implicitly. But after the optimization, we would only populate family aliases once we stumbled over a font request for a non-existent font. For "Segoe UI", we would simply return the regular weight font as the best imperfect match. The fix is to populate font family aliases not only when the family is non-existent, but when the match is imperfect, e.g. if we are asking for a Light weight font and only finding a regular one. User code can still avoid this somewhat expensive operation by using the full family names on Windows. This also requires a fix to a test. When removeApplicationFont() is called, we invalidate the font database, so it will be reset to a state that does not contain the family aliases. Therefore we cannot guarantee that it is identical to what it was before the test started, since this depends on what has happened previously in the application. [ChangeLog][QtGui][Text] Fixed an issue where some font styles and weights would not be selectable. This was especially noticeable on Windows. Pick-to: 5.15 6.1 6.2 Fixes: QTBUG-94835 Change-Id: I892855edd1c8e3d3734aace396f6000d897d2ec4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix bug with NoFontMerging when font does not support scriptEskil Abrahamsen Blomfeldt2021-08-191-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using NoFontMerging, no fallbacks should be resolved. If the font does not support a specific character in the text, we should display a box instead of merging it with another font. But in practice, Qt would still apply the fallback mechanism for one specific case: If the font itself does not support the script of the text, we would get no match and do a search for a fallback instead. Since NoFontMerging is set, we would then force this as preresolved for *all* scripts in the QFont's private data (logically, the match should only have a single response for NoFontMerging). The end result was that if you set the font family before updating the text, you would get broken rendering. This can happen e.g. in Qt Quick, where you could update the font family of a text label while it contains characters which are not supported by the new font. Qt would then pick a fallback instead. When you subsequently update the text, the fallback would already be preresolved for whatever script this is. If it does not support the updated text, we would then see boxes, even if the requested font actually would have supported it. The fix is simply to do an additional pass if NoFontMerging is set and we were not able to match with the specified script. Since the same family might be available in different foundries, with different writing system support, we still want to do a pass first to see if we can match the exact script of the text. Note that QRawFont::fromFont() exploited the bug by using NoFontMerging for getting the fallback font for a specific writing system. To keep this working without having to rewrite fromFont() and risk introducing regressions, we add an argument to make the findFont() function behave as before. It isn't super-pretty, but since it is private API it is hopefully fine. [ChangeLog][QtGui][Text] Fixed an issue with NoFontMerging and changing font families dynamically, where boxes would be seen in place of the correct text. Pick-to: 5.15 6.1 6.2 Done-with: Andy Shaw Fixes: QTBUG-81770 Change-Id: Ide9a36d7528a1040172c5864fa99e7a82eac4e83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tests: Remove unused SRCDIR definesIevgenii Meshcheriakov2021-08-173-6/+0
| | | | | | | | | | | Remove SRCDIR defines from tests that don't use them. There is a standard define called QT_TESTCASE_SOURCEDIR that is available to all tests and serves the same purpose. Pick-to: 6.2 Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>