Author: centic
Date: Thu Jun  8 08:53:15 2023
New Revision: 1910301

URL: http://svn.apache.org/viewvc?rev=1910301&view=rev
Log:
Bug 66632: Round char-width instead of cutting off

Otherwise we sometimes use a too low "default char width"
which leads to autosizing of columns with too wide columns.

We should propably return float instead of int here to
not introduce rounding errors at this point at all,
but it would need more API changes, so let's at least
make it work better for now.

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=1910301&r1=1910300&r2=1910301&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 Thu Jun  
8 08:53:15 2023
@@ -299,7 +299,7 @@ public class SheetUtil {
         copyAttributes(defaultFont, str, 0, 1);
         try {
             TextLayout layout = new TextLayout(str.getIterator(), 
fontRenderContext);
-            return (int) layout.getAdvance();
+            return Math.round(layout.getAdvance());
         } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError 
e) {
             if (ignoreMissingFontSystem) {
                 return DEFAULT_CHAR_WIDTH;



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

Reply via email to