summaryrefslogtreecommitdiffstats
path: root/src/gui/text
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* QFontCache: don't start cleanup timer if we are not in the main threadVolker Hilsheimer2021-10-012-15/+27
| | | | | | | | | | | | | 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>
* QTextImageFormat::setQuality: deprecate the default valueDavid Faure2021-10-011-2/+5
| | | | | Change-Id: Ia4532a7dd6eb6c0356aeea2dca0ae585ab9b1ffd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use Yu Gothic UI as the main fallback font for JapaneseEskil Abrahamsen Blomfeldt2021-09-281-0/+1
| | | | | | | | | | | | | | | Using MS Gothic UI as the fallback on Japanese locale has been outdated for many years. The default font on Japanese is Yu Gothic UI, and this caused mismatches between Japanese text when using the fallback and when just relying on the default. [ChangeLog][Text] Made the primary fallback font on Japanese locale "Yu Gothic UI" (the default system font). Fixes: QTBUG-96689 Pick-to: 6.2 Change-Id: I9cf34410619ff4a2ceb9b03d523018c5061c3634 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix QTextEdit cursor rectangle vertical positioningZhang Hao2021-09-181-2/+5
| | | | | | | | | | | | | | | When there are characters with different pointsize in QScriptLine, the value of si.descent is less than sl.descent, which will cause the y value of the cursor rectangle to be too large. If si.descent is less than sl.descent, the height of the cursor rectangle is equal to base plus si.descent. Amends e99a883bd382ca950192bd66cafb2a1de6394ce7 Fixes: QTBUG-96288 Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Pick-to: 6.1 6.2 Change-Id: I4a8566b32cfa75d8ca1a584f5e8e577c5c9caf0d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextDocumentLayout: remove multiple calls to lineHeightTypeWaqar Ahmed2021-09-161-5/+7
| | | | | | | | | | Get LineHeightType once and reuse the value. There still are 2 calls to lineHeightType from inside the QTextBlockFormat::lineHeight but leaving them cause they need a bigger change. Change-Id: I4016a5e483a0358d43f73d174a74545d4f3be338 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix querying font aliases that share name with other fontsEskil Abrahamsen Blomfeldt2021-09-111-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QTextImageFormat: add Qt7 TODO to remove the default valueDavid Faure2021-09-081-0/+1
| | | | | Change-Id: I8b60b302c9df7ce7c44b89fe45f813c4532b7bd6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QTextOdfWriter: fix exporting pixmaps to ODTDavid Faure2021-09-081-2/+2
| | | | | | | | | | | | | | | The QVariant returned by resource() can contain either a QPixmap or a QImage. The code here is now more similar to the one in qtextimagehandler.cpp. Also, the quality is 0 when not set, in which case we want a nice PNG rather than a very very low quality JPG with just a few large blocks of same-color pixels. Pick-to: 5.15 6.2 Change-Id: I49db542e2234c8068f85a636a81a7d8cdb7b5876 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-011-8/+8
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix text ellipsis not implemented in TibetanFan RuiJie2021-08-311-0/+5
| | | | | | | | | | | | | | | | | The original code checks the existence of an ellipsis character first.If this does not exist (glyph == 0,which is an invalid glyph index), then it falls back to looking up '.'. But in the Tibetan environment,the glyphIndex('.') also returns 0, so that it simply doesn't add any form of "...", and cuts the text instead. If both the attempts at getting something from the main font fails, we can do a third pass on the "multi" font engine. Fixes: QTBUG-95942 Pick-to: 6.1 6.2 Done-with: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Change-Id: I251de3fe92e19be0462c58c2059ecf7d354bfbb0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix default line thickness for fontsEskil Abrahamsen Blomfeldt2021-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | When we are unable to get the line thickness from a font, we fall back to calculating this based on pixel size and weight. But the font weight scale has changed in Qt 6, causing the calculated font weight to be 10x as thick as it should. This happened e.g. for Titillium Web, but only when using 100% UI scaling, because the GDI engine was unable to get the correct line thickness from the font, whereas the DirectWrite engine succeeded. [ChangeLog][Windows] Fixes an issue where underlines and other decorations would be too thick for some fonts. Pick-to: 6.1 6.2 Fixes: QTBUG-94529 Change-Id: Id2c88f0a145776151be0399ee646f28b3bdf9072 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix bug with NoFontMerging when font does not support scriptEskil Abrahamsen Blomfeldt2021-08-193-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix printing with unhinted fontsEskil Abrahamsen Blomfeldt2021-08-162-1/+19
| | | | | | | | | | | | | | | | | | On high-dpi displays or when you explicitly select an unhinted font, we pick a DirectWrite font engine. This hit an uncovered code path on Windows, because we relied on being able to get the HFONT from the font engine. To fix this, we introduce an alternative code path which gets the HFONT based on the DirectWrite font when this font engine is active. [ChangeLog][Windows] Fixed an issue where the characters in printed text would look too small. Pick-to: 6.1 6.2 Fixes: QTBUG-95720 Change-Id: Ifd609e92512e1f25f0ee2aace35cb5ccedf09030 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix a typo in the comment for TrueType fonts with embedded bitmapsTasuku Suzuki2021-08-111-1/+1
| | | | | Change-Id: I1484c32af03070b8c15c90f21a1ed8a8efde7797 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Undeprecate QFont(QString) since this is still useful for manyAndy Shaw2021-08-112-7/+0
| | | | | | | | Fixes: QTBUG-95441 Pick-to: 6.2 Change-Id: Ib1f78a5a797c7b7d7eb252a7bfa11b5c003ce0d3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QWindowsFontDatabase: port local QSets to QDuplicateTrackerMarc Mutz2021-07-302-9/+8
| | | | | | | | | | Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: I155f5518190c5f8f6d21fbec3fcecd6bcc7ff852 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTextEngine: Style fixRobert Löhning2021-07-261-2/+2
| | | | | Change-Id: I4269dd40eb4ad536f3ce8bde599241bacd898da7 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-264-8/+15
| | | | | | | | | | | Added missing #if-ery and deprecation macros to a QFont constructor that was only documented as deprecated. Fixes: QTBUG-94521 Fixes: QTBUG-95310 Pick-to: 6.2 6.1 Change-Id: I3d0418a3f7dca191a9068cc22627fe4deb7c53c5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTextCharFormat: mark a couple of API mistakes to be fixed in Qt 7Giuseppe D'Angelo2021-07-222-0/+40
| | | | | | | | | | | | | | | The fontFamilies and fontStyleName have an asymmetric getter and setter. The setter takes QStringList, but the getter returns QVariant (?), for no reason whatsoever (the underlying QFont APIs take QStringList, and the docs say that they should return QStringList). It's not entirely obvious that we can fix this without introducing badly-named getters (getX) or somesuch, so for the time being, mark this to be fixed in Qt 7. Change-Id: I49706af00906a2c5d950ada4be3cbc76dbee432c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Prevent array-out-of-bounds accessVolker Hilsheimer2021-07-211-1/+5
| | | | | | | | | | | | | | | Fixes static analyzer warning 12b19393e18b2394a398806f633c6eee, and amends a1a6e3d21b1a4fb799dfd245fed6bb6564178894. In the process, replace the "int& *= double" with correct integer arithmetic that'll produce the intended result without going via double. Done-with: Edward Welbourne <edward.welbourne@qt.io> Pick-to: 6.2 Task-number: QTBUG-8096 Change-Id: Ib2aa8ae46a1bfd4d121e61cf99141c0311502215 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Support pt units for sizes, as documentedVolker Hilsheimer2021-07-201-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Declaration::lengthValue only supported 'px' sizes, but one can transform any 'pt' value into 'px' by multiplying with 1.33. Notes: this ignores display DPI, and instead follows the W3C definition of 'pt' and 'px' as absolute lengths [1]. [1] https://www.w3.org/TR/css3-values/#absolute-lengths 1pt = 1/72th of 1 inch 1px = 1/96th of 1 inch so the conversion is px = pt * (72/96). Add unit test that verifies this using QPushButton's icon-sizes property, also with changed font in preparation of adding support for 'em' and 'ex' units in a follow up commit. Task-number: QTBUG-8096 Pick-to: 6.2 Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> Change-Id: I58782e7ad0e2ff9d89ed695f8a23b1e584cfed64 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz2021-07-141-2/+1
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix QTextFormat::FullWidthSelection for right-to-left text layoutsOliver Eftevaag2021-07-101-4/+11
| | | | | | | | | | | | | | | Using the QTextFormat::FullWidthSelection property to select a line would previously not take into account right-to-left text layouts. With this patch, the whole line should now be drawn correctly for both left-to-right, and right-to-left layouts. Pick-to: 6.2 6.1 5.15 Fixes: QTBUG-91125 Change-Id: Ide7b340cd7b4060e7c00e55e0011a86ffdfb5eb4 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revert "Windows: Add synthesized fonts also when there is a style name"Eskil Abrahamsen Blomfeldt2021-06-302-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a partial revert of commit f385b8827a75688b8a2cbd51e8da8a602d7f9567. This causes issues because we may overwrite genuine styles with synthetic ones. Lets say for instance that we register "Roboto Bold" and then later we register "Roboto Thin". When we register "Roboto Thin" we also register an alternative font which is called "Roboto" (because this is the typographical family name of the font) with bold weight, because we know Windows can synthesize this. This would work fine, except that on Windows we also store the original face name of the font as a user-pointer in the database. This contains the legacy name of the font: "Roboto Thin". This will override the font that is already stored. When we look up "Roboto" + bold weight in the database later, we will find this synthetic font, replace the requested family name with the legacy one "Roboto Thin" and use this instead. The right fix for now is to revert the cause of the regression. If we want to re-fix the original bug, we might be able to reintroduce f385b8827a75688b8a2cbd51e8da8a602d7f9567 and then make sure we always prefer the "real" font when there are conflicts (this would mean marking synthetic fonts in the database). [ChangeLog][Windows] Fixed a regression where different font styles and/or weights would not be available. Fixes: QTBUG-94781 Task-number: QTBUG-91398 Pick-to: 5.15 6.1 6.2 Change-Id: I092022b14ebf1d56685eaa3b8efe55f015659adc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* fc: Clean up current config on shutdownEskil Abrahamsen Blomfeldt2021-06-302-0/+6
| | | | | | | | | | | | | | | | | | | The FontConfig database had a static leak because we never dereferenced the current config. To make address sanitizer output less noisy, we clean this up on shutdown. From FcConfigDestroy docs: "Note that calling this function with the return from FcConfigGetCurrent will cause a new configuration to be created for use as current configuration." So this should be safe even if application execution continues after Qt shutdown, but it could trigger creation of a new current config in that case, if FontConfig calls are made. Fixes: QTBUG-92477 Pick-to: 5.15 6.1 6.2 Change-Id: I596055a84edc1a1b06157e2adf6c8627c6802db1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix right-to-left text with DirectWrite engine + QPainterPathEskil Abrahamsen Blomfeldt2021-06-181-1/+2
| | | | | | | | | | | | | | | | | When QPainterPath was used for RTL text, either directly or because the target text size exceeds 64 pixels, we would pass true for "isRightToLeft" to DirectWrite, causing it to do adaptation internally for this. But the RTL layout had already been handled by Qt, so we would essentially reverse the layout twice and also move the text to negative X coordinates. Passing false instead fixes this, as it will then just use the positions we pass in blindly. Fixes: QTBUG-94175 Pick-to: 5.15 6.1 6.2 Change-Id: Ie9a47e56e97fc867ede10ab21ac5e3f003ddcacb Reviewed-by: Lars Knoll <lars.knoll@qt.io>