- Segoe fonts added
- compiling all fonts into the support lib - fontconfig hacks removed
This commit is contained in:
parent
8fd8034d2a
commit
5dfcbf8cfa
|
@ -100,8 +100,8 @@
|
||||||
#include <QskNamespace.h>
|
#include <QskNamespace.h>
|
||||||
#include <QskPlatform.h>
|
#include <QskPlatform.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <qguiapplication.h>
|
||||||
#include <QScreen>
|
#include <qfontinfo.h>
|
||||||
|
|
||||||
namespace Fluent2
|
namespace Fluent2
|
||||||
{
|
{
|
||||||
|
@ -2050,7 +2050,19 @@ static inline QFont createFont( int size, int lineHeight, QFont::Weight weight )
|
||||||
"This value is always equal to leading()+height()"
|
"This value is always equal to leading()+height()"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QFont font( QStringLiteral( "Segoe UI Variable" ), -1, weight );
|
QFont font( QStringLiteral( "Segoe UI" ), -1, weight );
|
||||||
|
|
||||||
|
static bool checkFont = true;
|
||||||
|
if ( checkFont )
|
||||||
|
{
|
||||||
|
const QFontInfo info( font );
|
||||||
|
if ( info.family() != font.family() )
|
||||||
|
{
|
||||||
|
qWarning() << font.family() <<
|
||||||
|
"not found, using" << info.family() << "instead.";
|
||||||
|
}
|
||||||
|
checkFont = false;
|
||||||
|
}
|
||||||
|
|
||||||
// sp: this is like the dp unit, but it is also scaled by the user's font size preference
|
// sp: this is like the dp unit, but it is also scaled by the user's font size preference
|
||||||
font.setPixelSize( pixelSize );
|
font.setPixelSize( pixelSize );
|
||||||
|
|
|
@ -56,8 +56,8 @@
|
||||||
#include <QskNamespace.h>
|
#include <QskNamespace.h>
|
||||||
#include <QskPlatform.h>
|
#include <QskPlatform.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <qguiapplication.h>
|
||||||
#include <QScreen>
|
#include <qfontinfo.h>
|
||||||
|
|
||||||
static const int qskDuration = 150;
|
static const int qskDuration = 150;
|
||||||
|
|
||||||
|
@ -1444,6 +1444,19 @@ static inline QFont createFont( int size, int lineHeight,
|
||||||
const int pixelSize = qRound( qskDpToPixels( lineHeight ) );
|
const int pixelSize = qRound( qskDpToPixels( lineHeight ) );
|
||||||
|
|
||||||
QFont font( QStringLiteral( "Roboto" ), -1, weight );
|
QFont font( QStringLiteral( "Roboto" ), -1, weight );
|
||||||
|
|
||||||
|
static bool checkFont = true;
|
||||||
|
if ( checkFont )
|
||||||
|
{
|
||||||
|
const QFontInfo info( font );
|
||||||
|
if ( info.family() != font.family() )
|
||||||
|
{
|
||||||
|
qWarning() << font.family() <<
|
||||||
|
"not found, using" << info.family() << "instead.";
|
||||||
|
}
|
||||||
|
checkFont = false;
|
||||||
|
}
|
||||||
|
|
||||||
font.setPixelSize( pixelSize );
|
font.setPixelSize( pixelSize );
|
||||||
|
|
||||||
if ( spacing > 0.0 )
|
if ( spacing > 0.0 )
|
||||||
|
|
|
@ -72,8 +72,7 @@ void Skin::initHints()
|
||||||
{
|
{
|
||||||
const auto palette = Skin::palette( colorScheme() );
|
const auto palette = Skin::palette( colorScheme() );
|
||||||
|
|
||||||
QFontDatabase db;
|
QFontDatabase::addApplicationFont( ":/fonts/ProximaNova-Regular.otf" );
|
||||||
db.addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); // ### use fontconfig
|
|
||||||
|
|
||||||
setFont( { QskFontRole::Caption, QskFontRole::Low }, createFont( 9 ) );
|
setFont( { QskFontRole::Caption, QskFontRole::Low }, createFont( 9 ) );
|
||||||
setFont( { QskFontRole::Caption, QskFontRole::Normal }, createFont( 10 ) );
|
setFont( { QskFontRole::Caption, QskFontRole::Normal }, createFont( 10 ) );
|
||||||
|
|
|
@ -11,6 +11,8 @@ set(SOURCES
|
||||||
SkinnyShortcut.h SkinnyShortcut.cpp
|
SkinnyShortcut.h SkinnyShortcut.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_add_resources(SOURCES fonts.qrc)
|
||||||
|
|
||||||
set(target qsktestsupport)
|
set(target qsktestsupport)
|
||||||
|
|
||||||
if (BUILD_QSKDLL)
|
if (BUILD_QSKDLL)
|
||||||
|
@ -32,30 +34,8 @@ target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
if(ENABLE_ENSURE_SKINS)
|
if(ENABLE_ENSURE_SKINS)
|
||||||
target_include_directories(${target} PRIVATE ${QSK_SOURCE_DIR}/designsystems)
|
target_include_directories(${target} PRIVATE ${QSK_SOURCE_DIR}/designsystems)
|
||||||
target_compile_definitions(${target} PRIVATE ENSURE_SKINS)
|
target_compile_definitions(${target} PRIVATE ENSURE_SKINS ENSURE_FONTS)
|
||||||
target_link_libraries(${target} PRIVATE material3skin fluent2skin fusionskin)
|
target_link_libraries(${target} PRIVATE material3skin fluent2skin fusionskin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HIDE_SYSTEM_FONTS ON)
|
|
||||||
|
|
||||||
if(HIDE_SYSTEM_FONTS)
|
|
||||||
message( STATUS "Hiding system fonts from the examples" )
|
|
||||||
|
|
||||||
# The fonts being used in the examples are included and we do not
|
|
||||||
# need the fonts from the system. To avoid, that setting up the font
|
|
||||||
# cache slows doesn the stratup performance we hide the system fonts
|
|
||||||
# be using a dummy font config environment.
|
|
||||||
# ( this hack is pretty old ( Qt 5.4 ) - maybe it is not needed anymore TODO )
|
|
||||||
|
|
||||||
set(QSK_FONTDIR ${CMAKE_CURRENT_LIST_DIR}/fonts)
|
|
||||||
set(QSK_FONTCACHEDIR ${CMAKE_CURRENT_BINARY_DIR}/fontconfig)
|
|
||||||
set(QSK_FONTCONF_FILE ${QSK_FONTCACHEDIR}/fonts.conf)
|
|
||||||
|
|
||||||
configure_file(fonts.conf.cmake.in ${QSK_FONTCONF_FILE}
|
|
||||||
@ONLY NEWLINE_STYLE LF)
|
|
||||||
|
|
||||||
target_compile_definitions(${target}
|
|
||||||
PRIVATE FONTCONFIG_FILE=${QSK_FONTCONF_FILE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${target} PROPERTIES FOLDER libs)
|
set_target_properties(${target} PROPERTIES FOLDER libs)
|
||||||
|
|
|
@ -11,16 +11,12 @@
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QDir>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
|
||||||
#define STRING(x) STRINGIFY(x)
|
|
||||||
|
|
||||||
#if defined( PLUGIN_PATH )
|
#if defined( PLUGIN_PATH )
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define STRING(x) STRINGIFY(x)
|
#define STRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
|
@ -77,58 +73,30 @@ static bool pluginPath = initPluginPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_COREAPP_STARTUP_FUNCTION( initSkins )
|
Q_COREAPP_STARTUP_FUNCTION( initSkins )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ENSURE_FONTS
|
|
||||||
|
|
||||||
#if defined( ENSURE_FONTS )
|
#if defined( ENSURE_FONTS )
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
#include <QFontDatabase>
|
||||||
#include <QFontDatabase>
|
|
||||||
#include <QElapsedTimer>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void preloadFonts()
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
|
|
||||||
QFontDatabase(); // deprecated and doing nothing since Qt6
|
|
||||||
|
|
||||||
const auto elapsed = timer.elapsed();
|
|
||||||
|
|
||||||
if ( elapsed > 20 )
|
|
||||||
{
|
|
||||||
qWarning() << "Loading fonts needed" << elapsed << "ms"
|
|
||||||
<< "- usually because of creating a font cache.";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void initFonts()
|
static void initFonts()
|
||||||
{
|
{
|
||||||
if ( !qobject_cast< QGuiApplication* >( qApp ) )
|
const QString path = QStringLiteral( ":/fonts/" );
|
||||||
return; // no fonts needed
|
|
||||||
|
|
||||||
#ifdef FONTCONFIG_FILE
|
QDir dir( path );
|
||||||
const char env[] = "FONTCONFIG_FILE";
|
const auto fontFiles = dir.entryList();
|
||||||
if ( !qEnvironmentVariableIsSet( env ) )
|
|
||||||
qputenv( env, STRING( FONTCONFIG_FILE ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
preloadFonts();
|
for ( const auto& file : fontFiles )
|
||||||
|
{
|
||||||
/*
|
const auto fontPath = path + file;
|
||||||
The default initialization in QskSkin sets up its font table
|
if ( QFontDatabase::addApplicationFont( fontPath ) < 0 )
|
||||||
with using the application font for the default font role.
|
qWarning() << "couldn't load font file:" << fontPath;
|
||||||
*/
|
}
|
||||||
QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) );
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
Q_COREAPP_STARTUP_FUNCTION( initFonts )
|
Q_COREAPP_STARTUP_FUNCTION( initFonts )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void Skinny::changeSkin()
|
void Skinny::changeSkin()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
||||||
<fontconfig>
|
|
||||||
<dir>@QSK_FONTDIR@</dir>
|
|
||||||
<cachedir>@QSK_FONTCACHEDIR@/cache</cachedir>
|
|
||||||
</fontconfig>
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/fonts">
|
||||||
|
|
||||||
|
<file alias="DejaVuSans.ttf">fonts/DejaVuSans/DejaVuSans.ttf</file>
|
||||||
|
|
||||||
|
<file alias="Roboto-BlackItalic.ttf">fonts/Roboto/Roboto-BlackItalic.ttf</file>
|
||||||
|
<file alias="Roboto-Black.ttf">fonts/Roboto/Roboto-Black.ttf</file>
|
||||||
|
<file alias="Roboto-BoldItalic.ttf">fonts/Roboto/Roboto-BoldItalic.ttf</file>
|
||||||
|
<file alias="Roboto-Bold.ttf">fonts/Roboto/Roboto-Bold.ttf</file>
|
||||||
|
<file alias="Roboto-Italic.ttf">fonts/Roboto/Roboto-Italic.ttf</file>
|
||||||
|
<file alias="Roboto-LightItalic.ttf">fonts/Roboto/Roboto-LightItalic.ttf</file>
|
||||||
|
<file alias="Roboto-Light.ttf">fonts/Roboto/Roboto-Light.ttf</file>
|
||||||
|
<file alias="Roboto-MediumItalic.ttf">fonts/Roboto/Roboto-MediumItalic.ttf</file>
|
||||||
|
<file alias="Roboto-Medium.ttf">fonts/Roboto/Roboto-Medium.ttf</file>
|
||||||
|
<file alias="Roboto-Regular.ttf">fonts/Roboto/Roboto-Regular.ttf</file>
|
||||||
|
<file alias="Roboto-ThinItalic.ttf">fonts/Roboto/Roboto-ThinItalic.ttf</file>
|
||||||
|
<file alias="Roboto-Thin.ttf">fonts/Roboto/Roboto-Thin.ttf</file>
|
||||||
|
|
||||||
|
<file alias="segoeuib.ttf">fonts/SegoeUI/segoeuib.ttf</file>
|
||||||
|
<file alias="segoeuii.ttf">fonts/SegoeUI/segoeuii.ttf</file>
|
||||||
|
<file alias="segoeuil.ttf">fonts/SegoeUI/segoeuil.ttf</file>
|
||||||
|
<file alias="segoeuisl.ttf">fonts/SegoeUI/segoeuisl.ttf</file>
|
||||||
|
<file alias="segoeui.ttf">fonts/SegoeUI/segoeui.ttf</file>
|
||||||
|
<file alias="segoeuiz.ttf">fonts/SegoeUI/segoeuiz.ttf</file>
|
||||||
|
<file alias="seguibli.ttf">fonts/SegoeUI/seguibli.ttf</file>
|
||||||
|
<file alias="seguibl.ttf">fonts/SegoeUI/seguibl.ttf</file>
|
||||||
|
<file alias="seguiemj.ttf">fonts/SegoeUI/seguiemj.ttf</file>
|
||||||
|
<file alias="seguihis.ttf">fonts/SegoeUI/seguihis.ttf</file>
|
||||||
|
<file alias="seguili.ttf">fonts/SegoeUI/seguili.ttf</file>
|
||||||
|
<file alias="seguisbi.ttf">fonts/SegoeUI/seguisbi.ttf</file>
|
||||||
|
<file alias="seguisb.ttf">fonts/SegoeUI/seguisb.ttf</file>
|
||||||
|
<file alias="seguisli.ttf">fonts/SegoeUI/seguisli.ttf</file>
|
||||||
|
<file alias="seguisym.ttf">fonts/SegoeUI/seguisym.ttf</file>
|
||||||
|
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -1 +0,0 @@
|
||||||
For the Noto fonts see: https://www.google.com/get/noto/
|
|
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
For the Segue-UI fonts on Linux see: https://github.com/mrbvrz/segoe-ui-linux
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue