From ce3ee03fe1c345145e71ac6d10eba066472c4e4b3d3c0c7ffe4ddd87cbc2e5b6 Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Fri, 17 Apr 2015 14:22:23 +0000 Subject: [PATCH 1/5] - updated to 20150417: added --user option OBS-URL: https://build.opensuse.org/package/show/M17N/fonts-config?expand=0&rev=64 --- 10-rendering-options.conf.template | 10 +- 31-metric-aliases-bw.conf | 11 +- fonts-config | 274 ++++++++++++++++++++++------- fonts-config.changes | 6 + fonts-config.spec | 4 +- 5 files changed, 238 insertions(+), 67 deletions(-) diff --git a/10-rendering-options.conf.template b/10-rendering-options.conf.template index 8135f75..0674ec4 100644 --- a/10-rendering-options.conf.template +++ b/10-rendering-options.conf.template @@ -2,7 +2,7 @@ - + @@ -58,5 +58,13 @@ _USE_EMBEDDED_BITMAPS_PLACEHOLDER_ + + + + _METRIC_ALIASES_PLACEHOLDER_ + + + + _INCLUDE_USER_RENDERING_PLACEHOLDER_ diff --git a/31-metric-aliases-bw.conf b/31-metric-aliases-bw.conf index 744a5a4..0382bc5 100644 --- a/31-metric-aliases-bw.conf +++ b/31-metric-aliases-bw.conf @@ -5,6 +5,9 @@ are not well hinted. Fall back to Liberation Sans instead, when black and white rendering was chosen. --> + + true + true @@ -18,12 +21,15 @@ + + true + true - + Times @@ -31,6 +37,9 @@ + + true + true diff --git a/fonts-config b/fonts-config index fa51dc6..8e6316e 100644 --- a/fonts-config +++ b/fonts-config @@ -129,6 +129,11 @@ with the xtt module and with recent versions of the freetype module. Generate (or don't generate) font setup for Java. +=item B<-u>, B<--user> + +Run fontconfig setup for user. It reads ~/.config/fontconfig/fonts-config, +which is user analogy of /etc/sysconfig/fonts-config. + =item B<-f>, B<--force> Force the update of all generated files even if it appears to be @@ -316,16 +321,19 @@ Mike FABIAN, 2003, Petr Gajdos >, 2014. use utf8; use English; use Getopt::Long; +use File::Basename; +use File::Path qw(make_path); use Env; use strict; my $script_start_time = time(); -my $version = 20141207; +my $version = 20150417; # # OPTIONS # +my $OPT_USER = 0; my $OPT_FORCE = 0; my $OPT_QUIET = 0; my $OPT_VERBOSE = 0; @@ -375,26 +383,35 @@ my %sysconfig_options = ( "GENERATE_JAVA_FONT_SETUP" , "OPT_JAVA", ); -my %in_files = ( - "sysconfig file", "/etc/sysconfig/fonts-config", - "rendering config template", "/usr/share/fonts-config/10-rendering-options.conf.template", - "metric compatibility config", "/usr/share/fontconfig/conf.avail/30-metric-aliases.conf", - "metric compatibility bw config", "/usr/share/fonts-config/conf.avail/31-metric-aliases-bw.conf", +my $xdg_prefix = "$HOME/.config/"; +my %files = ( + "sysconfig file", "/etc/sysconfig/fonts-config", + "user sysconfig file", "fontconfig/fonts-config", + "rendering config template", "/usr/share/fonts-config/10-rendering-options.conf.template", + "rendering config", "/etc/fonts/conf.d/10-rendering-options.conf", + "user rendering config", "fontconfig/rendering-options.conf", + "metric compatibility symlink", "/etc/fonts/conf.d/30-metric-aliases.conf", + "metric compatibility config", "/etc/fonts/conf.d/30-metric-aliases.conf", + "metric compatibility avail", "/usr/share/fontconfig/conf.avail/30-metric-aliases.conf", + "metric compatibility bw symlink", "/etc/fonts/conf.d/31-metric-aliases-bw.conf", + "local family list", "/etc/fonts/conf.d/58-family-prefer-local.conf", + "user family list", "fontconfig/family-prefer.conf", "java fontconfig properties template", "/usr/share/fonts-config/fontconfig.SuSE.properties.template", - ); -my %out_files = ( - "rendering config", "/etc/fonts/conf.d/10-rendering-options.conf", - "local family list", "/etc/fonts/conf.d/58-family-prefer-local.conf", - "metric compatibility symlink", "/etc/fonts/conf.d/30-metric-aliases.conf", - "metric compatibility bw symlink", "/etc/fonts/conf.d/31-metric-aliases-bw.conf", - "java fontconfig properties", "/usr/lib*/jvm/jre/lib/fontconfig.SuSE.properties", - ); + "java fontconfig properties", "/usr/lib*/jvm/jre/lib/fontconfig.SuSE.properties", + ); -get_option_defaults_from_sysconfig($in_files{"sysconfig file"}); + +# read sysconfig and userconfig if --user was given +get_option_defaults_from_sysconfig($files{'sysconfig file'}); +if (grep(/^--user$/, @ARGV)) { + # read variables on the top on the system ones + get_option_defaults_from_sysconfig($xdg_prefix.$files{'user sysconfig file'}); +} # process command line options my %opt; unless (GetOptions(\%opt, + 'user|u', \$OPT_USER, 'force|f', \$OPT_FORCE, 'quiet|q', \$OPT_QUIET, 'verbose|v', \$OPT_VERBOSE, @@ -447,13 +464,9 @@ if ($OPT_HELP) { if ($OPT_INFO) { # this is read by yast-fonts, so may be that # change should be reflected in this yast module - print "Input Files\n"; - for my $f (keys %in_files) { - print " $f: $in_files{$f}\n" - } - print "Output Files\n"; - for my $f (keys %out_files) { - print " $f: $out_files{$f}\n" + print "Involved Files\n"; + for my $f (keys %files) { + print " $f: $files{$f}\n" } exit 0; } @@ -472,6 +485,14 @@ elsif ($OPT_VERBOSE) { $VERBOSITY = $VERBOSITY_VERBOSE; } +# +# +# + +if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print $OPT_USER ? "USER mode ($USER)\n" : "SYSTEM mode\n"; +} + # # SYSCONFIG VARS -- debug output # @@ -479,7 +500,9 @@ elsif ($OPT_VERBOSE) { no strict "vars"; no warnings; if ($VERBOSITY >= $VERBOSITY_DEBUG) { - print "--- sysconfig options (read from $in_files{'sysconfig file'}):\n"; + print "--- sysconfig options (read from $files{'sysconfig file'}". + ($OPT_USER ? ", $xdg_prefix$files{'user sysconfig file'}" : ""). + "):\n"; for my $i (keys %sysconfig_options) { if (defined eval ("\$$i")) { printf "$i=%s\n", eval("\$$i"); @@ -494,8 +517,8 @@ use strict; # UID 0 CHECK # -if ($UID != 0 && $ENV{USER} !~ /root/) { - print "*** error: you must be root to start $0\n"; +if (!$OPT_USER && $UID != 0 && $ENV{USER} !~ /root/) { + print "*** error: no root permissions; rerun with --user for user fontconfig setting\n"; exit 1; } @@ -503,7 +526,9 @@ if ($UID != 0 && $ENV{USER} !~ /root/) { # MKFONTSCALE, MKFONTSDIR # -mkfont_scale_dir(); +if (!$OPT_USER) { + mkfont_scale_dir(); +} # The following two calls may change files in /etc/fonts, therefore # they have to be called *before* fc-cache. If anything is @@ -514,31 +539,37 @@ mkfont_scale_dir(); # FONTCONFIG RENDERING SETUP # -rendering_options(); -family_preference_config(); +rendering_options($OPT_USER); +family_preference_config($OPT_USER); # # FONTCONFIG CACHE # -run_fccache (""); -run_fccache ("32"); -run_fccache ("64"); +if (!$OPT_USER) { + run_fccache (""); + run_fccache ("32"); + run_fccache ("64"); +} # # FONT DATABASE # -run_fp_rehash (); +if (!$OPT_USER) { + run_fp_rehash (); +} # generate_java_font_setup uses fontconfig, # therefore it has to be called *after* fc-cache -if ($OPT_JAVA) { +if (!$OPT_USER && $OPT_JAVA) { generate_java_font_setup (); } -reload_xfs_config (); +if (!$OPT_USER) { + reload_xfs_config (); +} exit 0; @@ -549,6 +580,7 @@ exit 0; sub usage { print "Usage: fonts-config [option] ...\n"; + print "-u, --user Run fontconfig setup for user.\n"; print "-f, --force Force the update of all generated files even\n"; print " if it appears unnecessary according to the time stamps\n"; print "-q, --quiet Work silently, unless an error occurs.\n"; @@ -616,11 +648,10 @@ sub get_option_defaults_from_sysconfig { eval("\$$sysconfig_options{$i}=0"); } } - return (0); } else { - print "--- NOTE: $sysconfig_file doesn't exist, using builtin defaults.\n"; - return (1); + # VERBOSITY still not defined! + print "NOTE: $sysconfig_file doesn't exist, using builtin defaults.\n"; } } @@ -950,7 +981,6 @@ sub make_fonts_scale_and_fonts_dir { if ($VERBOSITY >= $VERBOSITY_DEBUG) { print "mkfontscale is not available or it failed "; print "-> creating an empty fonts.scale file.\n"; - exit 1 } $try_again = 1; my_system ("echo 0 > $dir/fonts.scale"); @@ -1074,13 +1104,22 @@ sub create_symbolic_links { # sub rendering_options { - my $suse_rendering_file = $out_files{"rendering config"}; - my $suse_rendering_template_file = $in_files{"rendering config template"}; + my ($user) = @_; + my $suse_rendering_file; + my $suse_rendering_template_file = $files{'rendering config template'}; my $suse_rendering = ""; my $suse_rendering_template = ""; + if (!$user) { + $suse_rendering_file = $files{'rendering config'}; + } + else { + $suse_rendering_file = $xdg_prefix . $files{'user rendering config'}; + my_make_path(dirname($suse_rendering_file)); + } + if ($VERBOSITY >= $VERBOSITY_DEBUG) { - printf "--- Generating $suse_rendering_file ---\n"; + printf "--- generating $suse_rendering_file ---\n"; } if (-f "$suse_rendering_template_file") { @@ -1169,6 +1208,27 @@ sub rendering_options { } } } + elsif ($ARG =~ /_SYSCONFIG_FILE_PLACEHOLDER_/) { + my $arg = ($user ? " -\\-user" : ""); + $ARG =~ s/_SYSCONFIG_FILE_PLACEHOLDER_/$files{'sysconfig file'}/; + $ARG =~ s/_FONTSCONFIG_RUN_PLACEHOLDER_/$0$arg/; + $suse_rendering_template .= $ARG; + } + elsif ($ARG =~ /_METRIC_ALIASES_PLACEHOLDER_/) { + if ($OPT_SEARCH_METRIC_COMPATIBLE) { + $ARG =~ s/_METRIC_ALIASES_PLACEHOLDER_/true/; + } else { + $ARG =~ s/_METRIC_ALIASES_PLACEHOLDER_/false/; + } + $suse_rendering_template .= $ARG; + } + elsif ($ARG =~ /_INCLUDE_USER_RENDERING_PLACEHOLDER_/) { + if (!$user) { + # let user have a possibility to override system settings + $ARG =~ s@_INCLUDE_USER_RENDERING_PLACEHOLDER_@$files{'user rendering config'}@; + $suse_rendering_template .= $ARG; + } + } else { $suse_rendering_template .= $ARG; } @@ -1266,34 +1326,89 @@ sub family_preference_list { return $cfg; } +sub family_metric_compatibility { + my ($fontconfig_metric_conf, $user) = @_; + my $suse_metric = ""; + + if (-f "$fontconfig_metric_conf") { + open (CONF, "$fontconfig_metric_conf") || die "can't open file $fontconfig_metric_conf: $!"; + binmode CONF, ":utf8"; + while () { + $suse_metric .= $ARG; + if ($ARG =~ //) { + $suse_metric .= "\t true\n" + } elsif ($ARG =~ //) { + $suse_metric .= "\n"; + $suse_metric .= "\n"; + $suse_metric .= "\n"; + $suse_metric .= "\n"; + } + } + } else { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- WARNING: $fontconfig_metric_conf doesn't exist!\n"; + } + } + + close (CONF); + return $suse_metric; +} + sub family_preference_config { - my $suse_pref_file = $out_files{"local family list"}; - my $metric_file = $in_files{"metric compatibility config"}; - my $bw_metric_file = $in_files{"metric compatibility bw config"}; - my $metric_symlink = $out_files{"metric compatibility symlink"}; - my $bw_metric_symlink = $out_files{"metric compatibility bw symlink"}; + my ($user) = @_; + my $suse_pref_file = $files{'local family list'}; + my $suse_metric_file = $files{'metric compatibility config'}; + my $metric_symlink = $files{'metric compatibility symlink'}; + my $metric_avail = $files{'metric compatibility avail'}; + my $suse_metric = ""; my $suse_pref = ""; my $edit_options; - if ($VERBOSITY >= $VERBOSITY_DEBUG) { - printf "--- Generating $suse_pref_file ---\n"; + if (!$user) { + $suse_pref_file = $files{'local family list'}; + } + else { + $suse_pref_file = $xdg_prefix . $files{'user family list'}; + my_make_path(dirname($suse_pref_file)); } - if ($OPT_SEARCH_METRIC_COMPATIBLE) { - my_symlink($metric_file, $metric_symlink); - my_symlink($bw_metric_file, $bw_metric_symlink); - } else { - my_remove_symlink($metric_symlink); - my_remove_symlink($bw_metric_symlink); + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + printf "--- generating $suse_pref_file ---\n"; + } + + if (!$user) + { + # replace fontconfig's /etc/fonts/conf.d/30-metric-aliases.conf + # by fonts-config's one + + if (-l $metric_symlink) { + my_remove_symlink($metric_symlink); + } + + $suse_metric .= family_metric_compatibility($metric_avail, $user); + + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- writing $suse_metric_file ---\n"; + print "---\n"; + } + # same name as symlink from fontconfig + open (CONF, ">$suse_metric_file") || die "can't open file $suse_metric_file: $!"; + print CONF $suse_metric; + close (CONF); } $suse_pref .= "\n"; $suse_pref .= "\n"; $suse_pref .= "\n"; $suse_pref .= "\n"; - $suse_pref .= "\n"; + $suse_pref .= "\n"; $suse_pref .= "\n"; $suse_pref .= "\n"; + if (!$user) { + $suse_pref .= "\t\n"; + $suse_pref .= "\tfontconfig/family-prefer.conf\n"; + } + $suse_pref .= "\n"; $suse_pref .= family_preference_list("sans-serif", $OPT_SANS_FAMILIES); $suse_pref .= family_preference_list("serif", $OPT_SERIF_FAMILIES); $suse_pref .= family_preference_list("monospace", $OPT_MONO_FAMILIES); @@ -1399,8 +1514,8 @@ sub run_fp_rehash { # sub generate_java_font_setup { - my @fontconfig_SuSE_properties_globs = $out_files{"java fontconfig properties"}; - my $fontconfig_SuSE_properties_template_file = $in_files{"java fontconfig properties template"}; + my @fontconfig_SuSE_properties_globs = $files{'java fontconfig properties'}; + my $fontconfig_SuSE_properties_template_file = $files{'java fontconfig properties template'}; my $fontconfig_SuSE_properties_template = ""; my @sans_japanese_priority = ("MS Gothic", "HGGothicB", @@ -1494,10 +1609,10 @@ sub generate_java_font_setup { if ($VERBOSITY == $VERBOSITY_VERBOSE) { - printf "Generating java font setup ...\n"; + printf "generating java font setup ...\n"; } if ($VERBOSITY >= $VERBOSITY_DEBUG) { - printf "--- Generating java font setup\n"; + printf "--- generating java font setup\n"; } my ($font, $file); @@ -1704,7 +1819,16 @@ sub select_java_font { # sub reload_xfs_config { - my $pids = `ps -C xfs -o pid= | sed 's:[ \t]::g'`; + my $pids; + + if (! -x '/usr/bin/ps') { + if ($VERBOSITY >= $VERBOSITY_VERBOSE) { + print "--- WARNING: ps command is missing, couldn't search for X Font Server pids\n"; + } + return; + } + + $pids = `/usr/bin/ps -C xfs -o pid= | sed 's:[ \t]::g'`; $pids =~ s/\n//; if ($pids) { @@ -1765,8 +1889,8 @@ sub my_symlink { sub my_remove_symlink { my ($link) = @_; - if ($VERBOSITY >= $VERBOSITY_DEBUG) { - print "--- remove symlink: $link .. "; + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- removing symlink: $link .. "; } if (! -l $link) { if ($VERBOSITY >= $VERBOSITY_DEBUG) { @@ -1787,6 +1911,30 @@ sub my_remove_symlink { } } +sub my_make_path { + my ($dir) = @_; + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- creating directory: $dir .. "; + } + if (-d $dir) { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "exists\n"; + } + return; + } + make_path($dir); + if (! -d $dir) { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "can not create\n"; + } + exit 1; + } + + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "created\n"; + } +} + sub search_executable { for my $file (@_) { if (-x $file) { @@ -1796,7 +1944,7 @@ sub search_executable { if ($VERBOSITY >= $VERBOSITY_DEBUG) { print "--- WARNING: no executable from "; print join(", ", @_); - print "found\n"; + print " found\n"; } return ""; } diff --git a/fonts-config.changes b/fonts-config.changes index 22e4cb4..12f73b1 100644 --- a/fonts-config.changes +++ b/fonts-config.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Apr 17 11:55:10 UTC 2015 - pgajdos@suse.com + +- updated to 20150417: + added --user option + ------------------------------------------------------------------- Mon Jan 12 13:55:20 UTC 2015 - pgajdos@suse.com diff --git a/fonts-config.spec b/fonts-config.spec index de447a0..f77d13e 100644 --- a/fonts-config.spec +++ b/fonts-config.spec @@ -1,7 +1,7 @@ # # spec file for package fonts-config # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define infinality_srcver 1-20130104_1 %define infinality_name fontconfig-infinality Name: fonts-config -Version: 20141207 +Version: 20150417 Release: 0 Summary: Configures Fonts for X Windows and other applications License: GPL-2.0+ and MIT From 5ebc5e6578b680c8cfb9105cdeb4bc2e589d48a5bd50b89a17f3f1b0275707be Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Tue, 21 Apr 2015 13:45:45 +0000 Subject: [PATCH 2/5] - updated to 20150421: * use mkpath instead of make_path [bnc#927968] * behave better when /usr/share/fontconfig/conf.avail/30-metric-aliases.conf not found * added --user option OBS-URL: https://build.opensuse.org/package/show/M17N/fonts-config?expand=0&rev=65 --- fonts-config | 42 +++++++++++++++++++++++++----------------- fonts-config.changes | 11 ++++++++++- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/fonts-config b/fonts-config index 8e6316e..1cb1e0b 100644 --- a/fonts-config +++ b/fonts-config @@ -322,7 +322,7 @@ use utf8; use English; use Getopt::Long; use File::Basename; -use File::Path qw(make_path); +use File::Path qw(mkpath); use Env; use strict; @@ -1344,13 +1344,13 @@ sub family_metric_compatibility { $suse_metric .= "\n"; } } + close (CONF); } else { if ($VERBOSITY >= $VERBOSITY_DEBUG) { print "--- WARNING: $fontconfig_metric_conf doesn't exist!\n"; } } - close (CONF); return $suse_metric; } @@ -1378,23 +1378,31 @@ sub family_preference_config { if (!$user) { - # replace fontconfig's /etc/fonts/conf.d/30-metric-aliases.conf - # by fonts-config's one + if (-e $metric_avail) { + # replace fontconfig's /etc/fonts/conf.d/30-metric-aliases.conf + # by fonts-config's one - if (-l $metric_symlink) { - my_remove_symlink($metric_symlink); + if (-l $metric_symlink) { + my_remove_symlink($metric_symlink); + } + + $suse_metric .= family_metric_compatibility($metric_avail, $user); + + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- writing $suse_metric_file ---\n"; + print "---\n"; + } + # same name as symlink from fontconfig + open (CONF, ">$suse_metric_file") || die "can't open file $suse_metric_file: $!"; + print CONF $suse_metric; + close (CONF); } - - $suse_metric .= family_metric_compatibility($metric_avail, $user); - - if ($VERBOSITY >= $VERBOSITY_DEBUG) { - print "--- writing $suse_metric_file ---\n"; - print "---\n"; + else { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- WARNING: $metric_avail not found, not writing $suse_metric_file ---\n"; + print "---\n"; + } } - # same name as symlink from fontconfig - open (CONF, ">$suse_metric_file") || die "can't open file $suse_metric_file: $!"; - print CONF $suse_metric; - close (CONF); } $suse_pref .= "\n"; @@ -1922,7 +1930,7 @@ sub my_make_path { } return; } - make_path($dir); + mkpath($dir); if (! -d $dir) { if ($VERBOSITY >= $VERBOSITY_DEBUG) { print "can not create\n"; diff --git a/fonts-config.changes b/fonts-config.changes index 12f73b1..8cb23cd 100644 --- a/fonts-config.changes +++ b/fonts-config.changes @@ -1,8 +1,17 @@ +------------------------------------------------------------------- +Tue Apr 21 13:34:43 UTC 2015 - pgajdos@suse.com + +- updated to 20150421: + * use mkpath instead of make_path [bnc#927968] + * behave better when + /usr/share/fontconfig/conf.avail/30-metric-aliases.conf + not found + ------------------------------------------------------------------- Fri Apr 17 11:55:10 UTC 2015 - pgajdos@suse.com - updated to 20150417: - added --user option + * added --user option ------------------------------------------------------------------- Mon Jan 12 13:55:20 UTC 2015 - pgajdos@suse.com From 487c9a0028eb7306759db567e4f55268464c8f0a12681c7f4367dfdf1798114e Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Tue, 21 Apr 2015 13:47:19 +0000 Subject: [PATCH 3/5] OBS-URL: https://build.opensuse.org/package/show/M17N/fonts-config?expand=0&rev=66 --- fonts-config | 2 +- fonts-config.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fonts-config b/fonts-config index 1cb1e0b..8884347 100644 --- a/fonts-config +++ b/fonts-config @@ -327,7 +327,7 @@ use Env; use strict; my $script_start_time = time(); -my $version = 20150417; +my $version = 20150421; # # OPTIONS diff --git a/fonts-config.spec b/fonts-config.spec index f77d13e..a1e29b9 100644 --- a/fonts-config.spec +++ b/fonts-config.spec @@ -19,7 +19,7 @@ %define infinality_srcver 1-20130104_1 %define infinality_name fontconfig-infinality Name: fonts-config -Version: 20150417 +Version: 20150421 Release: 0 Summary: Configures Fonts for X Windows and other applications License: GPL-2.0+ and MIT From b8b735cf4b1d0d603e7021d4f6d7852325f9fca6b4172c5a99a328b52d97dd7e Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Thu, 23 Apr 2015 12:39:45 +0000 Subject: [PATCH 4/5] - updated to 20150423: * hide local system family preference list when user's one is in action OBS-URL: https://build.opensuse.org/package/show/M17N/fonts-config?expand=0&rev=67 --- fonts-config | 45 +++++++++++++++++++++++++++++--------------- fonts-config.changes | 7 +++++++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/fonts-config b/fonts-config index 8884347..f4bc515 100644 --- a/fonts-config +++ b/fonts-config @@ -327,7 +327,7 @@ use Env; use strict; my $script_start_time = time(); -my $version = 20150421; +my $version = 20150423; # # OPTIONS @@ -1273,7 +1273,7 @@ sub rendering_options { # sub family_preference_list { - my ($family, $prefered_families) = @_; + my ($family, $prefered_families, $user) = @_; my $cfg; my @families = split(/:/, $prefered_families); @@ -1293,9 +1293,12 @@ sub family_preference_list { $family =~ s/&/&/g; if (! $OPT_FORCE_FPL) { - $cfg .= " \n"; - $cfg .= " $family\n"; - $cfg .= " \n"; + $cfg .= "\t\n"; + if (!$user) { + $cfg .= "\t\tfalse\n" + } + $cfg .= "\t\t$family\n"; + $cfg .= "\t\t\n"; for my $f (@families) { $f =~ s/&/&/g; $cfg .= " $f\n"; @@ -1303,12 +1306,12 @@ sub family_preference_list { print "[$f] "; } } - $cfg .= " \n"; - $cfg .= " \n"; + $cfg .= "\t\t\n"; + $cfg .= "\t\n"; } else { - $cfg .= " \n"; - $cfg .= " $family\n"; - $cfg .= " \n"; + $cfg .= "\t\n"; + $cfg .= "\t\t$family\n"; + $cfg .= "\t\t\n"; for my $f (@families) { $f =~ s/&/&/g; $cfg .= " $f\n"; @@ -1316,8 +1319,8 @@ sub family_preference_list { print "[$f] "; } } - $cfg .= " \n"; - $cfg .= " \n"; + $cfg .= "\t\t\n"; + $cfg .= "\t\n"; } if ($VERBOSITY >= $VERBOSITY_DEBUG) { print "\n"; @@ -1414,12 +1417,24 @@ sub family_preference_config { $suse_pref .= "\n"; if (!$user) { $suse_pref .= "\t\n"; + $suse_pref .= "\t\n"; + $suse_pref .= "\t\t\n"; + $suse_pref .= "\t\t\tfalse\n"; + $suse_pref .= "\t\t\n"; + $suse_pref .= "\t\n"; $suse_pref .= "\tfontconfig/family-prefer.conf\n"; } + else { + $suse_pref .= "\t\n"; + $suse_pref .= "\t\t\n"; + $suse_pref .= "\t\t\ttrue\n"; + $suse_pref .= "\t\t\n"; + $suse_pref .= "\t\n"; + } $suse_pref .= "\n"; - $suse_pref .= family_preference_list("sans-serif", $OPT_SANS_FAMILIES); - $suse_pref .= family_preference_list("serif", $OPT_SERIF_FAMILIES); - $suse_pref .= family_preference_list("monospace", $OPT_MONO_FAMILIES); + $suse_pref .= family_preference_list("sans-serif", $OPT_SANS_FAMILIES, $user); + $suse_pref .= family_preference_list("serif", $OPT_SERIF_FAMILIES, $user); + $suse_pref .= family_preference_list("monospace", $OPT_MONO_FAMILIES, $user); $suse_pref .= "\n"; if ($VERBOSITY >= $VERBOSITY_DEBUG) { diff --git a/fonts-config.changes b/fonts-config.changes index 8cb23cd..9f0271d 100644 --- a/fonts-config.changes +++ b/fonts-config.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Apr 23 12:02:33 UTC 2015 - pgajdos@suse.com + +- updated to 20150423: + * hide local system family preference list when user's one is + in action + ------------------------------------------------------------------- Tue Apr 21 13:34:43 UTC 2015 - pgajdos@suse.com From 55243ef54bdd1b40fde56d79c9f061c76842669690419f355bead42782df1e3c Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Fri, 24 Apr 2015 08:21:53 +0000 Subject: [PATCH 5/5] - updated to 20150424: * introduce --remove-user-setting option OBS-URL: https://build.opensuse.org/package/show/M17N/fonts-config?expand=0&rev=68 --- fonts-config | 40 ++++++++++++++++++++++++++++++++++++---- fonts-config.changes | 6 ++++++ fonts-config.spec | 2 +- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/fonts-config b/fonts-config index f4bc515..3396681 100644 --- a/fonts-config +++ b/fonts-config @@ -131,9 +131,13 @@ Generate (or don't generate) font setup for Java. =item B<-u>, B<--user> -Run fontconfig setup for user. It reads ~/.config/fontconfig/fonts-config, +run fontconfig setup for user. it reads ~/.config/fontconfig/fonts-config, which is user analogy of /etc/sysconfig/fonts-config. +=item B<-U>, B<--remove-user-setting> + +remove user setting created by by B<--user>. + =item B<-f>, B<--force> Force the update of all generated files even if it appears to be @@ -327,13 +331,14 @@ use Env; use strict; my $script_start_time = time(); -my $version = 20150423; +my $version = 20150424; # # OPTIONS # my $OPT_USER = 0; +my $OPT_REMOVE_USER_SETTING = 0; my $OPT_FORCE = 0; my $OPT_QUIET = 0; my $OPT_VERBOSE = 0; @@ -412,6 +417,7 @@ if (grep(/^--user$/, @ARGV)) { my %opt; unless (GetOptions(\%opt, 'user|u', \$OPT_USER, + 'remove-user-setting|r', \$OPT_REMOVE_USER_SETTING, 'force|f', \$OPT_FORCE, 'quiet|q', \$OPT_QUIET, 'verbose|v', \$OPT_VERBOSE, @@ -486,8 +492,15 @@ elsif ($OPT_VERBOSE) { } # +# REMOVE USER SETTING # -# + +if ($OPT_REMOVE_USER_SETTING) { + my_remove_file($xdg_prefix.$files{'user sysconfig file'}); + my_remove_file($xdg_prefix.$files{'user rendering config'}); + my_remove_file($xdg_prefix.$files{'user family list'}); + exit 0; +} if ($VERBOSITY >= $VERBOSITY_DEBUG) { print $OPT_USER ? "USER mode ($USER)\n" : "SYSTEM mode\n"; @@ -1972,4 +1985,23 @@ sub search_executable { return ""; } - +sub my_remove_file { + my ($file) = @_; + if (-e $file) { + if(unlink $file) { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- $file deleted "; + } + } + else { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- WARNING: can not delete $file "; + } + } + } + else { + if ($VERBOSITY >= $VERBOSITY_DEBUG) { + print "--- WARNING: $file does not exist, can not delete"; + } + } +} diff --git a/fonts-config.changes b/fonts-config.changes index 9f0271d..dfe8c72 100644 --- a/fonts-config.changes +++ b/fonts-config.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Apr 24 08:20:24 UTC 2015 - pgajdos@suse.com + +- updated to 20150424: + * introduce --remove-user-setting option + ------------------------------------------------------------------- Thu Apr 23 12:02:33 UTC 2015 - pgajdos@suse.com diff --git a/fonts-config.spec b/fonts-config.spec index a1e29b9..74db991 100644 --- a/fonts-config.spec +++ b/fonts-config.spec @@ -19,7 +19,7 @@ %define infinality_srcver 1-20130104_1 %define infinality_name fontconfig-infinality Name: fonts-config -Version: 20150421 +Version: 20150424 Release: 0 Summary: Configures Fonts for X Windows and other applications License: GPL-2.0+ and MIT