Commit 42143acd authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* 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.
parent 47077837
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
......
......@@ -287,7 +287,7 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec)
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
......@@ -3117,7 +3117,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c)
{
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);
......@@ -3247,12 +3247,13 @@ font_open_for_lface (FRAME_PTR f, Lisp_Object entity, Lisp_Object *attrs, Lisp_O
}
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
}
......@@ -4021,7 +4022,7 @@ are to be displayed on. If omitted, the selected frame is used. */)
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));
}
......@@ -4532,7 +4533,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
{
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))
......
......@@ -276,9 +276,6 @@ struct frame
/* 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;
......@@ -569,6 +566,26 @@ fset_tool_bar_window (struct frame *f, Lisp_Object val)
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. */
......@@ -602,6 +619,37 @@ typedef struct frame *FRAME_PTR;
#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. */
......
......@@ -8554,10 +8554,10 @@ gs_load (struct frame *f, struct image *img)
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)))
......
......@@ -1243,9 +1243,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
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,
......
......@@ -4353,9 +4353,6 @@ This function is an internal primitive--use `make-frame' instead. */)
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);
......@@ -5420,9 +5417,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
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);
......
......@@ -1967,7 +1967,7 @@ static void
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))
......
......@@ -22082,11 +22082,6 @@ else if the text is replaced by an ellipsis. */)
*/
#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)
......@@ -22117,24 +22112,11 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
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;
}
}
......
......@@ -1592,7 +1592,7 @@ the face font sort order. */)
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));
......@@ -2118,7 +2118,7 @@ set_lface_from_font (struct frame *f, Lisp_Object lface,
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));
......
......@@ -3182,9 +3182,6 @@ This function is an internal primitive--use `make-frame' instead. */)
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);
......@@ -4631,9 +4628,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
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
......
......@@ -673,19 +673,14 @@ apply_xft_settings (struct x_display_info *dpyinfo,
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment