Add initial directwrite to svg conversion.

This commit is contained in:
jmsgrogan 2023-01-10 17:24:37 +00:00
parent 2c825adc1d
commit b7f75f903e
15 changed files with 571 additions and 7 deletions

View file

@ -1,5 +1,43 @@
#include "FontGlyph.h"
void GlyphRunOutlines::addToFeature(const Point& point)
{
mFeatures[mFeatures.size() - 1].mPoints.push_back(point);
}
void GlyphRunOutlines::startFeature(const Point& point, bool isFilled)
{
GlyphRunOutline feature;
feature.mFilled = isFilled;
feature.mPoints.push_back(point);
mFeatures.push_back(feature);
}
const std::vector<GlyphRunOutline> GlyphRunOutlines::getFeatures() const
{
return mFeatures;
}
std::string GlyphRunOutlines::toPostScriptPath()
{
std::string path;
for (const auto& feature : mFeatures)
{
if (feature.mPoints.empty())
{
continue;
}
auto last_point = feature.mPoints[0];
path += "M" + std::to_string(last_point.getX()) + " " + std::to_string(last_point.getY()) + " ";
for (std::size_t idx = 1; idx < feature.mPoints.size(); idx++)
{
path += "L" + std::to_string(feature.mPoints[idx].getX()) + " " + std::to_string(feature.mPoints[idx].getY()) + " ";
}
path += "z ";
}
return path;
}
FontGlyph::FontGlyph(unsigned width, unsigned height, int bearingX, int bearingY,
int advanceX, std::unique_ptr<Image<unsigned char> > image)
: mImage(std::move(image)),