new font-switcher Perl extension

Adam Spiers rxvt-unicode at adamspiers.org
Wed Jan 21 23:38:48 CET 2009


On Wed, Jan 21, 2009 at 05:04:02PM -0500, Aron Griffis wrote:
> Adam Spiers wrote:  [Wed Jan 21 2009, 02:25:45PM EST]
> > I guess you'd need a separate, parallel resource:
> > 
> >      URxvt.font-switcher-bold-list
> 
> Well, for the moment, here's what I'm doing as a halfway measure
> to avoid complexity in my configs.  It does the trick for xft
> fonts.  For x fonts, it blanks the boldFont setting so the
> non-bold font is used instead.
> 
> --- font-switcher	2009-01-21 17:03:06.000000000 -0500
> +++ skel/urxvt-scripts/font-switcher	2009-01-21 17:01:09.000000000 -0500
> @@ -90,18 +90,20 @@
>    $new_index = $#font_list if $new_index > $#font_list;
>  
>    my $new_font = $font_list[$new_index];
> +  my $bold_font = ($new_font =~ /^xft:/) ? $new_font.":bold" : "";
>    timed_popup($term, "$new_index $new_font", 0.5);
>  
>    # This has no effect by itself, but is used for the next time we
>    # lookup.  Also seems the Right Thing To Do.
>    $term->resource('font', $new_font);
> +  $term->resource('boldFont', $bold_font);
>  
>    # There's no API for changing font yet...
>    # http://thread.gmane.org/gmane.comp.terminal-emulators.rxvt-unicode.general/255
>    # $term->set_fonts($new_font);
>  
>    # so we do it via an escape sequence:
> -  $term->cmd_parse(sprintf "\33]50;%s\007", $new_font);
> -
> +  $term->cmd_parse(sprintf "\33]710;%s\007", $new_font);
> +  $term->cmd_parse(sprintf "\33]711;%s\007", $bold_font);
>    $term->want_refresh; # seems to help
>  }

Nice trick, thanks!




More information about the rxvt-unicode mailing list