diff options
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | render-bitmaps.pl.in | 28 |
2 files changed, 32 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am index 20b38d9..c205f85 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,16 +5,17 @@ SUBDIRS = po svg theme_in_files = index.theme.in.in theme_DATA = $(theme_in_files:.theme.in.in=.theme) -THEME_DIRS=$(shell SIZES="$(icon_sizes)"; for size in $$SIZES; do for dir in `find $$size/* -type d`; do printf "$$dir,"; done; done | sed -e "s/,$$//g") +THEME_DIRS=$(shell SIZES="$(render_sizes)"; for size in $$SIZES; do for dir in `find $$size/* -type d`; do printf "$$dir,"; done; done | sed -e "s/,$$//g") -%.theme.in: %.theme.in.in - for size in $(icon_sizes); do \ +%.theme.in: %.theme.in.in Makefile + for size in $(render_sizes); do \ make -C svg $$size; \ done dirs="$(THEME_DIRS)"; \ sed -e "s|\@THEME_DIRS\@|$$dirs|g" < $< > $@; \ for dir in `echo $$dirs | sed -e "s/,/ /g"`; do \ - size="`dirname $$dir`"; \ + sizefull="`dirname $$dir`"; \ + size="`echo $$sizefull | sed -e 's/x.*$$//g'`"; \ context="`basename $$dir`"; \ echo "[$$dir]" >> $@; \ echo "Size=$$size" >> $@; \ @@ -39,6 +40,9 @@ THEME_DIRS=$(shell SIZES="$(icon_sizes)"; for size in $$SIZES; do for dir in `fi if test "$$context" = "emotes"; then \ echo "Context=Emotes" >> $@; \ fi; \ + if test "$$context" = "intl"; then \ + echo "Context=International" >> $@; \ + fi; \ if test "$$context" = "mimetypes"; then \ echo "Context=MimeTypes" >> $@; \ fi; \ diff --git a/render-bitmaps.pl.in b/render-bitmaps.pl.in index 5552c7f..17eaa75 100644 --- a/render-bitmaps.pl.in +++ b/render-bitmaps.pl.in @@ -27,16 +27,16 @@ GetOptions ("size|s=s" => \$sizeonly, ############################################################################ -use Data::Dumper; +$outdir =~ s|[/]?$|/|g if ($outdir ne ""); 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"; + 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); } |