Show
Ignore:
Timestamp:
07/20/09 11:30:19 (12 months ago)
Author:
artem
Message:

+ applied patch from Jochen Topf :

* text_convert="none|toupper|tolower"

Convert all text to upper/lower case before rendering. "none" doesn't do
anything with the text and is the default. Works for labels along lines
or at points.

* line_spacing="<number>"

Add this many pixels space between two lines in text labels that have
been broken into several lines. Default is 0. Doesn't do anything for
labels along lines.

* character_spacing="<number>"

Add this many pixels space between two characters in a text. Default is 0.
Currently only works for text labels on point geometries. This should
also be implemented for labels along lines, but I'll leave that for
another day.

* wrap_character="<character>"

Instead of breaking text into lines on spaces, use this character. This
is useful, when you want to make sure that labels are broken at the right
spot. Note that you'll probably want to make wrap_width small so that
your lines are actually broken, otherwise you'll see the wrap_character
in the output. Default is ' ' (space). Doesn't do anything for labels
along lines.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/placement_finder.cpp

    r1167 r1254  
    7676        label_placement(sym.get_label_placement()),  
    7777        wrap_width(sym.get_wrap_width()),  
     78        wrap_char(sym.get_wrap_char()), 
    7879        text_ratio(sym.get_text_ratio()),  
    7980        label_spacing(sym.get_label_spacing()),  
     
    215216                                                          double label_x,  
    216217                                                          double label_y, 
    217                                                           vertical_alignment_e valign) 
     218                                                          vertical_alignment_e valign, 
     219                                                          unsigned line_spacing, 
     220                                                          unsigned character_spacing) 
    218221   { 
    219222      double x, y; 
     
    240243      if (wrap_at < string_width && p.info.num_characters() > 0) 
    241244      { 
    242          int last_space = 0; 
     245         int last_wrap_char = 0; 
    243246         string_width = 0; 
    244247         string_height = 0; 
     
    251254            character_info ci; 
    252255            ci = p.info.at(ii); 
     256 
     257            unsigned cwidth = ci.width + character_spacing; 
    253258                 
    254259            unsigned c = ci.character; 
    255             word_width += ci.width; 
    256             word_height = word_height > ci.height ? word_height : ci.height; 
     260            word_width += cwidth; 
     261            word_height = word_height > (ci.height + line_spacing) ? word_height : (ci.height + line_spacing); 
    257262         
    258             if (c == ' ') 
     263            if (c == p.wrap_char) 
    259264            { 
    260                last_space = ii; 
     265               last_wrap_char = ii; 
    261266               line_width += word_width; 
    262267               line_height = line_height > word_height ? line_height : word_height; 
     
    267272            { 
    268273               // Remove width of breaking space character since it is not rendered 
    269                line_width -= ci.width; 
     274               line_width -= cwidth; 
    270275               string_width = string_width > line_width ? string_width : line_width; 
    271276               string_height += line_height; 
    272                line_breaks.push_back(last_space); 
     277               line_breaks.push_back(last_wrap_char); 
    273278               line_widths.push_back(line_width); 
    274279               line_heights.push_back(line_height); 
    275                ii = last_space; 
     280               ii = last_wrap_char; 
    276281               line_width = 0; 
    277282               line_height = 0; 
     
    327332         ci = p.info.at(i); 
    328333             
     334         unsigned cwidth = ci.width + character_spacing; 
     335 
    329336         unsigned c = ci.character; 
    330337         if (i == index_to_wrap_at) 
     
    368375            p.envelopes.push(e); 
    369376         } 
    370          x += ci.width; 
     377         x += cwidth; 
    371378      } 
    372379      p.placements.push_back(current_placement.release());