diff options
author | ribet | 2007-10-18 15:49:26 +0000 |
---|---|---|
committer | ribet | 2007-10-18 15:49:26 +0000 |
commit | 42923b2543aa1681c7bddf4842588e881ce76103 (patch) | |
tree | dbfaeb157f013c98d1aed3fb3878b7057842ca8f /src/SVG | |
parent | a2f8239874832c27eea5ad0be47a3ee7c983e8ba (diff) | |
download | mtc-42923b2543aa1681c7bddf4842588e881ce76103.zip mtc-42923b2543aa1681c7bddf4842588e881ce76103.tar.gz mtc-42923b2543aa1681c7bddf4842588e881ce76103.tar.bz2 mtc-42923b2543aa1681c7bddf4842588e881ce76103.tar.xz |
Fix I'm not really proud of, but it works... (fontMetrics values are wrong)
Diffstat (limited to 'src/SVG')
-rw-r--r-- | src/SVG/SVG2zinc.pm | 19 | ||||
-rw-r--r-- | 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" <g> 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/ ) |