summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmfontdatabase.h
Commit message (Collapse)AuthorAgeFilesLines
* Use emoji segmenter to apply emoji fonts automaticallyEskil Abrahamsen Blomfeldt2024-11-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Colorful emojis in Unicode are not isolated to specific ranges of code points like other writing systems. Instead, there are a set of rules defining whether a sequence of characters should be displayed in color or black/white. http://www.unicode.org/reports/tr51/ For instance, appending a variation selector to a character can turn it into a color emoji, even if it is a code point that predates the invention of emojis. In addition, sequences of joined characters that are determined to be a color emoji sequence should be parsed by a single emoji font, so that it can apply things like skin color, etc. In general, users expect emojis and emoji sequences to be shown in the preferred color font of the system, even if a selected font has black/white characters for the symbols. This patch applies the emoji segmenter to strings to isolate sequences that should be in color. As an implementation hack, we mark this in the QScriptItems as a special "emoji" script. Note that this is not a real Unicode script and only exists internally for this reason, because the "emojiness" of the resulting glyph overrides the original script of the individual characters when selecting fonts. This way, we can use a lot of the same logic for itemizing the strings and looking up fonts, and we don't need to increase the size of the QScriptItem. (It is just an implementation detail and is not exposed to the user, so it can be replaced by other approaches later if we need to.) When matching an emoji sequence, we always try to apply a color font and ignore all others. The exception is if there is no color font at all on the system, then we will find a black and white font which supports the characters instead as a final failsafe. In addition, each platform will put its default emoji font at the top of the fallbacks list in order to make this the preference in case there are more than one. This patch also adds API to override this with an application-defined emoji font, since this is a common use case. Note: The font includes an environment variable to disable the feature as a fail safe. A flag to disable it per QFont will be added in a follow-up. Fixes: QTBUG-111801 Change-Id: I9431ec34d56772ab8688814963073b83b23002ae Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: <carl@carlschwan.eu>
* wasm: add config API for controlling local font loadingMorten Sørvig2023-12-181-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | This makes Qt read the following config options at startup: - qt.requestLocalFontsPermission - qt.localFontFamiliesCollection - qt.extraLocalFontFamilies And adds the following instance function - qtLoadLocalFontFamilies These can be used to control which local fonts Qt will use, and also if Qt should ask for local fonts permission on startup. Also register a startup task for font loading. Font loading completes asynchronously at some point after the initial startup, and this way we can prevent showing the application until the requested fonts are available. Change-Id: I2b353c8b9c1a4976dddeb447d1f867aa2adf7588 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: rework local font supportMorten Sørvig2023-04-251-1/+2
| | | | | | | | | | | | | | Populate a subset of the font families at startup if the local fonts access API is supported, and the access permission has been given. Since this code runs at app startup there is no opportunity to request font access. That should be done in response to user action, for example by having a "load local fonts" button in the application. Pick-to: 6.5 Change-Id: Ib6826deeec06ee3def0e793dd1462977710462be Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
* wasm: add local-fonts API supportAleksandr Reviakin2022-08-301-0/+3
| | | | | | | | | | | Add support for accessing local fonts via local-fonts API. Local fonts API is available in Chrome 103 and above. Fixes: QTBUG-81736 Change-Id: Iac47b3a30c7a22933cbdbfc97ce0791edb63b5bd Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+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>
* Move FreeType font engine/database to QtGuiTor Arne Vestbø2020-05-271-1/+1
| | | | | | Task-number: QTBUG-83255 Change-Id: If6be7057d6bd25b34acd99e18658744161985ed0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Enabler: Store more properties of application fontsEskil Abrahamsen Blomfeldt2020-03-061-1/+0
| | | | | | | | | | | | | | The family name of a font is ambiguous and without additional information there is no way to separate one font from another inside that family. In order to make it possible to expose more info about application fonts from FontLoader in Qt Quick, we need to store them in the font database. Task-number: QTBUG-68829 Change-Id: I931e1c2c004437ac0a21d4d88e55d176de676f34 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* wasm: add fixedPitch fontLorn Potter2019-05-071-0/+1
| | | | | | | | Also define our default font so as to return something we actually have Task-number: QTBUG-75587 Change-Id: I26e3c62921d369c3017af9796c0a20f7ac06d07c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-0/+49
This is the squashed diff from wip/webassembly to dev. Done-with: Peng Wu <peng.wu@intopalo.com> Done-with: Sami Enne <sami.enne@intopalo.com> Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Started-by: Andrew Knight <andrew.knight@intopalo.com> Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>