Enable HarfBuzz by default

HarfBuzz integration should be functional now, so to give it more wider
testing it is made now a required dependency on non-Windows non-Mac OSs.
By default text layout is now done by HarfBuzz but ICU LayoutEngine is
kept as a fallback and can be enabled with SAL_USE_ICULE env variable.

After 4.1.x is branched, ICU LayoutEngine should be removed completely.

Change-Id: I4fe3beeaf6092f33dd436906c11b83aeafdfbd5d
diff --git a/config_host/config_harfbuzz.h.in b/config_host/config_harfbuzz.h.in
deleted file mode 100644
index b408f52..0000000
--- a/config_host/config_harfbuzz.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
#ifndef CONFIG_HARFBUZZ_H
#define CONFIG_HARFBUZZ_H

#define ENABLE_HARFBUZZ 0

#endif
diff --git a/configure.ac b/configure.ac
index 75e26bd..cda53d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -720,11 +720,6 @@ AC_ARG_ENABLE(graphite,
        [Enables the compilation of Graphite smart font rendering.])
)

AC_ARG_ENABLE(harfbuzz,
    AS_HELP_STRING([--enable-harfbuzz],
        [Determines whether to use HarfBuzz text layout engine.])
)

AC_ARG_ENABLE(fetch-external,
    AS_HELP_STRING([--disable-fetch-external],
        [Disables fetching external tarballs from web sources.])
@@ -8482,10 +8477,9 @@ dnl ===================================================================
dnl HarfBuzz
dnl ===================================================================
AC_MSG_CHECKING([whether to enable HarfBuzz support])
if test "$_os" != "WINNT" -a "$_os" != "Darwin" && test "$enable_harfbuzz" = "" -o "$enable_harfbuzz" != "no"; then
if test "$_os" != "WINNT" -a "$_os" != "Darwin"; then
    AC_MSG_RESULT([yes])
    ENABLE_HARFBUZZ="TRUE"
    AC_DEFINE(ENABLE_HARFBUZZ)
    libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz >= 0.9.10])
else
    AC_MSG_RESULT([no])
@@ -11978,7 +11972,6 @@ AC_CONFIG_HEADERS([config_host/config_clang.h])
AC_CONFIG_HEADERS([config_host/config_features.h])
AC_CONFIG_HEADERS([config_host/config_global.h])
AC_CONFIG_HEADERS([config_host/config_graphite.h])
AC_CONFIG_HEADERS([config_host/config_harfbuzz.h])
AC_CONFIG_HEADERS([config_host/config_lgpl.h])
AC_CONFIG_HEADERS([config_host/config_kde4.h])
AC_CONFIG_HEADERS([config_host/config_mingw.h])
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 935a0e5..7df803f 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -17,7 +17,6 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <config_harfbuzz.h>
#include <gcach_ftyp.hxx>
#include <sallayout.hxx>
#include <salgdi.hxx>
@@ -31,10 +30,9 @@
#include <sal/alloca.h>
#include <rtl/instance.hxx>

#if ENABLE_HARFBUZZ
#include <harfbuzz/hb-icu.h>
#include <harfbuzz/hb-ot.h>
#endif

#include <layout/LayoutEngine.h>
#include <layout/LEFontInstance.h>
#include <layout/LELanguages.h>
@@ -50,10 +48,7 @@
ServerFontLayout::ServerFontLayout( ServerFont& rFont )
:   mrServerFont( rFont )
{
    bUseHarfBuzz = false;
#if ENABLE_HARFBUZZ
    bUseHarfBuzz = (getenv("SAL_USE_HARFBUZZ") != NULL);
#endif
    bUseHarfBuzz = (getenv("SAL_USE_ICULE") == NULL);
}

void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
@@ -208,7 +203,6 @@ static bool needNextCode(sal_Unicode cChar)
    return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
}

#if ENABLE_HARFBUZZ
static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData)
{
    char pTagName[5];
@@ -537,7 +531,6 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)

    return true;
}
#endif // ENABLE_HARFBUZZ

// =======================================================================
// bridge to ICU LayoutEngine
@@ -1214,12 +1207,10 @@ ServerFontLayoutEngine* ServerFont::GetLayoutEngine(bool bUseHarfBuzz)
{
    // find best layout engine for font, platform, script and language
    if (!mpLayoutEngine) {
#if ENABLE_HARFBUZZ
        if (bUseHarfBuzz)
            mpLayoutEngine = new HbLayoutEngine(*this);
        else
#endif
        mpLayoutEngine = new IcuLayoutEngine(*this);
            mpLayoutEngine = new IcuLayoutEngine(*this);
    }
    return mpLayoutEngine;
}