From 105c876a609d4610ce684c7513b8548feae3638a Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 9 Jul 2023 10:05:08 +0800 Subject: [PATCH] Update Android port * java/org/gnu/emacs/EmacsDrawPoint.java (perform): Don't fill an extra pixel. * java/org/gnu/emacs/EmacsService.java (onCreate): Make sure scaledDensity is always at least 160 dpi. --- java/org/gnu/emacs/EmacsDrawPoint.java | 5 ++++- java/org/gnu/emacs/EmacsService.java | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/java/org/gnu/emacs/EmacsDrawPoint.java b/java/org/gnu/emacs/EmacsDrawPoint.java index de8ddf09cc4..6a1cb744d60 100644 --- a/java/org/gnu/emacs/EmacsDrawPoint.java +++ b/java/org/gnu/emacs/EmacsDrawPoint.java @@ -25,7 +25,10 @@ public final class EmacsDrawPoint perform (EmacsDrawable drawable, EmacsGC immutableGC, int x, int y) { - EmacsDrawRectangle.perform (drawable, immutableGC, + /* Use EmacsFillRectangle instead of EmacsDrawRectangle, as the + latter actually draws a rectangle one pixel wider than + specified. */ + EmacsFillRectangle.perform (drawable, immutableGC, x, y, 1, 1); } } diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 62fd2740286..f484e2c9ca3 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -225,6 +225,17 @@ public final class EmacsService extends Service * pixelDensityX); resolver = getContentResolver (); + /* If the density used to compute the text size is lesser than + 160, there's likely a bug with display density computation. + Reset it to 160 in that case. + + Note that Android uses 160 ``dpi'' as the density where 1 point + corresponds to 1 pixel, not 72 or 96 as used elsewhere. This + difference is codified in PT_PER_INCH defined in font.h. */ + + if (scaledDensity < 160) + scaledDensity = 160; + try { /* Configure Emacs with the asset manager and other necessary @@ -240,7 +251,9 @@ public final class EmacsService extends Service Log.d (TAG, "Initializing Emacs, where filesDir = " + filesDir + ", libDir = " + libDir + ", and classPath = " + classPath - + "; fileToOpen = " + EmacsOpenActivity.fileToOpen); + + "; fileToOpen = " + EmacsOpenActivity.fileToOpen + + "; display density: " + pixelDensityX + " by " + + pixelDensityY + " scaled to " + scaledDensity); /* Start the thread that runs Emacs. */ thread = new EmacsThread (this, new Runnable () { -- 2.39.2