summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduce optional smarter font merging with ContextFontMergingEskil Abrahamsen Blomfeldt11 days1-23/+56
| | | | | | | | | | | | | | | | | | | | | | This introduces an optional, slightly more expensive approach to font merging which takes the full string into account, instead of just going character by character. This addresses the issue that you may sometimes get multiple fonts to cover one string of text in a single language. With Chinese, this is especially an issue because many fonts will only support parts of the very large character set. The new algorithm detects if the string was incompletely covered by the font and tries the fallback fonts in order to find the best match. This is obviously more expensive, especially if no perfect match is found and we have to check all the fallbacks in the list, but it is opt-in and only enabled if the ContextFontMerging flag is set. Task-number: QTBUG-121131 Change-Id: I8c7874d0918640bd83418e3c4726c89f43a220a3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Revert "Don't do font merging for PUA characters"Eskil Abrahamsen Blomfeldt2024-03-181-2/+1
| | | | | | | | | | | | | | This reverts commit fc33fea999365c36ed446eee0db0d59d94be306b. The change caused issues with system-wide PUA fallbacks on platforms where this is supported. It needs to be replaced by an approach which still falls back, but only for fonts which are explicitly categorized as PUA fallbacks. Pick-to: 6.5 6.6 6.7 Task-number: QTBUG-110502 Change-Id: I985a1f8076645593c50e81759872b4227d0fcd0d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* 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>
* Fix regression when selecting emojis using VS-16Eskil Abrahamsen Blomfeldt2023-12-131-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Replace MAKE_TAG macro with QFont::TagVolker Hilsheimer2023-10-201-9/+11
| | | | | | Task-number: QTBUG-117046 Change-Id: I26e0af634fed87199bb49d57e3aa3f4e3fea0e39 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Support variable applications fonts with DirectWriteEskil Abrahamsen Blomfeldt2023-10-021-5/+0
| | | | | | | | | | | | | | | | 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>
* Support loading variable fonts as application fonts in FreetypeEskil Abrahamsen Blomfeldt2023-09-201-0/+5
| | | | | | | | | | | | | | | | 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>
* gui/text: use const methods moreAnton Kudryavtsev2023-09-091-2/+2
| | | | | | | to avoid implicit detach Change-Id: I2c6edfcf8b9dc6e9bb0801b7bd58f34a8033a955 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* FontEngine: Skip 0-width glyphs when finding first left bearingMårten Nordheim2023-06-201-3/+3
| | | | | | | | | | | Since they don't contribute to the width of a string then we may accidentally end up ignoring the potential left-bearing that the first non-zero-width glyph has. Task-number: QTBUG-113679 Pick-to: 6.6 Change-Id: I8e89a428acf5d0a3da0255c50778ccc773ff20e1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Skip generation of glyphs for control charactersWladimir Leuschner2023-06-151-0/+1
| | | | | | | | | QFontEngine tries to generate glyphs for ASCII control characters. Those characters have no glyphs and should therefore not be generated. Task-number: QTBUG-113848 Change-Id: Ib15a50c642d8bc92bc007ab5522aebc5a7b2993d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Don't do font merging for PUA charactersEskil Abrahamsen Blomfeldt2023-02-101-1/+2
| | | | | | | | | | | | | | | | | | | | | The "Private Use Area" are subsets of Unicode which are not considered regular characters, but reserved for fonts to provide custom glyphs. If these were used and the main font did not have support for them, we would look them up in other fonts and sometimes display an arbitrary selection of glyphs, based on whatever existed on the platform. This is unexpected and different from how native apps work on Windows, for instance. [ChangeLog][QtGui][Text] Font merging (automatic assignment of alternative fonts) is no longer applied for characters in the Private Use Areas of Unicode. Pick-to: 6.5 Fixes: QTBUG-110502 Change-Id: Id2c63786aafda59bf170e0d7263eb78a391fe46d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* windows: Fix vertical metrics with GDI engineEskil Abrahamsen Blomfeldt2022-12-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 6 we consolidated vertical font metrics across all platforms (see f761ad3cd9ad1252f24b76ae413298dc7bed8af3 and follow-ups). However, a couple mistakes were made. First of all, when we use the winAscent/winDescent values from the OS/2 table, we would also set the leading to the line gap value from the HHEA table. However, the line gap is actually built into the winAscent/winDescent, so we ended up adding this twice to the line spacing, increasing it with some older fonts. When using the Windows legacy metrics, we now set the line gap to 0 instead to reflect that this is baked into the height. In addition, since we now calculate the values ourselves, we would not round them to nearest integer like the GDI engine does. We now round these values to make it clear that the GDI engine does not support any fractional metrics. [ChangeLog][Windows][Text] Fixed an issue where the line gap of some fonts would be included twice in the font's leading. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-109400 Change-Id: I02ab7447b5e82d9f4474f9bca581f82acee85ff3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Try to match variant-selector font to preceding characterEskil Abrahamsen Blomfeldt2022-12-121-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Variant-selectors are special unicode symbols which are used to modify glyph selection for the preceding character. For instance, a regular symbol could be turned into a color emoji using VS16, the emoji variation selector. In order for this to work, however, the font that handles the selector has to handle the full pair of characters, so that it can apply the correct substitution rules. One specific example of this was on macOS, where an airplane symbol + VS16 would match the symbol to the default UI font but the VS16 to the emoji font. Since there string provided for the emoji font did not have any preceding character for VS16, we just ignored it. To improve on this, we now detect variation selectors that have been matched to different font engines than the preceding character. When such a case occurs, we check if the selector font also supports the preceding character, and if it does, we keep the pair together and use the same font for both. [ChangeLog][QtGui][Text] Fix some cases where a variation-selector character would be ignored in font selection and the correct variant of a character would thus not be selected. Task-number: QTBUG-108799 Change-Id: I9f427e0520e652ee2f24a4f7dc3c1957251e06bd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Unify QFontEngine::boundingRect for coretext and WindowsAllan Sandfeld Jensen2022-07-061-0/+21
| | | | | | | | | | They were both using the same algorithm, and also both had the same mistake of not handling left-bearing. This unifies them and adds left bearing handling. Change-Id: Id06392abde0bfeb8b49faf4632082b2e25352497 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFontEngine: fix GCC 12 -Werror=array-boundsMarc Mutz2022-05-311-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Says GCC 12 with -sanitize address -sanitize undefined: qfontengine.cpp: In member function ‘bool QFontEngine::processHheaTable() const’: qfontengine.cpp:386:65: error: array subscript 4 is outside array bounds of ‘const char [1]’ [-Werror=array-bounds] 386 | qint16 ascent = qFromBigEndian<qint16>(hhea.constData() + 4); | ~~~~~~~~~~~~~~~~~^~~ qbytearray.h:56:23: note: at offset 4 into object ‘QByteArray::_empty’ of size 1 56 | static const char _empty; | ^~~~~~ (repeats several times) The compiler apparently assumes that data() and size() are independent of each other, and so finds that that constData() may return &_empty, which is a const char[1]. For some reason, storing the result of constData() in a temporary and indexing off of that fixes the issue. Potentially adding Q_ASSUME(d.data()[d.size] == '\0'); in some strategic place would fix it, too, but would incur runtime overhead. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105348 Task-number: QTBUG-103923 Pick-to: 6.3 6.2 Change-Id: Ia6e24e01d1c2a6bd9d91d4d082df9fba0d5c668f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* 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>
* Remove last traces of old HarfbuzzEskil Abrahamsen Blomfeldt2022-04-221-31/+18
| | | | | | | | | | | | | | | | | | | | | | In Qt 6, we removed the "old" Harfbuzz and Harfbuzz-NG became the only option. But the QT_HARFBUZZ=old environment variable would still be read and would disable certain parts of the code path. This has caused some confusion when porting older applications, where QT_HARFBUZZ=old was used to work around issues with the earlier versions of Harfbuzz-NG. Setting it now causes text to disappear completely. To avoid this confusion, we remove traces of the QT_HARFBUZZ environment variable as well. [ChangeLog][Text] Fixed an issue where setting the legacy environment variable QT_HARFBUZZ=old would cause text to disappear from the application. Fixes: QTBUG-102774 Change-Id: I0f07cdb2418202fc36b82e766ad9547c34477175 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Fix overlapping text for Osaka font on macOSEskil Abrahamsen Blomfeldt2021-12-021-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | The Osaka font on macOS has all zeroes in the OS/2 table, probably because it is not intended to be cross-platform. In Qt 6 (since f761ad3cd9ad1252f24b76ae413298dc7bed8af3) we are trying using the same vertical metrics on all platforms, but this only works if they are valid. To work around this issue, we detect the case when ascent/descent values are both 0, since this is very unlikely to be intentional, so we fall back to the system-provided ascent and descent in these cases. Adding the test also revealed that we had missed the check for a macOS-specific bitmap font format when skipping the check for bitmap fonts in 7a18b7e2c2394b2b2cc95833c755f91193d9ba2e. [ChangeLog][macOS][Text] Fixed a problem where using the Osaka font would lead to overlapping text. Pick-to: 6.2 Fixes: QTBUG-96880 Change-Id: Ifea7918641a68829e8f5ef20a4fb61c0a7e5b757 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix inconsistencies between advanceWidth and bounding rectsAllan Sandfeld Jensen2021-10-211-3/+3
| | | | | | | | | | | | | | | | 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>
* 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>
* Optimize subpixel positioningAllan Sandfeld Jensen2021-01-271-1/+1
| | | | | | | Dividing by (1/x) is the same as multiplying with x. Change-Id: Ica854d1e012ad83437e32f12de0d3513a42ae6f8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement vertical subpixel positioning where availableEskil Abrahamsen Blomfeldt2021-01-251-23/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some use cases, vertical subpixel positioning may be useful, as it allows you to vertically align text with other painting primitives. This does impose an overhead, so we make it opt-int with a render hint on the painter. Note that this is only supported on Freetype currently. It might be possible to support on older macOS versions, prior to Mojave (which has disabled subpixel positioning entirely), but since it would have limited usefulness and Freetype is cross-platform anyway, I skipped that. Note: This drive-by-fixes an issue with subpixel positioning where glyphs would always be offset by 1/64, because we added the aliasing offset *after* we had determined the closest subpixel position. The idea of this, as far as I can understand, is rather to snap to nearest subpixel position upwards, not to add an offset to all glyphs, so it should be added before finding the correct position. It had a subtle visual effect when animating the position. It might be that we could get rid of it entirely, as I haven't been able to reproduce any issues with that, but I have moved it instead, to match what I believe the intention was. [ChangeLog][QtGui][Text] Added render hint flag QPainter::VerticalSubpixelPositioning which will position text at subpixel positions vertically whenever supported. In absence of this, text position will be rounded vertically as before. Fixes: QTBUG-35682 Change-Id: I8ce7a72a64e5a0924dac7c244e3e07c2938bfd09 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QFont: Prefer setFamilies() over setFamily()Andy Shaw2020-11-201-11/+10
| | | | | | | | | | | | | | | | 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>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-7/+7
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Deprecate QFontDatabase constructorVolker Hilsheimer2020-11-031-1/+1
| | | | | | | | Move private methods into the private class. Fixes: QTBUG-88114 Change-Id: I92fa52980ed5a0675eee310359d8875f614921e6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix delay first time a font is usedEskil Abrahamsen Blomfeldt2020-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since 066daf750fcffff8eeae4d5749607501b9aa9a2f, we would mistakenly populate the fallback list for all ensureAt(index) calls, even when index == 0. This index indicates the main font, is always valid and does not require knowledge of any fallbacks. On Windows (and other platforms where QPlatformDatabase::fallbacksForFamily() is used) this would cause all fonts on the system to be loaded and should only be done when we actually need one of the fallbacks. With the GDI font database, in which font loading is slow because we have to manually read font data, this is especially bad. If we can later move to using DirectWrite for this, we should be able to improve on it, but in any case there is no need to pay the cost of the fallbacks when the application is just using the fonts it has selected (memory-wise this is also a bad idea). On my machine a simple text layout went from 370 ms to 37 ms. [ChangeLog][Text] Fixed an issue where on some platforms, there would be a delay the first time any font was used, sometimes causing a visible delay in the UI. Fixes: QTBUG-71737 Pick-to: 5.15 Change-Id: Ie8ce9b73f02a0e5cf39a2b280968b89f4caaf39e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Fix output with box font engineEskil Abrahamsen Blomfeldt2020-10-201-5/+5
| | | | | | | | | | | | | | | | The box font engine was passing in alpha values in the blue channel instead of alpha channel to QImage::setPixel(), probably assuming that setPixel() accepts the input in the format of the QImage. But the whole point of setPixel() is that it converts the input. If we just want to set the alpha value, we can do it directly on the QImage::bits(). [ChangeLog][Text] Fixed showing boxes for glyphs when there are no fonts available in the font database. Pick-to: 5.15 Change-Id: I7ae067c26b9ecba6aaa046e7e4b9ae520c4b3d23 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use valid glyph index for box font engineEskil Abrahamsen Blomfeldt2020-10-191-2/+2
| | | | | | | | | | | | | | | | | | Glyph index 0 is reserved for "glyph not found", which can confuse Harfbuzz. For QFontEngineBox we always return a valid glyph since it is the fallback font when no other fonts are available. Symptom of issue was that we could get to Q_UNREACHABLE for certain strings when Harfbuzz returned a glyph count of 0. [ChangeLog][QtGui] Fixed a potential crash when rendering text with an empty font database. Fixes: QTBUG-85016 Pick-to: 5.15 Change-Id: Iaf1d003cdff57320bf4327aa8e63dffd9d1da82c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFontEngine: Do not call getSfntTable with uninitalized valueChristoph Schleifenbaum2020-09-251-2/+2
| | | | | | | | | | On FreeType font engine this results in a call to FT_Load_Sfnt_Table with a pointer to an uninitialized value passed in as FT_ULong* length, crashing. Instead initialize value to 0. Change-Id: I50d6df3b2296a05640d939e862bc50adb0fec921 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit e041f5459660eaa7108fa5888e77e64f7d1b3d1d)
* Include harfbuzz header files without harfbuzz/ parent directoryDimitrios Apostolou2020-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | | This is in accordance to the examples from harfbuzz docs: https://harfbuzz.github.io/ch03s03.html The fix is because `pkg-config --cflags harfbuzz` returns the subdirectory as include path, for example: -I /usr/local/include/harfbuzz and this caused the system-harfbuzz not to be found when /usr/local/include was not included by default (recent change on macOS) and the code was doing #include <harfbuzz/hb.h>. Fixes: QTBUG-85568 Change-Id: I12a34638e8ad5e3085768828457f0bfa1a2c68ad Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-311-1/+1
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-10/+10
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Remove deprecated text-related enumsEskil Abrahamsen Blomfeldt2020-06-081-5/+5
| | | | | | | | Fixes: QTBUG-82367 Change-Id: Iff2645759657f8e350754e90e791dbd583017671 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtGui: fix deprecated QChar conversionsMarc Mutz2020-05-111-1/+1
| | | | | | | | | Conversions from non-char-types to QChar are going to be deprecated. Use QChar::fromUcs2(), fromUcs4(), QLatin1Char(), or convert the constructor argument to char16_t. Change-Id: Ib45ebd5560aa3a2bc460037ab09773607485c6e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix font height metrics with embedded bitmapsEskil Abrahamsen Blomfeldt2020-05-041-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | For fonts with embedded bitmaps, we cannot trust the HHEA and OS/2 tables, since there are a different set of font metrics in the EBLC/CBLC tables for each of the predefined bitmap sizes. In this case, we can safely fall back to the metrics returned by the system, as the inconsistency we were originally fixing was only between OS/2 and HHEA and will not matter for the bitmap fonts. This patch also simplifies the code path through the font engines a bit. Instead of setting the system metrics in the processHheaTable() function when the table cannot be found, we instead always fetch the system metrics at the very start of initializeHeightMetrics() and then override if there are no embedded bitmaps, and if the HHEA and OS/2 tables are available. This also reduces the number of virtual functions needed to sort out the height metrics. Fixes: QTBUG-83754 Change-Id: Ib9dc6fc6cf972e48209a4a272469d2b4bd1ebffe Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QtGui: fix a few more char/int/uint -> QChar conversionsMarc Mutz2020-04-301-2/+2
| | | | | | | | They were masked by all QChar ctors being made explicit, except the char16_t one, which was left as the only viable choice. Change-Id: I343269b61d555c259b5780011e99f85f5375ef78 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use consistent vertical metrics on all platformsEskil Abrahamsen Blomfeldt2020-04-221-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt assumes that ascent+descent is the bounding height of the text, but for historical reasons, the ascent for some fonts will not contain the diacritics. On Windows, the preference is to use data from the OS/2 table which were explicitly invented to work around this, but on other platforms we are not respecting this table. This causes a text layout that looks fine on Windows to have overlapping characters on e.g. macOS. To make vertical metrics (ascent, descent, leading) consistent across all platforms, we don't blindly trust the values we get from the underlying font system, but apply in the following order: 1. If OS/2 table exists and USE_TYPO_METRICS flag is set, we use the typo metrics from OS/2 table 2. If OS/2 table exists and USE_TYPO_METRICS flag is not set, we use winAscent/winDescent from OS/2 and the line gap from HHEA table. 3. If no OS/2 table exists, we try to get ascent, descent and line gap from the HHEA table. 4. If the HHEA table does not exist (not an SFNT), we fall back to the system-provided metrics. (on macOS, we know the system-provided metrics will match the data in HHEA, so we skip parsing that table and use the data from CoreText if there is no OS/2 table). Task-number: QTBUG-80554 Change-Id: I41e6561a99513698c8e42451b4ec98bd5eb6892f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Compile fixes for clang10Lars Knoll2020-04-151-4/+4
| | | | | | | Fix some warnings that are flagged as errors on clang10. Change-Id: I906634c8b2bd94db42d74a7f3d10efb086e373cc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * qpa: Remove references to lighthouseTor Arne Vestbø2020-04-031-1/+1
| | | | | | | | | | Change-Id: I37646113f626c878883cff49f4e186ec71bcfa15 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* | Follow bundled Harfbuzz updateKonstantin Ritt2020-03-281-12/+9
| | | | | | | | | | | | | | | | | | | | | | as we raised the minimum requirement for harfbuzz to version 2.6.0: * use new HB_SCRIPT values instead of tags * get rid of deprecated (and no-more-used) callbacks * replace deprecated hb_ot_tags_from_script() usage with a more flexible and up-to-date hb_ot_tags_from_script_and_language() Change-Id: I0eafdd2d2028c353fa3a93f5868efceccd364a70 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | Don't limit AAT support to Darwin based platformsLars Knoll2020-03-181-2/+0
| | | | | | | | | | | | | | | | Harfbuzz supports this in a cross platform way, so there's no reason not to accept a font with AAT tables on other platforms. Change-Id: I00c38a11dfd4a32e846254c1da9e8841090f5fd9 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* | Remove old harfbuzz support from QFontEngineLars Knoll2020-03-171-146/+3
| | | | | | | | | | Change-Id: I1595ce32d2b88b98157bcf8020ac22db93d7ea64 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* | Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-02-281-0/+3
|\| | | | | | | Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
| * Merge remote-tracking branch 'origin/5.14' into 5.15Lars Knoll2020-02-271-0/+3
| |\ | | | | | | | | | Change-Id: I4212d070d5752275085e754b96f0392113604dba
| | * Fix bounding box of zero-width entities in QFontEngineFTAllan Sandfeld Jensen2020-02-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Freetype can give us non empty bounds for zero-width characters, this change just makes us skip metrics of characters already found to not contribute to text advance. The coretext and windows font-engines already uses the already calculated advance. Change-Id: I82b3521a4fb92614be509be5982cd5ab9c1eb7de Fixes: QTBUG-58854 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | | Make bytes-per-line safe for int overflowAllan Sandfeld Jensen2020-02-201-2/+2
|/ / | | | | | | | | | | | | | | Goes through the Qt code and make sure bytes-per-line calculations are safe when they are too big for 32bit integers. Change-Id: I88b2d74b3da82e91407d316aa932a4a37587c0cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-20/+20
| | | | | | | | | | | | | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Avoid initializing QFlags with 0 or nullptr in further casesFriedemann Kleint2019-11-221-1/+1
| | | | | | | | | | | | | | | | | | Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>