Author: centic
Date: Tue Jan 30 21:01:53 2024
New Revision: 1915482

URL: http://svn.apache.org/viewvc?rev=1915482&view=rev
Log:
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.

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java?rev=1915482&r1=1915481&r2=1915482&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java Tue Jan 
30 21:01:53 2024
@@ -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;
             }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to