2023-01-10 17:24:37 +00:00
|
|
|
#include "TestFramework.h"
|
|
|
|
#include "TestUtils.h"
|
|
|
|
|
|
|
|
#include "DirectWriteHelpers.h"
|
|
|
|
#include "DirectWriteFontEngine.h"
|
|
|
|
#include "FileLogger.h"
|
|
|
|
|
|
|
|
#include "SvgDocument.h"
|
|
|
|
#include "SvgWriter.h"
|
|
|
|
#include "SvgShapeElements.h"
|
|
|
|
#include "File.h"
|
2023-01-25 16:51:36 +00:00
|
|
|
#include "FontItem.h"
|
2023-01-10 17:24:37 +00:00
|
|
|
|
|
|
|
TEST_CASE(TestDirectWriteFontEngine, "fonts")
|
|
|
|
{
|
|
|
|
DirectWriteFontEngine font_engine;
|
|
|
|
font_engine.initialize();
|
|
|
|
|
|
|
|
auto glyph_run_outlines = font_engine.getGlyphRunOutlines({ 66 });
|
|
|
|
auto path = glyph_run_outlines->toPostScriptPath();
|
|
|
|
|
|
|
|
auto doc = std::make_unique<SvgDocument>();
|
|
|
|
|
|
|
|
auto element = std::make_unique<SvgPath>();
|
|
|
|
element->setPath(path);
|
|
|
|
element->setFillRule("evenodd");
|
|
|
|
|
|
|
|
doc->getRoot()->addChild(std::move(element));
|
|
|
|
doc->setViewBox(-20.0, -20.0, 40.0, 40.0);
|
|
|
|
|
|
|
|
auto writer = std::make_unique<SvgWriter>();
|
|
|
|
auto doc_string = writer->toString(doc.get());
|
|
|
|
|
|
|
|
File file(TestUtils::getTestOutputDir(__FILE__) / "out.svg");
|
|
|
|
file.writeText(doc_string);
|
|
|
|
|
2023-01-25 16:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE(TestDirectWriteFontEngine_GlyphMetrics, "fonts")
|
|
|
|
{
|
|
|
|
DirectWriteFontEngine font_engine;
|
|
|
|
font_engine.initialize();
|
|
|
|
|
|
|
|
FontItem font("Verdana", 16);
|
|
|
|
|
|
|
|
const auto advance = font_engine.getHorizontalAdvance(font, "abc");
|
|
|
|
MLOG_INFO("Advance is: " << advance);
|
|
|
|
|
|
|
|
REQUIRE(advance != 0.0);
|
2023-01-10 17:24:37 +00:00
|
|
|
}
|