flathub / flathub/org.verapdf.veraPDF

Too cramped UI and a workaround for the issue

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I did not spend the time actually understanding the problem, so if this report seems off, feel free to close it.
**I "diagnosed" and fixed the issue with AI**, but wrote this report myself by hand.

I installed the Flatpak via Gnome Software, it looked like this, I have pretty vanilla Fedora Workstation:

Image

I asked an AI agent to diagnose the issue and it said that this is related to the issue, even though Fedora 44 scaling in Gnome GUI settings is set to 100%:
```
$ xrdb -query | grep Xft.dpi
Xft.dpi: 192
```
According to the AI: "This means the DE is setting 2x font DPI independently of the display scaling setting, which causes the patch's auto-detection to calculate SCALE_FACTOR=2"

## What the AI instructed me to do to the verapdf-gui.patch file:

On line 21: `+GDK_SCALE=$SCALE_FACTOR` -> `+GDK_SCALE=1`
Delete lines 37-42:
```
@@ -135,5 +157,4 @@
-Dapp.home="$BASEDIR" \
-Dbasedir="$BASEDIR" \
org.verapdf.apps.GreenfieldGuiWrapper \
- "--frameScale" "$SCALE_FACTOR" \
"$@"
```

Result, which works:
```
--- verapdf-gui.sh 2021-01-15 23:19:05.928387737 -0400
+++ verapdf-gui.sh 2021-01-16 13:03:01.368223370 -0400
@@ -125,6 +125,33 @@
# If you have problems with a cramped window and invisible window controls you can increase the SCALE_FACTOR below to 1.5 or even 2.0
SCALE_FACTOR=1.0

+# Retrieve DPI directly from X, and calculate scale_factor from it.
+# (depends on xgetres binary from https://github.com/tamirzb/xgetres)
+is_natural_number='^[0-9]+$'
+DPI=`xgetres Xft.dpi`
+# if $DPI is a natural number, taken from https://stackoverflow.com/a/806923
+if [[ $DPI =~ $is_natural_number ]] ; then
+ # float division in bash, taken from https://stackoverflow.com/a/21032001
+ SCALE=`echo "$DPI 96" | awk '{printf "%.1f \n", $1/$2}'`
+ # Round in bash, taken from https://stackoverflow.com/a/26465573
+ SCALE_FACTOR=$(LC_ALL=C printf "%.0f\n" $SCALE)
+fi
+
+# Java2D and Swing APIs use Xlib and support HiDPI via GDK_SCALE var
+# http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/bc2d1130105f#l27.8
+GDK_SCALE=1
+export GDK_SCALE
+
+# Allow Java CreateTempFile API to work under flatpak
+# Needs flatpak "--filesystem=xdg-cache" or "--filesystem=home"
+export JAVA_TOOL_OPTIONS="-Djava.io.tmpdir=${XDG_CACHE_HOME}/tmp"
+
+# We saved original config files in read-only location 'config-default'
+# copy them to 'config' writable dir before launching app
+# This workarounds known flatpak limitation, see https://github.com/flatpak/flatpak/issues/545#issuecomment-278931352
+cp -u /app/verapdf/config-default/* /var/config/
+
+# --frameScale was intended for Windows, produces bad results on Unix (linux) see https://github.com/veraPDF/veraPDF-library/issues/993
exec "$JAVACMD" $JAVA_OPTS \
-classpath "$CLASSPATH" \
-Dfile.encoding="UTF8"
```

The result:

Image

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with verapdf-gui.patch and verapdf-gui.sh, especially the SCALE_FACTOR, GDK_SCALE, and --frameScale handling described in the report. Reproduce the Flatpak launch on Fedora Workstation with Xft.dpi set to 192, then verify that the UI is no longer cramped and window controls remain visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
awk, bash, java
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.