Browse Source

Text: various minor cleanup.

pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
cec98b5278
  1. 188
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  2. 14
      src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp
  3. 18
      src/Magnum/Text/Test/AbstractLayouterTest.cpp
  4. 2
      src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp
  5. 4
      src/Magnum/Text/Test/GlyphCacheGLTest.cpp
  6. 20
      src/Magnum/Text/Test/RendererGLTest.cpp
  7. 18
      src/Magnum/Text/fontconverter.cpp

188
src/Magnum/Text/Test/AbstractFontConverterTest.cpp

@ -47,49 +47,42 @@ struct AbstractFontConverterTest: TestSuite::Tester {
void convertGlyphs();
void thingNotSupported();
void exportFontToSingleData();
void exportFontToSingleDataNotSupported();
void exportFontToSingleDataNotImplemented();
void exportFontToSingleDataNotSingleFile();
void exportFontToData();
void exportFontToDataNotSupported();
void exportFontToDataNotImplemented();
void exportFontToDataThroughSingleData();
void exportFontToDataThroughSingleDataFailed();
void exportFontToFile();
void exportFontToFileNotSupported();
void exportFontToFileNotImplemented();
void exportFontToFileThroughData();
void exportFontToFileThroughDataFailed();
void exportFontToFileThroughDataNotWritable();
void exportGlyphCacheToSingleData();
void exportGlyphCacheToSingleDataNotSupported();
void exportGlyphCacheToSingleDataNotImplemented();
void exportGlyphCacheToSingleDataNotSingleFile();
void exportGlyphCacheToData();
void exportGlyphCacheToDataNotSupported();
void exportGlyphCacheToDataNotImplemented();
void exportGlyphCacheToDataThroughSingleData();
void exportGlyphCacheToDataThroughSingleDataFailed();
void exportGlyphCacheToFile();
void exportGlyphCacheToFileNotSupported();
void exportGlyphCacheToFileNotImplemented();
void exportGlyphCacheToFileThroughData();
void exportGlyphCacheToFileThroughDataFailed();
void exportGlyphCacheToFileThroughDataNotWritable();
void importGlyphCacheFromSingleData();
void importGlyphCacheFromSingleDataNotSupported();
void importGlyphCacheFromSingleDataNotImplemented();
void importGlyphCacheFromSingleDataNotSingleFile();
void importGlyphCacheFromData();
void importGlyphCacheFromDataNoData();
void importGlyphCacheFromDataNotSupported();
void importGlyphCacheFromDataNotImplemented();
void importGlyphCacheFromDataAsSingleData();
void importGlyphCacheFromFile();
void importGlyphCacheFromFileNotSupported();
void importGlyphCacheFromFileNotImplemented();
void importGlyphCacheFromFileAsSingleData();
void importGlyphCacheFromFileAsSingleDataNotFound();
@ -103,49 +96,42 @@ struct AbstractFontConverterTest: TestSuite::Tester {
AbstractFontConverterTest::AbstractFontConverterTest() {
addTests({&AbstractFontConverterTest::convertGlyphs,
&AbstractFontConverterTest::thingNotSupported,
&AbstractFontConverterTest::exportFontToSingleData,
&AbstractFontConverterTest::exportFontToSingleDataNotSupported,
&AbstractFontConverterTest::exportFontToSingleDataNotImplemented,
&AbstractFontConverterTest::exportFontToSingleDataNotSingleFile,
&AbstractFontConverterTest::exportFontToData,
&AbstractFontConverterTest::exportFontToDataNotSupported,
&AbstractFontConverterTest::exportFontToDataNotImplemented,
&AbstractFontConverterTest::exportFontToDataThroughSingleData,
&AbstractFontConverterTest::exportFontToDataThroughSingleDataFailed,
&AbstractFontConverterTest::exportFontToFile,
&AbstractFontConverterTest::exportFontToFileNotSupported,
&AbstractFontConverterTest::exportFontToFileNotImplemented,
&AbstractFontConverterTest::exportFontToFileThroughData,
&AbstractFontConverterTest::exportFontToFileThroughDataFailed,
&AbstractFontConverterTest::exportFontToFileThroughDataNotWritable,
&AbstractFontConverterTest::exportGlyphCacheToSingleData,
&AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSupported,
&AbstractFontConverterTest::exportGlyphCacheToSingleDataNotImplemented,
&AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSingleFile,
&AbstractFontConverterTest::exportGlyphCacheToData,
&AbstractFontConverterTest::exportGlyphCacheToDataNotSupported,
&AbstractFontConverterTest::exportGlyphCacheToDataNotImplemented,
&AbstractFontConverterTest::exportGlyphCacheToDataThroughSingleData,
&AbstractFontConverterTest::exportGlyphCacheToDataThroughSingleDataFailed,
&AbstractFontConverterTest::exportGlyphCacheToFile,
&AbstractFontConverterTest::exportGlyphCacheToFileNotSupported,
&AbstractFontConverterTest::exportGlyphCacheToFileNotImplemented,
&AbstractFontConverterTest::exportGlyphCacheToFileThroughData,
&AbstractFontConverterTest::exportGlyphCacheToFileThroughDataFailed,
&AbstractFontConverterTest::exportGlyphCacheToFileThroughDataNotWritable,
&AbstractFontConverterTest::importGlyphCacheFromSingleData,
&AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSupported,
&AbstractFontConverterTest::importGlyphCacheFromSingleDataNotImplemented,
&AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSingleFile,
&AbstractFontConverterTest::importGlyphCacheFromData,
&AbstractFontConverterTest::importGlyphCacheFromDataNoData,
&AbstractFontConverterTest::importGlyphCacheFromDataNotSupported,
&AbstractFontConverterTest::importGlyphCacheFromDataNotImplemented,
&AbstractFontConverterTest::importGlyphCacheFromDataAsSingleData,
&AbstractFontConverterTest::importGlyphCacheFromFile,
&AbstractFontConverterTest::importGlyphCacheFromFileNotSupported,
&AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented,
&AbstractFontConverterTest::importGlyphCacheFromFileAsSingleData,
&AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataNotFound,
@ -200,6 +186,37 @@ void AbstractFontConverterTest::convertGlyphs() {
CORRADE_COMPARE(characters, U" 01Cab");
}
void AbstractFontConverterTest::thingNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override { return {}; }
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportFontToSingleData(dummyFont, dummyGlyphCache, {});
converter.exportFontToData(dummyFont, dummyGlyphCache, "font.out", {});
converter.exportFontToFile(dummyFont, dummyGlyphCache, "file.out", {});
converter.exportGlyphCacheToSingleData(dummyGlyphCache);
converter.exportGlyphCacheToData(dummyGlyphCache, "cache.out");
converter.exportGlyphCacheToFile(dummyGlyphCache, "cache.out");
converter.importGlyphCacheFromSingleData({});
converter.importGlyphCacheFromData({{}});
converter.importGlyphCacheFromFile({});
CORRADE_COMPARE_AS(out.str(),
"Text::AbstractFontConverter::exportFontToSingleData(): feature not supported\n"
"Text::AbstractFontConverter::exportFontToData(): feature not supported\n"
"Text::AbstractFontConverter::exportFontToFile(): feature not supported\n"
"Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported\n"
"Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported\n"
"Text::AbstractFontConverter::exportGlyphCacheToFile(): feature not supported\n"
"Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported\n"
"Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported\n"
"Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported\n",
TestSuite::Compare::String);
}
void AbstractFontConverterTest::exportFontToSingleData() {
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
@ -216,21 +233,6 @@ void AbstractFontConverterTest::exportFontToSingleData() {
TestSuite::Compare::Container);
}
void AbstractFontConverterTest::exportFontToSingleDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportFont;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportFontToSingleData(dummyFont, dummyGlyphCache, {});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToSingleData(): feature not supported\n");
}
void AbstractFontConverterTest::exportFontToSingleDataNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -288,21 +290,6 @@ void AbstractFontConverterTest::exportFontToData() {
TestSuite::Compare::Container);
}
void AbstractFontConverterTest::exportFontToDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportFont;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportFontToData(dummyFont, dummyGlyphCache, "font.out", {});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToData(): feature not supported\n");
}
void AbstractFontConverterTest::exportFontToDataNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -385,21 +372,6 @@ void AbstractFontConverterTest::exportFontToFile() {
"\xfe\x02", TestSuite::Compare::FileToString);
}
void AbstractFontConverterTest::exportFontToFileNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportFontToFile(dummyFont, dummyGlyphCache, "file.out", {});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToFile(): feature not supported\n");
}
void AbstractFontConverterTest::exportFontToFileNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -506,21 +478,6 @@ void AbstractFontConverterTest::exportGlyphCacheToSingleData() {
TestSuite::Compare::Container);
}
void AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportGlyphCacheToSingleData(dummyGlyphCache);
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported\n");
}
void AbstractFontConverterTest::exportGlyphCacheToSingleDataNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -577,21 +534,6 @@ void AbstractFontConverterTest::exportGlyphCacheToData() {
TestSuite::Compare::Container);
}
void AbstractFontConverterTest::exportGlyphCacheToDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportGlyphCacheToData(dummyGlyphCache, "cache.out");
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported\n");
}
void AbstractFontConverterTest::exportGlyphCacheToDataNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -675,21 +617,6 @@ void AbstractFontConverterTest::exportGlyphCacheToFile() {
"\xfe\xed", TestSuite::Compare::FileToString);
}
void AbstractFontConverterTest::exportGlyphCacheToFileNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportFont;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.exportGlyphCacheToFile(dummyGlyphCache, "cache.out");
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToFile(): feature not supported\n");
}
void AbstractFontConverterTest::exportGlyphCacheToFileNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -795,21 +722,6 @@ void AbstractFontConverterTest::importGlyphCacheFromSingleData() {
CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345}));
}
void AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ImportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.importGlyphCacheFromSingleData({});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported\n");
}
void AbstractFontConverterTest::importGlyphCacheFromSingleDataNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -859,21 +771,6 @@ void AbstractFontConverterTest::importGlyphCacheFromData() {
CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345}));
}
void AbstractFontConverterTest::importGlyphCacheFromDataNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ImportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.importGlyphCacheFromData({{}});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported\n");
}
void AbstractFontConverterTest::importGlyphCacheFromDataNoData() {
CORRADE_SKIP_IF_NO_ASSERT();
@ -946,21 +843,6 @@ void AbstractFontConverterTest::importGlyphCacheFromFile() {
CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345}));
}
void AbstractFontConverterTest::importGlyphCacheFromFileNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ExportGlyphCache;
}
} converter;
std::ostringstream out;
Error redirectError{&out};
converter.importGlyphCacheFromFile({});
CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported\n");
}
void AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();

14
src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

@ -71,13 +71,13 @@ struct DummyGlyphCache: AbstractGlyphCache {
};
void AbstractGlyphCacheTest::initialize() {
DummyGlyphCache cache({1024, 2048});
DummyGlyphCache cache{{1024, 2048}};
CORRADE_COMPARE(cache.textureSize(), (Vector2i{1024, 2048}));
}
void AbstractGlyphCacheTest::access() {
DummyGlyphCache cache(Vector2i(236));
DummyGlyphCache cache{Vector2i(236)};
Vector2i position;
Range2Di rectangle;
@ -108,14 +108,14 @@ void AbstractGlyphCacheTest::access() {
}
void AbstractGlyphCacheTest::reserve() {
DummyGlyphCache cache(Vector2i(236));
DummyGlyphCache cache{Vector2i(236)};
/* Verify that this works for "empty" cache */
CORRADE_VERIFY(!cache.reserve({{5, 3}}).empty());
}
void AbstractGlyphCacheTest::setImage() {
struct MyGlyphCache: AbstractGlyphCache {
struct: AbstractGlyphCache {
using AbstractGlyphCache::AbstractGlyphCache;
GlyphCacheFeatures doFeatures() const override { return {}; }
@ -150,7 +150,7 @@ void AbstractGlyphCacheTest::setImageOutOfBounds() {
}
void AbstractGlyphCacheTest::image() {
struct MyGlyphCache: AbstractGlyphCache {
struct: AbstractGlyphCache {
using AbstractGlyphCache::AbstractGlyphCache;
GlyphCacheFeatures doFeatures() const override { return GlyphCacheFeature::ImageDownload; }
@ -166,7 +166,7 @@ void AbstractGlyphCacheTest::image() {
void AbstractGlyphCacheTest::imageNotSupported() {
CORRADE_SKIP_IF_NO_ASSERT();
struct MyGlyphCache: AbstractGlyphCache {
struct: AbstractGlyphCache {
using AbstractGlyphCache::AbstractGlyphCache;
GlyphCacheFeatures doFeatures() const override { return {}; }
@ -182,7 +182,7 @@ void AbstractGlyphCacheTest::imageNotSupported() {
void AbstractGlyphCacheTest::imageNotImplemented() {
CORRADE_SKIP_IF_NO_ASSERT();
struct MyGlyphCache: AbstractGlyphCache {
struct: AbstractGlyphCache {
using AbstractGlyphCache::AbstractGlyphCache;
GlyphCacheFeatures doFeatures() const override { return GlyphCacheFeature::ImageDownload; }

18
src/Magnum/Text/Test/AbstractLayouterTest.cpp

@ -41,16 +41,14 @@ AbstractLayouterTest::AbstractLayouterTest() {
}
void AbstractLayouterTest::renderGlyph() {
class Layouter: public AbstractLayouter {
public:
explicit Layouter(): AbstractLayouter(3) {}
private:
std::tuple<Range2D, Range2D, Vector2> doRenderGlyph(UnsignedInt) override {
return std::make_tuple(Range2D({1.0f, 0.5f}, {1.1f, 1.0f}),
Range2D({0.3f, 1.1f}, {-0.5f, 0.7f}),
Vector2(2.0f, -1.0f));
}
struct Layouter: AbstractLayouter {
explicit Layouter(): AbstractLayouter{3} {}
std::tuple<Range2D, Range2D, Vector2> doRenderGlyph(UnsignedInt) override {
return std::make_tuple(Range2D({1.0f, 0.5f}, {1.1f, 1.0f}),
Range2D({0.3f, 1.1f}, {-0.5f, 0.7f}),
Vector2(2.0f, -1.0f));
}
};
/* Rectangle of zero size shouldn't be merged, but replaced */

2
src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp

@ -39,7 +39,7 @@ DistanceFieldGlyphCacheGLTest::DistanceFieldGlyphCacheGLTest() {
}
void DistanceFieldGlyphCacheGLTest::initialize() {
Text::DistanceFieldGlyphCache cache({1024, 2048}, {256, 256}, 16);
DistanceFieldGlyphCache cache{{1024, 2048}, {256, 256}, 16};
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES

4
src/Magnum/Text/Test/GlyphCacheGLTest.cpp

@ -23,8 +23,6 @@
DEALINGS IN THE SOFTWARE.
*/
#include <tuple>
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Text/GlyphCache.h"
@ -41,7 +39,7 @@ GlyphCacheGLTest::GlyphCacheGLTest() {
}
void GlyphCacheGLTest::initialize() {
Text::GlyphCache cache({1024, 2048});
GlyphCache cache{{1024, 2048}};
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES

20
src/Magnum/Text/Test/RendererGLTest.cpp

@ -54,7 +54,7 @@ RendererGLTest::RendererGLTest() {
&RendererGLTest::multiline});
}
class TestLayouter: public Text::AbstractLayouter {
class TestLayouter: public AbstractLayouter {
public:
explicit TestLayouter(Float size, std::size_t glyphCount): AbstractLayouter(glyphCount), _size(size) {}
@ -70,7 +70,7 @@ class TestLayouter: public Text::AbstractLayouter {
Float _size;
};
class TestFont: public Text::AbstractFont {
class TestFont: public AbstractFont {
FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return true; }
@ -94,7 +94,7 @@ void RendererGLTest::renderData() {
std::vector<Vector2> textureCoordinates;
std::vector<UnsignedInt> indices;
Range2D bounds;
std::tie(positions, textureCoordinates, indices, bounds) = Text::AbstractRenderer::render(font, nullGlyphCache, 0.25f, "abc", Alignment::MiddleRightIntegral);
std::tie(positions, textureCoordinates, indices, bounds) = AbstractRenderer::render(font, nullGlyphCache, 0.25f, "abc", Alignment::MiddleRightIntegral);
/* Three glyphs, three quads -> 12 vertices, 18 indices */
CORRADE_COMPARE(positions.size(), 12);
@ -177,7 +177,7 @@ void RendererGLTest::renderMesh() {
GL::Buffer vertexBuffer{GL::Buffer::TargetHint::Array},
indexBuffer{GL::Buffer::TargetHint::ElementArray};
Range2D bounds;
std::tie(mesh, bounds) = Text::Renderer3D::render(font, nullGlyphCache,
std::tie(mesh, bounds) = Renderer3D::render(font, nullGlyphCache,
0.25f, "abc", vertexBuffer, indexBuffer, GL::BufferUsage::StaticDraw, Alignment::TopCenter);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -229,7 +229,7 @@ void RendererGLTest::renderMeshIndexType() {
texture coordinates, each float is four bytes; six indices per glyph. */
/* 8-bit indices (exactly 256 vertices) */
std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache,
std::tie(mesh, std::ignore) = Renderer3D::render(font, nullGlyphCache,
1.0f, std::string(64, 'a'), vertexBuffer, indexBuffer, GL::BufferUsage::StaticDraw);
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> indicesByte = indexBuffer.data();
@ -243,7 +243,7 @@ void RendererGLTest::renderMeshIndexType() {
}), TestSuite::Compare::Container);
/* 16-bit indices (260 vertices) */
std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache,
std::tie(mesh, std::ignore) = Renderer3D::render(font, nullGlyphCache,
1.0f, std::string(65, 'a'), vertexBuffer, indexBuffer, GL::BufferUsage::StaticDraw);
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> indicesShort = indexBuffer.data();
@ -271,7 +271,7 @@ void RendererGLTest::mutableText() {
#endif
TestFont font;
Text::Renderer2D renderer(font, nullGlyphCache, 0.25f);
Renderer2D renderer(font, nullGlyphCache, 0.25f);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(renderer.capacity(), 0);
CORRADE_COMPARE(renderer.fontSize(), 0.25f);
@ -326,7 +326,7 @@ void RendererGLTest::mutableText() {
}
void RendererGLTest::multiline() {
class Layouter: public Text::AbstractLayouter {
class Layouter: public AbstractLayouter {
public:
explicit Layouter(UnsignedInt glyphCount): AbstractLayouter(glyphCount) {}
@ -336,7 +336,7 @@ void RendererGLTest::multiline() {
}
};
class Font: public Text::AbstractFont {
class Font: public AbstractFont {
public:
explicit Font(): _opened(false) {}
@ -366,7 +366,7 @@ void RendererGLTest::multiline() {
Range2D rectangle;
std::vector<UnsignedInt> indices;
std::vector<Vector2> positions, textureCoordinates;
std::tie(positions, textureCoordinates, indices, rectangle) = Text::Renderer2D::render(font,
std::tie(positions, textureCoordinates, indices, rectangle) = Renderer2D::render(font,
nullGlyphCache, 2.0f, "abcd\nef\n\nghi", Alignment::MiddleCenter);
/* We're rendering text at 2.0f size and the font is scaled to 0.3f, so the

18
src/Magnum/Text/fontconverter.cpp

@ -162,21 +162,21 @@ int FontConverter::exec() {
Utility::Path::join(args.value("plugin-dir"), Utility::Path::split(Trade::AbstractImageConverter::pluginSearchPaths().back()).second())};
/* Load font */
PluginManager::Manager<Text::AbstractFont> fontManager{
PluginManager::Manager<AbstractFont> fontManager{
args.value("plugin-dir").empty() ? Containers::String{} :
Utility::Path::join(args.value("plugin-dir"), Utility::Path::split(Text::AbstractFont::pluginSearchPaths().back()).second())};
Containers::Pointer<Text::AbstractFont> font = fontManager.loadAndInstantiate(args.value("font"));
Utility::Path::join(args.value("plugin-dir"), Utility::Path::split(AbstractFont::pluginSearchPaths().back()).second())};
Containers::Pointer<AbstractFont> font = fontManager.loadAndInstantiate(args.value("font"));
if(!font) return 1;
/* Register the image converter manager for potential dependencies
(MagnumFontConverter needs TgaImageConverter, for example) */
PluginManager::Manager<Text::AbstractFontConverter> converterManager{
PluginManager::Manager<AbstractFontConverter> converterManager{
args.value("plugin-dir").empty() ? Containers::String{} :
Utility::Path::join(args.value("plugin-dir"), Utility::Path::split(Text::AbstractFontConverter::pluginSearchPaths().back()).second())};
Utility::Path::join(args.value("plugin-dir"), Utility::Path::split(AbstractFontConverter::pluginSearchPaths().back()).second())};
converterManager.registerExternalManager(imageConverterManager);
/* Load font converter */
Containers::Pointer<Text::AbstractFontConverter> converter = converterManager.loadAndInstantiate(args.value("converter"));
Containers::Pointer<AbstractFontConverter> converter = converterManager.loadAndInstantiate(args.value("converter"));
if(!converter) return 2;
/* Open font */
@ -186,11 +186,11 @@ int FontConverter::exec() {
}
/* Create distance field glyph cache if radius is specified */
Containers::Pointer<Text::GlyphCache> cache;
Containers::Pointer<GlyphCache> cache;
if(!args.value<Vector2i>("output-size").isZero()) {
Debug() << "Populating distance field glyph cache...";
cache.reset(new Text::DistanceFieldGlyphCache(
cache.reset(new DistanceFieldGlyphCache(
args.value<Vector2i>("atlas-size"),
args.value<Vector2i>("output-size"),
args.value<Int>("radius")));
@ -199,7 +199,7 @@ int FontConverter::exec() {
} else {
Debug() << "Zero-size distance field output specified, populating normal glyph cache...";
cache.reset(new Text::GlyphCache(args.value<Vector2i>("atlas-size")));
cache.reset(new GlyphCache(args.value<Vector2i>("atlas-size")));
}
/* Fill the cache */

Loading…
Cancel
Save