conf.d/meson.build | 2 - meson.build | 100 ++++++++++++++++++++++++++++++++++++++++++++--------- meson_options.txt | 26 +++++++++++++ 3 files changed, 111 insertions(+), 17 deletions(-) New commits: commit 0c7bb301f44cd26d36edda38d5cd8e7bf99a44a9 Author: Tim-Philipp Müller <tim@xxxxxxxxxxxxxxx> Date: Sat Jul 2 19:12:09 2022 +0100 meson: add 'template-dir', 'baseconfig-dir', 'config-dir', and 'xml-dir' options Fixes #244 diff --git a/meson.build b/meson.build index ac02568..aca67ad 100644 --- a/meson.build +++ b/meson.build @@ -281,11 +281,25 @@ if host_machine.system() != 'windows' 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') -fc_xmldir = join_paths(prefix, get_option('datadir'), 'xml/fontconfig') +fc_templatedir = get_option('template-dir') +if fc_templatedir in ['default', 'yes', 'no'] + fc_templatedir = prefix / get_option('datadir') / 'fontconfig/conf.avail' +endif + +fc_baseconfigdir = get_option('baseconfig-dir') +if fc_baseconfigdir in ['default', 'yes', 'no'] +fc_baseconfigdir = prefix / get_option('sysconfdir') / 'fonts' +endif +fc_configdir = get_option('config-dir') +if fc_configdir in ['default', 'yes', 'no'] + fc_configdir = fc_baseconfigdir / 'conf.d' +endif + +fc_xmldir = get_option('xml-dir') +if fc_xmldir in ['default', 'yes', 'no'] + fc_xmldir = prefix / get_option('datadir') / 'xml/fontconfig' +endif conf.set_quoted('CONFIGDIR', fc_configdir) conf.set_quoted('FC_CACHEDIR', fc_cachedir) @@ -444,4 +458,8 @@ summary({ }, section: 'Defaults', bool_yn: true, list_sep: ', ') summary({ 'Cache directory': fc_cachedir, + 'Template directory': fc_templatedir, + 'Base config directory': fc_baseconfigdir, + 'Config directory': fc_configdir, + 'XML directory': fc_xmldir, }, section: 'Paths', bool_yn: true, list_sep: ', ') diff --git a/meson_options.txt b/meson_options.txt index 6c7013e..1a95241 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -27,3 +27,15 @@ option('additional-fonts-dirs', type: 'array', value: ['yes'], # Configuration paths option('cache-dir', type: 'string', value: 'default', description: 'Use DIR to store cache files (default=LOCALSTATEDIR/cache/fontconfig)') + +option('template-dir', type: 'string', value: 'default', + description: 'Use DIR to store the configuration template files (default=DATADIR/fontconfig/conf.avail)') + +option('baseconfig-dir', type: 'string', value: 'default', + description: 'Use DIR to store the base configuration files (default=SYSCONFDIR/fonts)') + +option('config-dir', type: 'string', value: 'default', + description: 'Use DIR to store active configuration files (default=BASECONFIGDIR/conf.d)') + +option('xml-dir', type: 'string', value: 'default', + description: 'Use DIR to store XML schema files (default=DATADIR/xml/fontconfig)') commit 6ae5623674d5c5ab7e83c6d3aa742081212748fc Author: Tim-Philipp Müller <tim@xxxxxxxxxxxxxxx> Date: Sat Jul 2 18:48:10 2022 +0100 meson: add 'cache-dir' option Fixes #244 diff --git a/meson.build b/meson.build index 1c01b63..ac02568 100644 --- a/meson.build +++ b/meson.build @@ -266,10 +266,16 @@ endforeach conf.set_quoted('FC_FONTPATH', escaped_xml_path) fonts_conf.set('FC_FONTPATH', 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()) +fc_cachedir = get_option('cache-dir') +if fc_cachedir in ['yes', 'no', 'default'] + if host_machine.system() == 'windows' + fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE' + else + fc_cachedir = join_paths(prefix, get_option('localstatedir'), 'cache', meson.project_name()) + endif +endif + +if host_machine.system() != 'windows' thread_dep = dependency('threads') conf.set('HAVE_PTHREAD', 1) deps += [thread_dep] @@ -436,3 +442,6 @@ summary({ 'Font directories': fc_fonts_paths, 'Additional font directories': fc_add_fonts, }, section: 'Defaults', bool_yn: true, list_sep: ', ') +summary({ + 'Cache directory': fc_cachedir, + }, section: 'Paths', bool_yn: true, list_sep: ', ') diff --git a/meson_options.txt b/meson_options.txt index 0e05e8b..6c7013e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,3 +23,7 @@ option('default-fonts-dirs', type: 'array', value: ['yes'], option('additional-fonts-dirs', type: 'array', value: ['yes'], description: 'Find additional fonts in DIR1,DIR2,... (set to "yes" for generic system-specific defaults)') + +# Configuration paths +option('cache-dir', type: 'string', value: 'default', + description: 'Use DIR to store cache files (default=LOCALSTATEDIR/cache/fontconfig)') commit 66fa47c6f16b0072d686d680abf984872a84d1b7 Author: Tim-Philipp Müller <tim@xxxxxxxxxxxxxxx> Date: Sat Jul 2 18:22:43 2022 +0100 meson: add 'additional-fonts-dirs' option Fixes #244 diff --git a/meson.build b/meson.build index 42189d2..1c01b63 100644 --- a/meson.build +++ b/meson.build @@ -237,6 +237,35 @@ endforeach conf.set_quoted('FC_DEFAULT_FONTS', escaped_xml_path) fonts_conf.set('FC_DEFAULT_FONTS', xml_path) +# Add more fonts if available. By default, add only the directories +# with outline fonts; those with bitmaps can be added as desired in +# local.conf or ~/.fonts.conf +fc_add_fonts = [] +additional_fonts_dirs = get_option('additional-fonts-dirs') +if additional_fonts_dirs == ['yes'] + fs = import('fs') + foreach dir : ['/usr/X11R6/lib/X11', '/usr/X11/lib/X11', '/usr/lib/X11'] + if fs.is_dir(dir / 'fonts') + fc_add_fonts += [dir / 'fonts'] + endif + endforeach +elif additional_fonts_dirs == ['no'] + # nothing to do +else + fc_add_fonts = additional_fonts_dirs +endif +xml_path = '' +escaped_xml_path = '' +foreach p : fc_add_fonts + s = '\t<dir>' + p + '</dir>\n' + xml_path += s + # No substitution method for string + s = '\\t<dir>' + p + '</dir>\\n' + escaped_xml_path += s +endforeach +conf.set_quoted('FC_FONTPATH', escaped_xml_path) +fonts_conf.set('FC_FONTPATH', xml_path) + if host_machine.system() == 'windows' fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE' else @@ -405,4 +434,5 @@ summary({ summary({ 'Hinting': preferred_hinting, 'Font directories': fc_fonts_paths, + 'Additional font directories': fc_add_fonts, }, section: 'Defaults', bool_yn: true, list_sep: ', ') diff --git a/meson_options.txt b/meson_options.txt index 132f6c5..0e05e8b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,3 +20,6 @@ option('default-hinting', type: 'combo', choices: ['none', 'slight', 'medium', ' 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)') + +option('additional-fonts-dirs', type: 'array', value: ['yes'], + description: 'Find additional fonts in DIR1,DIR2,... (set to "yes" for generic system-specific defaults)') commit 0d8d75e5598a98385a7bf1d5f2c1c5753c83423a Author: Tim-Philipp Müller <tim@xxxxxxxxxxxxxxx> Date: Sat Jul 2 17:30:27 2022 +0100 meson: add 'default-fonts-dirs' option Fixes #244 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<dir>' + p + '</dir>\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)') commit 56a24879246b4e4ae3bbe496b3e6d0a4443a598d Author: Tim-Philipp Müller <tim@xxxxxxxxxxxxxxx> Date: Sat Jul 2 17:05:47 2022 +0100 meson: add 'default-hinting' option Fixes #244 diff --git a/conf.d/meson.build b/conf.d/meson.build index dbb1606..1ccddc2 100644 --- a/conf.d/meson.build +++ b/conf.d/meson.build @@ -38,7 +38,7 @@ conf_files = [ '90-synthetic.conf', ] -preferred_hinting = 'slight' +preferred_hinting = get_option('default-hinting') conf_links = [ '10-hinting-@0@.conf'.format(preferred_hinting), diff --git a/meson.build b/meson.build index ab0fb13..cf21eb1 100644 --- a/meson.build +++ b/meson.build @@ -395,3 +395,6 @@ summary({ 'Tests': not get_option('tests').disabled(), 'Tools': not get_option('tools').disabled(), }, section: 'General', bool_yn: true, list_sep: ', ') +summary({ + 'Hinting': get_option('default-hinting'), + }, section: 'Defaults', bool_yn: true, list_sep: ', ') diff --git a/meson_options.txt b/meson_options.txt index b70edf1..3cad85a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,3 +13,7 @@ option('tools', type : 'feature', value : 'auto', yield : true, description: 'Build command-line tools (fc-list, fc-query, etc.)') option('cache-build', type : 'feature', value : 'enabled', description: 'Run fc-cache on install') + +# Defaults +option('default-hinting', type: 'combo', choices: ['none', 'slight', 'medium', 'full'], value: 'slight', + description: 'Preferred hinting configuration')