mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
clarify FontTrueType scope ownership
Document that a FontTrueType can be locally associated with only one ResourceScope and that catalog imports should be used to share fonts between scopes. Note the current single FontService pointer limitation and the possible future direction of moving fallback resolution out of shared fonts.
This commit is contained in:
@@ -24,6 +24,10 @@ struct FontDesc;
|
||||
*
|
||||
* Rendering policy changes are applied to TrueType fonts associated with this service. Imported
|
||||
* fonts remain associated with the service of their owning scope and are therefore not mutated.
|
||||
* A FontTrueType stores one borrowed FontService pointer, so the same FontTrueType instance must
|
||||
* not be published locally into multiple scopes: the latest publication would replace its service
|
||||
* association. Share such a font by importing its owning catalog instead. A future design may move
|
||||
* fallback resolution entirely out of the shared font object and remove this restriction.
|
||||
*
|
||||
* System fonts can be loaded with two different lifetime contracts:
|
||||
* - loadSystemFont() returns an independently owned, uncached font.
|
||||
|
||||
@@ -70,6 +70,9 @@ class EE_API ResourceScope {
|
||||
* @brief Publishes a font under @p key, replacing any existing local binding for that key.
|
||||
*
|
||||
* The requested semantic key is preserved. Fonts are never renamed to avoid a collision.
|
||||
* A FontTrueType instance can belong locally to only one ResourceScope because it has one
|
||||
* FontService association. To expose the same font to another scope, import this scope's local
|
||||
* catalog instead of publishing the same handle locally again.
|
||||
*/
|
||||
void publishLocalFont( ResourceKey key, FontPtr font );
|
||||
void publishLocalFont( std::string key, FontPtr font );
|
||||
|
||||
@@ -24,6 +24,10 @@ ResourceScope::~ResourceScope() {
|
||||
}
|
||||
|
||||
void ResourceScope::attachFontService( const FontPtr& font ) {
|
||||
// FontTrueType currently carries one borrowed service pointer. Catalog imports deliberately do
|
||||
// not call this function; sharing must preserve the service of the font's owning local scope.
|
||||
// Moving fallback resolution out of FontTrueType would allow true multi-scope local
|
||||
// publication.
|
||||
if ( font && font->getType() == FontType::TTF )
|
||||
static_cast<FontTrueType*>( font.get() )->setFontService( &mFontService );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user