- 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 <QskPlatform.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <qguiapplication.h>
|
||||
#include <qfontinfo.h>
|
||||
|
||||
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()"
|
||||
*/
|
||||
|
||||
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
|
||||
font.setPixelSize( pixelSize );
|
||||
|
@ -56,8 +56,8 @@
|
||||
#include <QskNamespace.h>
|
||||
#include <QskPlatform.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <qguiapplication.h>
|
||||
#include <qfontinfo.h>
|
||||
|
||||
static const int qskDuration = 150;
|
||||
|
||||
@ -1444,6 +1444,19 @@ static inline QFont createFont( int size, int lineHeight,
|
||||
const int pixelSize = qRound( qskDpToPixels( lineHeight ) );
|
||||
|
||||
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 );
|
||||
|
||||
if ( spacing > 0.0 )
|
||||
|
@ -72,8 +72,7 @@ void Skin::initHints()
|
||||
{
|
||||
const auto palette = Skin::palette( colorScheme() );
|
||||
|
||||
QFontDatabase db;
|
||||
db.addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); // ### use fontconfig
|
||||
QFontDatabase::addApplicationFont( ":/fonts/ProximaNova-Regular.otf" );
|
||||
|
||||
setFont( { QskFontRole::Caption, QskFontRole::Low }, createFont( 9 ) );
|
||||
setFont( { QskFontRole::Caption, QskFontRole::Normal }, createFont( 10 ) );
|
||||
|
@ -11,6 +11,8 @@ set(SOURCES
|
||||
SkinnyShortcut.h SkinnyShortcut.cpp
|
||||
)
|
||||
|
||||
qt_add_resources(SOURCES fonts.qrc)
|
||||
|
||||
set(target qsktestsupport)
|
||||
|
||||
if (BUILD_QSKDLL)
|
||||
@ -32,30 +34,8 @@ target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if(ENABLE_ENSURE_SKINS)
|
||||
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)
|
||||
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)
|
||||
|
@ -11,16 +11,12 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
#include <QFont>
|
||||
#include <QDebug>
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define STRING(x) STRINGIFY(x)
|
||||
|
||||
#if defined( PLUGIN_PATH )
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define STRING(x) STRINGIFY(x)
|
||||
|
||||
@ -77,58 +73,30 @@ static bool pluginPath = initPluginPath();
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION( initSkins )
|
||||
|
||||
#endif
|
||||
|
||||
#define ENSURE_FONTS
|
||||
|
||||
#if defined( ENSURE_FONTS )
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
||||
#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
|
||||
}
|
||||
#include <QFontDatabase>
|
||||
|
||||
static void initFonts()
|
||||
{
|
||||
if ( !qobject_cast< QGuiApplication* >( qApp ) )
|
||||
return; // no fonts needed
|
||||
const QString path = QStringLiteral( ":/fonts/" );
|
||||
|
||||
#ifdef FONTCONFIG_FILE
|
||||
const char env[] = "FONTCONFIG_FILE";
|
||||
if ( !qEnvironmentVariableIsSet( env ) )
|
||||
qputenv( env, STRING( FONTCONFIG_FILE ) );
|
||||
#endif
|
||||
QDir dir( path );
|
||||
const auto fontFiles = dir.entryList();
|
||||
|
||||
preloadFonts();
|
||||
|
||||
/*
|
||||
The default initialization in QskSkin sets up its font table
|
||||
with using the application font for the default font role.
|
||||
*/
|
||||
QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) );
|
||||
for ( const auto& file : fontFiles )
|
||||
{
|
||||
const auto fontPath = path + file;
|
||||
if ( QFontDatabase::addApplicationFont( fontPath ) < 0 )
|
||||
qWarning() << "couldn't load font file:" << fontPath;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION( initFonts )
|
||||
Q_COREAPP_STARTUP_FUNCTION( initFonts )
|
||||
|
||||
#endif
|
||||
|
||||
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>
|
36
support/fonts.qrc
Normal file
36
support/fonts.qrc
Normal file
@ -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.
1
support/fonts/SegoeUI/LICENSE.txt
Normal file
1
support/fonts/SegoeUI/LICENSE.txt
Normal file
@ -0,0 +1 @@
|
||||
For the Segue-UI fonts on Linux see: https://github.com/mrbvrz/segoe-ui-linux
|
0
support/fonts/SegoeUI/README
Normal file
0
support/fonts/SegoeUI/README
Normal file
BIN
support/fonts/SegoeUI/segoeui.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeui.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/segoeuib.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeuib.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/segoeuii.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeuii.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/segoeuil.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeuil.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/segoeuisl.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeuisl.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/segoeuiz.ttf
Executable file
BIN
support/fonts/SegoeUI/segoeuiz.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguibl.ttf
Executable file
BIN
support/fonts/SegoeUI/seguibl.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguibli.ttf
Executable file
BIN
support/fonts/SegoeUI/seguibli.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguiemj.ttf
Executable file
BIN
support/fonts/SegoeUI/seguiemj.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguihis.ttf
Executable file
BIN
support/fonts/SegoeUI/seguihis.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguili.ttf
Executable file
BIN
support/fonts/SegoeUI/seguili.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguisb.ttf
Executable file
BIN
support/fonts/SegoeUI/seguisb.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguisbi.ttf
Executable file
BIN
support/fonts/SegoeUI/seguisbi.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguisli.ttf
Executable file
BIN
support/fonts/SegoeUI/seguisli.ttf
Executable file
Binary file not shown.
BIN
support/fonts/SegoeUI/seguisym.ttf
Executable file
BIN
support/fonts/SegoeUI/seguisym.ttf
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user