Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp
- index 9c50d01..739f7a6 100644
- --- a/src/driver/fontrenderer.cpp
- +++ b/src/driver/fontrenderer.cpp
- @@ -393,7 +393,7 @@ int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on
- }
- #ifdef ENABLE_FRIBIDI
- -static std::string fribidi_shape_char(const char * text)
- +static std::string fribidi_shape_char(const char * text, bool &is_rtl)
- {
- if(text && *text)
- {
- @@ -408,7 +408,7 @@ static std::string fribidi_shape_char(const char * text)
- FriBidiCharSet fribidi_charset = FRIBIDI_CHAR_SET_UTF8;
- // tell bidi that we need bidirectional
- - FriBidiCharType fribidi_chartype = FRIBIDI_TYPE_L;
- + FriBidiCharType fribidi_chartype = FRIBIDI_TYPE_ON;
- // our buffer
- FriBidiChar *logical = (FriBidiChar *)alloca(sizeof(FriBidiChar)*(len + 1));
- @@ -427,6 +427,9 @@ static std::string fribidi_shape_char(const char * text)
- rtl_text = (char *)alloca(sizeof(char)*(rtl_len * 4 + 1));
- fribidi_unicode_to_charset(fribidi_charset, visual, rtl_len, rtl_text);
- + is_rtl = ((fribidi_chartype & FRIBIDI_MASK_RTL) || (fribidi_chartype & FRIBIDI_MASK_ARABIC));
- + if (is_rtl)
- + printf("FRIBIDI_MASK_RTL || FRIBIDI_MASK_ARABIC\n");
- return std::string(rtl_text);
- }
- }
- @@ -495,8 +498,9 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
- pthread_mutex_lock( &renderer->render_mutex );
- + bool is_rtl = false;
- #ifdef ENABLE_FRIBIDI
- - std::string Text = fribidi_shape_char(text);
- + std::string Text = fribidi_shape_char(text, is_rtl);
- text = Text.c_str();
- #endif
- @@ -512,6 +516,12 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
- int use_kerning=FT_HAS_KERNING(face);
- int left=x;
- + if (is_rtl)
- + {
- + int rtl_left = x + width - getRenderWidth(text);
- + if (rtl_left >= left)
- + left = rtl_left;
- + }
- int step_y=height;
- // ----------------------------------- box upper end (this is NOT a font metric, this is our method for y centering)
- @@ -690,8 +700,9 @@ int Font::getRenderWidth(const char *text, const bool utf8_encoded)
- {
- pthread_mutex_lock( &renderer->render_mutex );
- + bool is_rtl = false;
- #ifdef ENABLE_FRIBIDI
- - std::string Text = fribidi_shape_char(text);
- + std::string Text = fribidi_shape_char(text, is_rtl);
- text = Text.c_str();
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement