Update text rendering.
This commit is contained in:
parent
8536908eab
commit
8130308f7f
27 changed files with 503 additions and 77 deletions
53
src/rendering/visual_elements/svg/SvgTextElement.cpp
Normal file
53
src/rendering/visual_elements/svg/SvgTextElement.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include "SvgTextElement.h"
|
||||
|
||||
#include "XmlAttribute.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
SvgTextElement::SvgTextElement()
|
||||
:SvgElement("text")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SvgTextElement::setLocation(const Point& loc)
|
||||
{
|
||||
auto x = std::make_unique<XmlAttribute>("x");
|
||||
auto y = std::make_unique<XmlAttribute>("y");
|
||||
|
||||
x->setValue(std::to_string(loc.getX()));
|
||||
y->setValue(std::to_string(loc.getY()));
|
||||
|
||||
addAttribute(std::move(x));
|
||||
addAttribute(std::move(y));
|
||||
}
|
||||
|
||||
void SvgTextElement::setContent(const std::string& content)
|
||||
{
|
||||
setText(content);
|
||||
}
|
||||
|
||||
void SvgTextElement::setFill(const Color& fill)
|
||||
{
|
||||
auto attr = std::make_unique<XmlAttribute>("fill");
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "rgb(" << fill.toString() << ")";
|
||||
attr->setValue(sstr.str());
|
||||
|
||||
addAttribute(std::move(attr));
|
||||
}
|
||||
|
||||
void SvgTextElement::setFontFamily(const std::string& family)
|
||||
{
|
||||
auto attr = std::make_unique<XmlAttribute>("font-family");
|
||||
attr->setValue(family);
|
||||
addAttribute(std::move(attr));
|
||||
}
|
||||
|
||||
void SvgTextElement::setFontSize(float size)
|
||||
{
|
||||
auto attr = std::make_unique<XmlAttribute>("font-size");
|
||||
attr->setValue(std::to_string(size));
|
||||
addAttribute(std::move(attr));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue