std::pair<Float, Float> MagnumFont::doOpenData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data, const Float) { /* We need just the configuration file and image file */ if(data.size() != 2) { Error() << "Text::MagnumFont::openData(): wanted two files, got" << data.size(); return {}; } /* Open the configuration file */ std::istringstream in({reinterpret_cast<const char*>(data[0].second.begin()), data[0].second.size()}); Utility::Configuration conf(in, Utility::Configuration::Flag::SkipComments); if(!conf.isValid() || conf.isEmpty()) { Error() << "Text::MagnumFont::openData(): cannot open file" << data[0].first; return {}; } /* Check version */ if(conf.value<UnsignedInt>("version") != 1) { Error() << "Text::MagnumFont::openData(): unsupported file version, expected 1 but got" << conf.value<UnsignedInt>("version"); return {}; } /* Check that we have also the image file */ if(conf.value("image") != data[1].first) { Error() << "Text::MagnumFont::openData(): expected file" << conf.value("image") << "but got" << data[1].first; return {}; } /* Open and load image file */ Trade::TgaImporter importer; if(!importer.openData(data[1].second)) { Error() << "Text::MagnumFont::openData(): cannot open image file"; return {}; } std::optional<Trade::ImageData2D> image = importer.image2D(0); if(!image) { Error() << "Text::MagnumFont::openData(): cannot load image file"; return {}; } return openInternal(std::move(conf), std::move(*image)); }