From 42923b2543aa1681c7bddf4842588e881ce76103 Mon Sep 17 00:00:00 2001 From: ribet Date: Thu, 18 Oct 2007 15:49:26 +0000 Subject: Fix I'm not really proud of, but it works... (fontMetrics values are wrong) --- src/SVG/SVG2zinc.pm | 19 +++++++++++++------ src/SVG/SVG2zinc/Conversions.pm | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/SVG/SVG2zinc.pm b/src/SVG/SVG2zinc.pm index 54c369c..75e1429 100644 --- a/src/SVG/SVG2zinc.pm +++ b/src/SVG/SVG2zinc.pm @@ -1164,12 +1164,19 @@ my %save_current_context = (); my $theText = join ('', @texts); $res .= ", -text => '$theText', -priority => 10);"; my @ascent; + if ($current_font_key =~ /^XLFD/) { + my $fontname = $current_font_key; + $fontname =~ s/^XLFD//; + push (@ascent, "\$ascent = int(\`xlsfonts -l -fn '$fontname' |tail -1|cut -c 31-33\`);"); + } else { + push (@ascent, "\$ascent = -> fontMetrics (\$fonts{\"$current_font_key\"}, -ascent);"); + } if ($text_x != 0 || $text_y != 0) { - push (@ascent, "-> translate(\$previous, $text_x, $text_y);"); + push (@ascent, "-> translate(\$previous, $text_x, $text_y - \$ascent);"); + } else { + push (@ascent, "-> translate(\$previous,0, -\$ascent);"); } - push (@ascent, "\$ascent = -> fontMetrics (\$fonts{\"$current_font_key\"}, -ascent);"); - push (@ascent, "-> translate(\$previous,0, -\$ascent);"); &ddisplay ($res, @ascent, @transforms); @@ -1745,7 +1752,7 @@ sub analyze_text_style_hash foreach my $key (keys %keyvalues) { my $value = $keyvalues{$key}; - next if (!defined $value); # in this case, the SVG code is invalide (TBC) + next if (!defined $value); # in this case, the SVG code is invalid (TBC) if ($key eq 'text-anchor') { if ($value eq 'start') @@ -1771,7 +1778,7 @@ sub analyze_text_style_hash elsif ($key eq 'visibility') { ## BUG? if a "not-visible" group contains a visible graphic element - ## this element WILL NOT be visible in TkZinc , but should be visible in SVG!! + ## this element WILL NOT be visible in TkZinc, but should be visible in SVG!! ## Cf specif svg p. 284 if ($value eq 'hidden' or $value eq 'collapse') { @@ -1781,7 +1788,7 @@ sub analyze_text_style_hash } elsif ($key eq 'font-family') { - $value =~ s/\'//g; # on removing quotes around the fonte name + $value =~ s/\'//g; # on removing quotes around the font name $fontFamily = $value; } elsif ($key eq 'font-size') diff --git a/src/SVG/SVG2zinc/Conversions.pm b/src/SVG/SVG2zinc/Conversions.pm index ad3abeb..0c8fd43 100644 --- a/src/SVG/SVG2zinc/Conversions.pm +++ b/src/SVG/SVG2zinc/Conversions.pm @@ -116,10 +116,10 @@ sub createNamedFont { my ($fontName, $fontKey); if ($family =~ /^-[^-]*-([^-]*)-([^-]*)-[^-]*-[^-]*-[^-]*-([^-]*)-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*$/ ) { $weight = $2; - $size = $3; + $size = 0; # Warning: setting size changes font metrics! $fontKey = "XLFD$family"; $fontName = $family; - $family = $1; + #$family = $1; # Setting the real family prevent from loading the right font } else { $weight = "normal" unless $weight; if ( $size =~ /(.*)pt/ ) -- cgit v1.1