Ticket #4885: bidiosd.patch
File bidiosd.patch, 8.9 KB (added by , 16 years ago) |
---|
-
configure
2438 2438 disable fribidi 2439 2439 FRIBIDI_CONFIG="pkg-config fribidi" 2440 2440 if test x`which pkg-config 2>/dev/null` != x"" ; then 2441 if `pkg-config --atleast-version 0.1 9fribidi` ; then2441 if `pkg-config --atleast-version 0.10 fribidi` ; then 2442 2442 check_cc `${FRIBIDI_CONFIG} --cflags` `${FRIBIDI_CONFIG} --libs` << EOF && enable fribidi 2443 2443 #include <stdio.h> 2444 2444 #include <fribidi/fribidi.h> -
libs/libmythtv/osdtypes.cpp
707 707 m_linespacing(1.5f), 708 708 709 709 m_draw_info_str(""), 710 m_draw_info_len(0) ,710 m_draw_info_len(0) 711 711 712 codeci(NULL)713 712 { 714 713 } 715 714 … … 745 744 m_linespacing(1.5f), 746 745 747 746 m_draw_info_str(""), 748 m_draw_info_len(0) ,747 m_draw_info_len(0) 749 748 750 codeci(NULL)751 749 { 752 750 QMutexLocker locker(&other.m_lock); 753 751 … … 791 789 m_altfont = font; 792 790 } 793 791 794 QString OSDTypeText::BasicConvertFromRtoL(const QString &text)795 {796 QStringList rtl_string_composer;797 bool handle_rtl = false;798 QChar prev_char;799 800 // Handling Right-to-Left languages.801 // Left-to-Right languages are not affected.802 for (int i = (int)text.length() - 1; i >= 0; i--)803 {804 QChar::Direction text_dir = text[i].direction();805 if (text_dir != QChar::DirR &&806 text_dir != QChar::DirRLE &&807 text_dir != QChar::DirRLO)808 {809 if (handle_rtl || rtl_string_composer.empty())810 rtl_string_composer.append(QString());811 812 if (text[i].isSpace() && !prev_char.isNull()813 && prev_char.isDigit() && handle_rtl)814 rtl_string_composer.back().append(text[i]);815 else816 rtl_string_composer.back().prepend(text[i]);817 818 prev_char = text[i];819 820 handle_rtl = false;821 }822 else823 {824 if (!handle_rtl)825 {826 rtl_string_composer.append(QString());827 handle_rtl = true;828 prev_char = QChar();829 }830 rtl_string_composer.back().append(text[i]);831 }832 }833 834 QString output = rtl_string_composer.join("");835 836 return QDeepCopy<QString>(output);837 }838 839 QString OSDTypeText::ConvertFromRtoL(const QString &text) const840 {841 QString output = BasicConvertFromRtoL(text);842 843 #ifdef USING_FRIBIDI844 QMutexLocker locker(&fribidi_lock);845 if (!codeci)846 codeci = QTextCodec::codecForName("utf8");847 848 if (!codeci)849 return output;850 851 QCString temp = codeci->fromUnicode(output);852 853 FriBidiCharType base;854 size_t len;855 856 bool fribidi_flip_commas = true;857 base = (fribidi_flip_commas) ? FRIBIDI_TYPE_ON : FRIBIDI_TYPE_L;858 859 const char *ip = temp;860 FriBidiChar logical[strlen(ip) + 1], visual[strlen(ip) + 1];861 862 int char_set_num = fribidi_parse_charset("UTF-8");863 864 len = fribidi_charset_to_unicode(865 (FriBidiCharSet) char_set_num, ip, strlen(ip), logical);866 867 bool log2vis = fribidi_log2vis(868 logical, len, &base, visual, NULL, NULL, NULL); // output869 870 if (log2vis)871 len = fribidi_remove_bidi_marks(visual, len, NULL, NULL, NULL);872 873 output = "";874 for (size_t i = 0; i < len ; i++)875 output += QChar(visual[i]);876 #endif // USING_FRIBIDI877 878 return output;879 }880 881 792 void OSDTypeText::SetText(const QString &text) 882 793 { 883 794 QMutexLocker locker(&m_lock); 884 m_message = ConvertFromRtoL(text);795 m_message = text; //ConvertFromRtoL(text); 885 796 m_cursorpos = m_message.length(); 886 797 m_scrollinit = false; 887 798 } … … 895 806 void OSDTypeText::SetDefaultText(const QString &text) 896 807 { 897 808 QMutexLocker locker(&m_lock); 898 m_message = ConvertFromRtoL(text);809 m_message = text; //ConvertFromRtoL(text); 899 810 m_default_msg = QDeepCopy<QString>(m_message); 900 811 m_scrollinit = false; 901 812 } -
libs/libmythtv/osdtypes.h
238 238 void SetButton(bool is_button) { m_button = is_button; } 239 239 void SetEntryNum(int entrynum) { m_entrynum = entrynum; } 240 240 241 QString ConvertFromRtoL(const QString &text) const;242 243 static QString BasicConvertFromRtoL(const QString &text);244 245 241 protected: 246 242 ~OSDTypeText(); 247 243 … … 292 288 mutable uint m_draw_info_len; 293 289 mutable vector<DrawInfo> m_draw_info; 294 290 295 mutable QMutex fribidi_lock;296 mutable QTextCodec *codeci;297 291 }; 298 292 299 293 class OSDTypeImage : public OSDType -
libs/libmythtv/ttfont.h
8 8 #include <qstring.h> 9 9 #include <qmap.h> 10 10 #include <qcolor.h> 11 #include <qmutex.h> 11 12 12 13 #include "config.h" 13 14 … … 68 69 int height, int alphamod, kTTF_Color k = kTTF_Normal); 69 70 bool cache_glyph(unsigned short c); 70 71 72 QString ConvertFromRtoL(const QString &text) const; 73 74 static QString BasicConvertFromRtoL(const QString &text); 75 71 76 bool valid; 72 77 FT_Library library; 73 78 FT_Face face; … … 104 109 int loadedfontsize; 105 110 float m_wscale; 106 111 float m_hmult; 112 113 mutable QMutex fribidi_lock; 114 mutable QTextCodec *codeci; 115 107 116 }; 108 117 109 118 #endif -
libs/libmythtv/ttfont.cpp
21 21 22 22 #include <iostream> 23 23 24 #ifdef USING_FRIBIDI 25 #include "fribidi/fribidi.h" 26 #include <qtextcodec.h> 27 #endif // USING_FRIBIDI 28 24 29 using namespace std; 25 30 26 31 #include <cstdio> … … 430 435 surface->pow_lut); 431 436 } 432 437 438 QString TTFFont::BasicConvertFromRtoL(const QString &text) 439 { 440 QStringList rtl_string_composer; 441 bool handle_rtl = false; 442 QChar prev_char; 443 444 // Handling Right-to-Left languages. 445 // Left-to-Right languages are not affected. 446 for (int i = (int)text.length() - 1; i >= 0; i--) 447 { 448 QChar::Direction text_dir = text[i].direction(); 449 if (text_dir != QChar::DirR && 450 text_dir != QChar::DirRLE && 451 text_dir != QChar::DirRLO) 452 { 453 if (handle_rtl || rtl_string_composer.empty()) 454 rtl_string_composer.append(QString()); 455 456 if (text[i].isSpace() && !prev_char.isNull() 457 && prev_char.isDigit() && handle_rtl) 458 rtl_string_composer.back().append(text[i]); 459 else 460 rtl_string_composer.back().prepend(text[i]); 461 462 prev_char = text[i]; 463 464 handle_rtl = false; 465 } 466 else 467 { 468 if (!handle_rtl) 469 { 470 rtl_string_composer.append(QString()); 471 handle_rtl = true; 472 prev_char = QChar(); 473 } 474 rtl_string_composer.back().append(text[i]); 475 } 476 } 477 478 QString output = rtl_string_composer.join(""); 479 480 // return QDeepCopy<QString>(output); 481 return output; 482 } 483 484 QString TTFFont::ConvertFromRtoL(const QString &text) const 485 { 486 QString output = BasicConvertFromRtoL(text); 487 488 #ifdef USING_FRIBIDI 489 QMutexLocker locker(&fribidi_lock); 490 if (!codeci) 491 codeci = QTextCodec::codecForName("utf8"); 492 493 if (!codeci) 494 return output; 495 496 QCString temp = codeci->fromUnicode(text); 497 498 FriBidiCharType base; 499 size_t len; 500 501 bool fribidi_flip_commas = true; 502 base = (fribidi_flip_commas) ? FRIBIDI_TYPE_ON : FRIBIDI_TYPE_L; 503 504 const char *ip = temp; 505 FriBidiChar logical[strlen(ip) + 1], visual[strlen(ip) + 1]; 506 507 int char_set_num = fribidi_parse_charset("UTF-8"); 508 509 len = fribidi_charset_to_unicode( 510 (FriBidiCharSet) char_set_num, (char *)ip, strlen(ip), logical); 511 512 bool log2vis = fribidi_log2vis( 513 logical, len, &base, visual, NULL, NULL, NULL); // output 514 515 if (log2vis) 516 len = fribidi_remove_bidi_marks(visual, len, NULL, NULL, NULL); 517 518 output = ""; 519 for (size_t i = 0; i < len ; i++) 520 output += QChar(visual[i]); 521 #endif // USING_FRIBIDI 522 523 return output; 524 } 525 433 526 void TTFFont::DrawString(OSDSurface *surface, int x, int y, 434 527 const QString &text, int maxx, int maxy, 435 528 int alphamod, bool double_size) … … 452 545 } 453 546 rmap = create_font_raster(w, h); 454 547 455 render_text(rmap, rtmp, text, &inx, &iny, double_size);548 render_text(rmap, rtmp, ConvertFromRtoL(text), &inx, &iny, double_size); 456 549 457 550 is_pixmap = 1; 458 551