From 6146d798fb07b40da15aef8ca4d54cacd8677eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 4 Jan 2023 02:58:09 -0300 Subject: [PATCH] Fixed FontTrueType::getGlyphDrawable. ecode: Added -V/--version command parameter. --- src/eepp/graphics/fonttruetype.cpp | 28 ++++++++++++++++++++++------ src/tools/ecode/ecode.cpp | 6 ++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/eepp/graphics/fonttruetype.cpp b/src/eepp/graphics/fonttruetype.cpp index 8c9b722fb..cfb38dc8e 100644 --- a/src/eepp/graphics/fonttruetype.cpp +++ b/src/eepp/graphics/fonttruetype.cpp @@ -466,6 +466,7 @@ GlyphDrawable* FontTrueType::getGlyphDrawable( Uint32 codePoint, unsigned int ch GlyphDrawableTable& drawables = page.drawables; Uint32 glyphIndex = 0; + Uint32 tGlyphIndex = 0; Uint32 fontInternalId = mFontInternalId; if ( mEnableEmojiFallback && Font::isEmojiCodePoint( codePoint ) && !mIsColorEmojiFont && @@ -474,14 +475,24 @@ GlyphDrawable* FontTrueType::getGlyphDrawable( Uint32 codePoint, unsigned int ch FontManager::instance()->getColorEmojiFont()->getType() == FontType::TTF ) { FontTrueType* fontEmoji = static_cast( FontManager::instance()->getColorEmojiFont() ); - glyphIndex = fontEmoji->getGlyphIndex( codePoint ); - fontInternalId = fontEmoji->getFontInternalId(); + tGlyphIndex = fontEmoji->getGlyphIndex( codePoint ); + if ( 0 != tGlyphIndex ) { + glyphIndex = tGlyphIndex; + fontInternalId = fontEmoji->getFontInternalId(); + } else { + glyphIndex = getGlyphIndex( codePoint ); + } } else if ( !mIsEmojiFont && FontManager::instance()->getEmojiFont() != nullptr && FontManager::instance()->getEmojiFont()->getType() == FontType::TTF ) { FontTrueType* fontEmoji = static_cast( FontManager::instance()->getEmojiFont() ); - glyphIndex = fontEmoji->getGlyphIndex( codePoint ); - fontInternalId = fontEmoji->getFontInternalId(); + tGlyphIndex = fontEmoji->getGlyphIndex( codePoint ); + if ( 0 != tGlyphIndex ) { + glyphIndex = tGlyphIndex; + fontInternalId = fontEmoji->getFontInternalId(); + } else { + glyphIndex = getGlyphIndex( codePoint ); + } } else { glyphIndex = getGlyphIndex( codePoint ); } @@ -494,8 +505,13 @@ GlyphDrawable* FontTrueType::getGlyphDrawable( Uint32 codePoint, unsigned int ch FontManager::instance()->getFallbackFont()->getType() == FontType::TTF ) { FontTrueType* fontFallback = static_cast( FontManager::instance()->getFallbackFont() ); - glyphIndex = fontFallback->getGlyphIndex( codePoint ); - fontInternalId = fontFallback->getFontInternalId(); + tGlyphIndex = fontFallback->getGlyphIndex( codePoint ); + if ( 0 != tGlyphIndex ) { + glyphIndex = tGlyphIndex; + fontInternalId = fontFallback->getFontInternalId(); + } else { + glyphIndex = getGlyphIndex( codePoint ); + } } Uint64 key = getIndexKey( fontInternalId, glyphIndex, bold, outlineThickness ); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 4fd8ed7bd..f1c930d0e 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -4106,6 +4106,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { { "benchmark-mode" } ); args::Flag verbose( parser, "verbose", "Print all logs to the standard output.", { 'v', "verbose" } ); + args::Flag version( parser, "version", "Prints version information", { 'V', "version" } ); try { parser.ParseCLI( Sys::parseArguments( argc, argv ) ); } catch ( const args::Help& ) { @@ -4121,6 +4122,11 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { return EXIT_FAILURE; } + if ( version.Get() ) { + std::cout << ecode::Version::getVersionName() << '\n'; + return EXIT_SUCCESS; + } + if ( verbose.Get() ) Log::instance()->setConsoleOutput( true );