From fe630b0f587bc601d5932793a62fb85c3837311d Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Mon, 8 Sep 2008 09:51:13 -0400 Subject: 2008-09-08 Rodney Dawes * 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 --- render-bitmaps.pl.in | 24 ++++++++++++++++++++++-- 1 file 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); } -- cgit v1.2.3 From 2ee352bb7c0b98d985c0608579b67b7aa6f69f04 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Mon, 8 Sep 2008 15:52:32 -0400 Subject: 2008-09-08 Rodney Dawes * Makefile.am: Update to use render_sizes variable instead of icon_sizes Add missing intl context handling to index.theme generation rule --- Makefile.am | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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; \ -- cgit v1.2.3 From 069a09d6ef17741332f3aa289a26aa6b91e39223 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 9 Sep 2008 10:23:19 -0400 Subject: 2008-09-09 Rodney Dawes * render-bitmaps.pl.in: if the output directory was passed in, make sure it ends with a / (render_icons): Remove the / between $outdir and $size in the declaration of $dir --- render-bitmaps.pl.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/render-bitmaps.pl.in b/render-bitmaps.pl.in index 2c75712..17eaa75 100644 --- a/render-bitmaps.pl.in +++ b/render-bitmaps.pl.in @@ -27,7 +27,7 @@ GetOptions ("size|s=s" => \$sizeonly, ############################################################################ -use Data::Dumper; +$outdir =~ s|[/]?$|/|g if ($outdir ne ""); sub render_icons { my $filename = shift; @@ -69,7 +69,7 @@ sub render_icons { 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); -- cgit v1.2.3