From 0cbaca86a7f1084bda70aae364b2ed4b5e9ddb51 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 10 Jan 2022 20:45:05 +0200 Subject: [PATCH] use GNU FreeFont as last resort font Signed-off-by: Ivailo Monev --- doxygen.conf | 2 +- package/archlinux/PKGBUILD | 1 + package/debian/control | 2 +- package/fedora/katie.spec | 2 +- package/freebsd/Makefile | 5 +++-- package/netbsd/Makefile | 1 + package/openbsd/Makefile | 2 +- src/declarative/graphicsitems/qdeclarativetext.cpp | 4 ++-- .../graphicsitems/qdeclarativetextedit.cpp | 4 ++-- .../graphicsitems/qdeclarativetextinput.cpp | 2 +- src/declarative/qml/qdeclarativecompiler.cpp | 2 +- src/gui/kernel/qapplication_x11.cpp | 2 +- src/gui/text/qfont.cpp | 23 ++++++++++------------ src/gui/text/qfont_x11.cpp | 2 +- src/gui/text/qfontdatabase.cpp | 9 ++++----- src/gui/text/qfontsubset.cpp | 14 ++++++------- src/gui/widgets/qfontcombobox.cpp | 2 +- tests/auto/qfontmetrics/tst_qfontmetrics.cpp | 4 ++-- 18 files changed, 41 insertions(+), 42 deletions(-) diff --git a/doxygen.conf b/doxygen.conf index 28feec72e..a39f193d6 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -2236,7 +2236,7 @@ DOT_NUM_THREADS = 0 # The default value is: Helvetica. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTNAME = Helvetica +DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size (in points) of the font of # dot graphs. diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index f0f08127c..90a07cf86 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -13,6 +13,7 @@ license=('LGPL' 'BSD') depends=('libsm' 'libxcursor' 'libxinerama' 'libxpm' 'libxrandr' 'fontconfig' 'icu' 'jansson' 'libcups' 'xdg-utils') makedepends=('cmake' 'git' 'unifdef') +optdepends=('gnu-free-fonts: last resort font') source=("git+https://github.com/fluxer/katie") sha1sums=('SKIP') conflicts=('katie') diff --git a/package/debian/control b/package/debian/control index e38112f05..2c16ac103 100644 --- a/package/debian/control +++ b/package/debian/control @@ -15,7 +15,7 @@ Package: katie-runtime Architecture: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x hurd-i386 Section: x11 Depends: ${shlibs:Depends}, ${misc:Depends}, xdg-utils -Recommends: xserver-xorg-core +Recommends: xserver-xorg-core fonts-freefont-ttf Description: C++ toolkit derived from the Qt 4.8 framework Katie is continuation of the Qt4 C++ toolkit with the goal to keep it alive, clean it up, fix some bugs and backport some features from Qt5. It is based diff --git a/package/fedora/katie.spec b/package/fedora/katie.spec index 203c76b7a..9be007a0e 100644 --- a/package/fedora/katie.spec +++ b/package/fedora/katie.spec @@ -8,7 +8,7 @@ License: BSD and LGPLv2+ URL: https://github.com/fluxer/katie BuildRequires: gcc-c++ cmake libicu-devel libzstd-devel jansson-devel zlib-devel libpng-devel freetype-devel pcre-devel openssl-devel libX11-devel libXinerama-devel libXrandr-devel libXrender-devel libXfixes-devel libXcursor-devel libSM-devel libICE-devel dbus-devel fontconfig-devel cups-devel unifdef -Requires: xdg-utils +Requires: xdg-utils gnu-free-fonts Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig Requires(post): desktop-file-utils diff --git a/package/freebsd/Makefile b/package/freebsd/Makefile index f17bad00b..e25402515 100644 --- a/package/freebsd/Makefile +++ b/package/freebsd/Makefile @@ -1,4 +1,4 @@ -# https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/ +# https://docs.freebsd.org/en/books/porters-handbook/ PORTNAME = katie DISTVERSION = 4.12.0.d20201231 @@ -16,7 +16,8 @@ WRKSRC = ${WRKDIR}/katie-master USES = compiler:c++11-lang pkgconfig cmake ssl xorg desktop-file-utils USE_XORG = x11 xinerama xrandr xrender xfixes xcursor xext xpm sm ice USE_LDCONFIG = yes -RUN_DEPENDS = xdg-open:devel/xdg-utils +RUN_DEPENDS = xdg-open:devel/xdg-utils \ + ${LOCALBASE}/share/fonts/freefont-ttf/FreeSans.ttf:x11-fonts/freefont-ttf LIB_DEPENDS = libzstd.so:archivers/zstd libicuuc.so:devel/icu \ libicui18n.so:devel/icu libjansson.so:devel/jansson \ libpcre.so:devel/pcre libpng.so:graphics/png \ diff --git a/package/netbsd/Makefile b/package/netbsd/Makefile index 5947e8bbe..c929ea88f 100644 --- a/package/netbsd/Makefile +++ b/package/netbsd/Makefile @@ -22,6 +22,7 @@ USE_TOOLS = pkg-config msgfmt DL_AUTO_VARS = yes DEPENDS = xdg-utils-[0-9]*:../../misc/xdg-utils +DEPENDS += freefont-ttf-[0-9]*:../../fonts/freefont-ttf BUILD_DEPENDS = unifdef-[0-9]*:../../devel/unifdef .include "../../sysutils/desktop-file-utils/desktopdb.mk" diff --git a/package/openbsd/Makefile b/package/openbsd/Makefile index 07701d4ac..f11a39a1f 100644 --- a/package/openbsd/Makefile +++ b/package/openbsd/Makefile @@ -20,7 +20,7 @@ WRKSRC = ${WRKDIR}/katie-master COMPILER = base-clang ports-gcc MODULES = devel/cmake BUILD_DEPENDS = devel/gettext,-tools -RUN_DEPENDS = devel/desktop-file-utils devel/xdg-utils +RUN_DEPENDS = devel/desktop-file-utils devel/xdg-utils fonts/freefont-ttf LIB_DEPENDS = archivers/zstd textproc/icu4c devel/jansson devel/pcre \ graphics/png x11/dbus print/cups,-libs devel/gettext,-runtime WANTLIB = ${COMPILER_LIBCXX} ICE SM X11 Xcursor Xext Xfixes Xinerama Xrandr \ diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index fc4ddaf7a..4ee37020c 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -637,7 +637,7 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma \qml Text { text: "Hello World!" - font.family: "Helvetica" + font.family: "FreeSans" font.pointSize: 24 color: "red" } @@ -720,7 +720,7 @@ QDeclarativeText::~QDeclarativeText() Sets the family name of the font. - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". + The family name is case insensitive and may optionally include a foundry name, e.g. "FreeSans [GNU]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm. */ diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 349a03981..12be73dbc 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE TextEdit { width: 240 text: "Hello World!" - font.family: "Helvetica" + font.family: "FreeSans" font.pointSize: 20 color: "blue" focus: true @@ -112,7 +112,7 @@ QString QDeclarativeTextEdit::text() const Sets the family name of the font. - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". + The family name is case insensitive and may optionally include a foundry name, e.g. "FreeSans [GNU]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm. */ diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index c3e5db582..0ae7d172b 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -92,7 +92,7 @@ void QDeclarativeTextInput::setText(const QString &s) Sets the family name of the font. - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". + The family name is case insensitive and may optionally include a foundry name, e.g. "FreeSans [GNU]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm. */ diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 337c21130..7cff62956 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1793,7 +1793,7 @@ bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *p // Build "grouped" properties. In this example: // Text { // font.pointSize: 12 -// font.family: "Helvetica" +// font.family: "FreeSans" // } // font is a nested property. pointSize and family are not. bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop, diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index b2f516f3b..759a14763 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1255,7 +1255,7 @@ void qt_init(QApplicationPrivate *priv, Display *display, QApplicationPrivate::x11_apply_settings(); - // be smart about the size of the default font. most X servers have helvetica + // be smart about the size of the default font. most X servers have font // 12 point available at 2 resolutions: // 75dpi (12 pixels) and 100dpi (17 pixels). // At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17 diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 6a88baab8..bf30294d7 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -75,7 +75,7 @@ bool QFontDef::exactMatch(const QFontDef &other) const To compare the family members, we need to parse the font names and compare the family/foundry strings separately. This allows - us to compare e.g. "Helvetica" and "Helvetica [Adobe]" with + us to compare e.g. "FreeSans" and "FreeSans [GNU]" with positive results. */ if (pixelSize != -1 && other.pixelSize != -1) { @@ -304,8 +304,7 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other) \snippet doc/src/snippets/code/src_gui_text_qfont.cpp 2 You can specify the foundry you want in the family name. The font f - in the above example will be set to "Helvetica - [Cronyx]". + in the above example will be set to "FreeSans [GNU]". To determine the attributes of the font actually used in the window system, use a QFontInfo object, e.g. @@ -442,11 +441,10 @@ QFont::QFont() 12 points, except on Symbian where it is 7 points. The \a family name may optionally also include a foundry name, - e.g. "Helvetica [Cronyx]". If the \a family is - available from more than one foundry and the foundry isn't - specified, an arbitrary foundry is chosen. If the family isn't - available a family will be set using the \l{QFont}{font matching} - algorithm. + e.g. "FreeSans [GNU]". If the \a family is available from more + than one foundry and the foundry isn't specified, an arbitrary + foundry is chosen. If the family isn't available a family will + be set using the \l{QFont}{font matching} algorithm. \sa Weight, setFamily(), setPointSize(), setWeight(), setItalic(), QApplication::font() @@ -517,11 +515,10 @@ QString QFont::family() const may include a foundry name. The \a family name may optionally also include a foundry name, - e.g. "Helvetica [Cronyx]". If the \a family is - available from more than one foundry and the foundry isn't - specified, an arbitrary foundry is chosen. If the family isn't - available a family will be set using the \l{QFont}{font matching} - algorithm. + e.g. "FreeSans [GNU]". If the \a family is available from more + than one foundry and the foundry isn't specified, an arbitrary + foundry is chosen. If the family isn't available a family will be + set using the \l{QFont}{font matching} algorithm. \sa family(), QFontInfo */ diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp index 6d274c02f..7146ac0f0 100644 --- a/src/gui/text/qfont_x11.cpp +++ b/src/gui/text/qfont_x11.cpp @@ -88,7 +88,7 @@ FT_Face QFont::freetypeFace() const QString QFont::lastResortFamily() { - return QString::fromLatin1("Helvetica"); + return QString::fromLatin1("FreeSans"); } QT_END_NAMESPACE diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 8f36271dd..acb40c3e0 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -241,11 +241,10 @@ QString QFontDatabase::styleString(const QFontInfo &fontInfo) If the font family is available from two or more foundries the foundry name is included in the family name; for example: "Helvetica [Adobe]" and "Helvetica [Cronyx]". When you specify a - family, you can either use the old hyphenated "foundry-family" - format or the bracketed "family [foundry]" format; for example: - "Cronyx-Helvetica" or "Helvetica [Cronyx]". If the family has a - foundry it is always returned using the bracketed format, as is - the case with the value returned by families(). + family, you can either use "family [foundry]" format; for example: + "Helvetica [Cronyx]". If the family has a foundry it is always + returned using the bracketed format, as is the case with the + value returned by families(). The font() function returns a QFont given a family, style and point size. diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 65373c326..025955c28 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -1521,11 +1521,11 @@ static QByteArray charString(const QPainterPath &path, qreal advance, qreal lsb, return charstring; } -static const char *helvetica_styles[4] = { - "Helvetica", - "Helvetica-Bold", - "Helvetica-Oblique", - "Helvetica-BoldOblique" +static const char *freefont_styles[4] = { + "FreeSans", + "FreeSans-Bold", + "FreeSans-Oblique", + "FreeSans-BoldOblique" }; QByteArray QFontSubset::toType1() const @@ -1548,8 +1548,8 @@ QByteArray QFontSubset::toType1() const style += 2; if (fontEngine->fontDef.weight >= QFont::Bold) style++; - if (fontEngine->fontDef.family.contains(QLatin1String("Helvetica"))) { - psname = helvetica_styles[style]; + if (fontEngine->fontDef.family.contains(QLatin1String("FreeSans"))) { + psname = freefont_styles[style]; standard_font = true; } } diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp index 08adf1620..fdcd876e1 100644 --- a/src/gui/widgets/qfontcombobox.cpp +++ b/src/gui/widgets/qfontcombobox.cpp @@ -198,7 +198,7 @@ void QFontComboBoxPrivate::_q_currentChanged(const QString &text) \ingroup basicwidgets The combobox is populated with an alphabetized list of font - family names, such as Arial, Helvetica, and Times New Roman. + family names, such as FreeMono, FreeSans and FreeSerif. Family names are displayed using the actual font when possible. For fonts such as Symbol, where the name is not representable in the font itself, a sample of the font is displayed next to the diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index 9fd9618bf..9773e6d2b 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -166,8 +166,8 @@ void tst_QFontMetrics::elidedText_data() QTest::addColumn("font"); QTest::addColumn("text"); - QTest::newRow("helvetica hello") << QFont("helvetica",10) << QString("hello") ; - QTest::newRow("helvetica hello &Bye") << QFont("helvetica",10) << QString("hello&Bye") ; + QTest::newRow("freesans hello") << QFont("freesans",10) << QString("hello") ; + QTest::newRow("freesans hello &Bye") << QFont("freesans",10) << QString("hello&Bye") ; } -- 2.11.0