Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Dec 27, 2024
1 parent 524ea4d commit 48772bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions include/eepp/graphics/fonttruetype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ class EE_API FontTrueType : public Font {

void clearCache();

void updateMonospaceState();

protected:
friend class Text;

Expand Down Expand Up @@ -229,6 +227,7 @@ class EE_API FontTrueType : public Font {
bool mEnableDynamicMonospace{ false };
bool mIsBold{ false };
bool mIsItalic{ false };
mutable bool mIsMonospaceCompletePending{ false };
mutable UnorderedMap<unsigned int, unsigned int> mClosestCharacterSize;
mutable UnorderedMap<Uint32, Uint32> mCodePointIndexCache;
mutable UnorderedMap<Uint32, std::tuple<Uint32, Uint32, bool>> mKeyCache;
Expand All @@ -244,6 +243,8 @@ class EE_API FontTrueType : public Font {
void updateFontInternalId();

bool setFontFace( void* face );

void updateMonospaceState() const;
};

}} // namespace EE::Graphics
Expand Down
9 changes: 7 additions & 2 deletions src/eepp/graphics/fonttruetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,8 @@ bool FontTrueType::isColorEmojiFont() const {
}

bool FontTrueType::isMonospace() const {
if ( mIsMonospaceCompletePending )
updateMonospaceState();
return mIsMonospaceComplete;
}

Expand All @@ -1422,10 +1424,13 @@ void FontTrueType::setBoldAdvanceSameAsRegular( bool boldAdvanceSameAsRegular )
mBoldAdvanceSameAsRegular = boldAdvanceSameAsRegular;
}

void FontTrueType::updateMonospaceState() {
void FontTrueType::updateMonospaceState() const {
mIsMonospaceComplete = mIsMonospace && !mUsingFallback;
if ( !Engine::isEngineRunning() )
if ( !Engine::isEngineRunning() || !Engine::instance()->isMainThread() ) {
mIsMonospaceCompletePending = true;
return;
}
mIsMonospaceCompletePending = false;
if ( mIsMonospaceComplete && mFontBold != nullptr ) {
mIsMonospaceComplete = mIsMonospaceComplete && mFontBold->isMonospace() &&
getGlyph( ' ', 10, false, false ).advance ==
Expand Down
5 changes: 0 additions & 5 deletions src/tools/ecode/ecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3661,11 +3661,6 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
return;
}

FontManager::instance()->each( []( auto& font ) {
if ( font.second->getType() == FontType::TTF )
static_cast<FontTrueType*>( font.second )->updateMonospaceState();
} );

SceneManager::instance()->add( mUISceneNode );

setTheme( getThemePath() );
Expand Down
2 changes: 1 addition & 1 deletion src/tools/ecode/plugins/lsp/lspdocumentclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void LSPDocumentClient::highlight() {
[this, firstLine, lastLine]( UICodeEditor* editor ) {
if ( editor->isVisible() && &editor->getDocument() == mDoc &&
editor->getVisibleRange().intersectsLineRange( firstLine, lastLine ) ) {
editor->invalidateDraw();
editor->runOnMainThread( [editor] { editor->invalidateDraw(); } );
}
} );
}
Expand Down

0 comments on commit 48772bc

Please sign in to comment.