diff options
| author | Geoff Voelker | 1999-03-17 22:03:55 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1999-03-17 22:03:55 +0000 |
| commit | f46e6225bb14b179b9ae9ebcb05c9e439efe95f7 (patch) | |
| tree | f136f4bf2303be5e4cc0f7f4e1f8433860cba222 /src | |
| parent | 865203c3b7dbf3c99be9038089a91b459793a165 (diff) | |
| download | emacs-f46e6225bb14b179b9ae9ebcb05c9e439efe95f7.tar.gz emacs-f46e6225bb14b179b9ae9ebcb05c9e439efe95f7.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 8eb3c3ee218..e0b1a5e5354 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -141,9 +141,12 @@ Lisp_Object Vx_pixel_size_width_font_regexp; | |||
| 141 | /* Alist of bdf fonts and the files that define them. */ | 141 | /* Alist of bdf fonts and the files that define them. */ |
| 142 | Lisp_Object Vw32_bdf_filename_alist; | 142 | Lisp_Object Vw32_bdf_filename_alist; |
| 143 | 143 | ||
| 144 | Lisp_Object Vw32_system_coding_system; | ||
| 145 | |||
| 144 | /* A flag to control how to display unibyte 8-bit character. */ | 146 | /* A flag to control how to display unibyte 8-bit character. */ |
| 145 | int unibyte_display_via_language_environment; | 147 | int unibyte_display_via_language_environment; |
| 146 | 148 | ||
| 149 | /* A flag to control whether fonts are matched strictly or not. */ | ||
| 147 | int w32_strict_fontnames; | 150 | int w32_strict_fontnames; |
| 148 | 151 | ||
| 149 | /* Evaluate this expression to rebuild the section of syms_of_w32fns | 152 | /* Evaluate this expression to rebuild the section of syms_of_w32fns |
| @@ -5388,24 +5391,33 @@ w32_to_x_font (lplogfont, lpxstr, len) | |||
| 5388 | char * lpxstr; | 5391 | char * lpxstr; |
| 5389 | int len; | 5392 | int len; |
| 5390 | { | 5393 | { |
| 5391 | char fontname[50]; | 5394 | char *fontname; |
| 5392 | char height_pixels[8]; | 5395 | char height_pixels[8]; |
| 5393 | char height_dpi[8]; | 5396 | char height_dpi[8]; |
| 5394 | char width_pixels[8]; | 5397 | char width_pixels[8]; |
| 5395 | char *fontname_dash; | 5398 | char *fontname_dash; |
| 5396 | int display_resy = one_w32_display_info.height_in; | 5399 | int display_resy = one_w32_display_info.height_in; |
| 5397 | int display_resx = one_w32_display_info.width_in; | 5400 | int display_resx = one_w32_display_info.width_in; |
| 5401 | int bufsz; | ||
| 5402 | struct coding_system coding; | ||
| 5398 | 5403 | ||
| 5399 | if (!lpxstr) abort (); | 5404 | if (!lpxstr) abort (); |
| 5400 | 5405 | ||
| 5401 | if (!lplogfont) | 5406 | if (!lplogfont) |
| 5402 | return FALSE; | 5407 | return FALSE; |
| 5403 | 5408 | ||
| 5404 | strncpy (fontname, lplogfont->lfFaceName, 50); | 5409 | setup_coding_system (Fcheck_coding_system (Vw32_system_coding_system), |
| 5405 | fontname[49] = '\0'; /* Just in case */ | 5410 | &coding); |
| 5411 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 5412 | bufsz = decoding_buffer_size (&coding, LF_FACESIZE); | ||
| 5413 | |||
| 5414 | fontname = alloca(sizeof(*fontname) * bufsz); | ||
| 5415 | decode_coding (&coding, lplogfont->lfFaceName, fontname, | ||
| 5416 | strlen(lplogfont->lfFaceName), bufsz - 1); | ||
| 5417 | *(fontname + coding.produced) = '\0'; | ||
| 5406 | 5418 | ||
| 5407 | /* Replace dashes with underscores so the dashes are not | 5419 | /* Replace dashes with underscores so the dashes are not |
| 5408 | misinterpreted */ | 5420 | misinterpreted. */ |
| 5409 | fontname_dash = fontname; | 5421 | fontname_dash = fontname; |
| 5410 | while (fontname_dash = strchr (fontname_dash, '-')) | 5422 | while (fontname_dash = strchr (fontname_dash, '-')) |
| 5411 | *fontname_dash = '_'; | 5423 | *fontname_dash = '_'; |
| @@ -5454,8 +5466,10 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 5454 | char * lpxstr; | 5466 | char * lpxstr; |
| 5455 | LOGFONT * lplogfont; | 5467 | LOGFONT * lplogfont; |
| 5456 | { | 5468 | { |
| 5469 | struct coding_system coding; | ||
| 5470 | |||
| 5457 | if (!lplogfont) return (FALSE); | 5471 | if (!lplogfont) return (FALSE); |
| 5458 | 5472 | ||
| 5459 | memset (lplogfont, 0, sizeof (*lplogfont)); | 5473 | memset (lplogfont, 0, sizeof (*lplogfont)); |
| 5460 | 5474 | ||
| 5461 | /* Set default value for each field. */ | 5475 | /* Set default value for each field. */ |
| @@ -5498,8 +5512,12 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 5498 | 5512 | ||
| 5499 | if (fields > 0 && name[0] != '*') | 5513 | if (fields > 0 && name[0] != '*') |
| 5500 | { | 5514 | { |
| 5501 | strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); | 5515 | setup_coding_system |
| 5502 | lplogfont->lfFaceName[LF_FACESIZE-1] = 0; | 5516 | (Fcheck_coding_system (Vw32_system_coding_system), &coding); |
| 5517 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 5518 | encode_coding (&coding, name, lplogfont->lfFaceName, | ||
| 5519 | strlen (name), LF_FACESIZE-1); | ||
| 5520 | lplogfont->lfFaceName[coding.produced] = 0; | ||
| 5503 | } | 5521 | } |
| 5504 | else | 5522 | else |
| 5505 | { | 5523 | { |
| @@ -5695,6 +5713,10 @@ enum_font_cb2 (lplf, lptm, FontType, lpef) | |||
| 5695 | lplf->elfLogFont.lfHeight = lpef->logfont.lfHeight; | 5713 | lplf->elfLogFont.lfHeight = lpef->logfont.lfHeight; |
| 5696 | lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth; | 5714 | lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth; |
| 5697 | } | 5715 | } |
| 5716 | /* Make sure the height used here is the same as everywhere | ||
| 5717 | else (ie character height, not cell height). */ | ||
| 5718 | else if (lplf->elfLogFont.lfHeight > 0) | ||
| 5719 | lplf->elfLogFont.lfHeight = lptm->tmInternalLeading - lptm->tmHeight; | ||
| 5698 | 5720 | ||
| 5699 | /* The MaxCharWidth is not valid at this stage for scalable fonts. */ | 5721 | /* The MaxCharWidth is not valid at this stage for scalable fonts. */ |
| 5700 | if (FontType == RASTER_FONTTYPE) | 5722 | if (FontType == RASTER_FONTTYPE) |
| @@ -6869,15 +6891,38 @@ DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 1, 0, | |||
| 6869 | FRAME_PTR f = check_x_frame (frame); | 6891 | FRAME_PTR f = check_x_frame (frame); |
| 6870 | CHOOSEFONT cf; | 6892 | CHOOSEFONT cf; |
| 6871 | LOGFONT lf; | 6893 | LOGFONT lf; |
| 6894 | TEXTMETRIC tm; | ||
| 6895 | HDC hdc; | ||
| 6896 | HANDLE oldobj; | ||
| 6872 | char buf[100]; | 6897 | char buf[100]; |
| 6873 | 6898 | ||
| 6874 | bzero (&cf, sizeof (cf)); | 6899 | bzero (&cf, sizeof (cf)); |
| 6900 | bzero (&lf, sizeof (lf)); | ||
| 6875 | 6901 | ||
| 6876 | cf.lStructSize = sizeof (cf); | 6902 | cf.lStructSize = sizeof (cf); |
| 6877 | cf.hwndOwner = FRAME_W32_WINDOW (f); | 6903 | cf.hwndOwner = FRAME_W32_WINDOW (f); |
| 6878 | cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST | CF_SCREENFONTS; | 6904 | cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST | CF_SCREENFONTS; |
| 6879 | cf.lpLogFont = &lf; | 6905 | cf.lpLogFont = &lf; |
| 6880 | 6906 | ||
| 6907 | /* Initialize as much of the font details as we can from the current | ||
| 6908 | default font. */ | ||
| 6909 | hdc = GetDC (FRAME_W32_WINDOW (f)); | ||
| 6910 | oldobj = SelectObject (hdc, FRAME_FONT (f)->hfont); | ||
| 6911 | GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName); | ||
| 6912 | if (GetTextMetrics (hdc, &tm)) | ||
| 6913 | { | ||
| 6914 | lf.lfHeight = tm.tmInternalLeading - tm.tmHeight; | ||
| 6915 | lf.lfWeight = tm.tmWeight; | ||
| 6916 | lf.lfItalic = tm.tmItalic; | ||
| 6917 | lf.lfUnderline = tm.tmUnderlined; | ||
| 6918 | lf.lfStrikeOut = tm.tmStruckOut; | ||
| 6919 | lf.lfPitchAndFamily = tm.tmPitchAndFamily; | ||
| 6920 | lf.lfCharSet = tm.tmCharSet; | ||
| 6921 | cf.Flags |= CF_INITTOLOGFONTSTRUCT; | ||
| 6922 | } | ||
| 6923 | SelectObject (hdc, oldobj); | ||
| 6924 | ReleaseDC (FRAME_W32_WINDOW(f), hdc); | ||
| 6925 | |||
| 6881 | if (!ChooseFont (&cf) || !w32_to_x_font (&lf, buf, 100)) | 6926 | if (!ChooseFont (&cf) || !w32_to_x_font (&lf, buf, 100)) |
| 6882 | return Qnil; | 6927 | return Qnil; |
| 6883 | 6928 | ||
| @@ -7410,6 +7455,11 @@ Setting this to t will prevent wrong fonts being selected when\n\ | |||
| 7410 | fontsets are automatically created."); | 7455 | fontsets are automatically created."); |
| 7411 | w32_strict_fontnames = 0; | 7456 | w32_strict_fontnames = 0; |
| 7412 | 7457 | ||
| 7458 | DEFVAR_LISP ("w32-system-coding-system", | ||
| 7459 | &Vw32_system_coding_system, | ||
| 7460 | "Coding system used by Windows system functions, such as for font names."); | ||
| 7461 | Vw32_system_coding_system = Qnil; | ||
| 7462 | |||
| 7413 | defsubr (&Sx_get_resource); | 7463 | defsubr (&Sx_get_resource); |
| 7414 | defsubr (&Sx_list_fonts); | 7464 | defsubr (&Sx_list_fonts); |
| 7415 | defsubr (&Sx_display_color_p); | 7465 | defsubr (&Sx_display_color_p); |