diff options
-rw-r--r-- | meson.build | 7 | ||||
-rw-r--r-- | src/entry_backend/harfbuzz.c | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/meson.build b/meson.build index 910075b..09d6a10 100644 --- a/meson.build +++ b/meson.build @@ -149,6 +149,13 @@ if wayland_client.version().version_compare('<1.20.0') ) endif +if harfbuzz.version().version_compare('<4.0.0') + add_project_arguments( + ['-DNO_HARFBUZZ_METRIC_FALLBACK=1'], + language: 'c' + ) +endif + if harfbuzz.version().version_compare('<4.4.0') add_project_arguments( ['-DNO_HARFBUZZ_FONT_CHANGED=1'], 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; } |