summaryrefslogtreecommitdiffstats
path: root/src/gui/text
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Avoid overflow in text layoutEirik Aavitsland2021-06-171-1/+2
| | | | | | | | | | Fixes oss-fuzz issue 34597. Fixes: QTBUG-94197 Pick-to: 6.2 6.1 5.15 Change-Id: Icabcd5a87b809b6a5ae0f1a696ec3b5dd906886b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix rendering of text checkboxes when text is selectedShawn Rutledge2021-06-161-4/+8
| | | | | | | Fixes: QTBUG-94532 Pick-to: 5.15 6.1 6.2 Change-Id: I4343558dcec6149dcdcc0f7ca32c49fdc67452af Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextDocumentFragment: fix ifdef rangeIvan Solovev2021-06-151-1/+2
| | | | | | | | Move QT_END_NAMESPACE macro out of the #ifdef definition Pick-to: 6.2 6.1 5.15 Change-Id: I26b4e263b5ae0acebf035dbfe8c7e287cd740190 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Fix unaligned specialData formatsAllan Sandfeld Jensen2021-06-111-4/+9
| | | | | | | | | Handle the case were a format was applied that does not align with the fragments. Pick-to: 6.2 6.1 5.15 Change-Id: I27593a50c587a5ec0290ff9d0a7a9767a3981cac Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QTextHtmlParser::parseEntity: Remove const that prevents automatic moveAlbert Astals Cid2021-06-041-1/+1
| | | | | | | Reported in https://testresults.qt.io/codechecker/daily_diffs/qtbase/dev/qtbase-dev-20210604-57bb7cac64 Change-Id: I3365879d18ceb0977c5fc24e2c11c9339afaafd6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix support for using system supplied md4c libraryNiclas Rosenvik2021-06-031-0/+4
| | | | | | | | | | | | | | | | | | | Add FindWrapSystemMd4c.cmake so that the old md4c target can be used as well as the new one and set WrapSystemMd4c_FOUND. Link to the imported target WrapSystemMd4c::WrapSystemMd4c if the system library is used. Add qt_find_package line to find the package in configure.cmake. Fix the condition for enabling system-textmarkdownreader, it includes testing for textmarkdownreader because even if the code would compile correctly without it, it looks strange when the output says "textmarkdownreader no" and under "using system libmd4c yes" even if libmd4c is not used. Use system include when system-markdownreader is enabled. Add library mapping for libmd4c. Change-Id: Id5d5b13d6691a8c1cdf627238887977c847c1e67 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Extract the entity parsing code to a static functionAlbert Astals Cid2021-06-032-23/+34
| | | | | | | This way we can use it from qtdeclarative to parse styled text Change-Id: Ic888a75a9700558e97b3e743d6d42fda121ddcba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* minor: Clean up areMetricsTooLarge() conditionsEskil Abrahamsen Blomfeldt2021-05-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This amends e2bdff3555f8c2a275c7bbcf964d939a5f489100. The linearAdvance property has some history. First it was a 16 bit value (allowing for 10.6 fixed point numbers). Then it was turned into 22 bits to fit the 16 bits of Freetype integer parts into it (16.6). Then back to 10.6. Then in b7e436738756b1d5d7a45201b7a7204d7fe128a1 it was turned back into 16.6 again. But this was accidentally reverted as part of a bad conflict resolution in afb326f07109da0035112e6f56e683e37b8a5d72. Since there was no check for it, we would sometimes overflow the linearAdvance, but only in the rare cases where the width and height did not also overflow. Specifically this is the case for whitespace, which always has a width of 0 regardless of the advance. This change just moves the linearAdvance condition in together with the other checks to avoid fragmentation, and also adds this fun story to the commit log. Pick-to: 6.1 5.15 Change-Id: Iaac09942f4c50d1aced4a160b6eabb11eb8e6373 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-263-7/+7
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTextHtmlParserNode: Avoid invalid enum valuesRobert Löhning2021-05-211-1/+39
| | | | | | | | | | Fixes oss-fuzz issue 31027 Fixes: QTBUG-93072 Change-Id: I8c7fa31bae79221fbeaf84db7c839fc61c93d48e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix memory leak when using small caps fontEskil Abrahamsen Blomfeldt2021-05-201-4/+8
| | | | | | | | | | | | | | | The small caps version of a font is kept as a QFontPrivate* which is manually reference counted, but we neglected to actually delete it when the reference count went to 0. [ChangeLog][Fonts] Fixed a memory leak when initializing a small caps font. Fixes: QTBUG-93068 Pick-to: 6.1 5.15 Change-Id: Icc7fb7a59bf523da84d2e6fa026940a7d1230525 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Robert Löhning <robert.loehning@qt.io>
* Windows: Add synthesized fonts also when there is a style nameEskil Abrahamsen Blomfeldt2021-05-113-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Windows can synthesize certain font traits for us, we used to register these in the font database so that we could match against them. But after change 469b13916983aff4625657eecbb7d2399cac901d, this in principle no longer happens, because we opt out whenever there is a style name (which there usually is, this could be e.g. "Regular" for a normal font). The result of this was that if we looked for a bold variant of a font, we would not find it. In cases where a multi-engine was used, the request for bold would still survive in the multi engine's fontDef, so we would still pick it up later and apply the synthesis. But when NoFontMerging was set, then we would override the weight in the fontDef with the one from the font database. Since the comment documents that the additional registrations are there to make sure all the variants that Windows can synthesize are available for matching, it does not make sense to skip them just because the font has a style name. So this is a partial revert of 469b13916983aff4625657eecbb7d2399cac901d. Note: This exposed an error in QFontDatabase::isSmoothlyScalable(). The style parameter here is not the "styleName" (as in sub-family), but actually predates that API. Instead it is the "style" as returned by QFontDatabase::styles(), which may be the style name, but it can also be the generated description of the style and weight. In the latter case, we would return false for fonts that are actually smoothly scalable, which is incorrect. This caused a failure in tst_QFontMetrics::metrics(). To remedy this, we add an additional condition, and also match the style if it matches the generated descripion of the style key. [ChangeLog][Windows] Fixed an issue where bold/italic would not be synthesized for fonts if QFont::NoFontMerging was set. Pick-to: 5.15 6.1 Fixes: QTBUG-91398 Change-Id: Id2166a47ae2d386536cf6e5e27ff09165ae8a23a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Allow background inheritance between non-body block elementsAllan Sandfeld Jensen2021-05-081-1/+4
| | | | | | | | | | | Most nested block elements are merged together, so while we shouldn't do real inheritance we need to do it when block elements are combined. Pick-to: 6.1 Fixes: QTBUG-91236 Change-Id: I9e37b15f705db92c79a620d0d772f25d0ee72b8d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Support CSS text-decoration-color in underlines, overlines, strikethroughShawn Rutledge2021-05-075-4/+13
| | | | | | | | | | | | Also add a feature to the textedit example to set this value. [ChangeLog][QtGui][CSS] The CSS text-decoration-color attribute is now supported in rich text spans with underlines, overlines and strikethrough. Fixes: QTBUG-82114 Task-number: QTBUG-39617 Change-Id: I0065cb5431833da55b0f503ce7ff2b83b74b718a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Apply specialData font capitalization to non-rawFont textAllan Sandfeld Jensen2021-05-061-2/+12
| | | | | | | | | | | We were not using the capitalization details from specialData in the regular path of QTextEngine::itemize() causing it to be ignored. Pick-to: 6.1 5.15 Fixes: QTBUG-90840 Change-Id: I7bb71fad4009f6d0685905a946c36ac1d24d8d3c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* macOS: Fix synthesized boldEskil Abrahamsen Blomfeldt2021-05-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | When a user requested bold and there was no available font for this (which is quite common with CJK fonts and in fact is the case for the official Japanese font on the system), we should synthesize the boldness. This was done by checking if the requested font weight boldness matched the one in the font's traits, and if not, we flag the font boldness to be synthesized. But when initializing the font, we would first override the requested weight with the selected font's weight, *before* performing the check above. So even if there was a mismatch, we would not catch this and as a result, e.g. the system Japanese font would never be bold. [ChangeLog][macOS] Fixed an issue where boldness would not be correctly synthesized for families with no bold variant. Fixes: QTBUG-85634 Pick-to: 5.15 6.1 Change-Id: I36da59d7689455e29cca283cb0724a0841095918 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows: Work-around misreporting of Script and RomanEskil Abrahamsen Blomfeldt2021-05-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | Two legacy bitmap fonts are misreported as TMPF_VECTOR on Windows: Roman and Script. This causes them to be marked as scalable, and the automatic fallback to NativeRendering in Qt Quick does not kick in - causing the text elements to look empty instead. To work around this, we exploit the peculiarity that the type of these two fonts is reported as "0" in the enumeration, which is not a valid value. No other fonts on the system is reported as type 0, so we simply detect this error case and mark the fonts as non-scalable, which is the safer choice. [ChangeLog][Windows] Fixed text in "Roman" and "Script" bitmap fonts not showing in Qt Quick applications. Pick-to: 6.1 5.15 Fixes: QTBUG-85826 Change-Id: Id889f0dedb1d529e6dd64c6da9e17e303f4a9d04 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove Qt6 switches from QtGuiAllan Sandfeld Jensen2021-05-054-39/+0
| | | | | | | Removing now dead code Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix rare integer overflow in text shapingPaul Olav Tvete2021-05-051-1/+2
| | | | | | | | | | With extreme painter scaling, linearAdvance may be too large to fit in an unsigned short. Fixes: QTBUG-91758 Pick-to: 6.1 5.15 Change-Id: I7bbe6e77ec9bcef4aa5259da1d3000ed1a8eb27a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Write out the HTML correctly for nested listsAndy Shaw2021-05-052-3/+27
| | | | | | | | | | | | | | When we are having nested lists then we need to ensure that the HTML is outputted correctly so that the closing list and item tags are placed in the right order. [ChangeLog][QtGui][QTextDocument] The output of toHtml() now handles nested lists correctly. Fixes: QTBUG-88374 Pick-to: 6.1 5.15 Change-Id: I88afba0f897aeef78d4835a3124097fe6fd4d55e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Export text-decorationAllan Sandfeld Jensen2021-05-051-7/+22
| | | | | | | | | It used to be ignored because we couldn't disable it, but that works fine now. So re-enable it. Fixes: QTBUG-91171 Change-Id: I4cf966211bb200b73326e90fc7e4c4d3d4090511 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* doc: Warn about kerning in QRawFont::advancesForGlyphIndexes()Eskil Abrahamsen Blomfeldt2021-04-271-2/+12
| | | | | | | | | | | The fact that KernedAdvances does not work correctly on a majority of fonts is confusing. So we warn users that this is the case and point them to the correct function to use instead. Task-number: QTBUG-92930 Change-Id: I70f4b09ea1050fceabbff25a9c91008d1754f772 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Draw the cursor considering the descent is 0Tang Haixiang2021-04-201-3/+3
| | | | | | | | | | | | | | When the descent of the item is 0, ascent is the height of the item, base(base = si.ascent)> sl.base. At this time, sl.descent is not considered. The calculated y value may be <0. Fixes: QTBUG-86823 Fixes: QTBUG-92468 Pick-to: 5.15 6.0 6.1 Change-Id: I9cf088dec9162595e52ff72aa90ec3153a30fb72 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Assert that engine isn't nullptr before dereferencingVolker Hilsheimer2021-04-191-0/+1
| | | | | | | | | | | The engine pointer is guaranteed to be initialized in line 1838, so we can assert that the correct value is passed into the function to fix static analyzer warning 1d9b8ce922ee0891fb0d477dc17fdb8d. Change-Id: I773bbaa579afec0d7a79d4393ee66fd26ba9629b Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Assert that engine isn't nullptr before dereferencingVolker Hilsheimer2021-04-191-6/+8
| | | | | | | | | | | | | | | | | | | | Various checks for "engine" in the previous code suggested that engine might be nullptr by the time we want to populate the out-parameters. This must not be the case, and QFontDatabase::load asserts already that a valid engine is loaded and returned. Fix static analyzer warning 7f68daa282c72e8cc172c681eb02f559 by asserting it here as well. As a drive-by, change the tested out-parameter to the last one in the list of optional parameters. Pick-to: 6.1 Change-Id: I3d9ff0f5f7c4740014301c073480d14fef54e2fb Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix handling of surrogates in QBidiAlgorithmEdward Welbourne2021-04-161-2/+2
| | | | | | | | | | | | Prior code was naively assuming the character after a high surrogate would necessarily be a low surrogate, which is buggy. Fixes oss-fuzz issue 29718. Pick-to: 6.0 6.1 5.15 Change-Id: I10f023c4b5024a0d76fea0a3672001063591ec6d Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add new enum value VisualTabCharacter into QCharZhang Hao2021-04-151-1/+1
| | | | | | | | | | | | | | With this enumeration value, users can get the width of the current font TAB character more conveniently In addition, added some documentation about where users may use this enumeration. Fixes: QTBUG-92205 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Change-Id: I9794b7553e9299e351f9182de02866d07a1393fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>