diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2020-07-31 07:26:11 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2020-07-31 07:26:11 +0000 |
commit | 57a224f51d6c019e4ce5d75efb22f34a8330423e (patch) | |
tree | e3d7acfe511c07650db57c485c6dcf134e2c78a5 /conf.d | |
parent | 03aa12c75e117acb0d160212536f6f832e0dc8d9 (diff) | |
download | fontconfig-57a224f51d6c019e4ce5d75efb22f34a8330423e.tar.gz |
Add Meson build system
See https://mesonbuild.com
Diffstat (limited to 'conf.d')
-rw-r--r-- | conf.d/link_confs.py | 33 | ||||
-rw-r--r-- | conf.d/meson.build | 92 | ||||
-rwxr-xr-x | conf.d/write-35-lang-normalize-conf.py | 36 |
3 files changed, 161 insertions, 0 deletions
diff --git a/conf.d/link_confs.py b/conf.d/link_confs.py new file mode 100644 index 0000000..0c42efb --- /dev/null +++ b/conf.d/link_confs.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import os +import sys +import argparse + +if __name__=='__main__': + parser = argparse.ArgumentParser() + parser.add_argument('availpath') + parser.add_argument('confpath') + parser.add_argument('links', nargs='+') + args = parser.parse_args() + + confpath = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], args.confpath) + + if not os.path.exists(confpath): + os.makedirs(confpath) + + for link in args.links: + src = os.path.join(args.availpath, link) + dst = os.path.join(confpath, link) + try: + os.symlink(src, dst) + except NotImplementedError: + # Not supported on this version of Windows + break + except OSError as e: + # Symlink privileges are not available + if len(e.args) == 1 and 'privilege' in e.args[0]: + break + raise + except FileExistsError: + pass diff --git a/conf.d/meson.build b/conf.d/meson.build new file mode 100644 index 0000000..2cb144e --- /dev/null +++ b/conf.d/meson.build @@ -0,0 +1,92 @@ +conf_files = [ + '05-reset-dirs-sample.conf', + '09-autohint-if-no-hinting.conf', + '10-autohint.conf', + '10-hinting-full.conf', + '10-hinting-medium.conf', + '10-hinting-none.conf', + '10-hinting-slight.conf', + '10-no-sub-pixel.conf', + '10-scale-bitmap-fonts.conf', + '10-sub-pixel-bgr.conf', + '10-sub-pixel-rgb.conf', + '10-sub-pixel-vbgr.conf', + '10-sub-pixel-vrgb.conf', + '10-unhinted.conf', + '11-lcdfilter-default.conf', + '11-lcdfilter-legacy.conf', + '11-lcdfilter-light.conf', + '20-unhint-small-vera.conf', + '25-unhint-nonlatin.conf', + '30-metric-aliases.conf', + '40-nonlatin.conf', + '45-generic.conf', + '45-latin.conf', + '49-sansserif.conf', + '50-user.conf', + '51-local.conf', + '60-generic.conf', + '60-latin.conf', + '65-fonts-persian.conf', + '65-khmer.conf', + '65-nonlatin.conf', + '69-unifont.conf', + '70-no-bitmaps.conf', + '70-yes-bitmaps.conf', + '80-delicious.conf', + '90-synthetic.conf', +] + +preferred_hinting = 'slight' + +conf_links = [ + '10-hinting-@0@.conf'.format(preferred_hinting), + '10-scale-bitmap-fonts.conf', + '20-unhint-small-vera.conf', + '30-metric-aliases.conf', + '40-nonlatin.conf', + '45-generic.conf', + '45-latin.conf', + '49-sansserif.conf', + '50-user.conf', + '51-local.conf', + '60-generic.conf', + '60-latin.conf', + '65-fonts-persian.conf', + '65-nonlatin.conf', + '69-unifont.conf', + '80-delicious.conf', + '90-synthetic.conf', +] + +install_data(conf_files, install_dir: join_paths(get_option('datadir'), 'fontconfig/conf.avail')) + +meson.add_install_script('link_confs.py', + join_paths(get_option('prefix'), get_option('datadir'), 'fontconfig/conf.avail'), + join_paths(get_option('sysconfdir'), 'fonts', 'conf.d'), + conf_links, +) + +# 35-lang-normalize.conf +orths = [] +foreach o : orth_files # orth_files is from fc-lang/meson.build + o = o.split('.')[0] # strip filename suffix + if not o.contains('_') # ignore those with an underscore + orths += [o] + endif +endforeach + +custom_target('35-lang-normalize.conf', + output: '35-lang-normalize.conf', + command: [find_program('write-35-lang-normalize-conf.py'), ','.join(orths), '@OUTPUT@'], + install_dir: join_paths(get_option('datadir'), 'fontconfig/conf.avail'), + install: true) + +# README +readme_cdata = configuration_data() +readme_cdata.set('TEMPLATEDIR', fc_templatedir) +configure_file(output: 'README', + input: 'README.in', + configuration: readme_cdata, + install_dir: join_paths(get_option('sysconfdir'), 'fonts', 'conf.d'), + install: true) diff --git a/conf.d/write-35-lang-normalize-conf.py b/conf.d/write-35-lang-normalize-conf.py new file mode 100755 index 0000000..33d0d0e --- /dev/null +++ b/conf.d/write-35-lang-normalize-conf.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# +# fontconfig write-35-lang-normalize-conf.py + +import os +import sys + +if len(sys.argv) < 2: + print('ERROR: usage: {} ORTH_LIST [OUTPUT.CONF]'.format(sys.argv[0])) + sys.exit(-1) + +orth_list_unsorted = sys.argv[1].split(',') + +if len(sys.argv) > 2 and sys.argv[2] != '-': + f_out = open(sys.argv[2], 'w', encoding='utf8') +else: + f_out = sys.stdout + +orth_list = sorted(sys.argv[1].split(',')) + +print('<?xml version="1.0"?>', file=f_out) +print('<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">', file=f_out) +print('<fontconfig>', file=f_out) + +for o in orth_list: + print(f' <!-- {o}* -> {o} -->', file=f_out) + print(f' <match>', file=f_out) + print(f' <test name="lang" compare="contains"><string>{o}</string></test>', file=f_out) + print(f' <edit name="lang" mode="assign" binding="same"><string>{o}</string></edit>', file=f_out) + print(f' </match>', file=f_out) + +print('</fontconfig>', file=f_out) + +f_out.close() + +sys.exit(0) |