mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-29 17:46:29 +03:00
Update efsw.
Minor improvements in FontFamily. Added "readonly" keyword in TypeScript.
This commit is contained in:
@@ -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<std::string>& names );
|
||||
const std::string& ext,
|
||||
const std::vector<std::string_view>& names );
|
||||
|
||||
static FontTrueType* setFont( FontTrueType* font, const std::string& fontpath,
|
||||
const std::string& fontType );
|
||||
const std::string_view& fontType );
|
||||
};
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <eepp/graphics/fontfamily.hpp>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
|
||||
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<std::string>& names ) {
|
||||
const std::string& ext,
|
||||
const std::vector<std::string_view>& 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() );
|
||||
|
||||
@@ -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()
|
||||
|
||||
2
src/thirdparty/efsw
vendored
2
src/thirdparty/efsw
vendored
Submodule src/thirdparty/efsw updated: 2445f55268...aae269e0be
Reference in New Issue
Block a user