From 8c561733b6ea7fff75e95fde7cf3366ca7f4ee6c Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 12 Feb 2025 12:37:10 +0200 Subject: [PATCH] [test/coretext] Add a test for copying variations --- test/api/test-coretext.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/api/test-coretext.c b/test/api/test-coretext.c index 3a67d4966..0b14625d8 100644 --- a/test/api/test-coretext.c +++ b/test/api/test-coretext.c @@ -68,12 +68,42 @@ test_native_coretext_basic (void) CFRelease (ctfont); } +static void +test_native_coretext_variations (void) +{ + // Test that we copy variations from CTFont when creating hb_font_t + CTFontRef ctfont; + CFDictionaryRef variations; + CFIndex count; + hb_font_t *font; + unsigned int length; + + // System UI font is a variable font + ctfont = CTFontCreateUIFontForLanguage (kCTFontUIFontSystem, 12.0, CFSTR ("en-US")); + g_assert_nonnull (ctfont); + + variations = CTFontCopyVariation (ctfont); + g_assert_nonnull (variations); + + count = CFDictionaryGetCount (variations); + g_assert_cmpint (count, >, 0); + + font = hb_coretext_font_create (ctfont); + hb_font_get_var_coords_normalized(font, &length); + g_assert_cmpuint (length, !=, 0); + + hb_font_destroy (font); + + CFRelease (ctfont); +} + int main (int argc, char **argv) { hb_test_init (&argc, &argv); hb_test_add (test_native_coretext_basic); + hb_test_add (test_native_coretext_variations); return hb_test_run (); }