summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add API to provide user-defined fallback fontsEskil Abrahamsen Blomfeldt2024-04-181-1/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When depending on Qt's font merging for providing glyphs for certain languages, there are currently some drawbacks. For one, you will typically get a system font which might not fit together with the main font of the application. In addition, you might get some glyphs from one font and other from another (typically for Chinese where the character sets are so large that fonts will often only implement parts). And finally, you may get the wrong glyphs for writing systems with regional differences, if your application is e.g. written in Japanese and then run on a Chinese system, you might get Chinese versions of characters which are shared between the languages. Without language-based font matching in Qt, there's no silver bullet for fixing this. This patch introduces API which makes it possible for users to provide the solution themselves, either by selecting application-provided fonts as fallbacks for certain scripts or by hardcoding system fonts for a specific language. [ChangeLog][Fonts] Added API to override default fallback font families for specific scripts. Task-number: QTBUG-121131 Change-Id: I23ee17b7dfe1c1e481c87cc67a05a0522841b598 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* gui/text: use const methods moreAnton Kudryavtsev2023-09-091-4/+4
| | | | | | | to avoid implicit detach Change-Id: I2c6edfcf8b9dc6e9bb0801b7bd58f34a8033a955 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Delete links to removed examplesAndreas Eliasson2023-08-181-1/+1
| | | | | | | | | | The examples have been removed as part of the examples revamp project. This patch resolves a number of qdoc warnings. Pick-to: 6.6 6.5 Change-Id: Ie3d2f5637136c631d7e9f7a8ffd93baea52f77d8 Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add tracepointgen tool and convert qtgui to use itAntti Määttä2023-01-131-2/+7
| | | | | | | | | | | | | | | | | | | | | Allows automatically generating tracepoint files by scanning source files for instrumentation macros. This makes it easier to add tracepoint support to modules and also ensures that the tracepoint files do not get out of sync with the functions they are tracing. Q_TRACE_INSTRUMENT generates entry/exit tracespoints for a function it is set. Q_TRACE_PARAM_REPLACE is used to change a function parameter for these functions to convert it to supported parameter type. Q_TRACE_POINT can be used to create a standalone tracepoint. Q_TRACE_PREFIX can be used to add prefix for generated tracing backend for example to add includes for types used in the trace points.. Task-number: QTBUG-107238 Pick-to: 6.5 Change-Id: Ib395b80838434ceb72683dac0545ca20c4d09455 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add some more logging to QFontDatabaseTor Arne Vestbø2022-08-211-0/+7
| | | | | Change-Id: I5ac289cb7cb0beb842c403683681a739c44b26a1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Don't assume that QtFontFamily::ensurePopulated() will populateTor Arne Vestbø2022-08-191-12/+17
| | | | | | | | | | | | | | | | | | | The WASM platform populates a family asynchronously, so we can't assume that a family will be populated straight after calling ensurePopulated(). By adding a bool return to the function we can teach all the call sites to behave as if the font family does not exist yet if the font was not populated. The WASM platform will then invalidate the font database when the populated font's data comes in asynchronously, and then be ready for another call to ensurePopulated, which this time will succeed to populate the family. Change-Id: I4e0e6211c10e5c1123beebd77aca28ac82ba7186 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
* Fix QFontDatabase::hasFamily() for ambiguous familiesEskil Abrahamsen Blomfeldt2022-08-151-1/+13
| | | | | | | | | | | | | | | | | | | | | | | If a font family has several instances from different foundries, we disambiguate this by adding the foundry name in brackets behind the family. But QFontDatabase::hasFamily() would only check for families().contains(familyName). So if the database contains e.g. Foo [Bar] and Foo [Baz] then a check for hasFamily("Foo") would fail. So we need to actually check for the family name instead. In doing this, we also skip the extra step of building the list and then searching it, but just go directly to the source. This removes the BLACKLISTing of Ubuntu and also introduces a QSKIP on Unix-based platforms without fontconfig, since there is no way to know which default fonts are acceptable on those platforms. Pick-to: 6.4 Fixes: QTBUG-86967 Change-Id: Id8ad80a1671daf1c14fbad8bb8f4c51ee1c59709 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtGui: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I1945741794c25679a9d94c0d68c8642e2c823502 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-24/+25
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFontDatabase: Clear font cache before emitting fontDatabaseChangedTor Arne Vestbø2022-04-231-2/+2
| | | | | | | | | Matches the ordering in QFontDatabasePrivate::invalidate() and ensures that when the fontDatabaseChanged signal is processed by clients the cache is ready to be filled again. Change-Id: I9d09060284c6090ae2748147f6ee75b9f9b173c5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Allow partially populating the font databaseTor Arne Vestbø2022-04-221-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | We were using the count of the registered families as the way to determine if the font database had been populated yet. As a result we needed to invalidate the font database every time an application font was added to an empty database, as once the application font was added, the font database was no longer empty, and we would end up failing to populate any of the system/platform fonts. We now have a dedicated flag for tracking whether the font database has been populated, and we track whether an application font has been populated by looking at its properties list, avoiding a second round of populating when the full initialization happens. This also opens up the possibility of the platform font database populating (lazily or fully) fonts up front, for example as part of resolving theme fonts. The Windows font database had to be taught to invalidate itself at the right moment, instead of assuming doing so during populate was okey. Change-Id: I80c893df755d8d35fb8a84dd7a83c6756a8f24a2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-8/+8
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QFontDatabase: Simplify and standardize emit of fontDatabaseChanged signalTor Arne Vestbø2022-04-071-2/+2
| | | | | Change-Id: Iabb637b52de225bf8823b1c3089e50db932c0b85 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Add internal documentation for QFontDatabasePrivateTor Arne Vestbø2022-04-071-0/+50
| | | | | Change-Id: I40e770552110fa271c912d18197399a9c5071c56 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Track empty slots in application font list via file nameTor Arne Vestbø2022-04-071-4/+3
| | | | | | | | This allows us to use the properties of the application font as a way to distinguish whether the font has been populated or not. Change-Id: Iccce32b23c1b987f2f75fef955227bddc2495fa3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Move registration of platform application fonts into call sitesTor Arne Vestbø2022-04-071-11/+9
| | | | | | | | Makes it more transparent what's going on, rather than the opaquely named static helper function. Change-Id: I9a5bd348007e9ed11214f1e55c4b39d4734328dc Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Make match/bestFoundry/load(Single)Engine part of ↵Tor Arne Vestbø2022-04-071-15/+8
| | | | | | | | | QFontDatabasePrivate Makes it clearer where and how they are used, and to set breakpoints on them. Change-Id: Id2aaeb51ff80676ad3316d29e23661b2cad79478 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Flush font cache when we load new application fontsEskil Abrahamsen Blomfeldt2022-04-011-2/+8
| | | | | | | | | | | | | | If new application fonts are loaded during the lifetime of the application, it's possible that we have already cached fallbacks for requests for the newly loaded font families. To make sure we redo requests for the updated database, we have to flush the cache, just like we do when removing application fonts. Task-number: QTBUG-100697 Task-number: QDS-1142 Change-Id: I2a6d2a7459187d69d14ef639e2b710c8d553b86e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFontDatabase: Use more explicit function name for clearing familiesTor Arne Vestbø2022-03-311-2/+12
| | | | | | | | Avoids overloading on ::free() from stdlib.h Change-Id: I71d7fa4012f189cf5640968ed43d530eff79989f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QFontDatabase: Move writing_system_sample() into only callerTor Arne Vestbø2022-03-311-79/+76
| | | | | | Change-Id: I225a24a73c3d0e79db5b1a33513f5582d1abf531 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QFontDatabase: Remove un-needed load() functionTor Arne Vestbø2022-03-311-33/+2
| | | | | | | | | | The function didn't take any of the arguments into account, and was just initializing the font database, which all but one of the call sites were already doing. Change-Id: I83cab0059014dd256ec4b453e15fc2fe4bebcbdf Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QFontDatabase: Centralize initialization in ensureFontDatabase()Tor Arne Vestbø2022-03-311-26/+10
| | | | | | | | | | | | | | | Instead of having multiple code paths call initializeDb(), we use the already existing ensureFontDatabase() to provide the central point of ensuring an initialized font database. A couple of locks for the fontDatabaseMutex was added since the ensureFontDatabase() function documents that as a requirement for calling the function, but these locks were presumably already needed as the original code paths accessed the database in the same way. Change-Id: I5e29a069c4c7f68902dbe0c6c949a168d54f5f0e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QFontDatabase: Replace privateDb Q_GLOBAL_STATIC with instance() accessorTor Arne Vestbø2022-03-311-28/+27
| | | | | | | | | | | | The use of both a global static and a dedicated instance() function made it harder to know how and where the singleton font database was managed. As Q_GLOBAL_STATIC is no longer needed (as of C++11) for ensuring thread safe access we can contain the QFontDatabasePrivate singleton within the instance() accessor. Change-Id: Ia3d83ff2d83d326504243258a44d8ae8352d290d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: Remove unused createDatabase() functionTor Arne Vestbø2022-03-311-3/+0
| | | | | | | | Last uses was removed in 76068d0114157c6b59523f3fb032cd8de64e9a63. Pick-to: 6.2 6.3 Change-Id: I8e1f404d2422e0f11dc28e52ce6dafa77e148126 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Revert "Avoid populating font family aliases if family matched"Tor Arne Vestbø2022-03-291-15/+9
| | | | | | | | | | | This reverts commit 69d525a6fa19934b3e57f503132bb4ab19f6b923. The change introduced behavior changes on Windows, where family aliases are used to build a full set of styles for a family. Change-Id: I64ca1cf5febf0a6277cbe0a0041ccdb76da72196 Pick-to: 6.3 6.2 5.15 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Avoid populating font family aliases if family matchedTor Arne Vestbø2022-03-171-9/+15
| | | | | | | | | | | | | | | | | When trying to match a font request to fonts in the database we might end up with a mismatch due to the style not being available, but the font family itself was. If that's the case there's no point in trying to populate font aliases, so we explicitly propagate this fact back to QFontDatabasePrivate::findFont so that it can choose to not populate family aliases. Fixes: QTBUG-98369 Fixes: QTBUG-99216 Pick-to: 6.3 6.2 5.15 Change-Id: I14470554c73eace836f57cb65e63ada594ccf62e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Add styleName to debug outputNiklas Wenzel2022-03-111-2/+4
| | | | | | | | | This makes it easier to debug the font matching behavior. Task-number: QTBUG-101436 Pick-to: 6.3 Change-Id: Id682384e7d9d669b9e736e00ef22cadfd0b4bfec Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Avoid crash on app startup if the default font family is emptyLars Knoll2022-01-031-3/+6
| | | | | | | | Don't call first() on a potentially empty list of families. Fixes a crash on startup on QNX for me. Change-Id: I551d21dac8cfd104b774d6442bdbe1db35f8b75c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFontDatabase (Windows): Sanitize font requests earlyMårten Nordheim2021-12-061-1/+13
| | | | | | | | | | | | | | | | | | | After the windows font engine was no longer marking everything as scalable we started limiting the font size of requests to the maximum of Courier when it was requested. This was a regression from 5.8 and not in agreement with our documentation. The problem is that we would only make the switch from Courier to Courier New after having already gone through the foundry-lookup and found a closest-available font size for Courier. With this sanitization step in the backend we can make these changes early enough that we haven't yet adjusted e.g. the font size. Pick-to: 6.2 5.15 Fixes: QTBUG-58995 Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: unify relevant documentation piecesAndrei Golubev2021-12-031-9/+3
| | | | | | | | | | | | | | | | addApplicationFont and addApplicationFontFromData basically do the same thing (with one reading the data from a file and another reading it directly from QByteArray) The documentation is not quite identical, so fix that by using \include magic of qdoc As a drive-by, remove outdated \note within addApplicationFont() description Fixes: QTBUG-98752 Pick-to: 5.15 6.2 Change-Id: I29738e7411d241c26a4b2e1dd91d0af867fcc111 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Add const to read only local variablesOliver Eftevaag2021-11-011-2/+2
| | | | | | Pick-to: 6.2 Change-Id: Ideb34a5009277b919a8a3834e53af4ff550dfc6e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | 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>
* 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>
* 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>
* Fix bug with NoFontMerging when font does not support scriptEskil Abrahamsen Blomfeldt2021-08-191-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-261-1/+1
| | | | | | | | | | | 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>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-1/+1
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Windows: Add synthesized fonts also when there is a style nameEskil Abrahamsen Blomfeldt2021-05-111-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix compilation error when LTTng enabledHyungchan Kim2021-03-251-2/+2
| | | | | | | | Updates tracepoint for qtgui and qtopengl fit to current source code. Change-Id: I2e8ecc86a37942425734202a11bbc792e8f27bf3 Reviewed-by: Hyungchan Kim <hyungchan2.kim@lge.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Support family names that end/start with spaceEskil Abrahamsen Blomfeldt2021-03-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | If the family name starts or ends with a space in the actual font data, then this would not be selectable by Qt. This is because we trim the family name before matching it against the contents of the database. Testing on Windows GDI, it actually does trim the spaces on the family names (matching a request for "Chibola" with a font called "Chibola " for instance), but since we read the font data ourselves, we are not doing this. To ensure we never have font names that cannot be matched in the database, we make sure we trim the family names before registering them. [ChangeLog][QtGui][Text] Fixed matching against fonts which has a family name that ends or starts with a space. Task-number: QTBUG-79140 Pick-to: 6.1 Pick-to: 6.0 Pick-to: 5.15 Change-Id: I9cdb50b78a7da2d2697f992ce462033eb1d7ada7 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Gracefully reject requests for absurd font sizesEirik Aavitsland2021-01-211-0/+6
| | | | | | | | | Avoid overflows. Fixes: QTBUG-89899 Pick-to: 6.0 5.15 5.12 Change-Id: Ic1a83c1704fe20be3d032358dc91ee8e751f2281 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove debug outputEskil Abrahamsen Blomfeldt2021-01-201-1/+0
| | | | | | | Accidentally committed in d8602ce58b6ef268be84b9aa0166b0c3fa6a96e8. Change-Id: I553503720eace59a7bd510a7b9b2aba44c2242a1 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* QFont: Prefer setFamilies() over setFamily()Andy Shaw2020-11-201-32/+16
| | | | | | | | | | | | | | | | By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Deprecate QFontDatabase constructorVolker Hilsheimer2020-11-031-26/+25
| | | | | | | | Move private methods into the private class. Fixes: QTBUG-88114 Change-Id: I92fa52980ed5a0675eee310359d8875f614921e6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontDatabase: fix a uint->int implicit conversionGiuseppe D'Angelo2020-10-191-2/+2
| | | | | | | Just use an int, as it'll be converted to that anyhow for insertion. Change-Id: Ie5a9d35a7c10e38cbba49d8915602f9207b8e0ac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* When finding the engine for a fallback font, then clear the familiesAndy Shaw2020-09-051-0/+1
| | | | | | | | | | | If it is a fallback font, then it should just have family set to that font so it does not get interference from what the families were originally set to. Fixes: QTBUG-85560 Change-Id: I6232f3d2ae12052fa3b0b3bc0e7f106e239a585d Pick-to: 5.15 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Doc: Compile qfontdatabase snippetsPaul Wicking2020-08-281-2/+1
| | | | | | | | | | | | * Extend GUI snippets by adding the qfontdatabase project. * Rename the snippet file and replace main() with wrapper(). * Minor adjustments of the snippet itself. * Update documentation that includes the snippet. Done-with: Nico Vertriest <nico.vertriest@qt.io> Task-number: QTBUG-81486 Change-Id: Id23aff01a4c919c5264f7059971cb63398c2298c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>