From a168a2ae6da98d83700d31aabc60791e67ce7d9a Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Tue, 20 Jun 2017 03:40:47 +0300 Subject: [PATCH] Ensure that getTextRoot and getGlyphContext works correctly independent of if it is wrapped by a G element or not --- .../main/java/com/horcrux/svg/GroupShadowNode.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/horcrux/svg/GroupShadowNode.java b/android/src/main/java/com/horcrux/svg/GroupShadowNode.java index b0d176ab..ea48a6e5 100644 --- a/android/src/main/java/com/horcrux/svg/GroupShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/GroupShadowNode.java @@ -39,11 +39,20 @@ public class GroupShadowNode extends RenderableShadowNode { } protected GroupShadowNode getTextRoot() { + GroupShadowNode shadowNode = getShadowNode(GroupShadowNode.class); + if (shadowNode == null) { + return getShadowNode(TextShadowNode.class); + } + return shadowNode; + } + + @android.support.annotation.Nullable + private GroupShadowNode getShadowNode(Class shadowNodeClass) { if (mTextRoot == null) { mTextRoot = this; while (mTextRoot != null) { - if (mTextRoot.getClass() == GroupShadowNode.class) { + if (mTextRoot.getClass() == shadowNodeClass) { break; } @@ -66,6 +75,9 @@ public class GroupShadowNode extends RenderableShadowNode { } protected GlyphContext getGlyphContext() { + if (mGlyphContext == null) { + setupGlyphContext(); + } return mGlyphContext; }