Commit f46e6225 authored by Geoff Voelker's avatar Geoff Voelker
Browse files

(enum_font_cb2): Set the font height to be the

character height, not the cell height.
(Fw32_select_font): Initialize font dialog with current
default font.
(Vw32_system_coding_system): New variable.
(w32_strict_filenames): Add comment.
(w32_to_x_font): Decode font name using Vw32_system_coding_system.
(x_to_w32_font): Encode font name using Vw32_system_coding_system.
(syms_of_w32fns): Add w32-system-coding-system.
parent 865203c3
...@@ -141,9 +141,12 @@ Lisp_Object Vx_pixel_size_width_font_regexp; ...@@ -141,9 +141,12 @@ Lisp_Object Vx_pixel_size_width_font_regexp;
/* Alist of bdf fonts and the files that define them. */ /* Alist of bdf fonts and the files that define them. */
Lisp_Object Vw32_bdf_filename_alist; Lisp_Object Vw32_bdf_filename_alist;
Lisp_Object Vw32_system_coding_system;
/* A flag to control how to display unibyte 8-bit character. */ /* A flag to control how to display unibyte 8-bit character. */
int unibyte_display_via_language_environment; int unibyte_display_via_language_environment;
/* A flag to control whether fonts are matched strictly or not. */
int w32_strict_fontnames; int w32_strict_fontnames;
/* Evaluate this expression to rebuild the section of syms_of_w32fns /* Evaluate this expression to rebuild the section of syms_of_w32fns
...@@ -5388,24 +5391,33 @@ w32_to_x_font (lplogfont, lpxstr, len) ...@@ -5388,24 +5391,33 @@ w32_to_x_font (lplogfont, lpxstr, len)
char * lpxstr; char * lpxstr;
int len; int len;
{ {
char fontname[50]; char *fontname;
char height_pixels[8]; char height_pixels[8];
char height_dpi[8]; char height_dpi[8];
char width_pixels[8]; char width_pixels[8];
char *fontname_dash; char *fontname_dash;
int display_resy = one_w32_display_info.height_in; int display_resy = one_w32_display_info.height_in;
int display_resx = one_w32_display_info.width_in; int display_resx = one_w32_display_info.width_in;
int bufsz;
struct coding_system coding;
if (!lpxstr) abort (); if (!lpxstr) abort ();
if (!lplogfont) if (!lplogfont)
return FALSE; return FALSE;
strncpy (fontname, lplogfont->lfFaceName, 50); setup_coding_system (Fcheck_coding_system (Vw32_system_coding_system),
fontname[49] = '\0'; /* Just in case */ &coding);
coding.mode |= CODING_MODE_LAST_BLOCK;
bufsz = decoding_buffer_size (&coding, LF_FACESIZE);
fontname = alloca(sizeof(*fontname) * bufsz);
decode_coding (&coding, lplogfont->lfFaceName, fontname,
strlen(lplogfont->lfFaceName), bufsz - 1);
*(fontname + coding.produced) = '\0';
/* Replace dashes with underscores so the dashes are not /* Replace dashes with underscores so the dashes are not
misinterpreted */ misinterpreted. */
fontname_dash = fontname; fontname_dash = fontname;
while (fontname_dash = strchr (fontname_dash, '-')) while (fontname_dash = strchr (fontname_dash, '-'))
*fontname_dash = '_'; *fontname_dash = '_';
...@@ -5454,8 +5466,10 @@ x_to_w32_font (lpxstr, lplogfont) ...@@ -5454,8 +5466,10 @@ x_to_w32_font (lpxstr, lplogfont)
char * lpxstr; char * lpxstr;
LOGFONT * lplogfont; LOGFONT * lplogfont;
{ {
struct coding_system coding;
if (!lplogfont) return (FALSE); if (!lplogfont) return (FALSE);
memset (lplogfont, 0, sizeof (*lplogfont)); memset (lplogfont, 0, sizeof (*lplogfont));
/* Set default value for each field. */ /* Set default value for each field. */
...@@ -5498,8 +5512,12 @@ x_to_w32_font (lpxstr, lplogfont) ...@@ -5498,8 +5512,12 @@ x_to_w32_font (lpxstr, lplogfont)
if (fields > 0 && name[0] != '*') if (fields > 0 && name[0] != '*')
{ {
strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); setup_coding_system
lplogfont->lfFaceName[LF_FACESIZE-1] = 0; (Fcheck_coding_system (Vw32_system_coding_system), &coding);
coding.mode |= CODING_MODE_LAST_BLOCK;
encode_coding (&coding, name, lplogfont->lfFaceName,
strlen (name), LF_FACESIZE-1);
lplogfont->lfFaceName[coding.produced] = 0;
} }
else else
{ {
...@@ -5695,6 +5713,10 @@ enum_font_cb2 (lplf, lptm, FontType, lpef) ...@@ -5695,6 +5713,10 @@ enum_font_cb2 (lplf, lptm, FontType, lpef)
lplf->elfLogFont.lfHeight = lpef->logfont.lfHeight; lplf->elfLogFont.lfHeight = lpef->logfont.lfHeight;
lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth; lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth;
} }
/* Make sure the height used here is the same as everywhere
else (ie character height, not cell height). */
else if (lplf->elfLogFont.lfHeight > 0)
lplf->elfLogFont.lfHeight = lptm->tmInternalLeading - lptm->tmHeight;
/* The MaxCharWidth is not valid at this stage for scalable fonts. */ /* The MaxCharWidth is not valid at this stage for scalable fonts. */
if (FontType == RASTER_FONTTYPE) if (FontType == RASTER_FONTTYPE)
...@@ -6869,15 +6891,38 @@ DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 1, 0, ...@@ -6869,15 +6891,38 @@ DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 1, 0,
FRAME_PTR f = check_x_frame (frame); FRAME_PTR f = check_x_frame (frame);
CHOOSEFONT cf; CHOOSEFONT cf;
LOGFONT lf; LOGFONT lf;
TEXTMETRIC tm;
HDC hdc;
HANDLE oldobj;
char buf[100]; char buf[100];
bzero (&cf, sizeof (cf)); bzero (&cf, sizeof (cf));
bzero (&lf, sizeof (lf));
cf.lStructSize = sizeof (cf); cf.lStructSize = sizeof (cf);
cf.hwndOwner = FRAME_W32_WINDOW (f); cf.hwndOwner = FRAME_W32_WINDOW (f);
cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST | CF_SCREENFONTS; cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST | CF_SCREENFONTS;
cf.lpLogFont = &lf; cf.lpLogFont = &lf;
/* Initialize as much of the font details as we can from the current
default font. */
hdc = GetDC (FRAME_W32_WINDOW (f));
oldobj = SelectObject (hdc, FRAME_FONT (f)->hfont);
GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName);
if (GetTextMetrics (hdc, &tm))
{
lf.lfHeight = tm.tmInternalLeading - tm.tmHeight;
lf.lfWeight = tm.tmWeight;
lf.lfItalic = tm.tmItalic;
lf.lfUnderline = tm.tmUnderlined;
lf.lfStrikeOut = tm.tmStruckOut;
lf.lfPitchAndFamily = tm.tmPitchAndFamily;
lf.lfCharSet = tm.tmCharSet;
cf.Flags |= CF_INITTOLOGFONTSTRUCT;
}
SelectObject (hdc, oldobj);
ReleaseDC (FRAME_W32_WINDOW(f), hdc);
if (!ChooseFont (&cf) || !w32_to_x_font (&lf, buf, 100)) if (!ChooseFont (&cf) || !w32_to_x_font (&lf, buf, 100))
return Qnil; return Qnil;
...@@ -7410,6 +7455,11 @@ Setting this to t will prevent wrong fonts being selected when\n\ ...@@ -7410,6 +7455,11 @@ Setting this to t will prevent wrong fonts being selected when\n\
fontsets are automatically created."); fontsets are automatically created.");
w32_strict_fontnames = 0; w32_strict_fontnames = 0;
DEFVAR_LISP ("w32-system-coding-system",
&Vw32_system_coding_system,
"Coding system used by Windows system functions, such as for font names.");
Vw32_system_coding_system = Qnil;
defsubr (&Sx_get_resource); defsubr (&Sx_get_resource);
defsubr (&Sx_list_fonts); defsubr (&Sx_list_fonts);
defsubr (&Sx_display_color_p); defsubr (&Sx_display_color_p);
......
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