Check for pangoft2 >= 1.38 in configure too

We need to use PKG_CHECK_MODULES(pangoft2) anyhow because we need to
link with its libraries, so make the version check there too and
simplify wxFont::AddPrivateFont() implementation in wxGTK.
This commit is contained in:
Vadim Zeitlin
2017-11-14 15:22:35 +01:00
parent 283f5a4d56
commit a98c51e6bc
3 changed files with 67 additions and 76 deletions

58
configure vendored
View File

@@ -978,8 +978,8 @@ X_CFLAGS
XMKMF XMKMF
DIRECTFB_LIBS DIRECTFB_LIBS
DIRECTFB_CFLAGS DIRECTFB_CFLAGS
FONTCONFIG_LIBS PRIVATE_FONTS_LIBS
FONTCONFIG_CFLAGS PRIVATE_FONTS_CFLAGS
GTK_CONFIG GTK_CONFIG
GTK_LIBS GTK_LIBS
GTK_CFLAGS GTK_CFLAGS
@@ -1368,8 +1368,8 @@ CXX
CXXFLAGS CXXFLAGS
CCC CCC
PKG_CONFIG PKG_CONFIG
FONTCONFIG_CFLAGS PRIVATE_FONTS_CFLAGS
FONTCONFIG_LIBS PRIVATE_FONTS_LIBS
DIRECTFB_CFLAGS DIRECTFB_CFLAGS
DIRECTFB_LIBS DIRECTFB_LIBS
XMKMF XMKMF
@@ -2352,10 +2352,10 @@ Some influential environment variables:
CXX C++ compiler command CXX C++ compiler command
CXXFLAGS C++ compiler flags CXXFLAGS C++ compiler flags
PKG_CONFIG path to pkg-config utility PKG_CONFIG path to pkg-config utility
FONTCONFIG_CFLAGS PRIVATE_FONTS_CFLAGS
C compiler flags for FONTCONFIG, overriding pkg-config C compiler flags for PRIVATE_FONTS, overriding pkg-config
FONTCONFIG_LIBS PRIVATE_FONTS_LIBS
linker flags for FONTCONFIG, overriding pkg-config linker flags for PRIVATE_FONTS, overriding pkg-config
DIRECTFB_CFLAGS DIRECTFB_CFLAGS
C compiler flags for DIRECTFB, overriding pkg-config C compiler flags for DIRECTFB, overriding pkg-config
DIRECTFB_LIBS DIRECTFB_LIBS
@@ -22482,20 +22482,20 @@ $as_echo "not found" >&6; }
pkg_failed=no pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FONTCONFIG" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PRIVATE_FONTS" >&5
$as_echo_n "checking for FONTCONFIG... " >&6; } $as_echo_n "checking for PRIVATE_FONTS... " >&6; }
if test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG"; then
if test -n "$FONTCONFIG_CFLAGS"; then if test -n "$PRIVATE_FONTS_CFLAGS"; then
pkg_cv_FONTCONFIG_CFLAGS="$FONTCONFIG_CFLAGS" pkg_cv_PRIVATE_FONTS_CFLAGS="$PRIVATE_FONTS_CFLAGS"
else else
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fontconfig\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fontconfig >= 2.8.0 pangoft2 >= 1.38.0\""; } >&5
($PKG_CONFIG --exists --print-errors "fontconfig") 2>&5 ($PKG_CONFIG --exists --print-errors "fontconfig >= 2.8.0 pangoft2 >= 1.38.0") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_FONTCONFIG_CFLAGS=`$PKG_CONFIG --cflags "fontconfig" 2>/dev/null` pkg_cv_PRIVATE_FONTS_CFLAGS=`$PKG_CONFIG --cflags "fontconfig >= 2.8.0 pangoft2 >= 1.38.0" 2>/dev/null`
else else
pkg_failed=yes pkg_failed=yes
fi fi
@@ -22504,16 +22504,16 @@ else
pkg_failed=untried pkg_failed=untried
fi fi
if test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG"; then
if test -n "$FONTCONFIG_LIBS"; then if test -n "$PRIVATE_FONTS_LIBS"; then
pkg_cv_FONTCONFIG_LIBS="$FONTCONFIG_LIBS" pkg_cv_PRIVATE_FONTS_LIBS="$PRIVATE_FONTS_LIBS"
else else
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fontconfig\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fontconfig >= 2.8.0 pangoft2 >= 1.38.0\""; } >&5
($PKG_CONFIG --exists --print-errors "fontconfig") 2>&5 ($PKG_CONFIG --exists --print-errors "fontconfig >= 2.8.0 pangoft2 >= 1.38.0") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_FONTCONFIG_LIBS=`$PKG_CONFIG --libs "fontconfig" 2>/dev/null` pkg_cv_PRIVATE_FONTS_LIBS=`$PKG_CONFIG --libs "fontconfig >= 2.8.0 pangoft2 >= 1.38.0" 2>/dev/null`
else else
pkg_failed=yes pkg_failed=yes
fi fi
@@ -22532,21 +22532,21 @@ else
_pkg_short_errors_supported=no _pkg_short_errors_supported=no
fi fi
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
FONTCONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "fontconfig"` PRIVATE_FONTS_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "fontconfig >= 2.8.0 pangoft2 >= 1.38.0"`
else else
FONTCONFIG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "fontconfig"` PRIVATE_FONTS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "fontconfig >= 2.8.0 pangoft2 >= 1.38.0"`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$FONTCONFIG_PKG_ERRORS" >&5 echo "$PRIVATE_FONTS_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: fontconfig library not found, run-time font loading won't be supported by wxFont" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: fontconfig library not found or too old, run-time font loading won't be supported by wxFont" >&5
$as_echo "$as_me: WARNING: fontconfig library not found, run-time font loading won't be supported by wxFont" >&2;} $as_echo "$as_me: WARNING: fontconfig library not found or too old, run-time font loading won't be supported by wxFont" >&2;}
elif test $pkg_failed = untried; then elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: fontconfig library not found, run-time font loading won't be supported by wxFont" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: fontconfig library not found or too old, run-time font loading won't be supported by wxFont" >&5
$as_echo "$as_me: WARNING: fontconfig library not found, run-time font loading won't be supported by wxFont" >&2;} $as_echo "$as_me: WARNING: fontconfig library not found or too old, run-time font loading won't be supported by wxFont" >&2;}
else else
FONTCONFIG_CFLAGS=$pkg_cv_FONTCONFIG_CFLAGS PRIVATE_FONTS_CFLAGS=$pkg_cv_PRIVATE_FONTS_CFLAGS
FONTCONFIG_LIBS=$pkg_cv_FONTCONFIG_LIBS PRIVATE_FONTS_LIBS=$pkg_cv_PRIVATE_FONTS_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }

View File

@@ -2963,7 +2963,7 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
dnl fi dnl fi
fi fi
PKG_CHECK_MODULES(FONTCONFIG, [fontconfig >= 2.8.0], PKG_CHECK_MODULES(PRIVATE_FONTS, [fontconfig >= 2.8.0 pangoft2 >= 1.38.0],
[ [
AC_DEFINE(wxHAVE_FONTCONFIG_2_8_0) AC_DEFINE(wxHAVE_FONTCONFIG_2_8_0)
CXXFLAGS="$FONTCONFIG_CFLAGS $CXXFLAGS" CXXFLAGS="$FONTCONFIG_CFLAGS $CXXFLAGS"

View File

@@ -601,61 +601,52 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFcConfigDestroyModule, wxModule);
bool wxFontBase::AddPrivateFont(const wxString& filename) bool wxFontBase::AddPrivateFont(const wxString& filename)
{ {
wxString why; // We already checked that we have the required functions at compile-time,
// but we should also check if they're available at run-time in case we use
// All this code only works if we have pango_context_get_font_map() which // older versions of them than the ones we were compiled with.
// is new in 1.38, so don't bother compiling -- or running -- it if this is if ( wx_pango_version_check(1,38,0) != NULL )
// not the case.
#if PANGO_VERSION_CHECK(1,38,0)
if ( wx_pango_version_check(1,38,0) == NULL )
{ {
wxLogError(_("Using private fonts is not supported on this system: "
"Pango library is too old, 1.38 or later required."));
return false;
}
if ( !gs_fcConfig )
{
gs_fcConfig = FcInitLoadConfigAndFonts();
if ( !gs_fcConfig ) if ( !gs_fcConfig )
{ {
gs_fcConfig = FcInitLoadConfigAndFonts(); wxLogError(_("Failed to create font configuration object."));
if ( !gs_fcConfig )
{
wxLogError(_("Failed to create font configuration object."));
return false;
}
}
if ( !FcConfigAppFontAddFile(gs_fcConfig,
reinterpret_cast<const FcChar8*>(
static_cast<const char*>(filename.utf8_str())
)) )
{
wxLogError(_("Failed to add custom font \"%s\"."), filename);
return false; return false;
} }
wxGtkObject<PangoContext> context(wxGetPangoContext());
PangoFontMap* const fmap = pango_context_get_font_map(context);
if ( !fmap || !PANGO_IS_FC_FONT_MAP(fmap) )
{
wxLogError(_("Failed to register font configuration using private fonts."));
return false;
}
PangoFcFontMap* const fcfmap = PANGO_FC_FONT_MAP(fmap);
pango_fc_font_map_set_config(fcfmap, gs_fcConfig);
// Ensure that the face names defined by private fonts are recognized by
// our SetFaceName() which uses wxFontEnumerator to check if the name is in
// the list of available faces.
wxFontEnumerator::InvalidateCache();
return true;
} }
else
if ( !FcConfigAppFontAddFile(gs_fcConfig,
reinterpret_cast<const FcChar8*>(
static_cast<const char*>(filename.utf8_str())
)) )
{ {
why = _("system Pango library is too old, 1.38 or later required"); wxLogError(_("Failed to add custom font \"%s\"."), filename);
return false;
} }
#else // Pango < 1.38
why = _("this application was compiled with too old Pango library version");
#endif // Pango 1.38+/1.38-
wxLogError(_("Using private fonts is not supported: %s."), why); wxGtkObject<PangoContext> context(wxGetPangoContext());
return false; PangoFontMap* const fmap = pango_context_get_font_map(context);
if ( !fmap || !PANGO_IS_FC_FONT_MAP(fmap) )
{
wxLogError(_("Failed to register font configuration using private fonts."));
return false;
}
PangoFcFontMap* const fcfmap = PANGO_FC_FONT_MAP(fmap);
pango_fc_font_map_set_config(fcfmap, gs_fcConfig);
// Ensure that the face names defined by private fonts are recognized by
// our SetFaceName() which uses wxFontEnumerator to check if the name is in
// the list of available faces.
wxFontEnumerator::InvalidateCache();
return true;
} }
#endif // wxHAS_PRIVATE_FONTS #endif // wxHAS_PRIVATE_FONTS