summaryrefslogtreecommitdiff
path: root/src/entry_backend/harfbuzz.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-12-21 00:10:41 +0000
committerPhil Jones <philj56@gmail.com>2022-12-21 00:15:19 +0000
commita0cb6eab595e67b1e45efb6e4203bea2b5bdd7ae (patch)
treed08796e6f6b136e2a77182f78fafc210a35b4bc0 /src/entry_backend/harfbuzz.c
parent6c47cf7892d0f212b04e7b798e53c120f51022d7 (diff)
Fix compilation with Harfbuzz < 4.0.0.
Diffstat (limited to 'src/entry_backend/harfbuzz.c')
-rw-r--r--src/entry_backend/harfbuzz.c18
1 files changed, 18 insertions, 0 deletions
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;
}