diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 89c52e4e..1a5c70c3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,9 +49,13 @@ if (RT_LIBRARY) target_link_libraries(empty "${RT_LIBRARY}") target_link_libraries(threads "${RT_LIBRARY}") endif() -if (NOT WIN32) - find_package(Fontconfig REQUIRED) - target_link_libraries(input_text fontconfig) + +if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) + find_package(Fontconfig) + if (FONTCONFIG_FOUND) + target_compile_definitions(input_text PRIVATE FONTCONFIG_ENABLED) + target_link_libraries(input_text fontconfig) + endif() endif() set(GUI_ONLY_BINARIES empty gamma icon input_text inputlag joysticks tearing diff --git a/tests/input_text.c b/tests/input_text.c index 76022589..b63ff7fb 100644 --- a/tests/input_text.c +++ b/tests/input_text.c @@ -29,7 +29,8 @@ // // Currently, it is made for Japanese input only. // You have to select the correct font to display Japanese texts. -// You can set TTF_FONT_FILEPATH to set default font or you can choose a font by GUI in UNIX-like OS. +// You can set TTF_FONT_FILEPATH to set default font or you can choose a font by GUI +// if fontconfig libary is enabled in X11 or Wayland. // // To handle other languages, you need to add correct ranges to nk_font_config. // @@ -69,7 +70,7 @@ #include #include -#if !defined(_GLFW_WIN32) +#if defined(FONTCONFIG_ENABLED) #include #endif @@ -98,7 +99,7 @@ static char** fontFilePaths; static int fontNum = 0; static int currentFontIndex = 0; -#if (defined(_GLFW_WIN32) || defined(TTF_FONT_FILEPATH)) +#if (!defined(FONTCONFIG_ENABLED) || defined(TTF_FONT_FILEPATH)) static void init_font_list() { fontFamilyNames = (char**) malloc(sizeof(char*) * MAX_FONTS_LEN); @@ -207,7 +208,7 @@ static void init_font_list() static void deinit_font_list() { -#if !(defined(_GLFW_WIN32) || defined(TTF_FONT_FILEPATH)) +#if !(!defined(FONTCONFIG_ENABLED) || defined(TTF_FONT_FILEPATH)) for (int i = 1; i < fontNum; ++i) { free(fontFamilyNames[i]);