pixelDensityX and pixelDensityY are the DPI values that will be
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
NULL.
String cacheDir,
float pixelDensityX,
float pixelDensityY,
+ float scaledDensity,
String classPath,
EmacsService emacsService);
EmacsNative.setEmacsParams (assets, filesDir,
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
been dumped. */
final String filesDir, libDir, cacheDir, classPath;
final double pixelDensityX;
final double pixelDensityY;
+ final double scaledDensity;
SERVICE = this;
handler = new Handler (Looper.getMainLooper ());
metrics = getResources ().getDisplayMetrics ();
pixelDensityX = metrics.xdpi;
pixelDensityY = metrics.ydpi;
+ scaledDensity = ((metrics.scaledDensity
+ / metrics.density)
+ * pixelDensityX);
resolver = getContentResolver ();
try
EmacsNative.setEmacsParams (manager, filesDir, libDir,
cacheDir, (float) pixelDensityX,
(float) pixelDensityY,
+ (float) scaledDensity,
classPath, EmacsService.this);
}
}, extraStartupArgument,
/* The display's pixel densities. */
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. */
static char *android_files_dir;
jobject cache_dir,
jfloat pixel_density_x,
jfloat pixel_density_y,
+ jfloat scaled_density,
jobject class_path,
jobject emacs_service_object)
{
android_pixel_density_x = pixel_density_x;
android_pixel_density_y = pixel_density_y;
+ android_scaled_pixel_density = scaled_density;
__android_log_print (ANDROID_LOG_INFO, __func__,
"Initializing "PACKAGE_STRING"...\nPlease report bugs to "
extern const char *android_get_home_directory (void);
extern double android_pixel_density_x, android_pixel_density_y;
+extern double android_scaled_pixel_density;
enum android_handle_type
{
dpyinfo->color_map = color_map;
#ifndef ANDROID_STUBIFY
-
dpyinfo->resx = android_pixel_density_x;
dpyinfo->resy = android_pixel_density_y;
-
-#endif
+ dpyinfo->font_resolution = android_scaled_pixel_density;
+#endif /* ANDROID_STUBIFY */
/* https://lists.gnu.org/r/emacs-devel/2015-11/msg00194.html */
dpyinfo->smallest_font_height = 1;
/* DPI of the display. */
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. */
struct android_gc *scratch_cursor_gc;
if (FIXNUMP (val))
dpi = XFIXNUM (val);
else
- dpi = FRAME_RES_Y (f);
+ dpi = FRAME_RES (f);
pixel_size = POINT_TO_PIXEL (point_size, dpi);
return pixel_size;
}
{
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)
pixel_size = 1;
}
}
pt /= 10;
- size = POINT_TO_PIXEL (pt, FRAME_RES_Y (f));
+ size = POINT_TO_PIXEL (pt, FRAME_RES (f));
#ifdef HAVE_NS
if (size == 0)
{
Lisp_Object ffsize = get_frame_param (f, Qfontsize);
size = (NUMBERP (ffsize)
- ? POINT_TO_PIXEL (XFLOATINT (ffsize), FRAME_RES_Y (f))
+ ? POINT_TO_PIXEL (XFLOATINT (ffsize), FRAME_RES (f))
: 0);
}
#endif
if (FIXNUMP (val))
{
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++] = make_fixnum (PIXEL_TO_POINT (XFIXNUM (val) * 10, dpi));
}
{
CHECK_NUMBER (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))
args_out_of_range (font_entity, size);
if (! (INT_MIN <= isize && isize <= INT_MAX))
#define FRAME_RES_Y(f) \
(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 */
/* Defaults when no window system available. */
-#define FRAME_RES_X(f) default_pixels_per_inch_x ()
-#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
+#define FRAME_RES_X(f) default_pixels_per_inch_x ()
+#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
+#define FRAME_RES(f) default_pixels_per_inch_y ()
#endif /* HAVE_WINDOW_SYSTEM */
fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
{
Lisp_Object tmp, extra;
- int dpi = FRAME_RES_Y (f);
+ int dpi = FRAME_RES (f);
tmp = AREF (font_spec, FONT_DPI_INDEX);
if (FIXNUMP (tmp))
{
Lisp_Object font = AREF (vec, i);
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 v = CALLN (Fvector,
AREF (font, FONT_FAMILY_INDEX),
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);
ASET (lface, LFACE_HEIGHT_INDEX, make_fixnum (pt));