migrate fonts to scoped resource ownership

- replace FontManager with per-ResourceScope FontService instances
  - publish font factories into explicit or default resource scopes
  - import default resources into UI scene scopes unless explicitly disabled
  - keep related font faces strongly owned without hot-path weak_ptr locking
  - add cached glyph advance queries without creating texture pages
  - fix font picker preview ownership, cleanup, and rapid switching
  - selectively evict TextLayout cache entries when referenced fonts unload
  - document FontService, ResourceCatalog, and cache invalidation semantics
  - migrate examples, tools, benchmarks, and tests to the scoped font API
  - expand coverage for font ownership, texture release, and layout caching
This commit is contained in:
Martín Lucas Golini
2026-07-24 01:54:51 -03:00
parent 24531b4411
commit 6b277e508b
83 changed files with 1940 additions and 828 deletions
+4 -4
View File
@@ -276,7 +276,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
FontTrueType* fontMono = nullptr;
if ( fontPath && FileSystem::fileExists( fontPath.Get() ) ) {
FileInfo file( fontPath.Get() );
fontMono = FontTrueType::New( "monospace" );
fontMono = FontTrueType::New( "monospace" ).get();
if ( fontMono->loadFromFile( file.getFilepath() ) ) {
FontFamily::loadFromRegular( fontMono );
} else {
@@ -284,7 +284,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
}
}
if ( fontMono == nullptr ) {
fontMono = FontTrueType::New( "monospace" );
fontMono = FontTrueType::New( "monospace" ).get();
fontMono->loadFromFile( resPath + "fonts/DejaVuSansMonoNerdFontComplete.ttf" );
FontFamily::loadFromRegular( fontMono, "DejaVuSansMono" );
}
@@ -301,9 +301,9 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
? fallbackFontPathF.Get()
: resPath + "fonts/DroidSansFallbackFull.ttf" );
if ( FileSystem::fileExists( fallbackFontPath ) ) {
FontTrueType* fallbackFont = FontTrueType::New( "fallback-font" );
FontTrueType* fallbackFont = FontTrueType::New( "fallback-font" ).get();
if ( fallbackFont->loadFromFile( fallbackFontPath ) )
FontManager::instance()->addFallbackFont( fallbackFont );
defaultResourceScope().getFontService().addFallbackFont( fallbackFont );
}
Float realMaxFPS = maxFPS.Get() ? maxFPS.Get() : currentDisplay->getRefreshRate();