summaryrefslogtreecommitdiffstats
path: root/src/gui/text
Commit message (Collapse)AuthorAgeFilesLines
...
* QFontEngine: Silence bogus gcc warningsAxel Spoerl2024-01-221-16/+16
| | | | | | | | | | | | | gcc warns about using uninitialized variables in QFontEngine::getTrueTypeGlyphIndex. The warning is bogus, because all variables subject to the warning are initialized by passing their pointer to qSafeFromBigEndian(). Initialize them anyway to silence the warnings. Pick-to: 6.7 6.6 6.5 Change-Id: I25e062f25e2b06701af5edca27a9e56b939daa79 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QTextImageHandler: Use QUrl::toLocalFile to convert to local file nameChristian Ehrlicher2024-01-211-6/+8
| | | | | | | | | | | Simply stripping away the first six characters does not work on Windows. Amends 2d87c4d881b74619fef966ffb0d7a00cb4ccea50 Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-120577 Change-Id: If48ba026785cab784f46109e34ac80e39a990b79 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QFont::Tag: optimize toString by not searching for terminating nullVolker Hilsheimer2024-01-191-3/+2
| | | | | | | | | | The compiler knows how large the array is, so pass the size and drop the terminating null. Pick-to: 6.7 Change-Id: I5795c89834b8395f04d1777d737d080f19be2a21 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QTextDocument: Add missing default pixel font size check for html exportViktor Arvidsson2024-01-181-1/+3
| | | | | | | | If the size of the documents default font is specified in pixels all text ranges would get wrapped in a span specifying the font size again. Change-Id: Iae2ea34d79bb6253badd8a0575489d3fb6409eba Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix build with -no-directwriteEskil Abrahamsen Blomfeldt2024-01-181-5/+7
| | | | | | | | | | | | | QWindowsFontDatabaseBase::invalidate() was defined inside an the declaration was not. Since the font file loader is only protected by QT_CONFIG(directwrite), we move it out from the previous block and add an #if for the contents instead. Pick-to: 6.7 Change-Id: Iedc02cceb15fe3d25d21b49af1486659a4d6373b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix race condition when destroying Freetype font enginesEskil Abrahamsen Blomfeldt2024-01-171-19/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a QFont is moved to a different thread (B) than where it belongs (A), and the font cache is then purged on thread A, the last remaining reference to the engine will be on thread B. When this QFontEngine is later replaced with one created on B, we end up deleting A's QFontEngine on thread B. This caused QFreetypeFace::release() to be called on the wrong thread and the face would never be removed from the thread-local Freetype cache in A. Hence that cache would contain a dangling pointer to the freetype face which we would later end up fetching. To avoid this, we make sure the thread-local cache itself increases the ref count of the face. That way, the only time it will be deleted on a different thread is when the cache has been destroyed because the thread has shut down. If the last reference (except the cache reference) to a face is cleared on a different thread, we keep it in the cache until later. It will then be in a "deferred delete" mode and will be deleted as soon as possible. This is done either when the thread shuts down, when a lookup causes the "deferred delete" face to be returned, or when release() is called on any font on the thread (at which point we will purge all faces that only have the single cache reference.) Pick-to: 6.7 Fixes: QTBUG-118867 Change-Id: Ifa07a9cb6f4cd3e783e12a73d8b283e70d6fb474 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Skip 'off-by-one' adjustment in block length during undo operationSanthosh Kumar2023-12-201-2/+4
| | | | | | | | | | | | | | | | | | | | | | The adjustment of block length with 'off-by-one' affects content length during undo operation. The issue occurs when we perform undo operation for a set of group blocks that have same fragment position. Since their positions are same, group block change (QTextDocumentPrivate::documentChange) with respect to insertion doesn't affect document block length and further adjustment to 'off-by-one' without considering this leads to incorrect document content change information (such as invalid information with regard to characters removed). This patch skips adjustment of group block length during undo operation. Amends 8fbedf2196a292fe2affcf83ddc846b9c852772a Fixes: QTBUG-113865 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I315dcf01ba5b2f4ed6d95e9d6910d82848374aef Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix synthesized bold on WindowsEskil Abrahamsen Blomfeldt2023-12-152-11/+29
| | | | | | | | | | | | | | | | | | | There were a couple of problems with synthesizing boldness on Windows: For the DirectWrite font database, this was not implemented at all, so this change adds support for it. For the default GDI font database, the font engine is correctly created for a font with synthetic bold, but the function that retrieves the contours from the font does not apply the transformation. So when generating the distance fields for Qt Quick, we would get the unemboldened contours. The fix for this is simply to fall back to using DirectWrite for fonts that require any synthetization. This will later become the default anyway. Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-119995 Change-Id: I5b4e3b19d0d71c6599746172da0bee41e8fb3940 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix regression when selecting emojis using VS-16Eskil Abrahamsen Blomfeldt2023-12-132-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This amends 58907dfa812de8ce6c63295589f644bdf4257d15, which tried to make sure we select a color variant of a character when combining it with the VS-16 symbol, the emoji selector (and vice versa with VS-15). This is something which is not well-handled in Qt, and the original work-around assumed that any font supporting the conversion of Unicode characters to color glyphs would include the VS-16 character in its map. This was true for the symptomatic font on macOS, so it solved the problem there. However, if you manually select a color font and then request a color glyph, the font system should just pass it on and accept this. No need for any magic adaptation. Same if you select a non-color font and use VS-15. To avoid regression, we detect this case and disable the behavior introduced in 58907dfa812de8ce6c63295589f644bdf4257d15 when the existing font selection is already meeting the criteria. This is admittedly very hacky, and the plan is to do a larger refactor where sequences of emojis are separated out ahead of time so that the font selection can pick from a curated emoji font list for these. But to fix the immediate regression, this will basically just return to previous behavior for some cases which are currently prone to break, so despite the added layer of conditions, it does improve the situation temporarily. Pick-to: 6.5 6.6 6.7 Task-number: QTBUG-111801 Fixes: QTBUG-118642 Change-Id: I1a3ca711426a042b22003b887883646132335a9f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFont::Tag: use new comparison helper macrosVolker Hilsheimer2023-12-082-9/+9
| | | | | | Task-number: QTBUG-104111 Change-Id: Id57b075d00e657c2606b6c1a8f1215ed0d067cbd Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Long live QSpan as public API!Marc Mutz2023-12-071-1/+1
| | | | | | | | | | | Provide qspan_p.h as backward-compatibility header. [ChangeLog][QtCore][QSpan] New Qt equivalent of std::span. Fixes: QTBUG-115022 Change-Id: I1cc27dc0aa1f7406f0a41d7a75f176cd7f858feb Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix setting variable axes on FreetypeEskil Abrahamsen Blomfeldt2023-12-071-2/+5
| | | | | | | | | | | | Amends 7bc6f4ae8edc5758af567d8326cb798d423c3982. Some refactoring caused a bug in the conversion from floating point to the 16.16 fixed point values expected in Freetype. We now need to do this conversion when passing the value to Freetype. Task-number: QTBUG-117839 Change-Id: Iebec81adc26b27adf0661422a3f0534e6766d683 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Support arbitrary variable axis valuesEskil Abrahamsen Blomfeldt2023-12-0417-64/+427
| | | | | | | | | | | | | | | | | | | | | | | | This adds API to set arbitrary values for axes in variable fonts to QFont. It also implements support for the API in CoreText, FreeType (on all platforms) and DirectWrite. Note that in order for the mechanism to work with application fonts on DirectWrite, we need to keep the loader for the fonts around for the life time of the font (otherwise they cannot be reloaded with different parameters). The way this was handled before (just re-creating and throwing away the loader every time) was not ideal anyway, and this finally gives us a good reason to fix it. Fixes: QTBUG-119421 Fixes: QTBUG-117835 Fixes: QTBUG-117838 Fixes: QTBUG-117839 Change-Id: I3d1fe95fba1f9df52f34aa42e1ac5fa47dbe6d1a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add missing detach when clearing font featuresEskil Abrahamsen Blomfeldt2023-11-281-0/+4
| | | | | | | | Same as when setting the features, we need to detach (but keep the engine data) when clearing them. Change-Id: I3adcadfb24c4abfff9c9e1c4f42ed4af919c71f0 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* doc: Remove outdated comment about DirectWriteEskil Abrahamsen Blomfeldt2023-11-221-6/+0
| | | | | | | | | Qt 6 does not support any Windows versions without DirectWrite and no special configuration flag is needed to build it anymore. Pick-to: 6.2 6.5 6.6 Change-Id: I6553c4d1c70e5616f8cb3ec8fe6343c600a74462 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix cache cost on DirectWrite font enginesEskil Abrahamsen Blomfeldt2023-11-221-1/+1
| | | | | | | | | | | | | | | | | In Qt 6, we deferred getting the ascent/descent of the font until requested. This was used to calculate the cache cost of the font engine, so as an unintended result, the DirectWrite engines were seen as extremely cheap in the font cache, and we would accumulate thousands of them before triggering a flush. The cache_cost is just a heuristic and does not need to be accurate. For most engines, we should just flush when the number of cached fonts exceed 256, so we use the basic em square of a lowercase letter as the cost here instead. Pick-to: 6.5 6.6 Change-Id: I73a65cab38adfd9ef56e436f311a7d1a2d7fbf41 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix memory leak when resolving named instances in fontsEskil Abrahamsen Blomfeldt2023-11-131-0/+4
| | | | | | | | We need to free the memory allocated when getting the info about the variable font. Change-Id: I25c5f070a6d02468c904428ea2ae71efce1e847c Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Revert "QTextDocumentPrivate::plainText: simplify code"Mårten Nordheim2023-11-091-4/+8
| | | | | | | | | | This reverts commit a83a818791bc88725e07ea41b7c5fa50828e6b24. Reason for revert: It's causing asserts, solution to fix is unclear Change-Id: I33ef760a9402c096d3d7487e777c3ccdbb626d39 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Modify the MDI manual test to allow multiple views of same documentShawn Rutledge2023-11-021-0/+5
| | | | | | | | | | | | | | - editing same document in different views is possible? yes - resizing one QTextEdit calls QTextDocument::setTextWidth(), which affects the width in the other view too. You can resize either one, but you can't have two views with different layouts, of course. Added a categorized log message in QTextDocument::setTextWidth() for a sanity check. Task-nunber: QTBUG-35688 Change-Id: I59c4d10143fda3a66b946237832274d67f9d9d45 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* qtextengine: use const methods moreAnton Kudryavtsev2023-10-251-2/+2
| | | | | | | to avoid implicit detach Change-Id: I2fd36fef138eee23c12d413dfec3232ad1fa01df Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qtextengine: replace qlist with qvlaAnton Kudryavtsev2023-10-252-11/+11
| | | | | | | CoW is not required here Change-Id: Ia0d55dd1e82a225e089ca50f0d3c72bfb52d44f4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Tidy up qtextlayoutAnton Kudryavtsev2023-10-251-7/+3
| | | | | | | | | - remove unused variable - port index-based loop to range-based for - use const method more to avoid implicit detach Change-Id: I223f6c221d0c6277e94efd2e7b7be0f8d8456c60 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Adapt QRawFont to use QFont::TagVolker Hilsheimer2023-10-202-8/+23
| | | | | | | | | | | | Add an overload for fontTable (we can't deprecate the const char * overload as it will be used for string literals, even if the tag- overload would work), and use the tag type in the test instead of QByteArray. Task-number: QTBUG-117046 Change-Id: I104f11a25e9c453a5d1081b6cf320bdc186b7e80 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove obsolete font tag helpers and \preliminary tag from documentationVolker Hilsheimer2023-10-202-55/+6
| | | | | | Fixes: QTBUG-117046 Change-Id: I7e68298ba1c52bea9bdc2fca0c1f082df76d952e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Replace MAKE_TAG macro with QFont::TagVolker Hilsheimer2023-10-2011-47/+40
| | | | | | Task-number: QTBUG-117046 Change-Id: I26e0af634fed87199bb49d57e3aa3f4e3fea0e39 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Use QFont::Tag in the Windows font database implementationVolker Hilsheimer2023-10-202-22/+16
| | | | | | | | | | | | | | | | Replace the local MAKE_TAG macro definition with QFont::Tag's support conversions to and from big endian byte ordering. Also replace the incorrect usage of the big-endian-producing MAKE_TAG macro in the DirectWrite implementation. The IDWriteFontFace documentation suggests to use the DWRITE_MAKE_OPENTYPE_TAG macro for producting the tag, which is equivalent to the LittleEndian implementation of QFont::Tag::value. Task-number: QTBUG-117046 Change-Id: I1e522c1c6006b8bcf66110bd74a36a42ed28f7e4 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFont: add a tag type for features and other advanced propertiesVolker Hilsheimer2023-10-205-93/+264
| | | | | | | | | | | | | | | | | | | | Instead of overloads and generic string literals with runtime checks, use a dedicated Tag type for specifying the font feature. The Tag type can only be instantiated with a string literal of exactly 4 characters (plus the terminating null)l; longer or shorter literals result in a compile time error. Constructing a Tag from any other string type is possible through the named fromString constructor, in which case we can only check the length and warn at runtime. The type's API is almost completely constexpr so that we can use it to calculate e.g. enum values. Task-number: QTBUG-117046 Change-Id: I31038c7c6fd2b843a105b032f021e506b0b60822 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* qtextformat: port while loops to range forAnton Kudryavtsev2023-10-131-13/+5
| | | | | | | to improve readability Change-Id: I11b44154d8db35b93a887bb4797af9a985749f24 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Include what you need: <QPointer>Marc Mutz2023-10-122-0/+3
| | | | | | | | | | | | | | | | | | | | | | | All these TUs relied on transitive includes of qpointer.h, maybe to a large extent via qevent.h, though, given that qevent.h is more or less the only public QtBase header that includes qpointer.h, something else seems to be at play here. Said qevent.h actually needs QPointer in-name-only, so a forward declaration would suffice. Prepare for qevent.h dropping the include. The algorithm I used was: If the TU mentions 'passiveGrabbers', the name of the QEvent function that returns QPointers, and the TU doesn't have qpointer.h included explicitly, include it. That may produce False Positives, but better safe than sorry. Otherwise, in src/, add an include to all source and header files which mention QPointer. Exception: if foo.h of a foo.cpp already includes it, don't include again. Task-number: QTBUG-117670 Change-Id: I3321cccdb41ce0ba6d8a709cea92427aba398254 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QTextDocumentPrivate::plainText: simplify codeAnton Kudryavtsev2023-10-121-8/+4
| | | | | | | | | Use QSV more to avoid manual memcpy Also port loop to range-based for Change-Id: I06f4b424853a4b3ee245c66ccc650d87740e2cb8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Qt::mightBeRichText: port to QAnyStringViewAnton Kudryavtsev2023-10-092-12/+31
| | | | | | | | [ChangeLog][QtGui] Ported Qt::mightBeRichText() to QAnyStringView (was: QString). Change-Id: Ib5633ed45cba5f4f1211438397624574f7431908 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qtextdocument::insertText: port to QSVAnton Kudryavtsev2023-10-053-3/+5
| | | | | | | | and add QChar overload to reduce allocations Also port tests from char* literals to char16_t literals Change-Id: I99381a2da08d9d35e6135c48bd92bd8d72533065 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qtextdocument: replace fromLatin1 with L1 literalAnton Kudryavtsev2023-10-051-4/+8
| | | | | | | to reduce allocations Change-Id: Ie6f734269c9e880ff208629a625c88f4841e9533 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qtextdocument: use qsizetype moreAnton Kudryavtsev2023-10-051-7/+7
| | | | | | | | | in Qt::mightBeRichText, Qt::convertFromPlainText and emitFrameStyle to support large strings Pick-to: 6.6 6.5 6.2 Change-Id: I7187bd81d3cbcc11ba898e015bd2a8ec64e3bf34 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* coretext: Support variable application fontsEskil Abrahamsen Blomfeldt2023-10-032-6/+19
| | | | | | | | | | | | | | | | | | | | | | | Named instances of variable application fonts are exposed automatically through CTFontManagerCreateFontDescriptorsFromData() (and also for the URL equivalent). The main change here is just to call this instead of the overload which only returns the first font. Note that this also updates the test: This is because the conversion from CoreText normalized weight values to TTF values is not 100%. In the CoreText code, we map Heavy (0.56) to ExtraBold, but ExtraBold gets converted to 0.6, which is closer to the CoreText value for Black (0.62). To avoid hitting this inconsistency, the QtExtraBold has been changed to Black weight instead, which resolves to the same on all platforms. Task-number: QTBUG-108624 Change-Id: Ied6d42e9e3e1ba8b7102936c5be3d285b3d9e07f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Support variable applications fonts with DirectWriteEskil Abrahamsen Blomfeldt2023-10-0214-112/+204
| | | | | | | | | | | | | | | | For GDI, there doesn't seem to be any way to do this, so it depends on selecting the DirectWrite font database explicitly. This moves the supportsVariableApplicationFonts() check into the QPlatformFontDatabase instead of the font engine, since that's where it belongs. [ChangeLog][Fonts] Added support for selecting named instances in variable application fonts when using the DirectWrite backend. Task-number: QTBUG-108624 Change-Id: I51e0fedd7a9616088a06453a1d17f48bd18fa5a7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* DirectWrite: Fetch correct style name in font infoEskil Abrahamsen Blomfeldt2023-10-022-1/+22
| | | | | | | | | When getting the font info for a resolved QFont on DirectWrite, the style name would not be set, so there would be no way to check the style name of the actual resolved font. Change-Id: I5ff27e95619a330b7d2a0252222fad8629837418 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qtexthtmlparser: use tokenize instead of splitAnton Kudryavtsev2023-09-251-3/+2
| | | | | | | | to avoid needless tmp list Change-Id: I5f6bc9c3edd17c04e5293feb0aad86cd5ed49695 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Support loading variable fonts as application fonts in FreetypeEskil Abrahamsen Blomfeldt2023-09-207-20/+242
| | | | | | | | | | | | | | | | When loading the fonts, we go through all the named instances and register these as subfamilies. In addition to exposing these variants by style name, we also register them with the according weights, italic style and stretch. This adds a field to FontFile to allow piping the instance index through to when we instantiate the face. [ChangeLog][Fonts] Added support for selecting named instances in variable application fonts when using the Freetype backend. Task-number: QTBUG-108624 Change-Id: I57ef6b4802756dd408c3aae1f8a6c792a89bee6a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qdistancefiled: use rvalue overloads moreAnton Kudryavtsev2023-09-191-1/+1
| | | | | Change-Id: I8c665e6814967f3a0463cbad8686ca28d55ab124 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QWindowsFontDatabase: drop an usage of an atomic typeGiuseppe D'Angelo2023-09-152-5/+5
| | | | | | | | | | | UniqueFontData has an atomic refcount internally. I guess this was deemed necessary because font engines living in different threads may call refUniqueFont / derefUniqueFont and the refcount has to be thread safe. Those functions now are mutex protected (as they access the same map), so we don't also need atomicity for the refcounter. Change-Id: Ic223a12f4a61b7dcc567b3a5dcbe367eaa916004 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix crash when reading corrupt font dataEskil Abrahamsen Blomfeldt2023-09-151-16/+51
| | | | | | | | | | | | | | | | When loading the font data, we had some unprotected reads. To harden this, we check everything against the length of the font data before reading. [ChangeLog][QtGui][Windows] Fixed a possible crash that could happen when loading corrupted font data. Fixes: QTBUG-116773 Pick-to: 5.15 6.2 6.5 6.6 6.6.0 Change-Id: I156df3b8833c9ed785fcc690821a7a74d9a51126 Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QWindowsFontDatabase: fix a data raceGiuseppe D'Angelo2023-09-142-1/+10
| | | | | | | | | | | | | | | QRawFont::loadFromData can be called from any thread. It calls into QPlatformFontDatabase::fontEngine. The code path may end up creating a UniqueFontData and storing it a QWindowsFontDatabase member (a QMap). Two threads calling loadFromData (on different QRawFont objects) will therefore race on the mutation of the map. Add the missing mutex protection. Change-Id: Ib38c2b3539679c820d997a6548e4b397cbc2bb73 Pick-to: 6.2 6.5 6.6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QWindowsFontDatabase: avoid multiple map lookupsGiuseppe D'Angelo2023-09-141-6/+8
| | | | | | | | | | | | Use the iterator-based API, and avoid a quadruple (!) lookup into a QMap. I'm aggressively cherry-picking to avoid merge clashes with an upcoming fix. Pick-to: 6.2 6.5 6.6 Change-Id: I05968f4aec9e42f84f909a1103e43ba323a9544f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextFormat: Allow merging unset propertiesViktor Arvidsson2023-09-141-5/+7
| | | | | | | | | | | | | | | | | | | | | | There was no way to merge removal of properties which is required in case you want to unset some property on the current selected text in a text document. For example in case your text has font size set in pixels and you want to change it to point size, that would be impossible before this change. With this change you can set the font point size to what you want and then set font pixel size to QVariant(). This is maybe not the most obvious way to do it but any other way I could think of would require new api and quite some code duplication. [ChangeLog][QtGui][Text] QTextFormat now allows setting properties to an invalid QVariant to allow clearing properties via a merge. This changes behavior slightly where code iterating over a QTextFormats properties would never encounter invalid variants, which is now possible if setProperty with an invalid variant was used instead of using the clearProperty function to remove properties. Change-Id: Ie8290088d457bf19d9c4785cfe91ae6a1de572c4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* qtextlist::itemText: reduce allocationsAnton Kudryavtsev2023-09-131-8/+6
| | | | | | | Don't create tmp QBA, just append to QString directly Change-Id: Ib7c469ef7b9b459fbc2df662adbe613c8d74d88a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Mark feature API in QFont as preliminaryEskil Abrahamsen Blomfeldt2023-09-132-0/+12
| | | | | | | | | | | | | | | | | | | | | | | Using ints for the tags is not ideal. There is no type safe way to do conversions from strings, and how the int corresponds to the four-byte tag is not clear from the API, so user code can end up being less readable due to this. Especially since this type of tag is a data type used several places in fonts, and we will need them again for implementing support for variable axes, it's worth giving this an extra round of polish. Since it was not addressed in a timely manner and we don't want this to delay the upcoming release, we mark the API as preliminary for now, to give ourselves the option of changing it to something. Pick-to: 6.6 Fixes: QTBUG-116929 Change-Id: I498478785dcd5ece954151f01f1a017828d6b8b8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTextDocument::toPlainText: avoid unconditional detachAnton Kudryavtsev2023-09-121-2/+10
| | | | | | | Let's find replaceable chars and then do detach Change-Id: I4a4360d73a97af2388f4f2f284949ffcfbc48836 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Qt::mightBeRichText: use QVLA moreAnton Kudryavtsev2023-09-121-4/+4
| | | | | | | to reduce allocations Change-Id: I59e131bcdd626f740a73e621b926f4c7dad4738a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTextHtmlParser::lookupElement: port to QSVAnton Kudryavtsev2023-09-102-5/+5
| | | | | Change-Id: I7d45d1a8985b57457eaa8226332929b6a1817108 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>