joebowman / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

Default font families not supported in svgweb #646

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In the SVG spec:
http://www.w3.org/TR/SVG/fonts.html#FontFaceElementFontFamilyAttribute
http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#defined-to-exist

There are a set of 'fallback' font family names defined: serif, sans-serif, 
cursive, fantasy, monospace. Additionally, some SVG UAs (especially Inkscape), 
default to using "Sans" as an alias for "Sans-Serif".

At present, svgweb map all of these to the default font (serif) in the Flash 
viewer.

What steps will reproduce the problem?
1. Create an SVG file with font-family set to 
'Serif'/'Sans-Serif'/'Cursive'/'Monospace'
2. Load it in svgweb, comparing it to an alternative SVG viewer.

What is the expected output? What do you see instead? See attached PNG: svgweb 
uses 'serif' for all 'default' fonts.

The Flash Player defines '_sans', '_serif' and '_typewriter' as similar 
defaults for device fonts:
http://livedocs.adobe.com/flex/3/html/fonts_03.html
so, it's pretty easy (e.g. see attached SVGFonts.as) to map these default 
fonts, by adding the following to SVGTextNode.addTextFieldChunk:

  textFormat.font = SVGFonts.mapToSWFFont(fontFamily);

(see 'expected' image in PNG file attached).

Obviously, 'cursive' and 'fantasy' do not have defaults in the Flash Player, so 
can't be used, but this approach works well for Sans/Serif and Monospace; 
although, naturally, the formatting of fonts may vary from the original 
diagram, but this is expected in the spec.

Original issue reported on code.google.com by richbarb...@gmail.com on 16 Aug 2012 at 2:41

Attachments: