diff --git a/uppsrc/Painter/SvgInternal.h b/uppsrc/Painter/SvgInternal.h index 697eae8f5..d211f564e 100644 --- a/uppsrc/Painter/SvgInternal.h +++ b/uppsrc/Painter/SvgInternal.h @@ -84,6 +84,8 @@ struct SvgParser { String dash_array; double dash_offset; + int text_anchor; // 0 left, 1 middle, 2 right + Font font; const XmlNode *n; diff --git a/uppsrc/Painter/SvgParser.cpp b/uppsrc/Painter/SvgParser.cpp index ce17274a0..a412408cc 100644 --- a/uppsrc/Painter/SvgParser.cpp +++ b/uppsrc/Painter/SvgParser.cpp @@ -261,6 +261,8 @@ void SvgParser::Poly(const XmlNode& n, bool line) bp.Move(r[0].x, r[0].y); for(int i = 1; i < r.GetCount(); ++i) bp.Line(r[i].x, r[i].y); + if(!line) + bp.Close(); if(line) StrokeFinishElement(); else @@ -428,7 +430,13 @@ void SvgParser::Element(const XmlNode& n, int depth, bool dosymbols) text.Replace("\t", " "); if(text.GetCount()) { Font fnt = state.Top().font; - bp.Text(Dbl("x"), Dbl("y") - fnt.GetAscent(), text, fnt); + int anchor = state.Top().text_anchor; + double x = Dbl("x"); + if(anchor) { + Sizef sz = GetTextSize(text, fnt); // TODO; GetTextSizef + x -= anchor == 1 ? sz.cx / 2 : sz.cx; + } + bp.Text(x , Dbl("y") - fnt.GetAscent(), text, fnt); } }; DoText(n); diff --git a/uppsrc/Painter/SvgStyle.cpp b/uppsrc/Painter/SvgStyle.cpp index 636b8a069..319111afe 100644 --- a/uppsrc/Painter/SvgStyle.cpp +++ b/uppsrc/Painter/SvgStyle.cpp @@ -16,6 +16,7 @@ void SvgParser::Reset() s.opacity = s.fill_opacity = s.stroke_opacity = s.stroke_width = 1; s.dash_offset = 0; s.font = Serif(24); + s.text_anchor = 0; } void SvgParser::ProcessValue(const String& key, const String& value_) @@ -110,6 +111,9 @@ void SvgParser::ProcessValue(const String& key, const String& value_) else if(key == "font-weight") s.font.Bold(findarg(value, "bold", "bolder") >= 0 || atoi(value) >= 500); + else + if(key == "text-anchor") + s.text_anchor = decode(value, "left", 0, "middle", 1, "right", 2, 0); } } diff --git a/uppsrc/ide/SlideShow.cpp b/uppsrc/ide/SlideShow.cpp index 4d5b7bc90..a991b5f71 100644 --- a/uppsrc/ide/SlideShow.cpp +++ b/uppsrc/ide/SlideShow.cpp @@ -191,7 +191,6 @@ void SlideShow::SetPage() title.VMargins(0); int cy = min(title.GetCy() + DPI(10), GetSize().cy / 2); title.TopPos(0, cy); - text.Background(Yellow()); text.VSizePos(cy + 10, 0); title.Show(); }