meson: add 'default-fonts-dirs' option

Fixes #244
This commit is contained in:
Tim-Philipp Müller 2022-07-02 17:30:27 +01:00
parent 56a2487924
commit 0d8d75e559
2 changed files with 24 additions and 13 deletions

View File

@ -213,23 +213,21 @@ prefix = get_option('prefix')
fonts_conf = configuration_data() fonts_conf = configuration_data()
if host_machine.system() == 'windows' default_fonts_dirs = get_option('default-fonts-dirs')
fc_fonts_path = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR'] if default_fonts_dirs == ['yes']
fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE' if host_machine.system() == 'windows'
else fc_fonts_paths = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR']
if host_machine.system() == 'darwin' elif 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'] 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 else
fc_fonts_path = ['/usr/share/fonts', '/usr/local/share/fonts'] fc_fonts_paths = ['/usr/share/fonts', '/usr/local/share/fonts']
endif endif
fc_cachedir = join_paths(prefix, get_option('localstatedir'), 'cache', meson.project_name()) else
thread_dep = dependency('threads') fc_fonts_paths = default_fonts_dirs
conf.set('HAVE_PTHREAD', 1)
deps += [thread_dep]
endif endif
xml_path = '' xml_path = ''
escaped_xml_path = '' escaped_xml_path = ''
foreach p : fc_fonts_path foreach p : fc_fonts_paths
s = '\t<dir>' + p + '</dir>\n' s = '\t<dir>' + p + '</dir>\n'
xml_path += s xml_path += s
# No substitution method for string # No substitution method for string
@ -239,6 +237,15 @@ endforeach
conf.set_quoted('FC_DEFAULT_FONTS', escaped_xml_path) conf.set_quoted('FC_DEFAULT_FONTS', escaped_xml_path)
fonts_conf.set('FC_DEFAULT_FONTS', 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_templatedir = join_paths(prefix, get_option('datadir'), 'fontconfig/conf.avail')
fc_baseconfigdir = join_paths(prefix, get_option('sysconfdir'), 'fonts') fc_baseconfigdir = join_paths(prefix, get_option('sysconfdir'), 'fonts')
fc_configdir = join_paths(fc_baseconfigdir, 'conf.d') fc_configdir = join_paths(fc_baseconfigdir, 'conf.d')
@ -396,5 +403,6 @@ summary({
'Tools': not get_option('tools').disabled(), 'Tools': not get_option('tools').disabled(),
}, section: 'General', bool_yn: true, list_sep: ', ') }, section: 'General', bool_yn: true, list_sep: ', ')
summary({ summary({
'Hinting': get_option('default-hinting'), 'Hinting': preferred_hinting,
'Font directories': fc_fonts_paths,
}, section: 'Defaults', bool_yn: true, list_sep: ', ') }, section: 'Defaults', bool_yn: true, list_sep: ', ')

View File

@ -17,3 +17,6 @@ option('cache-build', type : 'feature', value : 'enabled',
# Defaults # Defaults
option('default-hinting', type: 'combo', choices: ['none', 'slight', 'medium', 'full'], value: 'slight', option('default-hinting', type: 'combo', choices: ['none', 'slight', 'medium', 'full'], value: 'slight',
description: 'Preferred hinting configuration') 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)')