From 6ec1a10c47cbe62f139c1fdba09a574b6e4eb2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 28 Oct 2025 00:48:21 -0300 Subject: [PATCH] Minor changes in UIApplication. --- include/eepp/graphics/fonttruetype.hpp | 4 ++-- include/eepp/ui/uiapplication.hpp | 11 ++++++++--- src/eepp/ui/uiapplication.cpp | 17 +++++++++++++---- src/tests/unit_tests/utest.h | 8 ++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/include/eepp/graphics/fonttruetype.hpp b/include/eepp/graphics/fonttruetype.hpp index 2a669fc7b..315be30c6 100644 --- a/include/eepp/graphics/fonttruetype.hpp +++ b/include/eepp/graphics/fonttruetype.hpp @@ -150,6 +150,8 @@ class EE_API FontTrueType : public Font { void clearCache(); + Uint32 getGlyphIndex( const Uint32& codePoint ) const; + protected: friend class Text; @@ -193,8 +195,6 @@ class EE_API FontTrueType : public Font { bool bold, bool italic, Float outlineThickness, Page& page ) const; - Uint32 getGlyphIndex( const Uint32& codePoint ) const; - Glyph loadGlyphByIndex( Uint32 codePoint, unsigned int characterSize, bool bold, bool italic, Float outlineThickness, Page& page ) const; diff --git a/include/eepp/ui/uiapplication.hpp b/include/eepp/ui/uiapplication.hpp index 051ff290d..66a77eaa4 100644 --- a/include/eepp/ui/uiapplication.hpp +++ b/include/eepp/ui/uiapplication.hpp @@ -18,7 +18,8 @@ class EE_API UIApplication { Settings( std::optional basePath, std::optional pixelDensity = {}, bool loadBaseResources = true, Font* baseFont = nullptr, - std::optional baseStyleSheetPath = {}, Font* emojiFont = nullptr ); + std::optional baseStyleSheetPath = {}, Font* emojiFont = nullptr, + Font* fallbackFont = nullptr ); //! By default it will use the current process path as the base path. This will set the //! default working directory. @@ -37,9 +38,13 @@ class EE_API UIApplication { //! The style sheet path is the path of the base UI theme stylesheet ( will look at //! "assets/ui/breeze.css" by default ) std::optional baseStyleSheetPath; - //! The default emoji font for the UI. If not provided it will load NotoEmoji-Regular ( will - //! look at "assets/fonts/NotoEmoji-Regular.ttf" ) + //! The default emoji font for the UI. If not provided it will load Noto Color Emoji ( it + //! will look at "assets/fonts/NotoColorEmoji.ttf" ) otherwise it will try NotoEmoji-Regular + //! ( it will look at "assets/fonts/NotoEmoji-Regular.ttf" ) Font* emojiFont{ nullptr }; + //! The default fallback font for the UI. If not provided it will load Droid Sans Fallback + //! Full ( it will look at "assets/fonts/DroidSansFallbackFull.ttf" ) + Font* fallbackFont{ nullptr }; }; UIApplication( const WindowSettings& windowSettings, const Settings& appSettings = Settings(), diff --git a/src/eepp/ui/uiapplication.cpp b/src/eepp/ui/uiapplication.cpp index 193e25f3d..c7e75551a 100644 --- a/src/eepp/ui/uiapplication.cpp +++ b/src/eepp/ui/uiapplication.cpp @@ -67,8 +67,16 @@ UIApplication::UIApplication( const WindowSettings& windowSettings, const Settin FontFamily::loadFromRegular( static_cast( monospaceFont ) ); } - if ( appSettings.emojiFont == nullptr ) - FontTrueType::New( "NotoEmoji-Regular", "assets/fonts/NotoEmoji-Regular.ttf" ); + if ( appSettings.emojiFont == nullptr ) { + if ( FileSystem::fileExists( "assets/fonts/NotoColorEmoji.ttf" ) ) + FontTrueType::New( "NotoColorEmoji", "assets/fonts/NotoColorEmoji.ttf" ); + else if ( FileSystem::fileExists( "assets/fonts/NotoEmoji-Regular.ttf" ) ) + FontTrueType::New( "NotoEmoji-Regular", "assets/fonts/NotoEmoji-Regular.ttf" ); + } + + if ( appSettings.fallbackFont == nullptr && + FileSystem::fileExists( "assets/fonts/DroidSansFallbackFull.ttf" ) ) + FontTrueType::New( "DroidSansFallbackFull", "assets/fonts/DroidSansFallbackFull.ttf" ); mUISceneNode->getUIThemeManager()->setDefaultFont( font ); mUISceneNode->getRoot()->addClass( "appbackground" ); @@ -120,13 +128,14 @@ int UIApplication::run() { UIApplication::Settings::Settings( std::optional basePath, std::optional pixelDensity, bool loadBaseResources, Font* baseFont, std::optional baseStyleSheetPath, - Font* emojiFont ) : + Font* emojiFont, Font* fallbackFont ) : basePath( basePath ), pixelDensity( pixelDensity ), loadBaseResources( loadBaseResources ), baseFont( baseFont ), baseStyleSheetPath( baseStyleSheetPath ), - emojiFont( emojiFont ) {} + emojiFont( emojiFont ), + fallbackFont( fallbackFont ) {} void UIApplication::setShowMemoryManagerResult( bool show ) { mShowMemoryManagerResult = show; diff --git a/src/tests/unit_tests/utest.h b/src/tests/unit_tests/utest.h index 5dc25b14c..31ab9cc2a 100644 --- a/src/tests/unit_tests/utest.h +++ b/src/tests/unit_tests/utest.h @@ -1415,7 +1415,7 @@ int utest_main(int argc, const char *const argv[]) { size_t skipped_testcases_length = 0; const char *filter = UTEST_NULL; utest_uint64_t ran_tests = 0; - int enable_mixed_units = 0; + int enable_mixed_units = 1; int random_order = 0; utest_uint32_t seed = 0; @@ -1437,7 +1437,7 @@ int utest_main(int argc, const char *const argv[]) { /* Test config switches */ const char filter_str[] = "--filter="; const char output_str[] = "--output="; - const char enable_mixed_units_str[] = "--enable-mixed-units"; + const char enable_mixed_units_str[] = "--disable-mixed-units"; const char random_order_str[] = "--random-order"; const char random_order_with_seed_str[] = "--random-order="; @@ -1451,7 +1451,7 @@ int utest_main(int argc, const char *const argv[]) { "names can be passed to --filter.\n"); printf(" --output= Output an xunit XML file to the file " "specified in .\n" - " --enable-mixed-units Enable the per-test output to contain " + " --disable-mixed-units Disable the per-test output to contain " "mixed units (s/ms/us/ns).\n" " --random-order[=] Randomize the order that the tests are " "ran in. If the optional argument is not provided, then a " @@ -1472,7 +1472,7 @@ int utest_main(int argc, const char *const argv[]) { return 0; } else if (0 == UTEST_STRNCMP(argv[index], enable_mixed_units_str, strlen(enable_mixed_units_str))) { - enable_mixed_units = 1; + enable_mixed_units = 0; } else if (0 == UTEST_STRNCMP(argv[index], random_order_with_seed_str, strlen(random_order_with_seed_str))) { seed =