~tex-sx/tex-sx/development

« back to all changes in this revision

Viewing changes to svgtopgf.pl

  • Committer: Andrew Stacey
  • Date: 2012-12-06 09:45:18 UTC
  • mto: This revision was merged to the branch mainline in revision 158.
  • Revision ID: stacey@math.ntnu.no-20121206094518-prtec3dl77cidebu
Bug fixes for pgf-blur: inverse blur needs eo rule, fadings need unique names; tikzmark highlighting code refactored; svgtopgf added rules for quadratic paths

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
open($xmlfile,$ARGV[0]);
10
10
 
11
11
$prefix = $ARGV[1];
12
 
$debug = 0;
 
12
$debug = 2;
13
13
 
14
14
$doc = parsefile($xmlfile);
15
15
 
67
67
        }
68
68
        &printbb($prefix . $glyph,$width,$height,$depth);
69
69
    } elsif ($glyphs[$i]{"name"} eq "hkern") {
70
 
        debugmsg(2,"Considering kern");
71
 
        $kerna = ord($glyphs[$i]{"attrib"}{"u1"});
72
 
        $kernb = ord($glyphs[$i]{"attrib"}{"u2"});
73
 
        $kern = -$glyphs[$i]{"attrib"}{"k"}/$scale;
74
 
        &printkern($prefix,$kerna,$kernb,$kern);
 
70
#       debugmsg(2,"Considering kern");
 
71
#       $kerna = ord($glyphs[$i]{"attrib"}{"u1"});
 
72
#       $kernb = ord($glyphs[$i]{"attrib"}{"u2"});
 
73
#       $kern = -$glyphs[$i]{"attrib"}{"k"}/$scale;
 
74
#       &printkern($prefix,$kerna,$kernb,$kern);
75
75
    }
76
76
}
77
77
 
346
346
    "z" => sub {
347
347
        print '\pgfpathclose' . "%\n";
348
348
        return '';
349
 
    }
 
349
    },
 
350
    "Q" => sub {
 
351
        my $coord = shift;
 
352
        my $coords = shift;
 
353
        my $xa = shift @$coords;
 
354
        my $ya = shift @$coords; 
 
355
        my $x = shift @$coords;
 
356
        my $y = shift @$coords; 
 
357
        $coord->[0] = $x;
 
358
        $coord->[1] = $y;
 
359
        $coord->[2] = 2*$x - $xa;
 
360
        $coord->[3] = 2*$y - $ya;
 
361
        print '\pgfpathquadraticcurveto{' 
 
362
            . '\pgfpointxy{' . &printnum($xa) . '}{' . &printnum($ya) . '}}{'
 
363
            . '\pgfpointxy{' . &printnum($coord->[0]) . '}{' . &printnum($coord->[1]) . '}}' . "%\n";
 
364
        if (@$coords) {
 
365
            return 'Q';
 
366
        } else {
 
367
            return '';
 
368
        }
 
369
    },
 
370
    "q" => sub {
 
371
        my $coord = shift;
 
372
        my $coords = shift;
 
373
        my $xa = shift @$coords;
 
374
        my $ya = shift @$coords; 
 
375
        my $x = shift @$coords;
 
376
        my $y = shift @$coords; 
 
377
        $xa += $coord->[0];
 
378
        $ya += $coord->[1];
 
379
        $coord->[0] += $x;
 
380
        $coord->[1] += $y;
 
381
        $coord->[2] = 2*$coord->[0] - $xa;
 
382
        $coord->[3] = 2*$coord->[1] - $ya;
 
383
        print '\pgfpathquadraticcurveto{' 
 
384
            . '\pgfpointxy{' . &printnum($xa) . '}{' . &printnum($ya) . '}}{'
 
385
            . '\pgfpointxy{' . &printnum($coord->[0]) . '}{' . &printnum($coord->[1]) . '}}' . "%\n";
 
386
        if (@$coords) {
 
387
            return 'q';
 
388
        } else {
 
389
            return '';
 
390
        }
 
391
    },
 
392
    "T" => sub {
 
393
        my $coord = shift;
 
394
        my $coords = shift;
 
395
        my $xa = $coord->[2];
 
396
        my $ya = $coord->[3];
 
397
        my $x = shift @$coords;
 
398
        my $y = shift @$coords; 
 
399
        $coord->[0] = $x;
 
400
        $coord->[1] = $y;
 
401
        $coord->[2] = 2*$x - $xa;
 
402
        $coord->[3] = 2*$y - $ya;
 
403
        print '\pgfpathquadraticcurveto{' 
 
404
            . '\pgfpointxy{' . &printnum($xa) . '}{' . &printnum($ya) . '}}{'
 
405
            . '\pgfpointxy{' . &printnum($coord->[0]) . '}{' . &printnum($coord->[1]) . '}}' . "%\n";
 
406
        if (@$coords) {
 
407
            return 'T';
 
408
        } else {
 
409
            return '';
 
410
        }
 
411
    },
 
412
    "t" => sub {
 
413
        my $coord = shift;
 
414
        my $coords = shift;
 
415
        my $xa = $coord->[2];
 
416
        my $ya = $coord->[3];
 
417
        my $x = shift @$coords;
 
418
        my $y = shift @$coords; 
 
419
        $coord->[0] += $x;
 
420
        $coord->[1] += $y;
 
421
        $coord->[2] = 2*$coord->[0] - $xa;
 
422
        $coord->[3] = 2*$coord->[1] - $ya;
 
423
        print '\pgfpathquadraticcurveto{' 
 
424
            . '\pgfpointxy{' . &printnum($xa) . '}{' . &printnum($ya) . '}}{'
 
425
            . '\pgfpointxy{' . &printnum($coord->[0]) . '}{' . &printnum($coord->[1]) . '}}' . "%\n";
 
426
        if (@$coords) {
 
427
            return 't';
 
428
        } else {
 
429
            return '';
 
430
        }
 
431
    },
 
432
 
350
433
};
351
434
 
352
435
}