[hb-view] Allow building without cairo-ft
Fixes https://github.com/harfbuzz/harfbuzz/issues/3925
This commit is contained in:
parent
f252cf80e1
commit
6add69a6ec
|
@ -181,7 +181,8 @@ if not get_option('cairo').disabled()
|
||||||
# harfbuzz support disabled, so when cairo will lookup freetype2 dependency
|
# harfbuzz support disabled, so when cairo will lookup freetype2 dependency
|
||||||
# it will be forced to use that one.
|
# it will be forced to use that one.
|
||||||
cairo_dep = dependency('cairo', required: get_option('cairo'))
|
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
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
|
|
||||||
#include "view-options.hh"
|
#include "view-options.hh"
|
||||||
#include "output-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 "helper-cairo-user.hh"
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
@ -88,14 +90,18 @@ helper_cairo_use_hb_draw (const font_options_t *font_opts)
|
||||||
static inline cairo_scaled_font_t *
|
static inline cairo_scaled_font_t *
|
||||||
helper_cairo_create_scaled_font (const font_options_t *font_opts)
|
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);
|
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;
|
cairo_font_face_t *cairo_face;
|
||||||
if (use_hb_draw)
|
if (use_hb_draw)
|
||||||
cairo_face = helper_cairo_create_user_font_face (font_opts);
|
cairo_face = helper_cairo_create_user_font_face (font_opts);
|
||||||
else
|
else
|
||||||
cairo_face = helper_cairo_create_ft_font_face (font_opts);
|
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_matrix_t ctm, font_matrix;
|
||||||
cairo_font_options_t *font_options;
|
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,
|
cairo_matrix_init_scale (&font_matrix,
|
||||||
font_opts->font_size_x,
|
font_opts->font_size_x,
|
||||||
font_opts->font_size_y);
|
font_opts->font_size_y);
|
||||||
|
#ifdef HAVE_CAIRO_FT
|
||||||
if (!use_hb_draw)
|
if (!use_hb_draw)
|
||||||
font_matrix.xy = -font_opts->slant * font_opts->font_size_x;
|
font_matrix.xy = -font_opts->slant * font_opts->font_size_x;
|
||||||
|
#endif
|
||||||
|
|
||||||
font_options = cairo_font_options_create ();
|
font_options = cairo_font_options_create ();
|
||||||
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
|
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
|
static inline bool
|
||||||
helper_cairo_scaled_font_has_color (cairo_scaled_font_t *scaled_font)
|
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)))
|
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);
|
return helper_cairo_user_scaled_font_has_color (scaled_font);
|
||||||
else
|
else
|
||||||
return helper_cairo_ft_scaled_font_has_color (scaled_font);
|
return helper_cairo_ft_scaled_font_has_color (scaled_font);
|
||||||
|
#else
|
||||||
|
return helper_cairo_user_scaled_font_has_color (scaled_font);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ hb_subset_cli_sources = [
|
||||||
util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep]
|
util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep]
|
||||||
|
|
||||||
if conf.get('HAVE_GLIB', 0) == 1
|
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,
|
hb_view = executable('hb-view', hb_view_sources,
|
||||||
cpp_args: cpp_args,
|
cpp_args: cpp_args,
|
||||||
include_directories: [incconfig, incsrc],
|
include_directories: [incconfig, incsrc],
|
||||||
|
|
Loading…
Reference in New Issue