From 09141fff3754ed0de7709187e3687a79364b5c75 Mon Sep 17 00:00:00 2001 From: j-dimension Date: Sun, 24 Nov 2024 22:12:00 +0100 Subject: [PATCH] higher DPI value for HiDPI displays. issue #2630 --- .../viewer/PdfImageScrollingPanel.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java index 0662deab4..c39cbc729 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.client.editors.documents.viewer; import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.utils.SystemUtils; import com.jdimension.jlawyer.client.utils.ThreadUtils; import com.jdimension.jlawyer.client.utils.einvoice.EInvoiceUtils; import java.awt.Color; @@ -1314,6 +1315,22 @@ public static int calculateDpi(int totalPages) { int baseDpi = 200; int minDpi = 120; + // macOS has a default scale factor of 2 - assume HiDPI for all Macs + if(SystemUtils.isMacOs()) { + return 300; + } + + String uiScale = System.getProperty("sun.java2d.uiScale"); + try { + if (uiScale != null && Double.parseDouble(uiScale) > 1.0) { + return 300; + } else { + // proceed with dynamic calculation below + } + } catch (Throwable t) { + log.warn("unable to get UI scale factor", t); + } + if (totalPages <= 20) { return 200; }