Commit 46c8688a authored by Chun-wei Fan's avatar Chun-wei Fan

build: Check for PangoFT2/FontConfig availability

On Windows the GTK+ stack does not hard depend on PangoFT2 (thus
Fontconfig--GTK+ uses PangoWin32 to do the Font discovery and
configuration stuff by default, unless one uses an envvar to force
PangoFT2 usage), unlike *NIX platforms, so we need to check for
it by doing:

-On Windows, enable the test code that uses PangoFT2/FontConfig if
 PangoFT2 and FontConfig is found during configure.  On Visual Studio
 builds, this is set to be disabled in config.h.win32(.in), and can be
 manually enabled by uncommenting #define HAVE_PANGOFT2 1 in
 config.h.win32 prior to the build (or rebuild).  This continues to have
 FontConfig and PangoFT2 to act as an optional dependency.

-On non-Windows platforms, make PangoFT2 and FontConfig a hard dependency,
 which is what the current code assumes.

We might probably need to make the custom TTF load via PangoWin32 and/or
the native Windows API to run the tests when PangoFT2 and FontConfig are
not found on Windows.

Also bump the Pango dependency to 1.38 as the test code uses API that is
introduced in 1.38.x.

https://bugzilla.gnome.org/show_bug.cgi?id=779405
parent 8a93c3d1
......@@ -20,6 +20,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Have the pangoft2 library */
/* #define HAVE_PANGOFT2 1 */
/* Define to 1 if you have the <stdint.h> header file. */
#if !defined (_MSC_VER) || (_MSC_VER >= 1600)
#define HAVE_STDINT_H 1
......
......@@ -42,7 +42,7 @@ GLIB_REQUIRED=2.12.0
GIO_REQUIRED=2.24.0
LIBXML_REQUIRED=2.7.0
CAIRO_REQUIRED=1.2.0
PANGO_REQUIRED=1.32.6
PANGO_REQUIRED=1.38.0
GDK_PIXBUF_REQUIRED=2.20
GTK3_REQUIRED=3.10.0
CROCO_REQUIRED=0.6.1
......@@ -296,6 +296,23 @@ GLIB_LC_MESSAGES
dnl ===========================================================================
# Check for pangoft2 and fontconfig, which is optional on Windows
PKG_CHECK_MODULES([PANGOFT2],[pangoft2 >= $PANGO_REQUIRED],[have_pangoft2=yes],[have_pangoft2=no])
PKG_CHECK_MODULES([FONTCONFIG],[fontconfig],[have_fontconfig=yes],[have_fontconfig=no])
if test "x$native_win32" != "xyes"; then
if test "x$have_pangoft2" != "xyes" -o "x$have_fontconfig" != "xyes"; then
AC_MSG_ERROR([pangoft2 and fontconfig are required for non-Windows platforms.])
fi
fi
if test "x$have_pangoft2" = "xyes" -a "x$have_fontconfig" = "xyes"; then
AC_DEFINE(HAVE_PANGOFT2, 1, [Have the pangoft2 library])
fi
dnl ===========================================================================
# Check whether MSVC toolset is explicitly set
AM_CONDITIONAL(MSVC_BASE_NO_TOOLSET_SET, [test x$MSVC_BASE_TOOLSET = x])
......
......@@ -27,6 +27,8 @@
Carl Worth <cworth@cworth.org>
*/
#include "config.h"
#include "rsvg-cairo-draw.h"
#include "rsvg-cairo-clip.h"
#include "rsvg-cairo-render.h"
......
......@@ -27,6 +27,8 @@
Carl Worth <cworth@cworth.org>
*/
#include "config.h"
#include "rsvg-cairo-draw.h"
#include "rsvg-cairo-render.h"
#include "rsvg-cairo-clip.h"
......@@ -130,6 +132,7 @@ _set_rsvg_affine (RsvgCairoRender * render, cairo_matrix_t *affine)
cairo_set_matrix (cr, &matrix);
}
#ifdef HAVE_PANGOFT2
static cairo_font_options_t *
get_font_options_for_testing (void)
{
......@@ -181,6 +184,7 @@ get_font_map_for_testing (RsvgCairoRender *render)
return render->font_map_for_testing;
}
#endif
PangoContext *
rsvg_cairo_create_pango_context (RsvgDrawingCtx * ctx)
......@@ -190,11 +194,15 @@ rsvg_cairo_create_pango_context (RsvgDrawingCtx * ctx)
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
double dpi_y;
#ifdef HAVE_PANGOFT2
if (ctx->is_testing) {
fontmap = get_font_map_for_testing (render);
} else {
#endif
fontmap = pango_cairo_font_map_get_default ();
#ifdef HAVE_PANGOFT2
}
#endif
context = pango_font_map_create_context (fontmap);
pango_cairo_update_context (render->cr, context);
......@@ -202,9 +210,11 @@ rsvg_cairo_create_pango_context (RsvgDrawingCtx * ctx)
rsvg_drawing_ctx_get_dpi (ctx, NULL, &dpi_y);
pango_cairo_context_set_resolution (context, dpi_y);
#ifdef HAVE_PANGOFT2
if (ctx->is_testing) {
set_font_options_for_testing (context);
}
#endif
return context;
}
......@@ -230,7 +240,7 @@ rsvg_cairo_render_pango_layout (RsvgDrawingCtx * ctx, PangoLayout * layout, doub
PangoGravity gravity = pango_context_get_gravity (pango_layout_get_context (layout));
double rotation;
pango_layout_get_extents (layout, &ink, NULL);
pango_layout_get_extents(layout, &ink, NULL);
if (ink.width == 0 || ink.height == 0) {
return;
......
......@@ -25,6 +25,8 @@
Caleb Moore <c.moore@student.unsw.edu.au>
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
......@@ -48,6 +50,7 @@ rsvg_cairo_render_free (RsvgRender * self)
g_assert (me->bb_stack == NULL);
g_assert (me->surfaces_stack == NULL);
#ifdef HAVE_PANGOFT2
if (me->font_config_for_testing) {
FcConfigDestroy (me->font_config_for_testing);
me->font_config_for_testing = NULL;
......@@ -57,6 +60,7 @@ rsvg_cairo_render_free (RsvgRender * self)
g_object_unref (me->font_map_for_testing);
me->font_map_for_testing = NULL;
}
#endif
g_free (me);
}
......@@ -86,8 +90,11 @@ rsvg_cairo_render_new (cairo_t * cr, double width, double height)
cairo_render->cr_stack = NULL;
cairo_render->bb_stack = NULL;
cairo_render->surfaces_stack = NULL;
#ifdef HAVE_PANGOFT2
cairo_render->font_config_for_testing = NULL;
cairo_render->font_map_for_testing = NULL;
#endif
cairo_matrix_init_identity (&matrix);
rsvg_bbox_init (&cairo_render->bbox, &matrix);
......
......@@ -30,7 +30,10 @@
#include "rsvg-private.h"
#include <cairo.h>
#ifdef HAVE_PANGOFT2
#include <pango/pangofc-fontmap.h>
#endif
G_BEGIN_DECLS typedef struct _RsvgCairoRender RsvgCairoRender;
......@@ -50,8 +53,10 @@ struct _RsvgCairoRender {
GList *bb_stack;
GList *surfaces_stack;
#ifdef HAVE_PANGOFT2
FcConfig *font_config_for_testing;
PangoFontMap *font_map_for_testing;
#endif
};
#define RSVG_CAIRO_RENDER(render) (_RSVG_RENDER_CIC ((render), RSVG_RENDER_TYPE_CAIRO, RsvgCairoRender))
......
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