Seite 1 von 1
neutrino arabic/hebrew font support
Verfasst: Dienstag 14. Januar 2014, 15:35
von mohousch
it seems like fribdidi code from VDR/XBMC works in neutrino, with higher libfribidi version arabic text can be right rendered but some times neutrino crashes when fribidi try to mirror charset, my poor knowldge about fribidi are not enought to fix this bug ;( it could be very pretty if someone (cst?) take a look a this issue
Re: neutrino arabic/hebrew font support
Verfasst: Dienstag 14. Januar 2014, 15:50
von seife
How large is the code size increase and the fribidi library? You need to consider that the tuxbox-SD boxes all have limited FLASH size (in today's standards
Re: neutrino arabic/hebrew font support
Verfasst: Dienstag 14. Januar 2014, 16:27
von mohousch
Oh sorry i wrote in wrong section
the peace code is very very small, stripped libfribidi is about 33 kb not stripped 39kb
Code: Alles auswählen
//
#if defined (ENABLE_FRIBIDI)
std::string fribidiShapeChar(const char * text)
{
int len = strlen(text);
char Rtl[len + 1];
//
fribidi_set_mirroring(true);
fribidi_set_reorder_nsm(false);
// init to utf-8
FriBidiCharSet fribidiCharset = FRIBIDI_CHAR_SET_UTF8;
// tell bidi that we need bidirectionnel
FriBidiCharType Base = FRIBIDI_TYPE_LTR;
// our buffer
FriBidiChar *Logical = (FriBidiChar *)malloc(sizeof(FriBidiChar)*(len + 1)) ;
FriBidiChar *Visual = (FriBidiChar *)malloc(sizeof(FriBidiChar)*(len + 1)) ;
if(!Visual)
{
free(Visual);
return text;
}
// convert from the selected charset to Unicode (logical)
int RtlLen = fribidi_charset_to_unicode(fribidiCharset, const_cast<char *>(text), len, Logical);
//char *Rtl = NULL;
// logical to visual
if (fribidi_log2vis(Logical, len, &Base, Visual, NULL, NULL, NULL))
{
// removes bidirectional marks
//fribidi_remove_bidi_marks(Visual, RtlLen, NULL, NULL, NULL);
//Rtl = (char *)malloc(sizeof(char)*(RtlLen * 4 + 1));
// convert back from Unicode to the charset
fribidi_unicode_to_charset(fribidiCharset, Visual, RtlLen, Rtl);
}
free(Logical);
free(Visual);
return Rtl;
}
#endif
Code: Alles auswählen
void Font::RenderString(int x, int y, const int width, const char *text, const unsigned char color, const int boxheight, const bool utf8_encoded)
{
if (!frameBuffer->getActive())
return;
pthread_mutex_lock( &renderer->render_mutex );
// fribidi
#if defined (ENABLE_FRIBIDI)
std::string Text = fribidiShapeChar(text);
text = Text.c_str();
#endif
...
Code: Alles auswählen
int Font::getRenderWidth(const char *text, const bool utf8_encoded)
{
pthread_mutex_lock( &renderer->render_mutex );
// fribidi
#if defined (ENABLE_FRIBIDI)
std::string Text = fribidiShapeChar(text);
text = Text.c_str();
#endif
...
Re: neutrino arabic/hebrew font support
Verfasst: Dienstag 2. September 2014, 00:08
von mohousch
* push up *
BTW:
if someone is interessted and able to translate/write arabic/hebrew local please contact me