mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Update Android port
* java/org/gnu/emacs/EmacsNative.java (scaledDensity): Announce new argument `scaledDensity'. * java/org/gnu/emacs/EmacsNoninteractive.java (main): Specify new argument. * java/org/gnu/emacs/EmacsService.java (onCreate): Compute an adjusted DPI for the font size based on the ratio between density and scaledDensity. (run): Specify that adjusted density. * src/android.c (setEmacsParams): Set `android_scaled_pixel_density'. * src/android.h: (android_scaled_pixel_density: New variable. * src/androidterm.c (android_term_init): Set `font_resolution'. * src/androidterm.h (struct android_display_info): New field. * src/font.c (font_pixel_size, font_find_for_lface) (font_open_for_lface, Ffont_face_attributes, Fopen_font): Use FRAME_RES instead of FRAME_RES_Y. * src/frame.h (FRAME_RES): New macro. Use this to convert between font point and pixel sizes as opposed to FRAME_RES_Y. * src/w32font.c (fill_in_logfont): * src/xfaces.c (Fx_family_fonts, set_lface_from_font): Use FRAME_RES instead of FRAME_RES_Y. (bug#64444)
This commit is contained in:
parent
af8232a150
commit
75db451170
11 changed files with 49 additions and 15 deletions
|
|
@ -60,6 +60,9 @@ public final class EmacsNative
|
||||||
pixelDensityX and pixelDensityY are the DPI values that will be
|
pixelDensityX and pixelDensityY are the DPI values that will be
|
||||||
used by Emacs.
|
used by Emacs.
|
||||||
|
|
||||||
|
scaledDensity is the DPI value used to translate point sizes to
|
||||||
|
pixel sizes when loading fonts.
|
||||||
|
|
||||||
classPath must be the classpath of this app_process process, or
|
classPath must be the classpath of this app_process process, or
|
||||||
NULL.
|
NULL.
|
||||||
|
|
||||||
|
|
@ -70,6 +73,7 @@ public final class EmacsNative
|
||||||
String cacheDir,
|
String cacheDir,
|
||||||
float pixelDensityX,
|
float pixelDensityX,
|
||||||
float pixelDensityY,
|
float pixelDensityY,
|
||||||
|
float scaledDensity,
|
||||||
String classPath,
|
String classPath,
|
||||||
EmacsService emacsService);
|
EmacsService emacsService);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ public final class EmacsNoninteractive
|
||||||
|
|
||||||
EmacsNative.setEmacsParams (assets, filesDir,
|
EmacsNative.setEmacsParams (assets, filesDir,
|
||||||
libDir, cacheDir, 0.0f,
|
libDir, cacheDir, 0.0f,
|
||||||
0.0f, null, null);
|
0.0f, 0.0f, null, null);
|
||||||
|
|
||||||
/* Now find the dump file that Emacs should use, if it has already
|
/* Now find the dump file that Emacs should use, if it has already
|
||||||
been dumped. */
|
been dumped. */
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ public final class EmacsService extends Service
|
||||||
final String filesDir, libDir, cacheDir, classPath;
|
final String filesDir, libDir, cacheDir, classPath;
|
||||||
final double pixelDensityX;
|
final double pixelDensityX;
|
||||||
final double pixelDensityY;
|
final double pixelDensityY;
|
||||||
|
final double scaledDensity;
|
||||||
|
|
||||||
SERVICE = this;
|
SERVICE = this;
|
||||||
handler = new Handler (Looper.getMainLooper ());
|
handler = new Handler (Looper.getMainLooper ());
|
||||||
|
|
@ -219,6 +220,9 @@ public final class EmacsService extends Service
|
||||||
metrics = getResources ().getDisplayMetrics ();
|
metrics = getResources ().getDisplayMetrics ();
|
||||||
pixelDensityX = metrics.xdpi;
|
pixelDensityX = metrics.xdpi;
|
||||||
pixelDensityY = metrics.ydpi;
|
pixelDensityY = metrics.ydpi;
|
||||||
|
scaledDensity = ((metrics.scaledDensity
|
||||||
|
/ metrics.density)
|
||||||
|
* pixelDensityX);
|
||||||
resolver = getContentResolver ();
|
resolver = getContentResolver ();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -247,6 +251,7 @@ public final class EmacsService extends Service
|
||||||
EmacsNative.setEmacsParams (manager, filesDir, libDir,
|
EmacsNative.setEmacsParams (manager, filesDir, libDir,
|
||||||
cacheDir, (float) pixelDensityX,
|
cacheDir, (float) pixelDensityX,
|
||||||
(float) pixelDensityY,
|
(float) pixelDensityY,
|
||||||
|
(float) scaledDensity,
|
||||||
classPath, EmacsService.this);
|
classPath, EmacsService.this);
|
||||||
}
|
}
|
||||||
}, extraStartupArgument,
|
}, extraStartupArgument,
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,10 @@ char *android_class_path;
|
||||||
/* The display's pixel densities. */
|
/* The display's pixel densities. */
|
||||||
double android_pixel_density_x, android_pixel_density_y;
|
double android_pixel_density_x, android_pixel_density_y;
|
||||||
|
|
||||||
|
/* The display pixel density used to convert between point and pixel
|
||||||
|
font sizes. */
|
||||||
|
double android_scaled_pixel_density;
|
||||||
|
|
||||||
/* The Android application data directory. */
|
/* The Android application data directory. */
|
||||||
static char *android_files_dir;
|
static char *android_files_dir;
|
||||||
|
|
||||||
|
|
@ -2000,6 +2004,7 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
|
||||||
jobject cache_dir,
|
jobject cache_dir,
|
||||||
jfloat pixel_density_x,
|
jfloat pixel_density_x,
|
||||||
jfloat pixel_density_y,
|
jfloat pixel_density_y,
|
||||||
|
jfloat scaled_density,
|
||||||
jobject class_path,
|
jobject class_path,
|
||||||
jobject emacs_service_object)
|
jobject emacs_service_object)
|
||||||
{
|
{
|
||||||
|
|
@ -2021,6 +2026,7 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
|
||||||
|
|
||||||
android_pixel_density_x = pixel_density_x;
|
android_pixel_density_x = pixel_density_x;
|
||||||
android_pixel_density_y = pixel_density_y;
|
android_pixel_density_y = pixel_density_y;
|
||||||
|
android_scaled_pixel_density = scaled_density;
|
||||||
|
|
||||||
__android_log_print (ANDROID_LOG_INFO, __func__,
|
__android_log_print (ANDROID_LOG_INFO, __func__,
|
||||||
"Initializing "PACKAGE_STRING"...\nPlease report bugs to "
|
"Initializing "PACKAGE_STRING"...\nPlease report bugs to "
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ extern int android_fclose (FILE *);
|
||||||
extern const char *android_get_home_directory (void);
|
extern const char *android_get_home_directory (void);
|
||||||
|
|
||||||
extern double android_pixel_density_x, android_pixel_density_y;
|
extern double android_pixel_density_x, android_pixel_density_y;
|
||||||
|
extern double android_scaled_pixel_density;
|
||||||
|
|
||||||
enum android_handle_type
|
enum android_handle_type
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6295,11 +6295,10 @@ android_term_init (void)
|
||||||
dpyinfo->color_map = color_map;
|
dpyinfo->color_map = color_map;
|
||||||
|
|
||||||
#ifndef ANDROID_STUBIFY
|
#ifndef ANDROID_STUBIFY
|
||||||
|
|
||||||
dpyinfo->resx = android_pixel_density_x;
|
dpyinfo->resx = android_pixel_density_x;
|
||||||
dpyinfo->resy = android_pixel_density_y;
|
dpyinfo->resy = android_pixel_density_y;
|
||||||
|
dpyinfo->font_resolution = android_scaled_pixel_density;
|
||||||
#endif
|
#endif /* ANDROID_STUBIFY */
|
||||||
|
|
||||||
/* https://lists.gnu.org/r/emacs-devel/2015-11/msg00194.html */
|
/* https://lists.gnu.org/r/emacs-devel/2015-11/msg00194.html */
|
||||||
dpyinfo->smallest_font_height = 1;
|
dpyinfo->smallest_font_height = 1;
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@ struct android_display_info
|
||||||
/* DPI of the display. */
|
/* DPI of the display. */
|
||||||
double resx, resy;
|
double resx, resy;
|
||||||
|
|
||||||
|
/* DPI used to convert font point sizes into pixel dimensions.
|
||||||
|
This is resy adjusted by a fixed scaling factor specified by
|
||||||
|
the user. */
|
||||||
|
double font_resolution;
|
||||||
|
|
||||||
/* Scratch GC for drawing a cursor in a non-default face. */
|
/* Scratch GC for drawing a cursor in a non-default face. */
|
||||||
struct android_gc *scratch_cursor_gc;
|
struct android_gc *scratch_cursor_gc;
|
||||||
|
|
||||||
|
|
|
||||||
12
src/font.c
12
src/font.c
|
|
@ -348,7 +348,7 @@ font_pixel_size (struct frame *f, Lisp_Object spec)
|
||||||
if (FIXNUMP (val))
|
if (FIXNUMP (val))
|
||||||
dpi = XFIXNUM (val);
|
dpi = XFIXNUM (val);
|
||||||
else
|
else
|
||||||
dpi = FRAME_RES_Y (f);
|
dpi = FRAME_RES (f);
|
||||||
pixel_size = POINT_TO_PIXEL (point_size, dpi);
|
pixel_size = POINT_TO_PIXEL (point_size, dpi);
|
||||||
return pixel_size;
|
return pixel_size;
|
||||||
}
|
}
|
||||||
|
|
@ -3023,7 +3023,7 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
|
||||||
{
|
{
|
||||||
double pt = XFIXNUM (attrs[LFACE_HEIGHT_INDEX]);
|
double pt = XFIXNUM (attrs[LFACE_HEIGHT_INDEX]);
|
||||||
|
|
||||||
pixel_size = POINT_TO_PIXEL (pt / 10, FRAME_RES_Y (f));
|
pixel_size = POINT_TO_PIXEL (pt / 10, FRAME_RES (f));
|
||||||
if (pixel_size < 1)
|
if (pixel_size < 1)
|
||||||
pixel_size = 1;
|
pixel_size = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -3175,13 +3175,13 @@ font_open_for_lface (struct frame *f, Lisp_Object entity, Lisp_Object *attrs, Li
|
||||||
}
|
}
|
||||||
|
|
||||||
pt /= 10;
|
pt /= 10;
|
||||||
size = POINT_TO_PIXEL (pt, FRAME_RES_Y (f));
|
size = POINT_TO_PIXEL (pt, FRAME_RES (f));
|
||||||
#ifdef HAVE_NS
|
#ifdef HAVE_NS
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
Lisp_Object ffsize = get_frame_param (f, Qfontsize);
|
Lisp_Object ffsize = get_frame_param (f, Qfontsize);
|
||||||
size = (NUMBERP (ffsize)
|
size = (NUMBERP (ffsize)
|
||||||
? POINT_TO_PIXEL (XFLOATINT (ffsize), FRAME_RES_Y (f))
|
? POINT_TO_PIXEL (XFLOATINT (ffsize), FRAME_RES (f))
|
||||||
: 0);
|
: 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4082,7 +4082,7 @@ are to be displayed on. If omitted, the selected frame is used. */)
|
||||||
if (FIXNUMP (val))
|
if (FIXNUMP (val))
|
||||||
{
|
{
|
||||||
Lisp_Object font_dpi = AREF (font, FONT_DPI_INDEX);
|
Lisp_Object font_dpi = AREF (font, FONT_DPI_INDEX);
|
||||||
int dpi = FIXNUMP (font_dpi) ? XFIXNUM (font_dpi) : FRAME_RES_Y (f);
|
int dpi = FIXNUMP (font_dpi) ? XFIXNUM (font_dpi) : FRAME_RES (f);
|
||||||
plist[n++] = QCheight;
|
plist[n++] = QCheight;
|
||||||
plist[n++] = make_fixnum (PIXEL_TO_POINT (XFIXNUM (val) * 10, dpi));
|
plist[n++] = make_fixnum (PIXEL_TO_POINT (XFIXNUM (val) * 10, dpi));
|
||||||
}
|
}
|
||||||
|
|
@ -4986,7 +4986,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
|
||||||
{
|
{
|
||||||
CHECK_NUMBER (size);
|
CHECK_NUMBER (size);
|
||||||
if (FLOATP (size))
|
if (FLOATP (size))
|
||||||
isize = POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES_Y (f));
|
isize = POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES (f));
|
||||||
else if (! integer_to_intmax (size, &isize))
|
else if (! integer_to_intmax (size, &isize))
|
||||||
args_out_of_range (font_entity, size);
|
args_out_of_range (font_entity, size);
|
||||||
if (! (INT_MIN <= isize && isize <= INT_MAX))
|
if (! (INT_MIN <= isize && isize <= INT_MAX))
|
||||||
|
|
|
||||||
18
src/frame.h
18
src/frame.h
|
|
@ -981,12 +981,26 @@ default_pixels_per_inch_y (void)
|
||||||
#define FRAME_RES_Y(f) \
|
#define FRAME_RES_Y(f) \
|
||||||
(eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
|
(eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
|
||||||
|
|
||||||
|
#ifdef HAVE_ANDROID
|
||||||
|
|
||||||
|
/* Android systems use a font scaling factor independent from the
|
||||||
|
display DPI. */
|
||||||
|
|
||||||
|
#define FRAME_RES(f) \
|
||||||
|
(eassert (FRAME_WINDOW_P (f)), \
|
||||||
|
FRAME_DISPLAY_INFO (f)->font_resolution)
|
||||||
|
|
||||||
|
#else /* !HAVE_ANDROID */
|
||||||
|
#define FRAME_RES(f) (FRAME_RES_Y (f))
|
||||||
|
#endif /* HAVE_ANDROID */
|
||||||
|
|
||||||
#else /* !HAVE_WINDOW_SYSTEM */
|
#else /* !HAVE_WINDOW_SYSTEM */
|
||||||
|
|
||||||
/* Defaults when no window system available. */
|
/* Defaults when no window system available. */
|
||||||
|
|
||||||
#define FRAME_RES_X(f) default_pixels_per_inch_x ()
|
#define FRAME_RES_X(f) default_pixels_per_inch_x ()
|
||||||
#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
|
#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
|
||||||
|
#define FRAME_RES(f) default_pixels_per_inch_y ()
|
||||||
|
|
||||||
#endif /* HAVE_WINDOW_SYSTEM */
|
#endif /* HAVE_WINDOW_SYSTEM */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2031,7 +2031,7 @@ static void
|
||||||
fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
|
fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
|
||||||
{
|
{
|
||||||
Lisp_Object tmp, extra;
|
Lisp_Object tmp, extra;
|
||||||
int dpi = FRAME_RES_Y (f);
|
int dpi = FRAME_RES (f);
|
||||||
|
|
||||||
tmp = AREF (font_spec, FONT_DPI_INDEX);
|
tmp = AREF (font_spec, FONT_DPI_INDEX);
|
||||||
if (FIXNUMP (tmp))
|
if (FIXNUMP (tmp))
|
||||||
|
|
|
||||||
|
|
@ -1612,7 +1612,7 @@ the face font sort order, see `face-font-selection-order'. */)
|
||||||
{
|
{
|
||||||
Lisp_Object font = AREF (vec, i);
|
Lisp_Object font = AREF (vec, i);
|
||||||
int point = PIXEL_TO_POINT (XFIXNUM (AREF (font, FONT_SIZE_INDEX)) * 10,
|
int point = PIXEL_TO_POINT (XFIXNUM (AREF (font, FONT_SIZE_INDEX)) * 10,
|
||||||
FRAME_RES_Y (f));
|
FRAME_RES (f));
|
||||||
Lisp_Object spacing = Ffont_get (font, QCspacing);
|
Lisp_Object spacing = Ffont_get (font, QCspacing);
|
||||||
Lisp_Object v = CALLN (Fvector,
|
Lisp_Object v = CALLN (Fvector,
|
||||||
AREF (font, FONT_FAMILY_INDEX),
|
AREF (font, FONT_FAMILY_INDEX),
|
||||||
|
|
@ -2173,7 +2173,7 @@ set_lface_from_font (struct frame *f, Lisp_Object lface,
|
||||||
|
|
||||||
if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
|
if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
|
||||||
{
|
{
|
||||||
int pt = PIXEL_TO_POINT (font->pixel_size * 10, FRAME_RES_Y (f));
|
int pt = PIXEL_TO_POINT (font->pixel_size * 10, FRAME_RES (f));
|
||||||
|
|
||||||
eassert (pt > 0);
|
eassert (pt > 0);
|
||||||
ASET (lface, LFACE_HEIGHT_INDEX, make_fixnum (pt));
|
ASET (lface, LFACE_HEIGHT_INDEX, make_fixnum (pt));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue