Skip to content

Commit

Permalink
Cache Fonts metadata in FontPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
nieznanysprawiciel committed Nov 23, 2024
1 parent 253bd18 commit 6993601
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions swGraphicAPI/Assets/TextAsset/Loader/FontPicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,15 @@ Nullable< std::vector< FontSearchEntry > > FontPicker::ListFonts( PathsManager*
auto files = fs::Dir::ListFiles( dir );
for( auto& file : files )
{
if( m_metadataCache.find( file ) != m_metadataCache.end() )
continue;

auto meta = GetFontMetadata( pm, file );
if( meta.IsValid() )
{
entries.push_back( meta.Get() );
m_metadataCache[ file ] = meta.Get().Metadata;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion swGraphicAPI/Assets/TextAsset/Loader/FontPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class FontPicker
{
private:

std::vector< fs::Path > m_searchPaths;
std::vector< fs::Path > m_searchPaths;

mutable std::map< fs::Path, FontMetadata > m_metadataCache;

protected:
public:
Expand Down

0 comments on commit 6993601

Please sign in to comment.