Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateFontFamily fails for Elements that don't have OwnerDocument #332

Closed
haykpetros opened this issue Aug 11, 2017 · 1 comment
Closed

Comments

@haykpetros
Copy link
Contributor

haykpetros commented Aug 11, 2017

Hi,

If one creates SvgText element at runtime it's OwnerDocument property will be Null. Afterwards trying to access Bounds property will throw "Object reference not set to an instance of an object.", because ValidateFontFamily expects "SvgDocument doc" not to be null.

var svgText = new SvgText("Hello World!");
// This line will throw "Object reference not set to an instance of an object." exception.
var textWidth = svgText.Bounds.Width;

So we need to modify ValidateFontFamily method (line 436 of SvgElementStyle.cs) to check for doc not being null:

if (doc != null && doc.FontDefns().TryGetValue(f, out sFaces)) return sFaces;

I created a Pull Request #333 to resolve this issue.

Thanks

haykpetros added a commit to haykpetros/SVG that referenced this issue Aug 11, 2017
mrbean-bremen pushed a commit that referenced this issue Dec 17, 2018
@mrbean-bremen
Copy link
Member

Fixed with #333.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants