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.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910301 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-06-08 08:53:15 +00:00
parent d3e35e740a
commit 6442dccab9
1 changed files with 1 additions and 1 deletions

View File

@ -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;