Add --title-url=URL option to rem2pdf.

This commit is contained in:
Dianne Skoll
2025-10-20 11:12:25 -04:00
parent 0e8889441d
commit 09814eac68
2 changed files with 16 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ my $settings = {
entry_font => 'Sans',
small_cal_font => 'Sans',
title_url => '',
title_size => 14,
header_size => 12,
daynum_size => 14,
@@ -122,6 +123,7 @@ Options:
--daynum-color=RRGGBB Set day number color
--smallcal-color=RRGGBB Set small calendar color
--bg-color=RRGGBB Set background color
--title-url=URL Link calendar title to URL
--verbose, -v Print progress messages
--help Display this help
EOF
@@ -142,6 +144,7 @@ my $ret = GetOptions('landscape|l' => \$settings->{landscape},
'wrap|y' => \$settings->{wrap_calendar},
'height|h=i' => \$settings->{height},
'title-font=s' => \$settings->{title_font},
'title-url=s' => \$settings->{title_url},
'header-font=s' => \$settings->{header_font},
'daynum-font=s' => \$settings->{daynum_font},
'entry-font=s' => \$settings->{entry_font},
@@ -572,6 +575,11 @@ you supply 3 hex digits, then they are effectively doubled, so that
The color of the calendar title at the top of the page.
=item --title-url=URL
Make the calendar title a link to URL. Note that no syntax checking is
done on the URL; it's up to you to make sure it is valid.
=item --header-color=RGB
The color of the weekday names in the header row.

View File

@@ -792,6 +792,8 @@ sub draw_title
my ($self, $cr, $settings) = @_;
my $title = $self->{monthname} . ' ' . $self->{year};
my $url = $settings->{title_url} // '';
# set_page_label not available in older versions of Cairo
eval { $cr->get_target()->set_page_label($title); };
my $layout = Pango::Cairo::create_layout($cr);
@@ -804,7 +806,13 @@ sub draw_title
$cr->save();
$self->set_cr_color($cr, $settings->{title_color});
$cr->move_to($settings->{width}/2 - $w/2, $settings->{margin_top});
if ($url ne '') {
$cr->tag_begin(Cairo::TAG_LINK, "uri='$url'");
}
Pango::Cairo::show_layout($cr, $layout);
if ($url ne '') {
$cr->tag_end(Cairo::TAG_LINK);
}
$cr->restore();
return $h + $settings->{margin_top} + $settings->{border_size};
}