From 0d8d75e5598a98385a7bf1d5f2c1c5753c83423a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 2 Jul 2022 17:30:27 +0100 Subject: [PATCH] meson: add 'default-fonts-dirs' option Fixes #244 --- meson.build | 34 +++++++++++++++++++++------------- meson_options.txt | 3 +++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index cf21eb1..42189d2 100644 --- a/meson.build +++ b/meson.build @@ -213,23 +213,21 @@ prefix = get_option('prefix') fonts_conf = configuration_data() -if host_machine.system() == 'windows' - fc_fonts_path = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR'] - fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE' -else - if host_machine.system() == 'darwin' - fc_fonts_path = ['/System/Library/Fonts', '/Library/Fonts', '~/Library/Fonts', '/System/Library/Assets/com_apple_MobileAsset_Font3', '/System/Library/Assets/com_apple_MobileAsset_Font4'] +default_fonts_dirs = get_option('default-fonts-dirs') +if default_fonts_dirs == ['yes'] + if host_machine.system() == 'windows' + fc_fonts_paths = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR'] + elif host_machine.system() == 'darwin' + fc_fonts_paths = ['/System/Library/Fonts', '/Library/Fonts', '~/Library/Fonts', '/System/Library/Assets/com_apple_MobileAsset_Font3', '/System/Library/Assets/com_apple_MobileAsset_Font4'] else - fc_fonts_path = ['/usr/share/fonts', '/usr/local/share/fonts'] + fc_fonts_paths = ['/usr/share/fonts', '/usr/local/share/fonts'] endif - fc_cachedir = join_paths(prefix, get_option('localstatedir'), 'cache', meson.project_name()) - thread_dep = dependency('threads') - conf.set('HAVE_PTHREAD', 1) - deps += [thread_dep] +else + fc_fonts_paths = default_fonts_dirs endif xml_path = '' escaped_xml_path = '' -foreach p : fc_fonts_path +foreach p : fc_fonts_paths s = '\t' + p + '\n' xml_path += s # No substitution method for string @@ -239,6 +237,15 @@ endforeach conf.set_quoted('FC_DEFAULT_FONTS', escaped_xml_path) fonts_conf.set('FC_DEFAULT_FONTS', xml_path) +if host_machine.system() == 'windows' + fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE' +else + fc_cachedir = join_paths(prefix, get_option('localstatedir'), 'cache', meson.project_name()) + thread_dep = dependency('threads') + conf.set('HAVE_PTHREAD', 1) + deps += [thread_dep] +endif + fc_templatedir = join_paths(prefix, get_option('datadir'), 'fontconfig/conf.avail') fc_baseconfigdir = join_paths(prefix, get_option('sysconfdir'), 'fonts') fc_configdir = join_paths(fc_baseconfigdir, 'conf.d') @@ -396,5 +403,6 @@ summary({ 'Tools': not get_option('tools').disabled(), }, section: 'General', bool_yn: true, list_sep: ', ') summary({ - 'Hinting': get_option('default-hinting'), + 'Hinting': preferred_hinting, + 'Font directories': fc_fonts_paths, }, section: 'Defaults', bool_yn: true, list_sep: ', ') diff --git a/meson_options.txt b/meson_options.txt index 3cad85a..132f6c5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -17,3 +17,6 @@ option('cache-build', type : 'feature', value : 'enabled', # Defaults option('default-hinting', type: 'combo', choices: ['none', 'slight', 'medium', 'full'], value: 'slight', description: 'Preferred hinting configuration') + +option('default-fonts-dirs', type: 'array', value: ['yes'], + description: 'Use fonts from DIR1,DIR2,... when config is busted (set to "yes" for generic system-specific defaults)')