mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Painter: More SVG fixes
git-svn-id: svn://ultimatepp.org/upp/trunk@12831 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d16d3c4a2d
commit
9b9743104e
4 changed files with 15 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue