From 6add69a6ec422406727186fdc5a7fcde289cbfbe Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 16 Dec 2022 19:54:00 +0200 Subject: [PATCH] [hb-view] Allow building without cairo-ft Fixes https://github.com/harfbuzz/harfbuzz/issues/3925 --- meson.build | 3 ++- util/helper-cairo.hh | 16 ++++++++++++++-- util/meson.build | 3 +-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 86b5b0169..3391fc799 100644 --- a/meson.build +++ b/meson.build @@ -181,7 +181,8 @@ if not get_option('cairo').disabled() # harfbuzz support disabled, so when cairo will lookup freetype2 dependency # it will be forced to use that one. cairo_dep = dependency('cairo', required: get_option('cairo')) - cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo')) + cairo_ft_required = get_option('cairo').enabled() and get_option('freetype').enabled() + cairo_ft_dep = dependency('cairo-ft', required: cairo_ft_required) endif endif diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index fbdbbb1db..a8463de4d 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -29,7 +29,9 @@ #include "view-options.hh" #include "output-options.hh" -#include "helper-cairo-ft.hh" +#ifdef HAVE_CAIRO_FT +# include "helper-cairo-ft.hh" +#endif #include "helper-cairo-user.hh" #include @@ -88,14 +90,18 @@ helper_cairo_use_hb_draw (const font_options_t *font_opts) static inline cairo_scaled_font_t * helper_cairo_create_scaled_font (const font_options_t *font_opts) { - bool use_hb_draw = helper_cairo_use_hb_draw (font_opts); hb_font_t *font = hb_font_reference (font_opts->font); +#ifdef HAVE_CAIRO_FT + bool use_hb_draw = helper_cairo_use_hb_draw (font_opts); cairo_font_face_t *cairo_face; if (use_hb_draw) cairo_face = helper_cairo_create_user_font_face (font_opts); else cairo_face = helper_cairo_create_ft_font_face (font_opts); +#else + cairo_font_face_t *cairo_face = helper_cairo_create_user_font_face (font_opts); +#endif cairo_matrix_t ctm, font_matrix; cairo_font_options_t *font_options; @@ -104,8 +110,10 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts) cairo_matrix_init_scale (&font_matrix, font_opts->font_size_x, font_opts->font_size_y); +#ifdef HAVE_CAIRO_FT if (!use_hb_draw) font_matrix.xy = -font_opts->slant * font_opts->font_size_x; +#endif font_options = cairo_font_options_create (); cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE); @@ -132,10 +140,14 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts) static inline bool helper_cairo_scaled_font_has_color (cairo_scaled_font_t *scaled_font) { +#ifdef HAVE_CAIRO_FT if (helper_cairo_user_font_face_has_data (cairo_scaled_font_get_font_face (scaled_font))) return helper_cairo_user_scaled_font_has_color (scaled_font); else return helper_cairo_ft_scaled_font_has_color (scaled_font); +#else + return helper_cairo_user_scaled_font_has_color (scaled_font); +#endif } diff --git a/util/meson.build b/util/meson.build index fdab620fc..136740554 100644 --- a/util/meson.build +++ b/util/meson.build @@ -17,8 +17,7 @@ hb_subset_cli_sources = [ util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep] if conf.get('HAVE_GLIB', 0) == 1 - if conf.get('HAVE_FREETYPE', 0) == 1 and conf.get('HAVE_CAIRO_FT', 0) == 1 - + if conf.get('HAVE_CAIRO', 0) == 1 hb_view = executable('hb-view', hb_view_sources, cpp_args: cpp_args, include_directories: [incconfig, incsrc],