mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
neutrino: add fribidi support; ported from mohousch's nhd2
This requires libfribidi and a font with arabic or hebrew glyphs.
To build libfribidi add something like this to your makefiles:
FRIBIDI_VER = 0.19.7
$(ARCHIVE)/fribidi-$(FRIBIDI_VER).tar.bz2:
$(WGET) https://fribidi.org/download/fribidi-$(FRIBIDI_VER).tar.bz2
$(D)/libfribidi: $(ARCHIVE)/fribidi-$(FRIBIDI_VER).tar.bz2 | $(TARGETPREFIX)
$(REMOVE)/fribidi-$(FRIBIDI_VER)
$(UNTAR)/fribidi-$(FRIBIDI_VER).tar.bz2
set -e; cd $(BUILD_TMP)/fribidi-$(FRIBIDI_VER); \
$(CONFIGURE) \
--prefix= \
--mandir=/.remove \
--disable-debug \
--disable-deprecated \
--enable-charsets \
--with-glib=no \
; \
$(MAKE); \
$(MAKE) install DESTDIR=$(TARGETPREFIX)
$(REWRITE_PKGCONF) $(PKG_CONFIG_PATH)/fribidi.pc
$(REWRITE_LIBTOOL)/libfribidi.la
$(REMOVE)/fribidi-$(FRIBIDI_VER)
touch $@
If you want to link libfribidi statically add --disable-shared
and --enable-static to configure call.
Origin commit data
------------------
Branch: ni/coolstream
Commit: ffcb1ec609
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-03-30 (Thu, 30 Mar 2017)
Origin message was:
------------------
- neutrino: add fribidi support; ported from mohousch's nhd2
This requires libfribidi and a font with arabic or hebrew glyphs.
To build libfribidi add something like this to your makefiles:
FRIBIDI_VER = 0.19.7
$(ARCHIVE)/fribidi-$(FRIBIDI_VER).tar.bz2:
$(WGET) https://fribidi.org/download/fribidi-$(FRIBIDI_VER).tar.bz2
$(D)/libfribidi: $(ARCHIVE)/fribidi-$(FRIBIDI_VER).tar.bz2 | $(TARGETPREFIX)
$(REMOVE)/fribidi-$(FRIBIDI_VER)
$(UNTAR)/fribidi-$(FRIBIDI_VER).tar.bz2
set -e; cd $(BUILD_TMP)/fribidi-$(FRIBIDI_VER); \
$(CONFIGURE) \
--prefix= \
--mandir=/.remove \
--disable-debug \
--disable-deprecated \
--enable-charsets \
--with-glib=no \
; \
$(MAKE); \
$(MAKE) install DESTDIR=$(TARGETPREFIX)
$(REWRITE_PKGCONF) $(PKG_CONFIG_PATH)/fribidi.pc
$(REWRITE_LIBTOOL)/libfribidi.la
$(REMOVE)/fribidi-$(FRIBIDI_VER)
touch $@
If you want to link libfribidi statically add --disable-shared
and --enable-static to configure call.
------------------
This commit was generated by Migit
This commit is contained in:
@@ -233,6 +233,13 @@ if test "$enable_testing" = "yes"; then
|
||||
AC_DEFINE(ENABLE_TESTING,1,[include devel code parts for neutrino tests - not recommended for general users!])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([fribidi],
|
||||
AS_HELP_STRING([--enable-fribidi], [enable fribidi support])
|
||||
)
|
||||
AM_CONDITIONAL(ENABLE_FRIBIDI, test "$enable_fribidi" = "yes")
|
||||
AS_IF([test "$enable_fribidi" = "yes"],
|
||||
AC_DEFINE(ENABLE_FRIBIDI, 1, [enable fribidi support])
|
||||
)
|
||||
|
||||
if test "$BOXTYPE" = "coolstream"; then
|
||||
if test -e ${srcdir}/lib/hardware/coolstream/hd1/libcoolstream/nevis_ir.h; then
|
||||
|
@@ -132,6 +132,11 @@ neutrino_LDADD += -lgif
|
||||
else
|
||||
neutrino_LDADD += -lungif
|
||||
endif
|
||||
|
||||
if ENABLE_FRIBIDI
|
||||
neutrino_LDADD += -lfribidi
|
||||
endif
|
||||
|
||||
if ENABLE_LUA
|
||||
neutrino_LDADD += @LUA_LIBS@
|
||||
endif
|
||||
|
@@ -39,6 +39,10 @@
|
||||
#include <system/debug.h>
|
||||
#include <global.h>
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
#include <fribidi/fribidi.h>
|
||||
#endif
|
||||
|
||||
FT_Error FBFontRenderClass::myFTC_Face_Requester(FTC_FaceID face_id,
|
||||
FT_Library /*library*/,
|
||||
FT_Pointer request_data,
|
||||
@@ -388,6 +392,49 @@ int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on
|
||||
return unicode_value;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
static std::string fribidi_shape_char(const char * text)
|
||||
{
|
||||
if(text && *text)
|
||||
{
|
||||
int len = strlen(text);
|
||||
char * rtl_text = NULL;
|
||||
int rtl_len = 0;
|
||||
|
||||
fribidi_set_mirroring(true);
|
||||
fribidi_set_reorder_nsm(false);
|
||||
|
||||
// init to utf-8
|
||||
FriBidiCharSet fribidi_charset = FRIBIDI_CHAR_SET_UTF8;
|
||||
|
||||
// tell bidi that we need bidirectional
|
||||
FriBidiCharType fribidi_chartype = FRIBIDI_TYPE_L;
|
||||
|
||||
// our buffer
|
||||
FriBidiChar *logical = (FriBidiChar *)alloca(sizeof(FriBidiChar)*(len + 1));
|
||||
FriBidiChar *visual = (FriBidiChar *)alloca(sizeof(FriBidiChar)*(len + 1));
|
||||
|
||||
// convert from the selected charset to Unicode
|
||||
rtl_len = fribidi_charset_to_unicode(fribidi_charset, const_cast<char *>(text), len, logical);
|
||||
//printf("len: %d rtl_len: %d\n", len, rtl_len);
|
||||
|
||||
// logical to visual
|
||||
if (fribidi_log2vis(logical, rtl_len, &fribidi_chartype, visual, NULL, NULL, NULL))
|
||||
{
|
||||
// removes bidirectional marks
|
||||
fribidi_remove_bidi_marks(visual, rtl_len, NULL, NULL, NULL);
|
||||
|
||||
rtl_text = (char *)alloca(sizeof(char)*(rtl_len * 4 + 1));
|
||||
fribidi_unicode_to_charset(fribidi_charset, visual, rtl_len, rtl_text);
|
||||
|
||||
return std::string(rtl_text);
|
||||
}
|
||||
}
|
||||
|
||||
return std::string(text);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Font::paintFontPixel(fb_pixel_t *td, uint8_t src)
|
||||
{
|
||||
#define DST_BLUE 0x80
|
||||
@@ -448,6 +495,11 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
|
||||
|
||||
pthread_mutex_lock( &renderer->render_mutex );
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
std::string Text = fribidi_shape_char(text);
|
||||
text = Text.c_str();
|
||||
#endif
|
||||
|
||||
FT_Error err = FTC_Manager_LookupSize(renderer->cacheManager, &scaler, &size);
|
||||
if (err != 0)
|
||||
{
|
||||
@@ -638,6 +690,11 @@ int Font::getRenderWidth(const char *text, const bool utf8_encoded)
|
||||
{
|
||||
pthread_mutex_lock( &renderer->render_mutex );
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
std::string Text = fribidi_shape_char(text);
|
||||
text = Text.c_str();
|
||||
#endif
|
||||
|
||||
FT_Error err = FTC_Manager_LookupSize(renderer->cacheManager, &scaler, &size);
|
||||
if (err != 0)
|
||||
{
|
||||
|
@@ -35,6 +35,10 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
#include <fribidi/fribidi.h>
|
||||
#endif
|
||||
|
||||
FT_Error LcdFontRenderClass::myFTC_Face_Requester(FTC_FaceID face_id,
|
||||
FT_Library /*library*/,
|
||||
FT_Pointer request_data,
|
||||
@@ -230,11 +234,20 @@ extern int UTF8ToUnicode(const char * &text, const bool utf8_encoded); // return
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
std::string fribidi_shape_char(const char * text);
|
||||
#endif
|
||||
|
||||
void LcdFont::RenderString(int x, int y, const int width, const char * text, const int color, const int selected, const bool utf8_encoded)
|
||||
{
|
||||
int err;
|
||||
pthread_mutex_lock(&renderer->render_mutex);
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
std::string Text = fribidi_shape_char(text);
|
||||
text = Text.c_str();
|
||||
#endif
|
||||
|
||||
FTC_ScalerRec scaler;
|
||||
|
||||
scaler.face_id = font.face_id;
|
||||
@@ -311,6 +324,12 @@ void LcdFont::RenderString(int x, int y, const int width, const char * text, con
|
||||
int LcdFont::getRenderWidth(const char * text, const bool utf8_encoded)
|
||||
{
|
||||
pthread_mutex_lock(&renderer->render_mutex);
|
||||
|
||||
#ifdef ENABLE_FRIBIDI
|
||||
std::string Text = fribidi_shape_char(text);
|
||||
text = Text.c_str();
|
||||
#endif
|
||||
|
||||
FT_Error err;
|
||||
FTC_ScalerRec scaler;
|
||||
scaler.face_id = font.face_id;
|
||||
|
Reference in New Issue
Block a user