Support Pango markup with PANGO special.

This commit is contained in:
Dianne Skoll
2022-01-27 13:29:20 -05:00
parent 2ac6378fea
commit 32adce2de8
3 changed files with 31 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ while(1) {
{color => 1,
shade => 1,
moon => 1,
pango => 1,
week => 1,});
if (!$obj) {

View File

@@ -11,7 +11,7 @@ sub new_from_hash
my ($class, $hash) = @_;
if (exists($hash->{passthru})) {
my $special = lc($hash->{passthru});
if ($special =~ /^(html|htmlclass|week|moon|shade|color|colour|postscript|psfile)$/) {
if ($special =~ /^(html|htmlclass|week|moon|shade|color|colour|postscript|psfile|pango)$/) {
$special = 'color' if $special eq 'colour';
$class = 'Remind::PDF::Entry::' . $special;
} else {
@@ -189,6 +189,31 @@ package Remind::PDF::Entry::postscript;
use base 'Remind::PDF::Entry';
package Remind::PDF::Entry::psfile;
use base 'Remind::PDF::Entry';
package Remind::PDF::Entry::pango;
use base 'Remind::PDF::Entry';
sub render
{
my ($self, $month, $cr, $settings, $so_far, $day, $col, $height) = @_;
my ($x1, $y1, $x2, $y2) = $month->col_box_coordinates($so_far, $col, $height, $settings);
my $layout = Pango::Cairo::create_layout($cr);
$layout->set_width(1024 * ($x2 - $x1 - 2 * $settings->{border_size}));
$layout->set_wrap('word-char');
$layout->set_markup($self->{body});
my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . $settings->{entry_size} . 'px');
$layout->set_font_description($desc);
my ($wid, $h) = $layout->get_pixel_size();
if ($height) {
$cr->save();
$cr->move_to($x1 + $settings->{border_size}, $so_far);
Pango::Cairo::show_layout($cr, $layout);
$cr->restore();
}
return $h;
}
package Remind::PDF::Entry::UNKNOWN;
use base 'Remind::PDF::Entry';

View File

@@ -10,6 +10,10 @@ REM 8 MSG अनुस्मारक
REM 9 SPECIAL COLOR 0 0 128 Эскертүү
REM 10 SPECIAL COLOR 0 128 0 Напоминание
REM 11 SPECIAL COLOR 128 0 0 Υπενθύμιση
REM 12 SPECIAL PANGO <b>Bold</b> <small>and</small> <i>Italic</i> <big>and</big> <span bgcolor="#C0C0C0" foreground="red"><u>underline</u></span>
REM 12 MSG Hello
REM 13 SPECIAL PANGO Invalid
REM 1 SPECIAL SHADE 128 255 128