diff options
author | Rodney Dawes <dobey@gnome.org> | 2008-09-08 09:51:13 -0400 |
---|---|---|
committer | Rodney Dawes <dobey@gnome.org> | 2008-09-08 09:51:13 -0400 |
commit | fe630b0f587bc601d5932793a62fb85c3837311d (patch) | |
tree | 37285c48fe57c9dc71da275310aa3101c68024a9 | |
parent | a33aa4cdae1df567391bfe2cf1687e0c480a8832 (diff) |
2008-09-08 Rodney Dawes <dobey.pwns@gmail.com>
* render-bitmaps.pl.in (render_icons):
Check if the plate layer is visible and error out if it is
Add comments describing some of the behavior
-rw-r--r-- | render-bitmaps.pl.in | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/render-bitmaps.pl.in b/render-bitmaps.pl.in index 5552c7f..2c75712 100644 --- a/render-bitmaps.pl.in +++ b/render-bitmaps.pl.in @@ -32,11 +32,11 @@ use Data::Dumper; sub render_icons { my $filename = shift; - my $mapping = XML::Simple::XMLin ($filename, + my $svgdata = XML::Simple::XMLin ($filename, keyattr => [ qw() ], forcearray => [ qw(g rect text) ]); - foreach my $icon (@{$mapping->{g}}) { + foreach my $icon (@{$svgdata->{g}}) { my $name; my $context; @@ -44,6 +44,16 @@ sub render_icons { if (defined $plate->{'inkscape:label'} && $plate->{'inkscape:label'} =~ m/plate(.*)/) { + # Error out if the 'plate' layer is visible + # This is to prevent background squares from appearing + # inside the rendered PNG files + if (defined $plate->{style} && + $plate->{style} ne "display:none") { + die "ERROR: $filename: Plate layer not hidden.\n"; + } + + # Get the icon's name and context so we can render it + # in the right location on disk foreach my $text (@{$plate->{text}}) { if (defined $text->{'inkscape:label'} && $text->{'inkscape:label'} eq "icon-name") { @@ -53,17 +63,27 @@ sub render_icons { $context = $text->{tspan}->{content}; } } + + # Grab the rectangle inside the plate and tell + # Inkscape to render the area to our PNG file foreach my $box (@{$plate->{rect}}) { if (defined $box->{'inkscape:label'}) { my $size = $box->{'inkscape:label'}; my $dir = "$outdir/$size/$context"; + # Skip this box if the size isn't the requested size next if (defined $sizeonly && $size ne $sizeonly); if (! -d $dir) { system ("mkdir -p $dir"); } + + # Only redirect STDOUT as STDERR is useful here my $cmd = "$inkscape -i $box->{id} -e $dir/$name.png $filename > /dev/null"; + + # Print the context/name.png string to STDOUT + # We are doing this until a better cache method can + # be implemented, to avoid having to use redirection print "$context/$name.png\n"; system ($cmd); } |