aboutsummaryrefslogtreecommitdiff
path: root/src/SVG/SVG2zinc.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/SVG/SVG2zinc.pm')
-rw-r--r--src/SVG/SVG2zinc.pm37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/SVG/SVG2zinc.pm b/src/SVG/SVG2zinc.pm
index 54126fe..c9be2cc 100644
--- a/src/SVG/SVG2zinc.pm
+++ b/src/SVG/SVG2zinc.pm
@@ -112,7 +112,7 @@ my %EVENT_ON_ANIM = map { $_ => 1 } @EVENT_ON_ANIM;
#### &analyze_style , &analyze_text_style , &groupContext , &attrs_implemented
my @STYLE_ATTRS = qw(
class style display ddisplay fill fill-opacity fill-rule stroke
- stroke-width stroke-opacity opacity font-size font-family
+ stroke-width stroke-opacity opacity font-size font-family font-style
font-weight stroke-linejoin stroke-linecap stroke-dasharray text-anchor
) ;
my %STYLE_ATTRS = map { $_ => 1 } @STYLE_ATTRS;
@@ -1141,7 +1141,7 @@ my %save_current_context = ();
$res .= &analyze_text_style (\%attrs);
@texts = ();
@transforms = &transform('$previous', $attrs{transform});
- &attrs_implemented ( 'text', $name, [qw (stroke-miterlimit x y id transform text-anchor font-family font-size)], %attrs );
+ &attrs_implemented ( 'text', $name, [qw (stroke-miterlimit x y id transform text-anchor font-family font-size font-weight font-style)], %attrs );
}
sub nextText {
@@ -1170,13 +1170,7 @@ 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 = -> fontMetrics ('$fontname', -ascent);");
- } else {
- push (@ascent, "\$ascent = -> fontMetrics (\$fonts{\"$current_font_key\"}, -ascent);");
- }
+ push (@ascent, "\$ascent = -> fontMetrics ('$current_font_key', -ascent);");
if ($text_x != 0 || $text_y != 0)
{
push (@ascent, "-> translate(\$previous, $text_x, $text_y - \$ascent);");
@@ -1565,7 +1559,7 @@ sub expandStyle {
$style = &removeComment ($style);
foreach my $keyvalue ( split ( /\s*;\s*/ , $style) )
{
- my ($key, $value) = $keyvalue =~ /(.*)\s*:\s*(.*)/ ;
+ my ($key, $value) = $keyvalue =~ /(.*?)\s*:\s*(.*)/ ;
$keyvalues{$key} = $value;
}
return %keyvalues;
@@ -1735,6 +1729,10 @@ sub analyze_style_hash {
{
### this attributes is for text only and is analyzed in &analyze_text_style_hash
}
+ elsif ($key eq 'font-style')
+ {
+ ### this attributes is for text only and is analyzed in &analyze_text_style_hash
+ }
else
{
&myWarn ("Unknown Style (in analyze_style_hash): $key (value is $value)\n") if $warn;
@@ -1756,7 +1754,7 @@ sub analyze_text_style_hash
my $fontFamily="";
my $fontSize ="";
my $fontWeight ="";
-
+ my $fontStyle = "";
foreach my $key (keys %keyvalues)
{
my $value = $keyvalues{$key};
@@ -1807,6 +1805,10 @@ sub analyze_text_style_hash
{
$fontWeight = $value;
}
+ elsif ($key eq 'font-style')
+ {
+ $fontStyle = $value;
+ }
elsif ($key eq 'fill')
{
my $fillOpacity;
@@ -1845,18 +1847,11 @@ sub analyze_text_style_hash
&myWarn ("Unknown Style of text: $key (value is $value)\n") if $warn;
}
}
- if ($fontFamily or $fontSize or $fontWeight)
+ if ($fontFamily or $fontSize or $fontWeight or $fontStyle)
{
## to be extended to all other fonts definition parameters
- ## NB: fontWeight is not used yet!
- my ($fontKey,$fontName,$code) = &createNamedFont ($fontFamily, $fontSize, $fontWeight);
- &display("\$fonts{\"$fontKey\"} = ") if $code;
- &display($code) if $code;
- if ($fontKey =~ /^XLFD-/ ) {
- $res .= ", -font => \"$fontName\"";
- } else {
- $res .= ", -font => \"$fontKey\"";
- }
+ my ($fontKey) = &createNamedFont ($fontFamily, $fontSize, $fontWeight, $fontStyle);
+ $res .= ", -font => \"$fontKey\"";
$current_font_key = $fontKey;
}
return $res;