From a5d7a5114bf38eca69e7eefe602cd24e4e8a93d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 11 Nov 2023 12:52:33 -0300 Subject: [PATCH] Update efsw. Minor improvements in FontFamily. Added "readonly" keyword in TypeScript. --- include/eepp/graphics/fontfamily.hpp | 5 ++-- src/eepp/graphics/fontfamily.cpp | 32 ++++++++++++++------- src/eepp/ui/doc/syntaxdefinitionmanager.cpp | 2 +- src/thirdparty/efsw | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/include/eepp/graphics/fontfamily.hpp b/include/eepp/graphics/fontfamily.hpp index e2196940d..734296210 100644 --- a/include/eepp/graphics/fontfamily.hpp +++ b/include/eepp/graphics/fontfamily.hpp @@ -11,10 +11,11 @@ class EE_API FontFamily { private: static std::string findType( const std::string& fontpath, const std::string& fontname, - const std::string& ext, const std::vector& names ); + const std::string& ext, + const std::vector& names ); static FontTrueType* setFont( FontTrueType* font, const std::string& fontpath, - const std::string& fontType ); + const std::string_view& fontType ); }; }} // namespace EE::Graphics diff --git a/src/eepp/graphics/fontfamily.cpp b/src/eepp/graphics/fontfamily.cpp index 4a7288330..6848a1d81 100644 --- a/src/eepp/graphics/fontfamily.cpp +++ b/src/eepp/graphics/fontfamily.cpp @@ -1,6 +1,8 @@ #include #include +using namespace std::literals; + namespace EE { namespace Graphics { void FontFamily::loadFromRegular( FontTrueType* font, std::string overwriteFontName ) { @@ -17,42 +19,50 @@ void FontFamily::loadFromRegular( FontTrueType* font, std::string overwriteFontN if ( String::endsWith( fontname, "-Regular" ) || String::endsWith( fontname, "-regular" ) ) { auto pos( fontname.find_last_of( '-' ) ); fontname.resize( pos ); + } else if ( String::endsWith( fontname, "Rg" ) ) { + fontname.resize( fontname.size() - 2 ); } - setFont( font, findType( font->getInfo().fontpath, fontname, ext, { "Bold", "bold" } ), - "bold" ); + setFont( font, + findType( font->getInfo().fontpath, fontname, ext, { "Bold"sv, "bold"sv, "Bd"sv } ), + "bold"sv ); setFont( font, findType( font->getInfo().fontpath, fontname, ext, { "Italic", "Oblique", "italic", "oblique", "It", "it" } ), - "italic" ); + "italic"sv ); - setFont( font, - findType( font->getInfo().fontpath, fontname, ext, { "BoldItalic", "BoldOblique" } ), - "bolditalic" ); + setFont( + font, + findType( font->getInfo().fontpath, fontname, ext, { "BoldItalic"sv, "BoldOblique"sv } ), + "bolditalic"sv ); } std::string FontFamily::findType( const std::string& fontpath, const std::string& fontname, - const std::string& ext, const std::vector& names ) { + const std::string& ext, + const std::vector& names ) { std::string path; for ( const auto& name : names ) { path = fontpath + fontname + "-" + name + "." + ext; if ( FileSystem::fileExists( path ) ) return path; + path = fontpath + fontname + name + "." + ext; + if ( FileSystem::fileExists( path ) ) + return path; } return ""; } FontTrueType* FontFamily::setFont( FontTrueType* font, const std::string& fontpath, - const std::string& fontType ) { + const std::string_view& fontType ) { if ( fontpath.empty() ) return nullptr; FontTrueType* loadedFont = FontTrueType::New( font->getName() + "-" + fontType, fontpath ); - if ( fontType == "bold" ) + if ( fontType == "bold"sv ) font->setBoldFont( loadedFont ); - else if ( fontType == "italic" ) + else if ( fontType == "italic"sv ) font->setItalicFont( loadedFont ); - else if ( fontType == "bolditalic" ) + else if ( fontType == "bolditalic"sv ) font->setBoldItalicFont( loadedFont ); loadedFont->setBoldAdvanceSameAsRegular( font->getBoldAdvanceSameAsRegular() ); loadedFont->setEnableDynamicMonospace( font->getEnableDynamicMonospace() ); diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index c8299767e..1cc346f71 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -249,7 +249,7 @@ static void addTypeScript() { { "type", "keyword2" }, { "typeof", "keyword" }, { "undefined", "literal" }, { "var", "keyword" }, { "void", "keyword" }, { "while", "keyword" }, { "with", "keyword" }, { "yield", "keyword" }, { "unknown", "keyword2" }, - { "namespace", "keyword" }, { "abstract", "keyword" } }, + { "namespace", "keyword" }, { "abstract", "keyword" }, { "readonly", "keyword" } }, "//" } ); SyntaxDefinitionManager::instance() diff --git a/src/thirdparty/efsw b/src/thirdparty/efsw index 2445f5526..aae269e0b 160000 --- a/src/thirdparty/efsw +++ b/src/thirdparty/efsw @@ -1 +1 @@ -Subproject commit 2445f5526812d2aa6fb198c41ba8a928db249bb6 +Subproject commit aae269e0be36292e4e5e1bb7f8672ca456fba956