diff options
author | Dominik Stadler <centic@apache.org> | 2024-01-30 21:01:53 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2024-01-30 21:01:53 +0000 |
commit | 209e8fc6599803c7cfe061f7755d6e19d9c14201 (patch) | |
tree | ec16d001c8bc7bb61e41a05cb8ae72893d8b265f /poi/src/main | |
parent | e696053e23b452a21572d60de045e1794f176775 (diff) | |
download | poi-209e8fc6599803c7cfe061f7755d6e19d9c14201.tar.gz poi-209e8fc6599803c7cfe061f7755d6e19d9c14201.zip |
Fix handling missing font libraries to again not throw on some types of exception
The previous change broke this handling by always re-throwing "Fatal" exceptions.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915482 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/main')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java index 6d7bc7f8e0..cc5abe81b1 100644 --- a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java +++ b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java @@ -353,8 +353,18 @@ public class SheetUtil { TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext); return layout.getAdvance(); } catch (Throwable t) { - // fatal exceptions will always be rethrown - if (!ExceptionUtil.isFatal(t) && ignoreMissingFontSystem) { + // ignore exception and return a default char width if + // the ignore-feature is enabled and the exception indicates that + // the underlying font system is not available + if (ignoreMissingFontSystem && ( + // the three types of exception usually indicate here that the font + // system is not fully installed, i.e. system libraries missing or + // some JDK classes cannot be loaded + t instanceof UnsatisfiedLinkError || + t instanceof NoClassDefFoundError || + t instanceof InternalError || + // other fatal exceptions will always be rethrown + !ExceptionUtil.isFatal(t))) { return DEFAULT_CHAR_WIDTH; } |