From a0cb6eab595e67b1e45efb6e4203bea2b5bdd7ae Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Wed, 21 Dec 2022 00:10:41 +0000 Subject: Fix compilation with Harfbuzz < 4.0.0. --- src/entry_backend/harfbuzz.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/entry_backend') diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c index cc5b253..999e555 100644 --- a/src/entry_backend/harfbuzz.c +++ b/src/entry_backend/harfbuzz.c @@ -521,18 +521,36 @@ void entry_backend_harfbuzz_init( hb_font_extents_t font_extents; hb_font_get_h_extents(hb->hb_font, &font_extents); int32_t underline_depth; +#ifdef NO_HARFBUZZ_METRIC_FALLBACK + if (!hb_ot_metrics_get_position( + hb->hb_font, + HB_OT_METRICS_TAG_UNDERLINE_OFFSET, + &underline_depth)) { + underline_depth = -font_size * 64.0 / 18; + } +#else hb_ot_metrics_get_position_with_fallback( hb->hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &underline_depth); +#endif entry->cursor_theme.underline_depth = (font_extents.ascender - underline_depth) / 64.0; if (entry->cursor_theme.style == CURSOR_STYLE_UNDERSCORE && !entry->cursor_theme.thickness_specified) { int32_t thickness; +#ifdef NO_HARFBUZZ_METRIC_FALLBACK + if (!hb_ot_metrics_get_position( + hb->hb_font, + HB_OT_METRICS_TAG_UNDERLINE_SIZE, + &thickness)) { + thickness = font_size * 64.0 / 18; + } +#else hb_ot_metrics_get_position_with_fallback( hb->hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &thickness); +#endif entry->cursor_theme.thickness = thickness / 64.0; } -- cgit v1.2.3