Browse Source

Text: allow empty files in AbstractFont.

In particular, MagnumFont can be an empty.
pull/325/head
Vladimír Vondruš 7 years ago
parent
commit
215d50a087
  1. 6
      doc/changelog.dox
  2. 5
      src/Magnum/Text/AbstractFont.cpp

6
doc/changelog.dox

@ -122,6 +122,12 @@ See also:
experience for example when using ANGLE on Windows. See
@ref Platform-Sdl2Application-usage-gles for more information.
@subsubsection changelog-latest-changes-text Text library
- For consistency with @ref Trade::AbstractImporter, @ref Text::AbstractFont
now doesn't fail when opening empty files --- instead this is handled in
the particular plugin implementations
@subsubsection changelog-latest-changes-trade Trade library
- The @ref Trade::AnyImageImporter "AnyImageImporter",

5
src/Magnum/Text/AbstractFont.cpp

@ -63,9 +63,10 @@ AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, const std::s
bool AbstractFont::openData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data, const Float size) {
CORRADE_ASSERT(features() & Feature::OpenData,
"Text::AbstractFont::openData(): feature not supported", false);
CORRADE_ASSERT(!data.empty(),
"Text::AbstractFont::openData(): no data passed", false);
/* We accept empty data here (instead of checking for them and failing so
the check doesn't be done on the plugin side) because for some file
formats it could be valid (MagnumFont in particular). */
close();
const Metrics metrics = doOpenData(data, size);
_size = metrics.size;

Loading…
Cancel
Save