Permalink
Browse files

+ linewrap-patch-r3362.patch from dimka (#189)

  • Loading branch information...
1 parent a88a499 commit 3d6ea00c6655286a9bd333711349d8acd47da614 @artemp artemp committed Sep 25, 2011
Showing with 27 additions and 3 deletions.
  1. +6 −1 include/mapnik/text_path.hpp
  2. +5 −0 src/font_engine_freetype.cpp
  3. +16 −2 src/placement_finder.cpp
@@ -56,11 +56,13 @@ class string_info : private boost::noncopyable
UnicodeString const& text_;
double width_;
double height_;
+ bool is_rtl;
public:
string_info(UnicodeString const& text)
: text_(text),
width_(0),
- height_(0) {}
+ height_(0),
+ is_rtl(false) {}
void add_info(int c, double width, double height)
{
@@ -71,6 +73,9 @@ class string_info : private boost::noncopyable
{
return characters_.size();
}
+
+ void set_rtl(bool value) {is_rtl = value;}
+ bool get_rtl() const {return is_rtl;}
character_info at(unsigned i) const
{
@@ -262,6 +262,11 @@ void font_face_set::get_string_info(string_info & info)
}
}
+ if (ubidi_getBaseDirection(ustr.getBuffer(), length) == UBIDI_RTL)
+ {
+ info.set_rtl(true);
+ }
+
ubidi_close(bidi);
info.set_dimensions(width, height);
}
View
@@ -379,7 +379,14 @@ void placement_finder<DetectorT>::find_point_placement(placement & p,
// set for upper left corner of text envelope for the first line, bottom left of first character
x = -(line_width / 2.0);
- y = (0.5 * (string_height + (line_spacing * (total_lines-1)))) - max_character_height;
+ if (p.info.get_rtl()==false)
+ {
+ y = (0.5 * (string_height + (line_spacing * (total_lines-1)))) - max_character_height;
+ }
+ else
+ {
+ y = -(0.5 * (string_height + (line_spacing * (total_lines-1)))) + max_character_height;
+ }
// if needed, adjust for desired justification (J_MIDDLE is the default)
if( po->jalign == J_LEFT )
@@ -404,7 +411,14 @@ void placement_finder<DetectorT>::find_point_placement(placement & p,
index_to_wrap_at = line_breaks[++line_number];
line_width = line_widths[line_number];
- y -= (max_character_height + line_spacing); // move position down to line start
+ if (p.info.get_rtl()==false)
+ {
+ y -= (max_character_height + line_spacing); // move position down to line start
+ }
+ else
+ {
+ y += (max_character_height + line_spacing); // move position up to line start
+ }
// reset to begining of line position
x = ((po->jalign == J_LEFT)? -(string_width / 2.0): ((po->jalign == J_RIGHT)? ((string_width /2.0) - line_width): -(line_width / 2.0)));

0 comments on commit 3d6ea00

Please sign in to comment.