1
0
Fork 0

Use resolvepath() for canvas SVGs

This commit is contained in:
Philosopher 2013-10-06 11:52:30 -05:00
parent 0a93f65beb
commit 24ab67fa32

View file

@ -14,6 +14,12 @@ var parsesvg = func(group, path, options = nil)
if( typeof(options) != "hash" ) if( typeof(options) != "hash" )
die("Options need to be of type hash!"); die("Options need to be of type hash!");
# resolve paths using standard SimGear logic
var file_path = resolvepath(path);
if (file_path == "")
die("File not found: "~path);
path = file_path;
var custom_font_mapper = options['font-mapper']; var custom_font_mapper = options['font-mapper'];
var font_mapper = func(family, weight) var font_mapper = func(family, weight)
{ {
@ -573,22 +579,6 @@ var parsesvg = func(group, path, options = nil)
} }
}; };
# check path relative to standard locations
foreach(
var p;
[ "", # absolute path
getprop("/sim/aircraft-dir") ~ "/", # current aircraft path
getprop("/sim/fg-root") ~ "/" # fgdata
])
{
var tmp_path = p ~ path;
if( io.stat(tmp_path) != nil )
{
path = tmp_path;
break;
}
}
call(func parsexml(path, start, end, data), nil, var err = []); call(func parsexml(path, start, end, data), nil, var err = []);
if( size(err) ) if( size(err) )
{ {