diff options
author | ribet | 2010-05-11 13:12:42 +0000 |
---|---|---|
committer | ribet | 2010-05-11 13:12:42 +0000 |
commit | 8489ecd3e999606b663647a2596314a36f2fa2d2 (patch) | |
tree | c33eec95f260ca8c69335fea85242588ea47a0d0 /src/SVG/SVG2zinc.pm | |
parent | 8ff58f98a8bc30dbd6bd6505028df19cd05a1945 (diff) | |
download | mtc-8489ecd3e999606b663647a2596314a36f2fa2d2.zip mtc-8489ecd3e999606b663647a2596314a36f2fa2d2.tar.gz mtc-8489ecd3e999606b663647a2596314a36f2fa2d2.tar.bz2 mtc-8489ecd3e999606b663647a2596314a36f2fa2d2.tar.xz |
Fontconfig's style font handling.
Diffstat (limited to 'src/SVG/SVG2zinc.pm')
-rw-r--r-- | src/SVG/SVG2zinc.pm | 37 |
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; |