diff options
Diffstat (limited to 'tests/manual/fontfeatures')
-rw-r--r-- | tests/manual/fontfeatures/fontfeatures.pro | 17 | ||||
-rw-r--r-- | tests/manual/fontfeatures/main.cpp | 14 | ||||
-rw-r--r-- | tests/manual/fontfeatures/mainwindow.cpp | 225 | ||||
-rw-r--r-- | tests/manual/fontfeatures/mainwindow.h | 32 | ||||
-rw-r--r-- | tests/manual/fontfeatures/mainwindow.ui | 116 |
5 files changed, 404 insertions, 0 deletions
diff --git a/tests/manual/fontfeatures/fontfeatures.pro b/tests/manual/fontfeatures/fontfeatures.pro new file mode 100644 index 0000000000..62769072b4 --- /dev/null +++ b/tests/manual/fontfeatures/fontfeatures.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = fontfeatures +INCLUDEPATH += . +QT += widgets + +# You can make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# Please consult the documentation of the deprecated API in order to know +# how to port your code away from it. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier + +# Input +HEADERS += mainwindow.h +FORMS += mainwindow.ui +SOURCES += main.cpp \ + mainwindow.cpp \ diff --git a/tests/manual/fontfeatures/main.cpp b/tests/manual/fontfeatures/main.cpp new file mode 100644 index 0000000000..38c32b1bd3 --- /dev/null +++ b/tests/manual/fontfeatures/main.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "mainwindow.h" + +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/tests/manual/fontfeatures/mainwindow.cpp b/tests/manual/fontfeatures/mainwindow.cpp new file mode 100644 index 0000000000..5e61a14d5e --- /dev/null +++ b/tests/manual/fontfeatures/mainwindow.cpp @@ -0,0 +1,225 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + setup(); + updateSampleText(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::updateSampleText() +{ + QFont font = ui->fontComboBox->currentFont(); + font.setPixelSize(54); + + for (int i = 0; i < ui->lwFeatures->count(); ++i) { + QListWidgetItem *it = ui->lwFeatures->item(i); + if (it->checkState() != Qt::PartiallyChecked) { + if (const auto maybeTag = QFont::Tag::fromString(it->text().toLatin1())) + font.setFeature(*maybeTag, !!it->checkState()); + } + } + + ui->lSampleDisplay->setFont(font); + ui->lSampleDisplay->setText(ui->leSampleText->text()); +} + +void MainWindow::enableAll() +{ + for (int i = 0; i < ui->lwFeatures->count(); ++i) { + QListWidgetItem *it = ui->lwFeatures->item(i); + it->setCheckState(Qt::Checked); + } +} + +void MainWindow::disableAll() +{ + for (int i = 0; i < ui->lwFeatures->count(); ++i) { + QListWidgetItem *it = ui->lwFeatures->item(i); + it->setCheckState(Qt::Unchecked); + } +} + +void MainWindow::reset() +{ + for (int i = 0; i < ui->lwFeatures->count(); ++i) { + QListWidgetItem *it = ui->lwFeatures->item(i); + it->setCheckState(Qt::PartiallyChecked); + } +} + +void MainWindow::setup() +{ + connect(ui->fontComboBox, &QFontComboBox::currentFontChanged, this, &MainWindow::updateSampleText); + connect(ui->leSampleText, &QLineEdit::textChanged, this, &MainWindow::updateSampleText); + connect(ui->lwFeatures, &QListWidget::itemChanged, this, &MainWindow::updateSampleText); + connect(ui->pbEnableAll, &QPushButton::clicked, this, &MainWindow::enableAll); + connect(ui->pbDisableAll, &QPushButton::clicked, this, &MainWindow::disableAll); + connect(ui->pbReset, &QPushButton::clicked, this, &MainWindow::reset); + + QList<QByteArray> featureList = + { + "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" + }; + + for (auto it = featureList.constBegin(); it != featureList.constEnd(); ++it) { + QListWidgetItem *item = new QListWidgetItem(*it); + item->setFlags(Qt::ItemIsUserTristate | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); + item->setCheckState(Qt::PartiallyChecked); + ui->lwFeatures->addItem(item); + } +} diff --git a/tests/manual/fontfeatures/mainwindow.h b/tests/manual/fontfeatures/mainwindow.h new file mode 100644 index 0000000000..8df130edd6 --- /dev/null +++ b/tests/manual/fontfeatures/mainwindow.h @@ -0,0 +1,32 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void updateSampleText(); + void enableAll(); + void disableAll(); + void reset(); + +private: + Ui::MainWindow *ui; + + void setup(); +}; +#endif // MAINWINDOW_H diff --git a/tests/manual/fontfeatures/mainwindow.ui b/tests/manual/fontfeatures/mainwindow.ui new file mode 100644 index 0000000000..17f56c5a01 --- /dev/null +++ b/tests/manual/fontfeatures/mainwindow.ui @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFontComboBox" name="fontComboBox"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Sample text:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="leSampleText"> + <property name="text"> + <string>Foobar</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="pbEnableAll"> + <property name="text"> + <string>Enable all</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbDisableAll"> + <property name="text"> + <string>Disable all</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbReset"> + <property name="text"> + <string>Reset</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QListWidget" name="lwFeatures"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="flow"> + <enum>QListView::TopToBottom</enum> + </property> + <property name="isWrapping" stdset="0"> + <bool>false</bool> + </property> + <property name="viewMode"> + <enum>QListView::ListMode</enum> + </property> + <property name="uniformItemSizes"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="lSampleDisplay"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>LABEL</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> |