Correctly set script and direction.
This commit is contained in:
parent
2e50936b13
commit
89b727d2fc
3 changed files with 9 additions and 8 deletions
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
//ICU
|
//ICU
|
||||||
#include <unicode/unistr.h>
|
#include <unicode/unistr.h>
|
||||||
class hb_font_t;
|
#include <unicode/uscript.h>
|
||||||
class hb_buffer_t;
|
#include <harfbuzz/hb.h>
|
||||||
class hb_glyph_info_t;
|
|
||||||
|
|
||||||
// freetype2
|
// freetype2
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -24,7 +23,7 @@ public:
|
||||||
text_shaping(FT_Face face);
|
text_shaping(FT_Face face);
|
||||||
~text_shaping();
|
~text_shaping();
|
||||||
|
|
||||||
uint32_t process_text(UnicodeString const& text);
|
uint32_t process_text(UnicodeString const& text, bool rtl, UScriptCode script);
|
||||||
hb_buffer_t *get_buffer() { return buffer_; }
|
hb_buffer_t *get_buffer() { return buffer_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -32,7 +32,7 @@ void text_layout::shape_text()
|
||||||
face_ptr face = *(face_set->begin()); //TODO: Implement font sets correctly
|
face_ptr face = *(face_set->begin()); //TODO: Implement font sets correctly
|
||||||
text_shaping shaper(face->get_face()); //TODO: Make this more efficient by caching this object in font_face
|
text_shaping shaper(face->get_face()); //TODO: Make this more efficient by caching this object in font_face
|
||||||
|
|
||||||
uint32_t bytes = shaper.process_text(itr->str);
|
uint32_t bytes = shaper.process_text(itr->str, itr->rtl == UBIDI_DEFAULT_RTL, itr->script);
|
||||||
hb_buffer_t *buffer = shaper.get_buffer();
|
hb_buffer_t *buffer = shaper.get_buffer();
|
||||||
|
|
||||||
unsigned num_glyphs = hb_buffer_get_length(buffer);
|
unsigned num_glyphs = hb_buffer_get_length(buffer);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define HAVE_FREETYPE
|
#define HAVE_FREETYPE
|
||||||
#include <harfbuzz/hb.h>
|
#include <harfbuzz/hb.h>
|
||||||
#include <harfbuzz/hb-ft.h>
|
#include <harfbuzz/hb-ft.h>
|
||||||
|
#include <harfbuzz/hb-icu.h>
|
||||||
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
@ -20,6 +21,7 @@ text_shaping::text_shaping(FT_Face face)
|
||||||
buffer_ (hb_buffer_create()),
|
buffer_ (hb_buffer_create()),
|
||||||
face_(face)
|
face_(face)
|
||||||
{
|
{
|
||||||
|
hb_buffer_set_unicode_funcs(buffer_, hb_icu_get_unicode_funcs());
|
||||||
load_font();
|
load_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ text_shaping::~text_shaping()
|
||||||
hb_font_destroy(font_);
|
hb_font_destroy(font_);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t text_shaping::process_text(const UnicodeString &text)
|
uint32_t text_shaping::process_text(UnicodeString const& text, bool rtl, UScriptCode script)
|
||||||
{
|
{
|
||||||
if (!font_) return 0;
|
if (!font_) return 0;
|
||||||
hb_buffer_reset(buffer_);
|
hb_buffer_reset(buffer_);
|
||||||
|
@ -37,9 +39,9 @@ uint32_t text_shaping::process_text(const UnicodeString &text)
|
||||||
std::string s;
|
std::string s;
|
||||||
text.toUTF8String(s);
|
text.toUTF8String(s);
|
||||||
hb_buffer_add_utf8(buffer_, s.c_str(), s.length(), 0, -1);
|
hb_buffer_add_utf8(buffer_, s.c_str(), s.length(), 0, -1);
|
||||||
|
hb_buffer_set_direction(buffer_, rtl?HB_DIRECTION_RTL:HB_DIRECTION_LTR);
|
||||||
|
hb_buffer_set_script(buffer_, hb_icu_script_to_script(script));
|
||||||
#if 0
|
#if 0
|
||||||
hb_buffer_set_direction(buffer, hb_direction_from_string (direction, -1));
|
|
||||||
hb_buffer_set_script(buffer, hb_script_from_string (script, -1));
|
|
||||||
hb_buffer_set_language(buffer, hb_language_from_string (language, -1));
|
hb_buffer_set_language(buffer, hb_language_from_string (language, -1));
|
||||||
#endif
|
#endif
|
||||||
hb_shape(font_, buffer_, 0 /*features*/, 0 /*num_features*/);
|
hb_shape(font_, buffer_, 0 /*features*/, 0 /*num_features*/);
|
||||||
|
|
Loading…
Reference in a new issue