From a2f8239874832c27eea5ad0be47a3ee7c983e8ba Mon Sep 17 00:00:00 2001 From: ribet Date: Wed, 17 Oct 2007 14:08:29 +0000 Subject: Amélioration de la prise en compte des fontes XLFD --- src/SVG/SVG2zinc/Conversions.pm | 64 +++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/SVG/SVG2zinc/Conversions.pm b/src/SVG/SVG2zinc/Conversions.pm index fccd4ae..ad3abeb 100644 --- a/src/SVG/SVG2zinc/Conversions.pm +++ b/src/SVG/SVG2zinc/Conversions.pm @@ -112,38 +112,46 @@ sub createNamedFont { $last_key = $fullFamily; } my $family = lc($fullFamily); - - $weight = "normal" unless $weight; - if ( $size =~ /(.*)pt/ ) - { - $size = -$1; - } - elsif ( $size =~ /(.*)px/ ) - { - $size = -$1; - } - elsif ( $size =~ /(\d*(.\d*)?)\s*$/ ) - { - $size = -$1; - } + + my ($fontName, $fontKey); + if ($family =~ /^-[^-]*-([^-]*)-([^-]*)-[^-]*-[^-]*-[^-]*-([^-]*)-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*$/ ) { + $weight = $2; + $size = $3; + $fontKey = "XLFD$family"; + $fontName = $family; + $family = $1; + } else { + $weight = "normal" unless $weight; + if ( $size =~ /(.*)pt/ ) + { + $size = -$1; + } + elsif ( $size =~ /(.*)px/ ) + { + $size = -$1; + } + elsif ( $size =~ /(\d*(.\d*)?)\s*$/ ) + { + $size = -$1; + } # $size = &float2int($size); # I round the font size, at least until we have vectorial font in Tk::Zinc $family = $fontsMapping{$family} if defined $fontsMapping{$family}; - if ( $family =~ /(\w*)-bold/ ) - { - $family = $1; - $weight = "bold"; - } - else - { - if ($weight eq '') { - $weight = "medium"; - } - } + if ( $family =~ /(\w*)-bold/ ) + { + $family = $1; + $weight = "bold"; + } + else + { + if ($weight eq '') { + $weight = "medium"; + } + } - my $fontKey = join "_", ($family, $size, $weight); - my $fontName = $family; - $fontKey =~ s/^-/XLFD-/; + $fontKey = join "_", ($family, $size, $weight); + $fontName = $family; + } if (!defined $fonts{$fontKey}) { $fonts{$fontKey} = $fontKey; -- cgit v1.1