available from window system-specific output context. Adjust users.
(default_pixesls_per_inch_x, default_pixesls_per_inch_y): New
functions to provide defaults when no window system available.
(FRAME_RES_X, FRAME_RES_Y): New macros.
(NUMVAL): Moved from xdisp.c.
* font.c (font_pixel_size, font_find_for_lface, font_open_for_lface)
(Ffont_face_attributes, Fopen_font):
* image.c (gs_load):
* w32font.c (fill_in_logfont):
* xdisp.c (calc_pixel_width_or_height):
* xfaces.c (Fx_family_fonts, set_lface_from_font): Use them.
* xsettings.c (apply_xft_settings): Drop frame loop and adjust comment.
+2013-03-20 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * frame.h (struct frame): Drop resx and resy because the same data is
+ available from window system-specific output context. Adjust users.
+ (default_pixesls_per_inch_x, default_pixesls_per_inch_y): New
+ functions to provide defaults when no window system available.
+ (FRAME_RES_X, FRAME_RES_Y): New macros.
+ (NUMVAL): Moved from xdisp.c.
+ * font.c (font_pixel_size, font_find_for_lface, font_open_for_lface)
+ (Ffont_face_attributes, Fopen_font):
+ * image.c (gs_load):
+ * w32font.c (fill_in_logfont):
+ * xdisp.c (calc_pixel_width_or_height):
+ * xfaces.c (Fx_family_fonts, set_lface_from_font): Use them.
+ * xsettings.c (apply_xft_settings): Drop frame loop and adjust comment.
+
2013-03-20 Kenichi Handa <handa@gnu.org>
* coding.c (syms_of_coding): Initialize disable_ascii_optimization
if (INTEGERP (val))
dpi = XINT (val);
else
- dpi = f->resy;
+ dpi = FRAME_RES_Y (f);
pixel_size = POINT_TO_PIXEL (point_size, dpi);
return pixel_size;
#else
{
double pt = XINT (attrs[LFACE_HEIGHT_INDEX]);
- pixel_size = POINT_TO_PIXEL (pt / 10, f->resy);
+ pixel_size = POINT_TO_PIXEL (pt / 10, FRAME_RES_Y (f));
}
ASET (work, FONT_SIZE_INDEX, Qnil);
foundry[0] = AREF (work, FONT_FOUNDRY_INDEX);
}
pt /= 10;
- size = POINT_TO_PIXEL (pt, f->resy);
+ size = POINT_TO_PIXEL (pt, FRAME_RES_Y (f));
#ifdef HAVE_NS
if (size == 0)
{
Lisp_Object ffsize = get_frame_param (f, Qfontsize);
- size = NUMBERP (ffsize) ? POINT_TO_PIXEL (XINT (ffsize), f->resy) : 0;
+ size = (NUMBERP (ffsize)
+ ? POINT_TO_PIXEL (XINT (ffsize), FRAME_RES_Y (f)) : 0);
}
#endif
}
if (INTEGERP (val))
{
Lisp_Object font_dpi = AREF (font, FONT_DPI_INDEX);
- int dpi = INTEGERP (font_dpi) ? XINT (font_dpi) : f->resy;
+ int dpi = INTEGERP (font_dpi) ? XINT (font_dpi) : FRAME_RES_Y (f);
plist[n++] = QCheight;
plist[n++] = make_number (PIXEL_TO_POINT (XINT (val) * 10, dpi));
}
{
CHECK_NUMBER_OR_FLOAT (size);
if (FLOATP (size))
- isize = POINT_TO_PIXEL (XFLOAT_DATA (size), f->resy);
+ isize = POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES_Y (f));
else
isize = XINT (size);
if (! (INT_MIN <= isize && isize <= INT_MAX))
/* Size of the frame window in pixels. */
int pixel_height, pixel_width;
- /* Dots per inch of the screen the frame is on. */
- double resx, resy;
-
/* These many pixels are the difference between the outer window (i.e. the
left and top of the window manager decoration) and FRAME_X_WINDOW. */
int x_pixels_diff, y_pixels_diff;
f->tool_bar_window = val;
}
+#define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
+
+FRAME_INLINE double
+default_pixels_per_inch_x (void)
+{
+ Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
+ ? XCAR (Vdisplay_pixels_per_inch)
+ : Vdisplay_pixels_per_inch);
+ return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
+}
+
+FRAME_INLINE double
+default_pixels_per_inch_y (void)
+{
+ Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
+ ? XCDR (Vdisplay_pixels_per_inch)
+ : Vdisplay_pixels_per_inch);
+ return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
+}
+
#define FRAME_KBOARD(f) ((f)->terminal->kboard)
/* Return a pointer to the image cache of frame F. */
#else
#define FRAME_NS_P(f) ((f)->output_method == output_ns)
#endif
+
+/* Dots per inch of the screen the frame F is on. */
+
+#ifdef HAVE_X_WINDOWS
+#define FRAME_RES_X(f) \
+ (eassert (FRAME_X_P (f)), FRAME_X_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f) \
+ (eassert (FRAME_X_P (f)), FRAME_X_DISPLAY_INFO (f)->resy)
+#endif
+
+#ifdef HAVE_NTGUI
+#define FRAME_RES_X(f) \
+ (eassert (FRAME_W32_P (f)), FRAME_W32_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f) \
+ (eassert (FRAME_W32_P (f)), FRAME_W32_DISPLAY_INFO (f)->resy)
+#endif
+
+#ifdef HAVE_NS
+#define FRAME_RES_X(f) \
+ (eassert (FRAME_NS_P (f)), FRAME_NS_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f) \
+ (eassert (FRAME_NS_P (f)), FRAME_NS_DISPLAY_INFO (f)->resy)
+#endif
+
+/* Defaults when no window system available. */
+
+#ifndef FRAME_RES_X
+#define FRAME_RES_X(f) default_pixels_per_inch_x ()
+#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
+#endif
+
/* FRAME_WINDOW_P tests whether the frame is a window, and is
defined to be the predicate for the window system being used. */
info. */
pt_width = image_spec_value (img->spec, QCpt_width, NULL);
in_width = INTEGERP (pt_width) ? XFASTINT (pt_width) / 72.0 : 0;
- in_width *= FRAME_X_DISPLAY_INFO (f)->resx;
+ in_width *= FRAME_RES_X (f);
pt_height = image_spec_value (img->spec, QCpt_height, NULL);
in_height = INTEGERP (pt_height) ? XFASTINT (pt_height) / 72.0 : 0;
- in_height *= FRAME_X_DISPLAY_INFO (f)->resy;
+ in_height *= FRAME_RES_Y (f);
if (! (in_width <= INT_MAX && in_height <= INT_MAX
&& check_image_size (f, in_width, in_height)))
specbind (Qx_resource_name, name);
}
- f->resx = dpyinfo->resx;
- f->resy = dpyinfo->resy;
-
block_input ();
register_font_driver (&nsfont_driver, f);
x_default_parameter (f, parms, Qfont_backend, Qnil,
specbind (Qx_resource_name, name);
}
- f->resx = dpyinfo->resx;
- f->resy = dpyinfo->resy;
-
if (uniscribe_available)
register_font_driver (&uniscribe_font_driver, f);
register_font_driver (&w32font_driver, f);
specbind (Qx_resource_name, name);
}
- f->resx = dpyinfo->resx;
- f->resy = dpyinfo->resy;
-
if (uniscribe_available)
register_font_driver (&uniscribe_font_driver, f);
register_font_driver (&w32font_driver, f);
fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec)
{
Lisp_Object tmp, extra;
- int dpi = FRAME_W32_DISPLAY_INFO (f)->resy;
+ int dpi = FRAME_RES_Y (f);
tmp = AREF (font_spec, FONT_DPI_INDEX);
if (INTEGERP (tmp))
*/
-#define NUMVAL(X) \
- ((INTEGERP (X) || FLOATP (X)) \
- ? XFLOATINT (X) \
- : - 1)
-
static int
calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
struct font *font, int width_p, int *align_to)
pixels = 0;
if (pixels > 0)
{
- double ppi;
-#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_WINDOW_P (it->f)
- && (ppi = (width_p
- ? FRAME_X_DISPLAY_INFO (it->f)->resx
- : FRAME_X_DISPLAY_INFO (it->f)->resy),
- ppi > 0))
- return OK_PIXELS (ppi / pixels);
-#endif
+ double ppi = (width_p ? FRAME_RES_X (it->f)
+ : FRAME_RES_Y (it->f));
- if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0)
- || (CONSP (Vdisplay_pixels_per_inch)
- && (ppi = (width_p
- ? NUMVAL (XCAR (Vdisplay_pixels_per_inch))
- : NUMVAL (XCDR (Vdisplay_pixels_per_inch))),
- ppi > 0)))
+ if (ppi > 0)
return OK_PIXELS (ppi / pixels);
-
return 0;
}
}
ASET (v, 0, AREF (font, FONT_FAMILY_INDEX));
ASET (v, 1, FONT_WIDTH_SYMBOLIC (font));
point = PIXEL_TO_POINT (XINT (AREF (font, FONT_SIZE_INDEX)) * 10,
- XFRAME (frame)->resy);
+ FRAME_RES_Y (XFRAME (frame)));
ASET (v, 2, make_number (point));
ASET (v, 3, FONT_WEIGHT_SYMBOLIC (font));
ASET (v, 4, FONT_SLANT_SYMBOLIC (font));
if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
{
- int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
+ int pt = PIXEL_TO_POINT (font->pixel_size * 10, FRAME_RES_Y (f));
eassert (pt > 0);
ASET (lface, LFACE_HEIGHT_INDEX, make_number (pt));
specbind (Qx_resource_name, name);
}
- f->resx = dpyinfo->resx;
- f->resy = dpyinfo->resy;
-
#ifdef HAVE_FREETYPE
#ifdef HAVE_XFT
register_font_driver (&xftfont_driver, f);
specbind (Qx_resource_name, name);
}
- f->resx = dpyinfo->resx;
- f->resy = dpyinfo->resy;
-
register_font_driver (&xfont_driver, f);
#ifdef HAVE_FREETYPE
#ifdef HAVE_XFT
if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi
&& settings->dpi > 0)
{
- Lisp_Object frame, tail;
-
FcPatternDel (pat, FC_DPI);
FcPatternAddDouble (pat, FC_DPI, settings->dpi);
++changed;
oldsettings.dpi = settings->dpi;
- /* Change the DPI on this display and all frames on the display. */
+ /* Changing the DPI on this display affects all frames on it.
+ Check FRAME_RES_X and FRAME_RES_Y in frame.h to see how. */
dpyinfo->resy = dpyinfo->resx = settings->dpi;
- FOR_EACH_FRAME (tail, frame)
- if (FRAME_X_P (XFRAME (frame))
- && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
- XFRAME (frame)->resy = XFRAME (frame)->resx = settings->dpi;
}
if (changed)