]> git.sesse.net Git - vlc/commitdiff
- all: use fribidi in skins2 text rendering if available
authorCyril Deguet <asmax@videolan.org>
Sun, 20 Mar 2005 15:58:04 +0000 (15:58 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 20 Mar 2005 15:58:04 +0000 (15:58 +0000)
configure.ac
modules/gui/skins2/src/ft2_font.cpp

index 17c8da621091d83ee63427aeec42b6274e7808b7..2780bd41726591c7d82776de9316a110c25bff15 100644 (file)
@@ -2950,7 +2950,9 @@ from http://www.freetype.org/, or configure with --disable-freetype. Have a nice
     if test "${FRIBIDI_CONFIG}" != "no"
     then
       VLC_ADD_CFLAGS([freetype], [`${FRIBIDI_CONFIG} --cflags` -DHAVE_FRIBIDI])
+      VLC_ADD_CPPFLAGS([skins2], [`${FRIBIDI_CONFIG} --cflags` -DHAVE_FRIBIDI])
       VLC_ADD_LDFLAGS([freetype], [`${FRIBIDI_CONFIG} --libs`])
+      VLC_ADD_LDFLAGS([skins2], [`${FRIBIDI_CONFIG} --libs`])
     fi
   fi
 fi
index f4cddf27d5ab2b3e7e1323632078d86b459ad8b3..1edb5f241a4b6e9ce955eb001212a69aaf74bbff 100644 (file)
 #include "ft2_bitmap.hpp"
 #include "../utils/ustring.hpp"
 
+#ifdef HAVE_FRIBIDI
+#include <fribidi/fribidi.h>
+#endif
+
 
 FT2Font::FT2Font( intf_thread_t *pIntf, const string &rName, int size ):
     GenericFont( pIntf ), m_name( rName ), m_buffer( NULL ), m_size( size ),
@@ -160,6 +164,19 @@ GenericBitmap *FT2Font::drawString( const UString &rString, uint32_t color,
     // Get the length of the string
     int len = rString.length();
 
+    // Use fribidi if available
+#ifdef HAVE_FRIBIDI
+    uint32_t *pFribidiString = NULL;
+    if( len > 0 )
+    {
+        pFribidiString = new uint32_t[len+1];
+        FriBidiCharType baseDir = FRIBIDI_TYPE_ON;
+        fribidi_log2vis( (FriBidiChar*)pString, len, &baseDir,
+                         (FriBidiChar*)pFribidiString, 0, 0, 0 );
+        pString = pFribidiString;
+    }
+#endif
+
     // Array of glyph bitmaps and position
     FT_Glyph *glyphs = new FT_Glyph[len];
     int *pos = new int[len];
@@ -241,6 +258,13 @@ GenericBitmap *FT2Font::drawString( const UString &rString, uint32_t color,
         }
     }
 
+#ifdef HAVE_FRIBIDI
+    if( len > 0 )
+    {
+        delete[] pFribidiString;
+    }
+#endif
+
     // Adjust the size for vertical padding
     yMax = __MAX( yMax, m_ascender );
     yMin = __MIN( yMin, m_descender );