summaryrefslogtreecommitdiffstats
path: root/src/gui/text
Commit message (Collapse)AuthorAgeFilesLines
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-212-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove obsolete virtual method after submodules adjustedVolker Hilsheimer2022-01-211-4/+1
| | | | | | | | | | Amends cb27ed30f7bc58474eba991f837843eb76cbd339 after follow-up change 43fb6953fb940edfec358a2d1c01e05705712829 in Qt Svg. Task-number: QTBUG-99642 Pick-to: 6.2 6.3 Change-Id: Ice190dc9d1bdcb08d74c86edf0028cf50266d94e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QCSS: Support Qt 5-style integer property selectorsVolker Hilsheimer2022-01-153-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix crash when text shaping failsEskil Abrahamsen Blomfeldt2022-01-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | If text shaping failed for some reason (for example if the string passed to Harfbuzz contains ignorables only), we would return a single glyph for the whole string. But we forgot to initialize the log clusters array, which could cause crashes later when this was read. We initialize a single cluster consisting of the "missing glyph" glyph to be consistent. Amends fccd419dd632306a4bd85928223e0a56a59510ef. [ChangeLog][QtGui][Text] Fixed a possible crash with certain fonts when shaping strings consisting only of control characters. Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-89155 Fixes: QTBUG-92358 Change-Id: I1ec0237d99b48be2a8bb340f0feb056bca4fdffe Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use QTextCharFormat::fontFixedPitch to remember Markdown backtick spansShawn Rutledge2022-01-112-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
* Use ranged for loops instead of QString::utf16Øystein Heskestad2022-01-072-14/+7
| | | | | | | | Task-number: QTBUG-98763 Change-Id: I27a854121a783e67afcc4f8634ea7c8c921430c2 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QString::utf16() with data() in memcpy() and QByteArray ctorØystein Heskestad2022-01-071-3/+3
| | | | | | | | | | | QString::utf16() needlessly detaches fromRawData() to ensure a terminating NUL. Use data() where we don't require said NUL, taking care not to call the mutable data() overload, which would detach, too. Task-number: QTBUG-98763 Change-Id: I7075a8f18ab1f82ebbcf8cfab1643e8ab7f38d51 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QFontDatabase: remove outdated commentsYuhang Zhao2022-01-072-6/+0
| | | | | | | | | | | | | | QtBase/2526df506bda99f9497e83a4e6820557a722660e has resolved what the comment said. As a drive-by, remove the unused QSystemLibrary include, which is forgotten in 2526df506bda99f9497e83a4e6820557a722660e. Amends commit 2526df506bda99f9497e83a4e6820557a722660e Pick-to: 6.3 Change-Id: Iab5c7d00e22d306be63d7588ea44bf73d377793d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextMarkdownImporter: don't apply text char format to list item blockShawn Rutledge2022-01-061-0/+3
| | | | | | | | | | | | | | | | | | 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-062-6/+27
| | | | | | | | | | | | 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>
* Use block char format to render list item bullets and numbersAlbert Astals Cid2022-01-051-1/+1
| | | | | | | | | | | | | It needs to be rendered with the format of the block not the format of the first letter of the block; otherwise if the first letter is black or italics or something, but the rest of the block isn't, the list item text looks out of place. Task-number: QTBUG-3583 Fixes: QTBUG-99148 Pick-to: 6.3 6.2 5.15 Change-Id: I63d8d6d6b7cee6bd9938fe1cf42a5f90da1bc0d3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Avoid crash on app startup if the default font family is emptyLars Knoll2022-01-031-3/+6
| | | | | | | | Don't call first() on a potentially empty list of families. Fixes a crash on startup on QNX for me. Change-Id: I551d21dac8cfd104b774d6442bdbe1db35f8b75c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTextHtmlParser: fix prefix lookahead and html commentsOliver Eftevaag2021-12-222-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QZipReader: update to unzip partly broken archivesIvan Solovev2021-12-191-0/+20
| | | | | | | | | | | | | | | | The problem was discovered while providing a fix for the linked issue. The original zip archive is very old, and it does not contain separate entries for directories, only for files. As a result, QZipReader algorithm was failing to create all the necessary subdirectory structures, and unzipping failed. This patch detects such case, and creates a directory hierarchy based on the file paths. Task-number: QTBUG-81503 Pick-to: 6.3 6.2 5.15 Change-Id: I204f9b620853b3ffcbb9cbf6fe08fb5958776ea0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add css media rule support for QTextDocument::setHtml()Ralf Habacker2021-12-155-5/+20
| | | | | | | | | | | | | | | | | 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>
* QGlyphRun: always use stored bounding rect even if it's emptyVladimir Belyavsky2021-12-131-2/+2
| | | | | | | | | | | | | | | | | QGlyphRun's bounding rectangle may have zero width, e.g. when it contains only non-printable characters. Some code, e.g. QTextLine::glyphRuns(), may pre-calculate bounding rectangle for QGlyphRun and store it inside via QGlyphRun::setBoundingRect(). Previously, we would ignore empty rects as an indication that no bounding rect had been set on the QGlyphRun. This should be checking for valid rects instead, to allow for runs containing non-printable characters exclusively. Fixes: QTBUG-96463 Pick-to: 6.2 Change-Id: Ia934749cfda37e60ebf98fb76536434054baa4d1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Trust CoreText-provided vertical metrics on macOSEskil Abrahamsen Blomfeldt2021-12-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In f761ad3cd9ad1252f24b76ae413298dc7bed8af3 we added a cross-platform consistent approach to vertical spacing of text. However, this has created problem on macOS, as some of the default fonts on the system have inconsistent metrics. Specifically, Monaco is missing the typographical metrics flag in its OS/2 table, and the alternative metrics in the table are about 30% larger than the typographical metrics (which match what is used natively). As a result, the fonts look the same on macOS as on other platforms now, but different from when the same fonts are used in native apps. We can't have fonts look wrong on their native platform, so we revert this change for CoreText, trusting the metrics we get from the system instead. We keep the consistent approach for the FreeType engine, as its main use case is cross-platform consistent text rendering. [ChangeLog][macOS][Text] Fixed an issue where certain fonts, such as Monaco, would have a different line spacing than expected. Pick-to: 6.2 Fixes: QTBUG-97818 Change-Id: I0a3dbe4636d67779935e645066b1e51c1517dc6d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix qtdeclarative baseline test failure for text tablesVolker Hilsheimer2021-12-061-3/+3
| | | | | | | | | | | | | | Amend 97cfd4940157817dd761fd02f2e6da4afc5b4a30, which resulted in incorrectly laid out tables in Text elements. Reported by the baseline test for the scenegraph. Not reproducible using a QtWidget text widget, so no unit-test added here. Pick-to: 6.2 5.15 Task-number: QTBUG-86671 Task-number: QTBUG-97463 Change-Id: I607b1fea3fb5923f81f05a3646bafebec3dcf3b5 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QFontDatabase (Windows): Sanitize font requests earlyMårten Nordheim2021-12-063-11/+34
| | | | | | | | | | | | | | | | | | | 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>
* QFontDatabase: unify relevant documentation piecesAndrei Golubev2021-12-031-9/+3
| | | | | | | | | | | | | | | | addApplicationFont and addApplicationFontFromData basically do the same thing (with one reading the data from a file and another reading it directly from QByteArray) The documentation is not quite identical, so fix that by using \include magic of qdoc As a drive-by, remove outdated \note within addApplicationFont() description Fixes: QTBUG-98752 Pick-to: 5.15 6.2 Change-Id: I29738e7411d241c26a4b2e1dd91d0af867fcc111 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Don't let text table cells shrink below their minimum widthVolker Hilsheimer2021-12-021-0/+1
| | | | | | | | | | | | | | 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>
* Freetype: adjust underlinePosition to match our expectationsMårten Nordheim2021-12-021-1/+2
| | | | | | | | | | | | | | | | | We expect underlinePosition() to be the topleft corner of where we start drawing the underline but freetype reports the _center_ of the underline: "underline_position: [...]. It is the center of the underlining stem." - https://freetype.org/freetype2/docs/reference/ft2-base_interface.html Pick-to: 6.2 5.15 Fixes: QTBUG-62602 Change-Id: I96808816f50f3f37b18f579adf285502c88e6ea5 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix overlapping text for Osaka font on macOSEskil Abrahamsen Blomfeldt2021-12-021-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix missing characters or assert with certain font sizesEskil Abrahamsen Blomfeldt2021-12-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | The alphaMapBoundingBox() only exists to prefetch the size of rendered alpha maps, to reserve space in the glyph cache. Since 104e6d0f5427f5ebaab106b1651eb76c4c56df98 we have not used the QPainterPath fallback code path when actually rendering the glyphs, but that patch neglected to update the code that retrieved the bounding box. This could in some cases cause a mismatch, and if the alpha map we ended up with in the end was larger than the reserved space, this could trigger an assert or an empty spot in the cache. [ChangeLog][Text][Freetype] Fixed an issue where characters would in some rare cases be missing from text, depending on font metrics, font size and system scale factor. Pick-to: 5.15 6.2 Fixes: QTBUG-86633 Change-Id: Ic8ade168115e4f51bac71539325936bbae993120 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't shrink a column when it spans multiple columnsVolker Hilsheimer2021-12-011-0/+2
| | | | | | | | | | | | | | | | | | 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>
* Fix gaps between lines of selectionEskil Abrahamsen Blomfeldt2021-11-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | When a font has fractional metrics, we could get visible gaps between lines in a multi-line selection, if the bottom of the rect was not aligned to the pixel grid. In Qt 5, this was primarily an issue on macOS, but since making vertical metrics consistent in f761ad3cd9ad1252f24b76ae413298dc7bed8af3, we could also get this on other platforms, causing a regression on these platforms. The fix is to align the rect to the pixel grid. [ChangeLog][Text] Fixed an issue where there would sometimes be visible gaps in selections spanning multiple lines. Pick-to: 6.2 Fixes: QTBUG-98372 Change-Id: I03cb1465602b6d78c60a0c764d920f7f092418a8 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QTextDocument: fix an off-by-one in the changed signal for listsEirik Aavitsland2021-11-291-1/+4
| | | | | | | | | | | | | | | | | 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>
* Fix deserializing Qt 5.x fonts through QDataStreamEskil Abrahamsen Blomfeldt2021-11-181-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* FreeType: allow falling back to synthesized bold if desiredAndy Shaw2021-11-031-1/+3
| | | | | | | | | | Some users still prefer the fake bold look even if in some cases it does not look good. So add an environment variable - QT_NO_SYNTHESIZED_BOLD_LIMIT - to allow that fallback to stay in place. Pick-to: 6.2 5.15 Change-Id: I8212c1fa36edb4730b187dc4a23ea45f94981154 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove pre-Win10 code paths in QtBaseYuhang Zhao2021-11-022-38/+5
| | | | | | | | | | | | | | Mostly a removal of dynamically loaded API. They should all exist on Windows 10 1809 (Qt6's minimum supported version). accessibility parts left untouched to make sure MinGW still compiles. Task-number: QTBUG-84432 Pick-to: 6.2 Change-Id: I7a091fc967bd6b9d18ac2de39db16e3b4b9a76ea Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* Add const to read only local variablesOliver Eftevaag2021-11-012-3/+3
| | | | | | Pick-to: 6.2 Change-Id: Ideb34a5009277b919a8a3834e53af4ff550dfc6e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Doc: Fix qdoc warnngsVenugopal Shivashankar2021-10-231-2/+2
| | | | | | | | | | | qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:75: (qdoc) warning: Cannot tie this documentation to anything [qdoc found a /*! ... */ comment, but there was no topic command (e.g., '\fn', '\page') in the comment and no function definition following the comment.] qt5/qtbase/src/gui/text/qtextformat.cpp:1500: (qdoc) warning: Overrides a previous doc qt5/qtbase/src/gui/text/qtextformat.cpp:1487: (qdoc) warning: (The previous doc is here) qt5/qtbase/src/gui/text/qtextformat.cpp:1533: (qdoc) warning: Overrides a previous doc qt5/qtbase/src/gui/text/qtextformat.cpp:1520: (qdoc) warning: (The previous doc is here) Change-Id: I5a089bef1841d6d69bff4c780805d20e5926fe6f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Add QFontMetricsF methods taking text options into accountAllan Sandfeld Jensen2021-10-222-6/+201
| | | | | | | | | | This is needed by Qt Quick to be able to calculate font metrics using design metrics matching Quick text rendering. Task-number: QTBUG-85936 Task-number: QTBUG-94023 Change-Id: I67c74e2a912bd58df7a57349a858f20f04609f0f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix inconsistencies between advanceWidth and bounding rectsAllan Sandfeld Jensen2021-10-213-117/+57
| | | | | | | | | | | | | | | | 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>
* QtGui & its plugins: remove set-but-unused variablesThiago Macieira2021-10-191-4/+0
| | | | | | | | | Found by clang 13: qfontsubset.cpp:1211:10: warning: variable 'sumAdvances' set but not used [-Wunused-but-set-variable] Change-Id: Iea05060bc2c046928536fffd16adf500fb9bc8e5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Update UCD to Revision 28Ievgenii Meshcheriakov2021-10-182-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This corresponds to Unicode version 14.0.0. Added the following scripts: * CyproMinoan * OldUyghur * Tangsa * Toto * Vithkuqi Full support of these scripts requires harfbuzz version 3.0.0, this version adds support for Unicode 14.0: https://github.com/harfbuzz/harfbuzz/releases/tag/3.0.0 With this release 10 test cases in tst_qurluts46 were fixed, one additional test case is failing in tst_qtextboundaryfinder and is commented out. In total 62 line break test cases and 44 word break test cases are failing. A comment in src/corelib/text/qt_attribution.json was updated to include the URL of the page containing UCD version number. Fixes: QTBUG-94359 Change-Id: Iefc9ff13f3df279f91cbdb1246d56f75b20ecb35 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix cursor positioning on bidi boundariesVolker Hilsheimer2021-10-181-43/+74
| | | | | | | | | | | | | | | | | 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-26/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QFontDatabase: suppress warning about its constructor being deprecatedThiago Macieira2021-10-161-1/+1
| | | | | | | | | | qmetatype.h:2263:76: warning: 'QFontDatabase' is deprecated: Call the static functions instead [-Wdeprecated-declarations] ... moc_qfontdatabase.cpp:159:1: note: in instantiation of variable template specialization 'qt_incomplete_metaTypeArray<qt_meta_stringdata_QFontDatabase_t, QtPrivate::TypeAndForceComplete<QFontDatabase, std::integral_constant<bool, true>>>' requested here qfontdatabase.h:113:7: note: 'QFontDatabase' has been explicitly marked deprecated here Change-Id: Iea05060bc2c046928536fffd16adf537be122db2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Markdown importer: keep entities in HTML blocks with the HTMLShawn Rutledge2021-10-161-1/+4
| | | | | | | | | | | | 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-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | - 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-143-4/+19
| | | | | | | | | [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-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* freetype/no-fc: Disambiguate fonts with different widthsEskil Abrahamsen Blomfeldt2021-10-121-1/+31
| | | | | | | | | | | | | | | | | When using the Freetype font database, we would ignore the typographical width of loaded fonts, which could make it impossible to select certain fonts in a family. [ChangeLog][Freetype] Fixed a bug where fonts of different width within the same family would be unselectable if the Freetype font database (no-fontconfig configuration) was in use. Pick-to: 5.15 6.2 Fixes: QTBUG-89640 Change-Id: Ic9c17a7c3cc14eb7e942b05d6b21b7c1602816cf Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-126-11/+11
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-126-8/+8
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Revert "Support family names that end/start with space"Eskil Abrahamsen Blomfeldt2021-10-071-3/+1
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7fd9ed32012bd9001e78ad692a4802e0e3366e44. While trimming the font name worked for cases with application fonts, it actually introduced an assert for system fonts that ended with a space, because enumerating these failed. So the original assumption that all Windows APIs also trimmed the family name was wrong. The original bug was that the font with the trailing space could not be selected, but when using setFamilies(), it can. So there is a perfectly fine way around the original bug when using a font that has this problem. Therefore, no additional fix is needed for that. [ChangeLog][Windows] Fixed an assert that happened when the system had a font with a trailing or leading space in its name. Pick-to: 5.15 6.1 6.2 Fixes: QTBUG-93885 Task-number: QTBUG-79140 Change-Id: I6d9df31a4f2c6555d38d51da374f69b6fb0f1ecb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlatformFontDatabase: Don't copy metaobjectsUlf Hermann2021-10-071-2/+2
| | | | | | | | This is expensive and unnecessary here. Change-Id: I542c0309db5839c696f51b066cd5423a63468438 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Respect font stretch if set together with font styleAlbert Astals Cid2021-10-041-1/+1
| | | | | | Fixes: QTBUG-77854 Change-Id: I2bf9cea9d5ecd151a9d96bbe93e9477a9159ca1f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Doc: Replace broken link to Roman Czyborra's personal pageLuca Di Sera2021-10-011-2/+2
| | | | | | | | | | | | | | | | | | | | The `QFont` documentation refers to Roman Czyborra's personal page with the intent of providing information about encodings. The page seems to have been down for many years and may contain information that is now deprecated such that it is now replaced with a link to the Unicode Technical Report 17 about the Unicode Character Encoding Model. The new link was chosen as a substitute as it seems to cover or provide the intuition for, standing by the last captured version of Roman Czyborra's personal page on the Wayback Machine, many of the same concepts. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: Ibf901b5023688c14efb3d6f77a10609f7ba80e72 Reviewed-by: Paul Wicking <paul.wicking@qt.io>