diff --git a/doc/snippets/plugins.cpp b/doc/snippets/plugins.cpp index bcd8e3754..24807f9fe 100644 --- a/doc/snippets/plugins.cpp +++ b/doc/snippets/plugins.cpp @@ -2,6 +2,8 @@ #include #include "Magnum/Text/AbstractFont.h" +#include "Magnum/Text/AbstractFontConverter.h" +#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImporter.h" #ifdef __has_include @@ -68,4 +70,20 @@ importer->configuration().group("postprocess")->setValue("PreTransformVertices", /* [configuration] */ } +{ +/* [MagnumFont-importer-register] */ +PluginManager::Manager importerManager; +PluginManager::Manager fontManager; +fontManager.registerExternalManager(importerManager); +/* [MagnumFont-importer-register] */ +} + +{ +/* [MagnumFontConverter-imageconverter-register] */ +PluginManager::Manager imageConverterManager; +PluginManager::Manager fontConverterManager; +fontConverterManager.registerExternalManager(imageConverterManager); +/* [MagnumFontConverter-imageconverter-register] */ +} + } diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.h b/src/MagnumPlugins/MagnumFont/MagnumFont.h index fe76a12f1..798433102 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.h +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.h @@ -144,6 +144,12 @@ find_package(Magnum REQUIRED MagnumFont) target_link_libraries(your-app PRIVATE Magnum::MagnumFont) @endcode +Because the plugin needs access to @ref Trade::AbstractImporter plugins, you +need to instantiate a manager for them and register it with +@ref Corrade::PluginManager::Manager::registerExternalManager(): + +@snippet plugins.cpp MagnumFont-importer-register + See @ref building, @ref cmake and @ref plugins for more information. */ class MAGNUM_MAGNUMFONT_EXPORT MagnumFont: public AbstractFont { diff --git a/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp b/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp index 191082c15..762759798 100644 --- a/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp +++ b/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp @@ -50,6 +50,7 @@ MagnumFontGLTest::MagnumFontGLTest() { /* Load the plugins directly from the build tree. Otherwise they're static and already loaded. */ + _fontManager.registerExternalManager(_importerManager); #if defined(TGAIMPORTER_PLUGIN_FILENAME) && defined(MAGNUMFONT_PLUGIN_FILENAME) CORRADE_INTERNAL_ASSERT_OUTPUT(_importerManager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); CORRADE_INTERNAL_ASSERT_OUTPUT(_fontManager.load(MAGNUMFONT_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); diff --git a/src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp b/src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp index be72bda16..220fd6783 100644 --- a/src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp +++ b/src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp @@ -64,6 +64,7 @@ MagnumFontTest::MagnumFontTest() { /* Load the plugins directly from the build tree. Otherwise they're static and already loaded. */ + _fontManager.registerExternalManager(_importerManager); #if defined(TGAIMPORTER_PLUGIN_FILENAME) && defined(MAGNUMFONT_PLUGIN_FILENAME) CORRADE_INTERNAL_ASSERT_OUTPUT(_importerManager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); CORRADE_INTERNAL_ASSERT_OUTPUT(_fontManager.load(MAGNUMFONT_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h index 54a07822f..7409fd649 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h @@ -87,6 +87,12 @@ find_package(Magnum REQUIRED MagnumFontConverter) target_link_libraries(your-app PRIVATE Magnum::MagnumFontConverter) @endcode +Because the plugin needs access to @ref Trade::AbstractImageConverter plugins, +you need to instantiate a manager for them and register it with +@ref Corrade::PluginManager::Manager::registerExternalManager(): + +@snippet plugins.cpp MagnumFontConverter-imageconverter-register + See @ref building, @ref cmake and @ref plugins for more information. */ class MAGNUM_MAGNUMFONTCONVERTER_EXPORT MagnumFontConverter: public Text::AbstractFontConverter { diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp b/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp index e7a3c0de9..0175cc05b 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp @@ -61,6 +61,7 @@ MagnumFontConverterTest::MagnumFontConverterTest() { /* Load the plugins directly from the build tree. Otherwise they are static and already loaded. */ + _fontConverterManager.registerExternalManager(_imageConverterManager); #if defined(TGAIMAGECONVERTER_PLUGIN_FILENAME) && defined(MAGNUMFONTCONVERTER_PLUGIN_FILENAME) CORRADE_INTERNAL_ASSERT_OUTPUT(_imageConverterManager.load(TGAIMAGECONVERTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); CORRADE_INTERNAL_ASSERT_OUTPUT(_fontConverterManager.load(MAGNUMFONTCONVERTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);