diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2013-11-03 17:20:48 +0000 |
|---|---|---|
| committer | Krzysztof Kosiński <tweenk.pl@gmail.com> | 2013-11-03 17:20:48 +0000 |
| commit | 1e3a49fabcb564b43e0aba17a7a13771ddc5f7a6 (patch) | |
| tree | 258859e2f30d806fcd284b7f3318d6f259fc106b | |
| parent | hpgl export + import and serial plotter driver extension with tool offset cor... (diff) | |
| download | inkscape-1e3a49fabcb564b43e0aba17a7a13771ddc5f7a6.tar.gz inkscape-1e3a49fabcb564b43e0aba17a7a13771ddc5f7a6.zip | |
Remove antiquated Perl extensions and modules, which were mostly useless.
(bzr r12774)
| -rwxr-xr-x | share/extensions/Inkscape.pm | 260 | ||||
| -rw-r--r-- | share/extensions/Makefile.am | 7 | ||||
| -rwxr-xr-x | share/extensions/SpSVG.pm | 351 | ||||
| -rwxr-xr-x | share/extensions/ill2svg.pl | 363 | ||||
| -rw-r--r-- | share/extensions/outline2svg.inx | 17 | ||||
| -rwxr-xr-x | share/extensions/outline2svg.pl | 165 | ||||
| -rw-r--r-- | share/extensions/txt2svg.inx | 17 | ||||
| -rwxr-xr-x | share/extensions/txt2svg.pl | 36 |
8 files changed, 0 insertions, 1216 deletions
diff --git a/share/extensions/Inkscape.pm b/share/extensions/Inkscape.pm deleted file mode 100755 index 3e9027baa..000000000 --- a/share/extensions/Inkscape.pm +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -=head1 NAME - -Inkscape - a helper for Inkscape extensions writen in PERL - -=head1 SYNOPSIS - - use Inkscape; - my ($w, $h) = $inkscape->getCanvasSize; - $svg->setElAttribute {tag=>'svg',pos=>0}, 'width', $w * 2; - -=head1 DESCRIPTION - -This package try to do the common initial work in inkscape extensions -and provide a collection of helper methods about inkscape interaction -and SVG basic manipulation. - -If you want more power to SVG manipulation, try use SVG::DOM together. -http://search.cpan.org/~ronan/SVG-2.44/lib/SVG/DOM.pm - -=cut - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Inkscape Package # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -{ -package Inkscape; -our $VERSION = "0.01"; - -=head2 The %args hash - -The B<%args> hash gives to you all arguments provided by Inkscape. - - $svg->setElAttribute 'svg', 'width', $w * $args{zoom}; - -The B<id> will allways be an array reference. Also if it is empty. - -=cut - -#use vars qw($VERSION $inkscape %args @ISA @EXPORT %EXPORT_TAGS $TODO); -#require Exporter; -#@ISA = qw(Exporter); -#my $inkscape = Inkscape->new; -#@EXPORT = qw( $inkscape ); - -sub import { - if ( defined $_[1] && $_[1] eq 'AUTO_LOAD' ) { - #$inkscape->getArgs(@ARGV); - if ( $#ARGV > -1 && -f $ARGV[$#ARGV] ) { - #$inkscape->getSVG($ARGV[$#ARGV]); - } - } -} - -sub getArgs { - my $self = shift; - my @argv = @_; - @argv = @ARGV if ( $#argv == -1 ); - my %args = (id => []); - foreach ( @argv ) { - if ( m/^--([^=]+)=(.*)$/ ) { - my $key = $1; - my $val = $2; - $val = 1 if $val eq 'true'; - $val = 0 if $val eq 'false'; - if ( defined $args{$key} ) { - if ( ref($args{$key}) ne 'ARRAY' ) { - $args{$key} = [ $args{$key} ]; - } - push( @{$args{$key}}, $val ); - } else { - $args{$key} = $val; - } - } - } - %args; -} - -sub getSVG{ - my $self = shift; - my $file = shift; - SVGHelper->new( $file ); -} - -=head2 Inkscape Methods - -The $inkscape auto defined object is a helper to use non interactive -inkscape interface. You allways need to provide an SVG file path to -the methods. - -=cut - -my $singleton; -sub new { - my $class = shift; - my $self = {}; - #$self->{args} = ( id => [] ); - $singleton ||= bless $self, $class; -} - -} # end package Inkscape - - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# SVG Package # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -{ -package SVGHelper; -our $VERSION = "0.01"; - -=head2 SVGHelper Methods - -The $svg auto defined object is a helper to access the SVG file provided -by the Inkscape. That is not a singleton, so if you want manipulate other -SVG files, you can instanciate a new SVGHelper. - -=head3 new - - my $mysvg = SVGHelper->new( '/path/to/my.svg' ); - -Instantiates SVGHelper with a SVG file. - -=cut - -sub new { - my ( $class, $file ) = @_; - my $self = {}; - $file = $ARGV[$#ARGV] if ( ! $file ); - open SVG, $file or die "Can't open \"$file\": $!\n"; - $self->{file} = $file; - $self->{code} = join('',<SVG>); - close SVG; - bless $self, $class; -} - -=head3 generateSearchRegExp - - if ( $svg->{code} =~ m/$svg->generateSearchRegExp({class=>"hot"})/ ) - print "Yes! there are Hot elements!" - -Generates the regexp string to localize tags in the SVG, based in the arguments -on the localizator hash. - -Arguments to localize the tags: - B<{id}> = "<some tag id>" - Select only one tag with this id. You don't need to use other select - arguments with this one. - B<{pos}> = <number> - When you use inprecise arguments for selection the position will select - only one tag in the defined position at the finded list of tags. - B<{tag}> = "<tag_name>" - Select by tag name, may select a list if you don't use {pos}. - B<{>B<<any tag attribute>>B<}> = <a valid attribute value> - Select by - -=cut - -sub generateSearchRegExp { - # '.*' in a value will break all. we must change '.' by '[^"]' - -} - -=head3 setElAttribute - - # Setting an attribute in a tag localizated it's id: - $svg->setElAttribute {id=>'myDrawing'}, 'width', $w * 2; - # Setting an attribute in a tag localizated it's position: - $svg->setElAttribute {tag=>'svg',pos=>0}, 'width', $w * 2; - # Setting an attribute in some tags localizated by attributes: - $svg->setElAttribute {tag=>'circle',r=>10}, 'r', 50; - -This method will set an attribute in a tag or in a colection of tags, selected -by the localizator hash. - -=cut - -sub setElAttribute { - my $self = shift; - my ( $searchArgs, $att, $val ) = @_; - print $self->generateSearchRegExp( $searchArgs ); -} - -sub convertUnit { - my $self = shift; - $_[0] =~ m/^([.0-9]*)\s*([^ ]*)/; - my $num = $1; - my $unFrom = $2 || 'px'; - my $unTo = $_[1]; - my $appendUnit = $_[2]; - # From http://www.w3.org/TR/SVG/coords.html#Units - # "1pt" equals "1.25px" (and therefore 1.25 user units) - # "1pc" equals "15px" (and therefore 15 user units) - # "1mm" would be "3.543307px" (3.543307 user units) - # "1cm" equals "35.43307px" (and therefore 35.43307 user units) - # "1in" equals "90px" (and therefore 90 user units) - my %equivPX = ( - px => 1, - pt => 1.25, - pc => 15, - mm => 3.543307, - cm => 35.43307, - in => 90 - ); - ( ( $num * $equivPX{$unFrom} ) / $equivPX{$unTo} ) . ( $appendUnit ? $unTo : '' ); -} - -=head3 getCanvasSize - - my ($w, $h) = $svg->getCanvasSize; - -Get the B<width> and B<height> values of the B<<svg>> tag. - -=cut - -sub getCanvasSize { - my $self = shift; - my $unitTo = $_[0]; - $self->{code} =~ m/<svg\s[^>]*width="([^"]*)"[^>]*height="([^"]*)"[^>]*>/; - my ( $w, $h ) = - ( $unitTo ) ? - ( $self->convertUnit($1, $unitTo), $self->convertUnit($2, $unitTo) ) : - ( $1, $2 ); -} - -my $sysNULL = ( -e '/dev/null' )? '/dev/null' : 'NIL'; - -sub getElPosition { - my $self = shift; - my $x = `inkscape --query-id=$_[0] --query-x "$self->{file}" 2>$sysNULL`; - my $y = `inkscape --query-id=$_[0] --query-y "$self->{file}" 2>$sysNULL`; - return ( $x )? ( $x, $y ) : undef; -} - -sub getElSize { - my $self = shift; - my $w = `inkscape --query-id=$_[0] --query-width "$self->{file}" 2>$sysNULL`; - my $h = `inkscape --query-id=$_[0] --query-height "$self->{file}" 2>$sysNULL`; - return ( $w )? ( $w, $h ) : undef; -} - -} # end package SVGHelper - -=head1 AUTHOR - -Aurelio A. Heckert <aurium@gmail.com> - -=head1 COPYRIGHT - -Copyright (C) 2008 Aurelio A. Heckert <aurium@gmail.com> - -This PERL module is a free software licenced under LGPL v3 -http://www.gnu.org/licenses/lgpl-3.0-standalone.html - -=cut - -1; diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index ffbe1ec77..c9a557532 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -80,10 +80,8 @@ extensions = \ hershey.py \ hersheydata.py \ hpgl_output.py \ - ill2svg.pl \ ink2canvas.py \ inkex.py \ - Inkscape.pm \ inkscape_follow_link.py \ inkwebeffect.py \ interp.py \ @@ -113,7 +111,6 @@ extensions = \ new_glyph_layer.py \ next_glyph_layer.py \ previous_glyph_layer.py \ - outline2svg.pl \ param_curves.py \ pathalongpath.py\ pathscatter.py\ @@ -147,7 +144,6 @@ extensions = \ simpletransform.py \ sk1_output.py \ sk2svg.sh \ - SpSVG.pm \ spirograph.py\ split.py \ straightseg.py \ @@ -169,7 +165,6 @@ extensions = \ text_braille.py \ text_merge.py \ triangle.py \ - txt2svg.pl \ uniconv-ext.py \ uniconv_output.py \ voronoi.py \ @@ -309,7 +304,6 @@ modules = \ new_glyph_layer.inx \ next_glyph_layer.inx \ previous_glyph_layer.inx \ - outline2svg.inx \ param_curves.inx \ pathalongpath.inx\ pathscatter.inx\ @@ -354,7 +348,6 @@ modules = \ text_braille.inx \ text_merge.inx \ triangle.inx \ - txt2svg.inx \ voronoi2svg.inx \ webslicer_create_group.inx \ webslicer_create_rect.inx \ diff --git a/share/extensions/SpSVG.pm b/share/extensions/SpSVG.pm deleted file mode 100755 index 5976d6d97..000000000 --- a/share/extensions/SpSVG.pm +++ /dev/null @@ -1,351 +0,0 @@ -#!/usr/bin/env perl -w -# -# SpSVG -# -# Perl module for sodipodi extensions -# -# This is a temporary hack that provides the following: -# * Some standard getopts (help, i/o, ids) -# * A way to exit that produces the error codes outlined in -# the extension specs (SpSVG::error) -# * A method that takes a function as its arguments and passes -# each specified element ('--id=foo --id=bar', 'ids=fooz,baaz', -# and so forth) as plain text to the function. The function is -# expected to return the processed version of this text. -# -# TODO: -# -# * Write POD -# * Exit with a friendly message if XML::XQL isn't installed -# * Decide how to implement the module interface -# * Move from XML::XQL to SVG/SVG::Parser (see below) -# * Make the process method more efficient (again, see below) -# -# Authors: Daniel Goude (goude@dtek.chalmers.se) -# - -package SpSVG; # Think of a better name -use strict; -#use Carp; -use Exporter; -use Getopt::Long; -#use Data::Dumper; # For debugging - -# From the SVG.pm documentation (actually -# http://roasp.com/tutorial/tutorial6.shtml): -# -# > Currently, version 2.0 of SVG.pm does not internally support DOM -# > traversiong functionality such as getting the children,siblings,or -# > parent of an element, so the interaction capability between SVG::Parser -# > and SVG is limited to manipulations of a known image. The next version -# > of SVG will support all these and more key functions which will make -# > SVG::Parser extremely useful. -# -# I plan to replace the /XML::XQL(::DOM)?/ code as soon as this is -# fixed. - -#use SVG; -#use SVG::Parser; - -use XML::XQL; -use XML::XQL::DOM; - -use vars qw(@ISA @EXPORT $VERSION); - -$VERSION = 1.02; # fixme: use SpSVG 1.01 doesn't raise exception. -@ISA = qw(Exporter); - -# Symbols -@EXPORT = qw( - -); - -sub new { - my $self = { - status => make_status(), - name => '', # Name of script - usage => '', # Usage string - opt_help => [], # Used for --help - - ids => [], # Array of ids that will be iterated over - # in process() - svg => '', # SVG document object - - }; - bless $self; -} - -sub parse { - my $self = shift; - - my $infile = $self->{'opts'}->{'file'}; - - my $xml; - { - local $/=undef; - if ($infile) { - open (IN, $infile) or - $self->error('IO_ERR', "Can't open $infile: $!\n"); - $xml = <IN>; - close IN or - $self->error('IO_ERR', "Can't close $infile: $!\n"); - } else { - $xml = <>; - } - } - - - $self->{'parser'} = new XML::DOM::Parser; - my $parser = $self->{'parser'}; - my $svg = $parser->parse($xml) || - $self->error('INPUT_ERR', "Couldn't parse input: $!."); - $self->{'svg'} = $svg; -} - -# Return SVG document as a string -sub get { - my $self = shift; - my $string = $self->{'svg'}->toString; - -} - -# Print to $outfile|STDOUT -sub dump { - my $self = shift; - my $outfile = $self->{'opts'}->{'output'}; - if ($outfile) { - open(OUT, ">$outfile") or - $self->error('IO_ERR', "Can't open $outfile for writing: $!\n"); - print OUT $self->get; - close OUT or $self->error('IO_ERR', "Can't close $outfile: $!\n"); - } else { - print $self->get; - } -} - -sub process_ids { - my $self = shift; - my $func = shift; - - my @ids = @{$self->{'ids'}}; - - # Apply a user supplied function to each id - foreach my $id (@ids) { - my $svg = $self->{'svg'}; - #warn "ID: $id\n"; - my @nodes = $svg->xql("//*[\@id = '$id']") or - $self->error('NOOP_ERR', "Couldn't find element $id."); - my $node = shift @nodes; # Ids are unique - # fixme: Add more checking. - - # Call the user function on the node identified by $id - my $new_node = $func->($node->toString); - - # Replace the comment with user generated SVG - my $parent = $node->getParentNode; - my $comment = $svg->createComment('SpSVG'); - $parent->replaceChild($comment, $node); - my $output = $self->{'svg'}->toString; - $output =~ s/<!--SpSVG-->/$new_node/; - - # Here the whole (new) document is parsed. Probably VERY inefficient, - # but at least you get syntax checking for free.. - $self->{'svg'} = $self->{'parser'}->parse($output); - #print $self->{'svg'}->toString; - } - - -} - -# Exit status codes -sub make_status { - my $self = shift; - my %status = ( - 0 => ["SUCCESS", "Extension exited gracefully"], - 1 => ["GEN_FAIL", "General failure"], - 2 => ["MEM_ERR", "Memory error"], - 3 => ["IO_ERR", "File I/O error"], - 4 => ["MATH_ERR", "Math error"], - 5 => ["INPUT_ERR", "Input not understood (not valid SVG)"], - 6 => ["NOOP_ERR", "Could not operate on any objects in this " . - "data stream"], - 7 => ["ARG_ERR", "Incorrect script arguments"] - ); - - # Generate error subs dynamically - foreach my $exit_code (sort keys %status) { - eval "sub $status{$exit_code}[0] { $exit_code; }"; - die $@ if $@; - } - return \%status; - -} - -# Create an option array suitable for Getopt::Long -sub make_opt_vals { - my $self = shift; - my @opt_desc = @_; - my @opt_vals; - my @opt_help = @{$self->{'opt_help'}}; - foreach (@opt_desc) { - my %h = %$_; - foreach my $key (keys %h) { - #print "Key : $h{$key}\n"; - if ($key eq 'opt') { - push @opt_vals, $h{'opt'}; - } elsif ($key eq 'desc') { - my $option = $h{'opt'}; - $option =~ s/([^=]+)=.+/$1/; - $option =~ s/([^|]+)/(length "$1" > 1 ? '--' : '-') . "$1"/eg; - push @opt_help, [$option, $h{'desc'}]; - } - } - } - $self->{'opt_help'} = \@opt_help; - return @opt_vals; -} - -# Parse command line options -sub get_opts { - my $self = shift; - my @user_opt_desc = @_; - - my @opt_desc = ( - { - opt => 'help|h', - desc => 'Display this help and exit.', - }, - - { - opt => 'version|v', - desc => 'Print version and exit.', - }, - - { - opt => 'file|F=s', - desc => 'Input file (default: STDIN).', - }, - - { - opt => 'output|o=s', - desc => 'Output file (default: STDOUT).', - }, - - { - opt => 'id=s@', - desc => 'svg id to operate on (can be multiple).', - }, - - { - opt => 'ids=s', - desc => 'Comma-separated list of svg ids to operate on.', - }, - ); - - # Create option arrays for Getopt::Long - my @opt_vals = $self->make_opt_vals(@opt_desc); - my @user_opt_vals = $self->make_opt_vals(@user_opt_desc); - - # Append user options - foreach (@user_opt_vals) { - push @opt_vals, $_; - } - - # Where the parsed options are stored - my %opts; - - #exit 0; - - # Parse all options - GetOptions(\%opts, @opt_vals) or usage(); - - # Handle comma-separated 'ids=foo,bar' - my @ids = @{$opts{'id'}} if $opts{'id'}; - if (exists $opts{'ids'} && $opts{'ids'} =~ /[\w\d_]+(,[\w\d_]+)*/) { - push (@ids, split(/,/, $opts{'ids'})); - } - - # Display usage etc. (and exit) - exists $opts{'version'} && $self->version(); - exists $opts{'help'} && $self->usage(); - - # Save id values for later processing - $self->{'ids'} = \@ids; - - # Save options - $self->{'opts'} = \%opts; - - # Return the options to script - return %opts; -} - -# Exit with named exit status -sub error { - my $self = shift; - my $error_name = shift; - my $script_error_msg = shift || ''; - - my %status = %{$self->{'status'}}; - - foreach (keys %status) { - if ($status{$_}[0] eq $error_name) { - $! = $_; # Set exit status - - # Commented out; let sodipodi handle the error code instead - #my $msg = ($status{$_}->[1] . ": $script_error_msg"); - - my $msg = "$script_error_msg"; - die $msg; - } - } - - # Will not be reached unless an improper error_name is given - $! = 255; # Exit status - warn "Illegal error code '$error_name' called from script\n"; -} - -# Some accessor methods -sub set_usage { - my $self = shift; - my $usage = shift || die "No usage string supplied!\n"; - $self->{'usage'} = $usage; -} - -sub set_name { - my $self = shift; - my $name = shift || die "No script name supplied!\n"; - $self->{'name'} = $name; -} - -# Print usage and exit -sub usage { - my $self = shift; - print "Usage: $self->{'name'} OPTIONS FILE\n"; - print $self->{'usage'}; - - my @opt_help = @{$self->{'opt_help'}}; - foreach (@opt_help) { - print pad($_->[0]) . $_->[1] . "\n"; - } - - exit ARG_ERR(); -} - -sub pad { - my $string = shift; - my $width = '20'; - return $string . ' ' x ($width - length($string)); -} - -# Print version -sub version { - print "Uses SpSVG version $VERSION\n"; - exit ARG_ERR(); -} - -# End of module; return something true -1; - -__END__ - -DOCUMENTATION HERE diff --git a/share/extensions/ill2svg.pl b/share/extensions/ill2svg.pl deleted file mode 100755 index 60c4fe1db..000000000 --- a/share/extensions/ill2svg.pl +++ /dev/null @@ -1,363 +0,0 @@ -#!/usr/bin/perl -# convert an illustrator file (on stdin) to svg (on stdout) -use strict; -use warnings; -use Getopt::Std; - -my $skip_images; - -BEGIN { - $skip_images = 0; - eval "use Image::Magick;"; - if ($@) { - warn "Couldn't load Perl module Image::Magick. Images will be skipped.\n"; - warn "$@\n"; - $skip_images = 1; - } -} - - -my %args; - -# Newline characters -my $NL_DOS = "\015\012"; -my $NL_MAC = "\015"; -my $NL_UNX = "\012"; - -getopts('h:', \%args); - -my @ImageData; -my $pagesize=1052.36218; -my $imagewidth = 128; -my $imageheight = 88; -my $imagex = 0; -my $imagey = 0; -my $imagenum = 0; -my $strokeparams; -my $strokecolor; -my $strokewidth; -my $fillcolor; -my $firstChar = 0; -my $image; -my $path; -my $color = 0; -my $weareinimage=0; -my $weareintext=0; -my($red,$green,$blue); -my($cpx,$cpy); - -if ($args{h}) { usage() && exit } - -$color = "#000"; - -sub addImageLine { - my ($data) = @_; - chomp($data); - #push (@ImageData, $data); - - my $len = length( $data ); - my $count = 0; - - #printf("%s %d\r\n",$data,$len); - #for( $loop=1; $loop < ($len - 2); $loop += 2){ - for( my $loop=1; $loop < $len; $loop += 2){ - my $value = substr( $data, $loop, 2); - - #printf("[%d:%s]",$loop,$value); - - if( $color == 0 ){ - #$red = hex($value); - $red = $value; - $color ++; - #printf("Color: RED: %s,",$red); - } elsif ( $color == 1 ) { - #$green = hex($value); - $green = $value; - $color ++; - #printf("Color: GREEN %s,",$green); - - } else { - $blue = $value; - my $pixel="pixel[${imagex},${imagey}]"; - my $rgb=sprintf("#%s%s%s",$red,$green,$blue); - #$image->Set($pixel=>$rgb); - $image->Set("pixel[${imagex},${imagey}]"=>"#${red}${green}${blue}") - unless ($skip_images); - #printf("PIXX: %d ",$image->Get($pixel)); - $color = 0; - $imagex++; - - #printf("Color:BLUE: %s, X: %d Y: %d %dx%d %s [%s]\r\n",$blue,$imagex,$imagey,$imagewidth,$imageheight,$rgb,$pixel); - - if( $imagex == $imagewidth ){ - $imagex = 0; - $imagey ++; - } # if - - - } #else - - } - - #printf("len: %d %dx%d\r\n",$len,$imagewidth,$imageheight); - -} - -sub cmyk_to_css { - my ($c, $m, $y, $k) = @_; - my ($r, $g, $b); - - $r = 1 - ($k + $c); - if ($r < 0) { $r = 0; } - $g = 1 - ($k + $m); - if ($g < 0) { $g = 0; } - $b = 1 - ($k + $y); - if ($b < 0) { $b = 0; } - return sprintf ("#%02x%02x%02x", 255 * $r, 255 * $g, 255 * $b); -} - -sub nice_float { - my ($x) = @_; - - my $result = sprintf ("%.3f", $x); - $result =~ s/0*$//; - $result =~ s/\.$//; - return $result; -} - -sub xform_xy { - my ($x, $y) = @_; - my @result = (); - - for my $i (0..$#_) { - if ($i & 1) { - #push @result, 1000 - $_[$i]; - push @result, $pagesize - $_[$i]; - } else { - #push @result, $_[$i] - 100; - push @result, $_[$i]; - } - } - return join ' ', map { nice_float ($_) } @result; -} - -sub strokeparams { - $strokecolor ||= 'black'; - my $result = "stroke:$strokecolor"; - if ($strokewidth && $strokewidth != 1) { - $result .= "; stroke-width:$strokewidth"; - } - return $result; -} - -sub usage { - warn qq|Usage: ill2svg [-l "string" -h] infile > outfile -options: - -h print this message and exit -|; -} - -sub process_line { - chomp; - return if /^%_/; - - if (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) k$/) { - $fillcolor = cmyk_to_css ($1, $2, $3, $4); - } elsif (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) K$/) { - $strokecolor = cmyk_to_css ($1, $2, $3, $4); - } elsif (/^([\d\.]+) g$/) { - $fillcolor = cmyk_to_css (0, 0, 0, 1 - $1); - } elsif (/^([\d\.]+) G$/) { - $strokecolor = cmyk_to_css (0, 0, 0, 1 - $1); - } elsif (/^([\d\.]+) ([\d\.]+) m$/) { - $path .= 'M'.xform_xy($1, $2); - $cpx = $1; - $cpy = $2; - } elsif (/^([\d\.]+) ([\d\.]+) l$/i) { - $path .= 'L'.xform_xy($1, $2); - $cpx = $1; - $cpy = $2; - } elsif (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) v$/i) { - $path .= 'C'.xform_xy($cpx, $cpy, $1, $2, $3, $4); - $cpx = $3; - $cpy = $4; - } elsif (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) y$/i) { - $path .= 'C'.xform_xy($1, $2, $3, $4, $3, $4); - $cpx = $3; - $cpy = $4; - } elsif (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) c$/i) { - $path .= 'C'.xform_xy($1, $2, $3, $4, $5, $6); - $cpx = $5; - $cpy = $6; - } elsif (/^b$/) { - $path .= 'z'; - $strokeparams = strokeparams (); - print " <g style=\"fill: $fillcolor; $strokeparams\">\n"; - print " <path d=\"$path\"/>\n"; - print " </g>\n"; - $path = ''; - } elsif (/^B$/) { - $strokeparams = strokeparams (); - print " <g style=\"fill: $fillcolor; $strokeparams\">\n"; - print " <path d=\"$path\"/>\n"; - print " </g>\n"; - $path = ''; - } elsif (/^f$/i) { - $path .= 'z'; - if (! $fillcolor) { - warn "Error: Fill color not defined in source file!\n"; - print " <path d=\"$path\"/>\n"; - } else { - print " <g style=\"fill: $fillcolor;\">\n"; - print " <path d=\"$path\"/>\n"; - print " </g>\n"; - } - $path = ''; - } elsif (/^s$/) { - $path .= 'z'; - $strokeparams = strokeparams (); - #print " <g style=\"fill:none;stroke:black;stroke-opacity:1; $strokeparams\">\n"; - print " <g style=\"fill:none; $strokeparams\">\n"; - print " <path d=\"$path\"/>\n"; - print " </g>\n"; - $path = ''; - } elsif (/^S$/) { - $strokeparams = strokeparams (); - #print " <g style=\"fill:none; $strokeparams\">\n"; - print " <g style=\"fill:none;stroke:black;$strokeparams;\">\n"; - print " <path d=\"$path\"/>\n"; - print " </g>\n"; - $path = ''; - } elsif (/^1 XR$/) { - - if( $firstChar != 0){ - print (" </tspan>\n</text>\n"); - } - - $weareintext=0; - - $firstChar = 0; - } elsif (/^TP$/) { - #Something do with the text;) -# $weareintext=1; - } elsif (/^([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) Tp$/i) { - - # Text position etc; - $cpx=$5; - $cpy=$pagesize - $6; - ## print ("x:$5 y:$6\r\n"); - - } elsif (/^TO$/) { - #one text ends - } elsif (/^LB$/) { - #Everything ends?? - ## Sometimes ain't working - warn "Error: Unexpected 'LB'! Everything has ended??\n"; - if( $weareintext != 0){ - print (" </tspan>\n</text>\n"); - } - - } elsif (/^\/_([\S\s]+) ([\d\.]+) Tf$/) { - my $FontName = $1; - my $FontSize = $2; - - ## When we know font name we can render this. - if( $firstChar != 1){ - print ("<text x=\"$cpx\" y=\"$cpy\""); - print (" style=\"font-size:$FontSize;font-weight:normal;stroke-width:1;"); - print ("fill:$fillcolor;fill-opacity:1;"); - print ("font-family:$FontName;\" id=\"text$5\">\n<tspan>"); - $firstChar = 1; - $weareintext=1; - } else { - print ("</tspan>\n<tspan x=\"$cpx\" y=\"$cpy\""); - print (" style=\"font-size:$FontSize;font-weight:normal;stroke-width:1;"); - print ("fill:$fillcolor;fill-opacity:1;"); - print ("font-family:$FontName;\" id=\"text$5\">"); - $weareintext=1; - } - - } elsif (/^\(([\S\s]+)\) Tx$/) { - # Normal text - my $text = $1; - $text =~ s/ä/ä/; - $text =~ s/ö/ö/; - $text =~ s/å/Ã¥/; - - print ("$text"); - - } elsif (/([\d\.]+) w$/) { - $strokewidth = $1; - } elsif (/^%%BeginData: ([\d\.]+)/) { - #How much we got image data - } elsif(/^%%EndData/) { - #and the data ends - } elsif (/^XI/) { - #actual image starts - $weareinimage=1; - } elsif (/^XH/) { - #it ends like they allways do. - #we just save it after this.. - $weareinimage=0; - my $imagename="${imagenum}.png"; - $image->Write($imagename) unless ($skip_images); - $imagenum++; - } elsif (/\[(.*)\](.*)Xh/) { - my @imagepos = split(/ /, $1); - my @imageinfo = split(/ /, $2); - $imagewidth = $imageinfo[1]; - $imageheight = $imageinfo[2]; - - if (! $imagewidth && ! $imageheight ) { - die "ERROR: This fileformat is not supported by " - ."ill2svg.pl.\n(Is it possible you are trying to " - ."use ill2svg.pl on a PDF file?) \n"; - } - - my $imageposx = $imagepos[4]; - my $imageposy = $pagesize - $imagepos[5]; - - #printf("%s %d %d Position x: %f 9y: %f\r\n",$1,@imagepos[4],@imagepos[5],$imageposx,$imageposy); - printf("<image"); - printf(" xlink:href=\"%d.png\"",$imagenum); - printf(" width=\"%d\"",$imagewidth); - printf(" height=\"%d\"",$imageheight); - printf(" x=\"%f\"",$imageposx); - printf(" y=\"%f\"",$imageposy); - printf("/>\r\n"); - - my $size = "${imagewidth}x${imageheight}"; - - if (!$skip_images) { - $image = Image::Magick->new(size=>$size); - $image->Set('density'=>'72'); - $image->Read("xc:white"); - } - $imagex=0; - $imagey=0; - - } else { - if( $weareinimage == 1 ){ - addImageLine( $_ ); - } - - chomp; - - #print "$_\r\n"; - } -} - if( $firstChar != 0){ - print (" </tspan>\n</text>\n"); - } - -print "<svg"; -print " xmlns=\"http://www.w3.org/2000/svg\""; -print " xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n"; - -while (<>) { - foreach (split /[\015\012]+/) { - process_line($_); - } -} -print "</svg>\n"; - diff --git a/share/extensions/outline2svg.inx b/share/extensions/outline2svg.inx deleted file mode 100644 index 2713ef444..000000000 --- a/share/extensions/outline2svg.inx +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>Text Outline Input</_name> - <id>org.inkscape.input.outline</id> - <dependency type="executable" location="extensions">outline2svg.pl</dependency> - <dependency type="executable" location="path">perl</dependency> - <input> - <extension>.outline</extension> - <mimetype>text/html</mimetype> - <_filetypename>Text Outline File (*.outline)</_filetypename> - <_filetypetooltip>ASCII Text with outline markup</_filetypetooltip> - </input> - <script> - <command reldir="extensions" interpreter="perl">outline2svg.pl</command> - <check reldir="extensions">outline2svg.pl</check> - </script> -</inkscape-extension> diff --git a/share/extensions/outline2svg.pl b/share/extensions/outline2svg.pl deleted file mode 100755 index 1c1daf0c3..000000000 --- a/share/extensions/outline2svg.pl +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/perl - -# This is a script to render a plain text outline file into SVG. -# -# Copyright (C) 2006 Bryce Harrington. Available for use under the GPL. -# -# Usage: outline2svg.pl <presentation.outline> [ --master=template.svg ] -# -use strict; -use Getopt::Long; -use Pod::Usage; -use SVG::Parser; -use vars qw($VERSION); -$VERSION = '1.00'; - -our $opt_version = 0; -our $opt_help = 0; -our $opt_man = 0; -our $opt_debug = 1; -our $opt_master = "template.svg"; -our $opt_width = 300; -our $opt_height = 200; -our $opt_x_margin = 100; -our $opt_y_margin = 150; -our $opt_font = 'Arial'; -our $opt_font_family = 'Arial'; -our $opt_font_size = 24; - -Getopt::Long::Configure ("bundling", "no_ignore_case"); -GetOptions( - "version|V", # Prints the version and exits - "help|h", # Prints a brief help message - "man", # Prints a manual page (detailed help) - "debug|D=i", # Prints debug messages - "master|m=s", # Master template to use - "width|w=i", # Page width - "height|h=i", # Page height - "x-margin|x=i", # Horizontal offset - "y-margin|y=i", # Vertical offset - "font=s", # Default font name - "font-family=s", # Default font family - "font-size=s", # Default font size - ); - -my $i = 0; -my $page = 0; -my $filename; -my $svg; - -sub start_page { - my $title = shift; - end_page(); - - $filename = sprintf("%02d_$title.svg", $page); - $filename =~ s/\s+/_/g; - $filename =~ s#/#-#g; - $filename =~ s#[^\w\:\.\,\+\-]+#_#g; - - $svg = SVG::Parser->new()->parsefile($opt_master); - $svg->comment('Generated by outline2svg'); - $page++; - $i = 0; -} - -sub end_page { - if (defined($svg) && defined($filename)) { - open(FILE, ">$filename") - or die "Could not open '$filename' for writing: $!\n"; - my $contents = $svg->xmlify(); - # Work-around bug in SVG::Parser - $contents =~ s/�//g; - print "$filename\n" if $opt_debug>0; - print FILE $contents; - close(FILE) || print "Error closing $filename: $!\n"; - - undef $svg; - undef $filename; - } -} - - -my $font = $opt_font; -my $font_family = $opt_font_family; -my $font_size = $opt_font_size; -my $line_spacing = $font_size * 1.5; - -while (my $line = <>) { - chomp($line); - $line =~ s/\s+$//; # Trim trailing space - my $x = 10; - my $style = { 'font' => $font, - 'font-family' => $font_family, - 'font-size' => $font_size - }; - - # Convert tabs into spaces, otherwise we get errors about invalid char - $line =~ s/\t/ /g; - - # If we've encountered a page marker, increment the page number - if ($line =~ /^\* (.*)$/) { - my $title = $1; - start_page($title); - - if ($title !~ /^(title|overview)$/i ) { - $style->{'font-size'} *= 1.5; - $svg->text(id => "title_$i", - x => $opt_x_margin, - y => $opt_y_margin, - 'xml:space' => 'preserve', - style => $style, - ) - ->cdata($title); - } - $i++; - - } elsif (defined($svg)) { - my $y = $line_spacing*(1+$i); - - my $num_leading_spaces = 0; - if ($line =~ /^(\s+)/) { - $num_leading_spaces = length($1); - - } - - if ($num_leading_spaces > 0 && - length($line) > $num_leading_spaces && - length($line) + $num_leading_spaces > 70 && - length($line) + $num_leading_spaces <76 ) { - # Looks like user is trying to center this text - $line =~ s/^\s+//; - $style->{'align'} = 'centered'; - $style->{'anchor'} = 'middle'; - $x = $opt_width / 2; - - } else { - while ($line && $line =~ /^\s/) { - $line =~ s/^\s//; # Just delete one space at a time - $x += 5; - } - - # Create bullets if needed - if ($line =~ /^-\s+/) { - $line =~ s/^-\s+//; - $x += 10; - $svg->circle(cx=>$opt_x_margin + $x - ($font_size/2), - cy=>$opt_y_margin + $y - ($font_size/3), - r=>($font_size/6.0)); - } - } - - # Convert markup into appropriate SVG-isms - $svg->text(id => "text_line_$i", - x => $opt_x_margin + $x, - y => $opt_y_margin + $y, - 'xml:space' => 'preserve', - style => $style, - ) - ->cdata($line); - $i++; - } -} -end_page(); - -#print $svg->xmlify(); - diff --git a/share/extensions/txt2svg.inx b/share/extensions/txt2svg.inx deleted file mode 100644 index 6aea850d1..000000000 --- a/share/extensions/txt2svg.inx +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>Text Input</_name> - <id>org.inkscape.input.txt</id> - <dependency type="executable" location="extensions">txt2svg.pl</dependency> - <dependency type="executable" location="path">perl</dependency> - <input> - <extension>.txt</extension> - <mimetype>text/html</mimetype> - <_filetypename>Text File (*.txt)</_filetypename> - <_filetypetooltip>ASCII Text</_filetypetooltip> - </input> - <script> - <command reldir="extensions" interpreter="perl">txt2svg.pl</command> - <check reldir="extensions">txt2svg.pl</check> - </script> -</inkscape-extension> diff --git a/share/extensions/txt2svg.pl b/share/extensions/txt2svg.pl deleted file mode 100755 index c28637d8c..000000000 --- a/share/extensions/txt2svg.pl +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl - -# This is a script to render a plain text file into SVG, line by line. - -use strict; -use SVG; -use Encode; -use vars qw($VERSION); -$VERSION = '1.01'; - -binmode(STDOUT, ":utf8"); - -my $svg = new SVG; - -$svg->comment('Generated by txt2svg'); - -my $i=0; -while (<>) { - chomp($_); - s/\t/ /g; # Convert tabs into spaces, otherwise we get errors about invalid char - - my $text = $svg->text(id => "text_line_$i", - x => 10, - y => 12*(1+$i), - 'xml:space' => 'preserve', - style => { 'font' => 'Courier', - 'font-family' => 'Courier 10 pitch', - 'font-size' => 10, - } - ) - ->cdata(decode_utf8($_)); - $i++; -} - -print $svg->xmlify(); - |
