Implement missing functions.
This is the first version that actually renders text. And it's working correctly!
This commit is contained in:
parent
9f2ec07cd8
commit
beed2d08f2
4 changed files with 35 additions and 11 deletions
|
@ -92,12 +92,15 @@ public:
|
|||
void break_lines();
|
||||
void shape_text();
|
||||
void clear();
|
||||
unsigned size() const;
|
||||
unsigned size() const { return glyphs_.size(); }
|
||||
|
||||
typedef std::vector<glyph_info> glyph_vector;
|
||||
glyph_vector const& get_glyphs() const { return glyphs_; }
|
||||
|
||||
private:
|
||||
text_itemizer itemizer;
|
||||
std::vector<text_line_ptr> lines_;
|
||||
std::vector<glyph_info> glyphs_;
|
||||
glyph_vector glyphs_;
|
||||
face_manager_freetype &font_manager_;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,7 +72,8 @@ private:
|
|||
pixel_position base_point_;
|
||||
bool point_;
|
||||
text_layout_ptr layout_;
|
||||
unsigned current_;
|
||||
signed current_;
|
||||
pixel_position current_position_;
|
||||
};
|
||||
typedef boost::shared_ptr<glyph_positions> glyph_positions_ptr;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
*****************************************************************************/
|
||||
//mapnik
|
||||
#include <mapnik/text/placement_finder_ng.hpp>
|
||||
#include <mapnik/text/layout.hpp>
|
||||
#include <mapnik/text_properties.hpp>
|
||||
|
||||
//boost
|
||||
#include <boost/make_shared.hpp>
|
||||
|
@ -54,21 +56,39 @@ void glyph_positions::point_placement(pixel_position base_point)
|
|||
point_ = true;
|
||||
}
|
||||
|
||||
bool glyph_positions::next()
|
||||
{
|
||||
if (current_ == -1)
|
||||
{
|
||||
current_ = 0;
|
||||
return layout_->size();
|
||||
}
|
||||
if (current_ >= layout_->size()) return false;
|
||||
glyph_info glyph = layout_->get_glyphs()[current_];
|
||||
current_position_.x += glyph.width + glyph.format->character_spacing;
|
||||
std::cout << "width:" << glyph.width << "\n";
|
||||
current_++;
|
||||
if (current_ >= layout_->size()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void glyph_positions::rewind()
|
||||
{
|
||||
current_ = 0;
|
||||
current_ = -1;
|
||||
current_position_ = pixel_position(0, 0);
|
||||
}
|
||||
|
||||
glyph_info const& glyph_positions::get_glyph() const
|
||||
{
|
||||
assert(layout_);
|
||||
assert(current_ < layout_->size());
|
||||
|
||||
return layout_->get_glyphs()[current_];
|
||||
}
|
||||
|
||||
pixel_position glyph_positions::get_position() const
|
||||
{
|
||||
return pixel_position(0, 0);
|
||||
std::cout << "current_position_.x:" << current_position_.x << "\n";
|
||||
return current_position_;
|
||||
}
|
||||
|
||||
double glyph_positions::get_angle() const
|
||||
|
|
|
@ -17,28 +17,28 @@
|
|||
<Rule>
|
||||
<!-- This is an easy test to ensure text shaping actually works. Ligatures are rendered when harfbuzz is used, but not with the old text rendering system. -->
|
||||
<Filter>[nr] = "1"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="16">"fi"</TextSymbolizer>
|
||||
<!-- <TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="16">"fi"</TextSymbolizer> -->
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="-16">"mixed نامجو mixed"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<!-- In addition to the problem mentioned in the bug report (which seems to be gone) this the position is calculated incorrectly -->
|
||||
<Filter>[nr] = "3"</Filter>
|
||||
<Filter>[nr] = "13"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="16">"نامجو 17"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dy="-16">"#519"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[nr] = "5"</Filter>
|
||||
<Filter>[nr] = "15"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="-16">"زنقة الملاح"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dy="16">"#1154"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<!--TODO: Find suitable font! -->
|
||||
<Filter>[nr] = "7"</Filter>
|
||||
<Filter>[nr] = "17"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="16">"អក្សរខ្មែរ"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dy="-16">"#1208"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[nr] = "9"</Filter>
|
||||
<Filter>[nr] = "19"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="-16">"أڭادير"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dy="16">"#1146"</TextSymbolizer>
|
||||
</Rule>
|
||||
|
|
Loading…
Add table
Reference in a new issue