[Bugs] #1856 HIGH: long strings don't wrap in SVG output

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Sat Jul 3 06:06:18 EDT 2010


#1856: long strings don't wrap in SVG output
----------------------------+-----------------------------------------------
    Reporter:  walter       |          Owner:  walter                     
        Type:  defect       |         Status:  new                        
    Priority:  High         |      Milestone:  Unspecified by Release Team
   Component:  Turtleart    |        Version:  Git as of bugdate          
    Severity:  Major        |       Keywords:  sugar-love                 
Distribution:  Unspecified  |   Status_field:  New                        
----------------------------+-----------------------------------------------

Comment(by timClicks):

 This is one strategy for a function that would meet 2. 2 appears to be the
 friendliest to the user, because then they can select the whole paragraph.

 parse SVG files, looking for text elements
   for each text element
     store the attrs as a dict
     if there is a attr['style']['line-height'], then
       set h as that value
     otherwise
       set h to 13px #? - just a guess
     split the contents into multiple strings #using split_at_len perhaps
 (below)
     tspans = []
     for each line in the split
       tspans.append('<tspan x="%s" y="%s">%s</tspan>' % (x_of_parent,
 y_of_parent+h,line ))
     insert tspans into the text area

 {{{
 def split_at_len(s, max_len=50, delimiter=None):
     """
     Returns a list of strings, that are split from an
     input string. Delimits on whitespace by default.
     """
     if delimiter is None:
         s = s.split()
     else:
         s = s.split(delimiter)

     lines = []
     current_line = ''
     for word in s:
         if len(current_line) >= max_len:
             short.append(current_line)
             current_line = word
         else:
             current_line = '%s %s' % (current_line, word);
     lines[0] = lines[0][1:] #hack required by string formatting
     lines.append(current_line)
     return lines
 }}}

-- 
Ticket URL: <http://bugs.sugarlabs.org/ticket/1856#comment:4>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list