aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/fontfeatures
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-05-23 14:21:29 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-05-26 17:12:04 +0200
commit995a584c100e3f5bad9025947e001eb5730dc9b6 (patch)
tree046b6292e01856af1cc93f41277c2926a7f782f0 /tests/manual/fontfeatures
parent58e601e13a207cbab392ef1bd7c075c62331deed (diff)
Add font.features API to match the one in QFont
For convenience, we make this a map from strings to integers and just ignore any entries which are not valid four-letter tags. [ChangeLog][QtQuick] Added font.features property for fine-grained customization of the shaping process. Change-Id: I4ceaed859c1641f7b5888b27fa5a5bd576b05547 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/manual/fontfeatures')
-rw-r--r--tests/manual/fontfeatures/CMakeLists.txt30
-rw-r--r--tests/manual/fontfeatures/main.cpp17
-rw-r--r--tests/manual/fontfeatures/main.qml241
3 files changed, 288 insertions, 0 deletions
diff --git a/tests/manual/fontfeatures/CMakeLists.txt b/tests/manual/fontfeatures/CMakeLists.txt
new file mode 100644
index 0000000000..7938d64803
--- /dev/null
+++ b/tests/manual/fontfeatures/CMakeLists.txt
@@ -0,0 +1,30 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(fontfeatures LANGUAGES C CXX ASM)
+ find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+endif()
+
+qt_internal_add_manual_test(tst_manual_fontfeatures
+ GUI
+ SOURCES
+ main.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::Qml
+ Qt::QuickControls2
+)
+
+# Resources:
+set(qmake_immediate_resource_files
+ "main.qml"
+)
+
+qt_internal_add_resource(tst_manual_fontfeatures "qmake_immediate"
+ PREFIX
+ "/"
+ FILES
+ ${qmake_immediate_resource_files}
+)
diff --git a/tests/manual/fontfeatures/main.cpp b/tests/manual/fontfeatures/main.cpp
new file mode 100644
index 0000000000..f2e86cc7de
--- /dev/null
+++ b/tests/manual/fontfeatures/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/qsettings.h>
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
+#include <QtQuickControls2/qquickstyle.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/tests/manual/fontfeatures/main.qml b/tests/manual/fontfeatures/main.qml
new file mode 100644
index 0000000000..e65568dc79
--- /dev/null
+++ b/tests/manual/fontfeatures/main.qml
@@ -0,0 +1,241 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtCore
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtQuick.Dialogs
+
+ApplicationWindow {
+ id: window
+ width: 800
+ height: 600
+ title: "Font features"
+ visible: true
+ color: "white"
+
+ function handleFont(font)
+ {
+ var map = font.features
+ for (var i = 0; i < listView.count; ++i) {
+ var item = listView.itemAtIndex(i)
+ if (item !== null) {
+ if (item.checkState === Qt.Checked)
+ map[item.text] = true
+ else if (item.checkState === Qt.Unchecked)
+ map[item.text] = false
+ }
+ }
+
+ font.features = map
+ return font
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ RowLayout {
+ Text {
+ text: "Font:"
+ }
+ Text {
+ text: sampleText.font.family
+ }
+ ToolButton {
+ text: "..."
+ onClicked: fontDialog.visible = true
+ }
+ }
+ TextField {
+ id: sampleText
+ text: "This text is fine"
+ font.family: "Calibri"
+ font.pixelSize: 20
+ }
+ TextField {
+ id: smcpText
+ text: "Small caps"
+ font: {
+ "family": sampleText.font.family,
+ "pixelSize": sampleText.font.pixelSize,
+ "features": { "smcp": 1 }
+ }
+ }
+ TextField {
+ id: noLigaturesOrKerning
+ text: "This text is fine"
+ font.family: sampleText.font.family
+ font.pixelSize: sampleText.font.pixelSize
+ font.features: { "liga": 0, "dlig": 0, "clig": 0, "hlig": 0, "kern": 0 }
+ }
+
+ ListView {
+ id: listView
+ height: window.height / 2
+ width: window.width
+ model: [ "aalt",
+ "abvf",
+ "abvm",
+ "abvs",
+ "afrc",
+ "akhn",
+ "blwf",
+ "blwm",
+ "blws",
+ "calt",
+ "case",
+ "ccmp",
+ "cfar",
+ "chws",
+ "cjct",
+ "clig",
+ "cpct",
+ "cpsp",
+ "cswh",
+ "curs",
+ "cv01",
+ "c2pc",
+ "c2sc",
+ "dist",
+ "dlig",
+ "dnom",
+ "dtls",
+ "expt",
+ "falt",
+ "fin2",
+ "fin3",
+ "fina",
+ "flac",
+ "frac",
+ "fwid",
+ "half",
+ "haln",
+ "halt",
+ "hist",
+ "hkna",
+ "hlig",
+ "hngl",
+ "hojo",
+ "hwid",
+ "init",
+ "isol",
+ "ital",
+ "jalt",
+ "jp78",
+ "jp83",
+ "jp90",
+ "jp04",
+ "kern",
+ "lfbd",
+ "liga",
+ "ljmo",
+ "lnum",
+ "locl",
+ "ltra",
+ "ltrm",
+ "mark",
+ "med2",
+ "medi",
+ "mgrk",
+ "mkmk",
+ "mset",
+ "nalt",
+ "nlck",
+ "nukt",
+ "numr",
+ "onum",
+ "opbd",
+ "ordn",
+ "ornm",
+ "palt",
+ "pcap",
+ "pkna",
+ "pnum",
+ "pref",
+ "pres",
+ "pstf",
+ "psts",
+ "pwid",
+ "qwid",
+ "rand",
+ "rclt",
+ "rkrf",
+ "rlig",
+ "rphf",
+ "rtbd",
+ "rtla",
+ "rtlm",
+ "ruby",
+ "rvrn",
+ "salt",
+ "sinf",
+ "size",
+ "smcp",
+ "smpl",
+ "ss01",
+ "ss02",
+ "ss03",
+ "ss04",
+ "ss05",
+ "ss06",
+ "ss07",
+ "ss08",
+ "ss09",
+ "ss10",
+ "ss11",
+ "ss12",
+ "ss13",
+ "ss14",
+ "ss15",
+ "ss16",
+ "ss17",
+ "ss18",
+ "ss19",
+ "ss20",
+ "ssty",
+ "stch",
+ "subs",
+ "sups",
+ "swsh",
+ "titl",
+ "tjmo",
+ "tnam",
+ "tnum",
+ "trad",
+ "twid",
+ "unic",
+ "valt",
+ "vatu",
+ "vchw",
+ "vert",
+ "vhal",
+ "vjmo",
+ "vkna",
+ "vkrn",
+ "vpal",
+ "vrt2",
+ "vrtr",
+ "zero"
+ ]
+
+ delegate: CheckBox {
+ id: checkBox
+ text: modelData
+ tristate: true
+ checkState: Qt.PartiallyChecked
+ onCheckedChanged: {
+ sampleText.font = handleFont(fontDialog.currentFont)
+ }
+ }
+ }
+ }
+
+ FontDialog {
+ id: fontDialog
+ visible: false
+ title: "Please select a font"
+ onAccepted: {
+ sampleText.font = handleFont(fontDialog.currentFont)
+ }
+ }
+}