Commit 57cb3e53 authored by Salah-Eddin Shaban's avatar Salah-Eddin Shaban Committed by Jean-Baptiste Kempf

freetype: use HarfBuzz for text shaping

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 063cba9f
...@@ -3102,6 +3102,8 @@ AC_ARG_ENABLE(freetype, ...@@ -3102,6 +3102,8 @@ AC_ARG_ENABLE(freetype,
[ --enable-freetype freetype support (default auto)]) [ --enable-freetype freetype support (default auto)])
AC_ARG_ENABLE(fribidi, AC_ARG_ENABLE(fribidi,
[ --enable-fribidi fribidi support (default auto)]) [ --enable-fribidi fribidi support (default auto)])
AC_ARG_ENABLE(harfbuzz,
[ --enable-harfbuzz harfbuzz support (default auto)])
AC_ARG_ENABLE(fontconfig, AC_ARG_ENABLE(fontconfig,
[ --enable-fontconfig fontconfig support (default auto)]) [ --enable-fontconfig fontconfig support (default auto)])
...@@ -3130,6 +3132,7 @@ AC_ARG_WITH([default-monospace-font-family], ...@@ -3130,6 +3132,7 @@ AC_ARG_WITH([default-monospace-font-family],
have_freetype="no" have_freetype="no"
have_fontconfig="no" have_fontconfig="no"
have_fribidi="no" have_fribidi="no"
have_harfbuzz="no"
if test "${enable_freetype}" != "no"; then if test "${enable_freetype}" != "no"; then
PKG_CHECK_MODULES(FREETYPE, freetype2, [ PKG_CHECK_MODULES(FREETYPE, freetype2, [
...@@ -3152,7 +3155,18 @@ if test "${enable_freetype}" != "no"; then ...@@ -3152,7 +3155,18 @@ if test "${enable_freetype}" != "no"; then
have_fribidi="yes" have_fribidi="yes"
VLC_ADD_CPPFLAGS([skins2], [${FRIBIDI_CFLAGS} -DHAVE_FRIBIDI]) VLC_ADD_CPPFLAGS([skins2], [${FRIBIDI_CFLAGS} -DHAVE_FRIBIDI])
VLC_ADD_LIBS([skins2], [${FRIBIDI_LIBS}]) VLC_ADD_LIBS([skins2], [${FRIBIDI_LIBS}])
],[AC_MSG_WARN([${FRIBIDI_PKG_ERRORS}. Bidirectional support will be disabled in FreeType.])]) ],[AC_MSG_WARN([${FRIBIDI_PKG_ERRORS}. Bidirectional text and complex scripts (Arabic, Farsi, Thai...) will be disabled in FreeType.])])
fi
dnl harfbuzz support
if test "${have_fribidi}" != "no"; then
if test "${enable_harfbuzz}" != "no"; then
PKG_CHECK_MODULES(HARFBUZZ, harfbuzz, [
have_harfbuzz="yes"
VLC_ADD_CPPFLAGS([skins2], [${HARFBUZZ_CFLAGS} -DHAVE_HARFBUZZ])
VLC_ADD_LIBS([skins2], [${HARFBUZZ_LIBS}])
],[AC_MSG_WARN([${HARFBUZZ_PKG_ERRORS}. Support for complex scripts (Arabic, Farsi, Thai...) will be disabled in FreeType.])])
fi
fi fi
],[ ],[
AS_IF([test -n "${enable_freetype}"],[ AS_IF([test -n "${enable_freetype}"],[
...@@ -3164,6 +3178,7 @@ fi ...@@ -3164,6 +3178,7 @@ fi
AM_CONDITIONAL([HAVE_FREETYPE], [test "${have_freetype}" = "yes"]) AM_CONDITIONAL([HAVE_FREETYPE], [test "${have_freetype}" = "yes"])
AM_CONDITIONAL([HAVE_FONTCONFIG], [test "${have_fontconfig}" = "yes"]) AM_CONDITIONAL([HAVE_FONTCONFIG], [test "${have_fontconfig}" = "yes"])
AM_CONDITIONAL([HAVE_FRIBIDI], [test "${have_fribidi}" = "yes"]) AM_CONDITIONAL([HAVE_FRIBIDI], [test "${have_fribidi}" = "yes"])
AM_CONDITIONAL([HAVE_HARFBUZZ], [test "${have_harfbuzz}" = "yes"])
dnl dnl
......
...@@ -6,7 +6,8 @@ text_LTLIBRARIES = libtdummy_plugin.la ...@@ -6,7 +6,8 @@ text_LTLIBRARIES = libtdummy_plugin.la
libfreetype_plugin_la_SOURCES = \ libfreetype_plugin_la_SOURCES = \
text_renderer/text_renderer.c text_renderer/text_renderer.h \ text_renderer/text_renderer.c text_renderer/text_renderer.h \
text_renderer/platform_fonts.c text_renderer/platform_fonts.h \ text_renderer/platform_fonts.c text_renderer/platform_fonts.h \
text_renderer/freetype.c text_renderer/freetype.c text_renderer/freetype.h \
text_renderer/text_layout.c text_renderer/text_layout.h
libfreetype_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS) libfreetype_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
libfreetype_plugin_la_LIBADD = $(LIBM) $(FREETYPE_LIBS) libfreetype_plugin_la_LIBADD = $(LIBM) $(FREETYPE_LIBS)
if HAVE_FREETYPE if HAVE_FREETYPE
...@@ -20,6 +21,10 @@ if HAVE_FRIBIDI ...@@ -20,6 +21,10 @@ if HAVE_FRIBIDI
libfreetype_plugin_la_CPPFLAGS += $(FRIBIDI_CFLAGS) -DHAVE_FRIBIDI libfreetype_plugin_la_CPPFLAGS += $(FRIBIDI_CFLAGS) -DHAVE_FRIBIDI
libfreetype_plugin_la_LIBADD += $(FRIBIDI_LIBS) libfreetype_plugin_la_LIBADD += $(FRIBIDI_LIBS)
endif endif
if HAVE_HARFBUZZ
libfreetype_plugin_la_CPPFLAGS += $(HARFBUZZ_CFLAGS) -DHAVE_HARFBUZZ
libfreetype_plugin_la_LIBADD += $(HARFBUZZ_LIBS)
endif
libfreetype_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(FREETYPE_LDFLAGS) -rpath '$(textdir)' libfreetype_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(FREETYPE_LDFLAGS) -rpath '$(textdir)'
if HAVE_DARWIN if HAVE_DARWIN
libfreetype_plugin_la_LDFLAGS += -Wl,-framework,Carbon libfreetype_plugin_la_LDFLAGS += -Wl,-framework,Carbon
......
This diff is collapsed.
/*****************************************************************************
* freetype.h : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Salah-Eddin Shaban <salshaaban@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
typedef struct faces_cache_t
{
FT_Face *p_faces;
text_style_t *p_styles;
int i_faces_count;
int i_cache_size;
} faces_cache_t;
/*****************************************************************************
* filter_sys_t: freetype local data
*****************************************************************************
* This structure is part of the video output thread descriptor.
* It describes the freetype specific properties of an output thread.
*****************************************************************************/
struct filter_sys_t
{
FT_Library p_library; /* handle to library */
FT_Face p_face; /* handle to face object */
FT_Stroker p_stroker; /* handle to path stroker object */
xml_reader_t *p_xml; /* vlc xml parser */
text_style_t style; /* Current Style */
/* More styles... */
float f_shadow_vector_x;
float f_shadow_vector_y;
int i_default_font_size;
/* Attachments */
input_attachment_t **pp_font_attachments;
int i_font_attachments;
/* Font faces cache */
faces_cache_t faces_cache;
char * (*pf_select) (filter_t *, const char* family,
bool bold, bool italic, int size,
int *index);
};
#define FT_FLOOR(X) ((X & -64) >> 6)
#define FT_CEIL(X) (((X + 63) & -64) >> 6)
#ifndef FT_MulFix
#define FT_MulFix(v, s) (((v)*(s))>>16)
#endif
FT_Face LoadFace( filter_t *p_filter, const text_style_t *p_style );
This diff is collapsed.
/*****************************************************************************
* text_layout.h : Text shaping and layout
*****************************************************************************
* Copyright (C) 2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Salah-Eddin Shaban <salshaaban@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
typedef struct
{
FT_BitmapGlyph p_glyph;
FT_BitmapGlyph p_outline;
FT_BitmapGlyph p_shadow;
uint32_t i_color; /* ARGB color */
int i_line_offset; /* underline/strikethrough offset */
int i_line_thickness; /* underline/strikethrough thickness */
} line_character_t;
typedef struct line_desc_t line_desc_t;
struct line_desc_t
{
line_desc_t *p_next;
int i_width;
int i_height;
int i_base_line;
int i_character_count;
line_character_t *p_character;
FT_BBox bbox;
};
void FreeLine( line_desc_t *p_line );
void FreeLines( line_desc_t *p_lines );
line_desc_t *NewLine( int i_count );
int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
FT_BBox *p_bbox, int *pi_max_face_height,
uni_char_t *psz_text, text_style_t **pp_styles,
uint32_t *pi_k_dates, int i_len );
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment