[Sugar-devel] [PATCH] TurtleArt - SVG text wrapping #sl1856
Tim McNamara
paperless at timmcnamara.co.nz
Sat Jul 3 17:35:47 EDT 2010
On 4 July 2010 05:08, Walter Bender <walter.bender at gmail.com> wrote:
> On Sat, Jul 3, 2010 at 7:44 AM, Tim McNamara
> <paperless at timmcnamara.co.nz> wrote:
> > Hi Walter, et all,
> > This patch should go most of the way to fixing the bug. However, I
> haven't
> > tested it locally & it contains a few assumptions about what the SVG
> files
> > look like that that it's processing. I'm also not 100% sure about the
> > elementtree implementation of ElementTree (am used to lxml). That said, I
> > would like your feedback about whether you consider this to be an
> > appropriate way to approach the problem.
>
> I don't know much about ElementTree, but the patch itself looks OK.
> What I don't understand is how the textbox width is determined. How do
> we know how long to make the strings?
>
My patch includes the max_len argument twice, for convenience only.
process_text_in_svg
passes those arguments to process_text_in_svg, which itself passes those
arguments to split_at_len. My thought was that it would enable the functions
to be accessed externally. Then again, I should use objects if I would like
to maintain state like this.
As far as how the width is calculated, I've created an arbitrary cut-off at
50 characters. This is used by split_at_len. It would be better to draw an
inference about the available space left on the page from the element's x/y
position and the height/width of the whole page. However, I consider this
patch an intermediate step & patch submission as a pit stop to get review
comments.
Relationship between three functions
process_text_in_svg accepts whole SVG file/string, calls
process_svg_text_element on <text> tags, returns SVG as a string
process_svg_text_element accepts a list of Element objects, calling
split_at_len on their content, returning the Element
split_at_len accepts single string, returns list of strings
I'll work on an OO implementation on this. It'll add flexibility & clarity.
-Tim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20100704/31e69516/attachment.htm
More information about the Sugar-devel
mailing list