current_element().attributes.font_family = font_family;
}
+void SVGAnalyzer::set_font_size(double font_size) {
+ current_element().attributes.font_size = font_size;
+}
+
void SVGAnalyzer::set_fill(std::string_view fill) {
current_element().attributes.fill = fill;
}
void set_cx(double cx) override;
void set_cy(double cy) override;
void set_font_family(std::string_view font_family) override;
+ void set_font_size(double font_size) override;
void set_fill(std::string_view fill) override;
void set_height(double height) override;
void set_id(std::string_view id) override;
virtual void set_cx(double cx) = 0;
virtual void set_cy(double cy) = 0;
virtual void set_font_family(std::string_view font_family) = 0;
+ virtual void set_font_size(double font_size) = 0;
virtual void set_fill(std::string_view fill) = 0;
virtual void set_height(double height) = 0;
virtual void set_id(std::string_view id) = 0;
attributes.viewBox.height);
break;
case SVG::SVGElementType::Text:
- attributes_str +=
- fmt::format(R"(text-anchor="{}" x="{}" y="{}" font-family="{}")",
- attributes.text_anchor, attributes.x, attributes.y,
- attributes.font_family);
+ attributes_str += fmt::format(
+ R"(text-anchor="{}" x="{}" y="{}" font-family="{}" font-size="{:.2f}")",
+ attributes.text_anchor, attributes.x, attributes.y,
+ attributes.font_family, attributes.font_size);
break;
case SVG::SVGElementType::Title:
// Graphviz doesn't generate attributes on 'title' elements
double cy;
std::string fill;
std::string font_family;
+ double font_size;
double height;
std::string id;
std::vector<SVGPoint> points;
m_svgAnalyzer->set_font_family({v.begin(), v.end()});
}
+void SvgppContext::set(svgpp::tag::attribute::font_size, const double v) {
+ m_svgAnalyzer->set_font_size(v);
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::xx_small) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'xx_small' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::x_small) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'x_small' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::smaller) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'smaller' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::small) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'small' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::medium) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'medium' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::large) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'large' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::larger) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'larger' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::x_large) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'x_large' value is not yet implemented"};
+}
+
+void SvgppContext::set(svgpp::tag::attribute::font_size,
+ svgpp::tag::value::xx_large) {
+ throw std::runtime_error{
+ "the 'font_size' attribute 'xx_large' value is not yet implemented"};
+}
+
void SvgppContext::set(svgpp::tag::attribute::text_anchor,
svgpp::tag::value::start) {
m_svgAnalyzer->set_text_anchor("start");
boost::iterator_range<const char *> v);
void set(svgpp::tag::attribute::font_family a,
boost::iterator_range<const char *> v);
+ void set(svgpp::tag::attribute::font_size a, double v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::xx_small v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::x_small v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::smaller v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::small v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::medium v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::large v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::larger v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::x_large v);
+ void set(svgpp::tag::attribute::font_size a, svgpp::tag::value::xx_large v);
void set(svgpp::tag::attribute::text_anchor a, svgpp::tag::value::start v);
void set(svgpp::tag::attribute::text_anchor a, svgpp::tag::value::middle v);
void set(svgpp::tag::attribute::text_anchor a, svgpp::tag::value::end v);
svgpp::tag::attribute::cy, //
svgpp::tag::attribute::fill, //
svgpp::tag::attribute::font_family, //
+ svgpp::tag::attribute::font_size, //
svgpp::tag::attribute::height, //
svgpp::tag::attribute::id, //
svgpp::tag::attribute::points, //
// yet handle all attributes on the 'path' element
break;
}
- if (recreated_svg_lines[i].starts_with(
- "<text text-anchor=\"middle\" x=\"")) {
- // stop comparison here since we do not yet handle all attributes on the
- // 'text' element
- break;
- }
REQUIRE(recreated_svg_lines[i] == original_svg_lines[i]);
}
CHECK(recreated_svg.find("<title>g1</title>") != std::string::npos);
CHECK(recreated_svg.find("<title>a</title>") != std::string::npos);
CHECK(recreated_svg.find("<title>b</title>") != std::string::npos);
- if (shape != "point") {
- CHECK(recreated_svg.find("<text text-anchor=\"middle\" x=\"") !=
- std::string::npos);
- CHECK(recreated_svg.find("\" y=\"") != std::string::npos);
- CHECK(recreated_svg.find(" font-family=\"Times,serif\">a</text>") !=
- std::string::npos);
- CHECK(recreated_svg.find(" font-family=\"Times,serif\">b</text>") !=
- std::string::npos);
- }
CHECK(recreated_svg.find("<path fill=\"none\" stroke=\"black\"/>") !=
std::string::npos);
CHECK(recreated_svg.find("<!-- a -->") != std::string::npos);