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

Fix NullPointerException when calling getBBox #1215

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ public WritableMap getBBox(int tag, ReadableMap options) {
svg.initBounds();

RectF bounds = new RectF();
if (fill) {
if (fill && svg.mFillBounds != null) {
bounds.union(svg.mFillBounds);
}
if (stroke) {
if (stroke && svg.mStrokeBounds != null) {
bounds.union(svg.mStrokeBounds);
}
if (markers) {
if (markers && svg.mMarkerBounds != null) {
bounds.union(svg.mMarkerBounds);
}
if (clipped) {
Expand Down
4 changes: 4 additions & 0 deletions android/src/main/java/com/horcrux/svg/TSpanView.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ Path getPath(Canvas canvas, Paint paint) {
return mCachedPath;
}

if (canvas == null || paint == null) {
return null;
}

setupTextPath();

pushGlyphContext();
Expand Down
6 changes: 6 additions & 0 deletions android/src/main/java/com/horcrux/svg/TextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ Path getPath(Canvas canvas, Paint paint) {
if (mPath != null) {
return mPath;
}
if (canvas == null || paint == null) {
return null;
}
setupGlyphContext(canvas);
return getGroupPath(canvas, paint);
}
Expand Down Expand Up @@ -211,6 +214,9 @@ Path getGroupPath(Canvas canvas, Paint paint) {
if (mPath != null) {
return mPath;
}
if (canvas == null || paint == null) {
return null;
}
pushGlyphContext();
mPath = super.getPath(canvas, paint);
popGlyphContext();
Expand Down