diff options
| author | Jason Rumney | 2000-01-30 18:42:51 +0000 |
|---|---|---|
| committer | Jason Rumney | 2000-01-30 18:42:51 +0000 |
| commit | d88c567c94b7b0c25054d1762b8ca4397f01dfce (patch) | |
| tree | 31f11e0987bb31b2a0b5dbc211a9445f09abb03a /src | |
| parent | 807fac2a9d9404227a3a57a360a09df68971791b (diff) | |
| download | emacs-d88c567c94b7b0c25054d1762b8ca4397f01dfce.tar.gz emacs-d88c567c94b7b0c25054d1762b8ca4397f01dfce.zip | |
(w32_defined_color): Check for valid frame before
applying gamma correction. Eliminate dependency on frame elsewhere.
(w32_load_system_font): Switch FIXED_PITCH and VARIABLE_PITCH.
(w32_to_x_font): Use resx and resy not height_in and width_in.
(x_to_w32_font): Doc fix.
(xlfd_strip_height): New function to strip and return font height.
(w32_font_match): Compare height separately from rest of xlfd
spec, using xlfd_strip_height.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 171 |
1 files changed, 157 insertions, 14 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 21d80af0572..ea52c2d3808 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1781,18 +1781,21 @@ w32_defined_color (f, color, color_def, alloc) | |||
| 1781 | 1781 | ||
| 1782 | if (!NILP (tem)) | 1782 | if (!NILP (tem)) |
| 1783 | { | 1783 | { |
| 1784 | /* Apply gamma correction. */ | 1784 | if (f) |
| 1785 | w32_color_ref = XUINT (tem); | 1785 | { |
| 1786 | gamma_correct (f, &w32_color_ref); | 1786 | /* Apply gamma correction. */ |
| 1787 | XSETINT (tem, w32_color_ref); | 1787 | w32_color_ref = XUINT (tem); |
| 1788 | gamma_correct (f, &w32_color_ref); | ||
| 1789 | XSETINT (tem, w32_color_ref); | ||
| 1790 | } | ||
| 1788 | 1791 | ||
| 1789 | /* Map this color to the palette if it is enabled. */ | 1792 | /* Map this color to the palette if it is enabled. */ |
| 1790 | if (!NILP (Vw32_enable_palette)) | 1793 | if (!NILP (Vw32_enable_palette)) |
| 1791 | { | 1794 | { |
| 1792 | struct w32_palette_entry * entry = | 1795 | struct w32_palette_entry * entry = |
| 1793 | FRAME_W32_DISPLAY_INFO (f)->color_list; | 1796 | one_w32_display_info.color_list; |
| 1794 | struct w32_palette_entry ** prev = | 1797 | struct w32_palette_entry ** prev = |
| 1795 | &FRAME_W32_DISPLAY_INFO (f)->color_list; | 1798 | &one_w32_display_info.color_list; |
| 1796 | 1799 | ||
| 1797 | /* check if color is already mapped */ | 1800 | /* check if color is already mapped */ |
| 1798 | while (entry) | 1801 | while (entry) |
| @@ -1811,10 +1814,10 @@ w32_defined_color (f, color, color_def, alloc) | |||
| 1811 | SET_W32_COLOR (entry->entry, XUINT (tem)); | 1814 | SET_W32_COLOR (entry->entry, XUINT (tem)); |
| 1812 | entry->next = NULL; | 1815 | entry->next = NULL; |
| 1813 | *prev = entry; | 1816 | *prev = entry; |
| 1814 | FRAME_W32_DISPLAY_INFO (f)->num_colors++; | 1817 | one_w32_display_info.num_colors++; |
| 1815 | 1818 | ||
| 1816 | /* set flag that palette must be regenerated */ | 1819 | /* set flag that palette must be regenerated */ |
| 1817 | FRAME_W32_DISPLAY_INFO (f)->regen_palette = TRUE; | 1820 | one_w32_display_info.regen_palette = TRUE; |
| 1818 | } | 1821 | } |
| 1819 | } | 1822 | } |
| 1820 | /* Ensure COLORREF value is snapped to nearest color in (default) | 1823 | /* Ensure COLORREF value is snapped to nearest color in (default) |
| @@ -5343,7 +5346,7 @@ w32_load_system_font (f,fontname,size) | |||
| 5343 | lf.lfItalic = font->tm.tmItalic; | 5346 | lf.lfItalic = font->tm.tmItalic; |
| 5344 | lf.lfCharSet = font->tm.tmCharSet; | 5347 | lf.lfCharSet = font->tm.tmCharSet; |
| 5345 | lf.lfPitchAndFamily = ((font->tm.tmPitchAndFamily & TMPF_FIXED_PITCH) | 5348 | lf.lfPitchAndFamily = ((font->tm.tmPitchAndFamily & TMPF_FIXED_PITCH) |
| 5346 | ? FIXED_PITCH : VARIABLE_PITCH); | 5349 | ? VARIABLE_PITCH : FIXED_PITCH); |
| 5347 | lf.lfOutPrecision = ((font->tm.tmPitchAndFamily & TMPF_VECTOR) | 5350 | lf.lfOutPrecision = ((font->tm.tmPitchAndFamily & TMPF_VECTOR) |
| 5348 | ? OUT_STROKE_PRECIS : OUT_STRING_PRECIS); | 5351 | ? OUT_STROKE_PRECIS : OUT_STRING_PRECIS); |
| 5349 | } | 5352 | } |
| @@ -5709,8 +5712,8 @@ w32_to_x_font (lplogfont, lpxstr, len) | |||
| 5709 | char height_dpi[8]; | 5712 | char height_dpi[8]; |
| 5710 | char width_pixels[8]; | 5713 | char width_pixels[8]; |
| 5711 | char *fontname_dash; | 5714 | char *fontname_dash; |
| 5712 | int display_resy = one_w32_display_info.height_in; | 5715 | int display_resy = one_w32_display_info.resy; |
| 5713 | int display_resx = one_w32_display_info.width_in; | 5716 | int display_resx = one_w32_display_info.resx; |
| 5714 | int bufsz; | 5717 | int bufsz; |
| 5715 | struct coding_system coding; | 5718 | struct coding_system coding; |
| 5716 | 5719 | ||
| @@ -5894,7 +5897,7 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 5894 | fields--; | 5897 | fields--; |
| 5895 | 5898 | ||
| 5896 | /* Strip the trailing '-' if present. (it shouldn't be, as it | 5899 | /* Strip the trailing '-' if present. (it shouldn't be, as it |
| 5897 | fails the test against xlfn-tight-regexp in fontset.el). */ | 5900 | fails the test against xlfd-tight-regexp in fontset.el). */ |
| 5898 | { | 5901 | { |
| 5899 | int len = strlen (remainder); | 5902 | int len = strlen (remainder); |
| 5900 | if (len > 0 && remainder[len-1] == '-') | 5903 | if (len > 0 && remainder[len-1] == '-') |
| @@ -5947,6 +5950,125 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 5947 | return (TRUE); | 5950 | return (TRUE); |
| 5948 | } | 5951 | } |
| 5949 | 5952 | ||
| 5953 | /* Strip the pixel height and point height from the given xlfd, and | ||
| 5954 | return the pixel height. If no pixel height is specified, calculate | ||
| 5955 | one from the point height, or if that isn't defined either, return | ||
| 5956 | 0 (which usually signifies a scalable font). | ||
| 5957 | */ | ||
| 5958 | int xlfd_strip_height (char *fontname) | ||
| 5959 | { | ||
| 5960 | int pixel_height, point_height, dpi, field_number; | ||
| 5961 | char *read_from, *write_to; | ||
| 5962 | |||
| 5963 | xassert (fontname); | ||
| 5964 | |||
| 5965 | pixel_height = field_number = 0; | ||
| 5966 | write_to = NULL; | ||
| 5967 | |||
| 5968 | /* Look for height fields. */ | ||
| 5969 | for (read_from = fontname; *read_from; read_from++) | ||
| 5970 | { | ||
| 5971 | if (*read_from == '-') | ||
| 5972 | { | ||
| 5973 | field_number++; | ||
| 5974 | if (field_number == 7) /* Pixel height. */ | ||
| 5975 | { | ||
| 5976 | read_from++; | ||
| 5977 | write_to = read_from; | ||
| 5978 | |||
| 5979 | /* Find end of field. */ | ||
| 5980 | for (;*read_from && *read_from != '-'; read_from++) | ||
| 5981 | ; | ||
| 5982 | |||
| 5983 | /* Split the fontname at end of field. */ | ||
| 5984 | if (*read_from) | ||
| 5985 | { | ||
| 5986 | *read_from = '\0'; | ||
| 5987 | read_from++; | ||
| 5988 | } | ||
| 5989 | pixel_height = atoi (write_to); | ||
| 5990 | /* Blank out field. */ | ||
| 5991 | if (read_from > write_to) | ||
| 5992 | { | ||
| 5993 | *write_to = '-'; | ||
| 5994 | write_to++; | ||
| 5995 | } | ||
| 5996 | /* If the pixel height field is at the end (partial xfld), | ||
| 5997 | return now. */ | ||
| 5998 | else | ||
| 5999 | return pixel_height; | ||
| 6000 | |||
| 6001 | /* If we got a pixel height, the point height can be | ||
| 6002 | ignored. Just blank it out and break now. */ | ||
| 6003 | if (pixel_height) | ||
| 6004 | { | ||
| 6005 | /* Find end of point size field. */ | ||
| 6006 | for (; *read_from && *read_from != '-'; read_from++) | ||
| 6007 | ; | ||
| 6008 | |||
| 6009 | if (*read_from) | ||
| 6010 | read_from++; | ||
| 6011 | |||
| 6012 | /* Blank out the point size field. */ | ||
| 6013 | if (read_from > write_to) | ||
| 6014 | { | ||
| 6015 | *write_to = '-'; | ||
| 6016 | write_to++; | ||
| 6017 | } | ||
| 6018 | else | ||
| 6019 | return pixel_height; | ||
| 6020 | |||
| 6021 | break; | ||
| 6022 | } | ||
| 6023 | /* If the point height is already blank, break now. */ | ||
| 6024 | if (*read_from == '-') | ||
| 6025 | { | ||
| 6026 | read_from++; | ||
| 6027 | break; | ||
| 6028 | } | ||
| 6029 | } | ||
| 6030 | else if (field_number == 8) | ||
| 6031 | { | ||
| 6032 | /* If we didn't get a pixel height, try to get the point | ||
| 6033 | height and convert that. */ | ||
| 6034 | int point_size; | ||
| 6035 | char *point_size_start = read_from++; | ||
| 6036 | |||
| 6037 | /* Find end of field. */ | ||
| 6038 | for (; *read_from && *read_from != '-'; read_from++) | ||
| 6039 | ; | ||
| 6040 | |||
| 6041 | if (*read_from) | ||
| 6042 | { | ||
| 6043 | *read_from = '\0'; | ||
| 6044 | read_from++; | ||
| 6045 | } | ||
| 6046 | |||
| 6047 | point_size = atoi (point_size_start); | ||
| 6048 | |||
| 6049 | /* Convert to pixel height. */ | ||
| 6050 | pixel_height = point_size | ||
| 6051 | * one_w32_display_info.height_in / 720; | ||
| 6052 | |||
| 6053 | /* Blank out this field and break. */ | ||
| 6054 | *write_to = '-'; | ||
| 6055 | write_to++; | ||
| 6056 | break; | ||
| 6057 | } | ||
| 6058 | } | ||
| 6059 | } | ||
| 6060 | |||
| 6061 | /* Shift the rest of the font spec into place. */ | ||
| 6062 | if (write_to && read_from > write_to) | ||
| 6063 | { | ||
| 6064 | for (; *read_from; read_from++, write_to++) | ||
| 6065 | *write_to = *read_from; | ||
| 6066 | *write_to = '\0'; | ||
| 6067 | } | ||
| 6068 | |||
| 6069 | return pixel_height; | ||
| 6070 | } | ||
| 6071 | |||
| 5950 | /* Assume parameter 1 is fully qualified, no wildcards. */ | 6072 | /* Assume parameter 1 is fully qualified, no wildcards. */ |
| 5951 | BOOL | 6073 | BOOL |
| 5952 | w32_font_match (fontname, pattern) | 6074 | w32_font_match (fontname, pattern) |
| @@ -5954,8 +6076,12 @@ w32_font_match (fontname, pattern) | |||
| 5954 | char * pattern; | 6076 | char * pattern; |
| 5955 | { | 6077 | { |
| 5956 | char *regex = alloca (strlen (pattern) * 2); | 6078 | char *regex = alloca (strlen (pattern) * 2); |
| 6079 | char *font_name_copy = alloca (strlen (fontname) + 1); | ||
| 5957 | char *ptr; | 6080 | char *ptr; |
| 5958 | 6081 | ||
| 6082 | /* Copy fontname so we can modify it during comparison. */ | ||
| 6083 | strcpy (font_name_copy, fontname); | ||
| 6084 | |||
| 5959 | ptr = regex; | 6085 | ptr = regex; |
| 5960 | *ptr++ = '^'; | 6086 | *ptr++ = '^'; |
| 5961 | 6087 | ||
| @@ -5975,8 +6101,25 @@ w32_font_match (fontname, pattern) | |||
| 5975 | *ptr = '$'; | 6101 | *ptr = '$'; |
| 5976 | *(ptr + 1) = '\0'; | 6102 | *(ptr + 1) = '\0'; |
| 5977 | 6103 | ||
| 6104 | /* Strip out font heights and compare them seperately, since | ||
| 6105 | rounding error can cause mismatches. This also allows a | ||
| 6106 | comparison between a font that declares only a pixel height and a | ||
| 6107 | pattern that declares the point height. | ||
| 6108 | */ | ||
| 6109 | { | ||
| 6110 | int font_height, pattern_height; | ||
| 6111 | |||
| 6112 | font_height = xlfd_strip_height (font_name_copy); | ||
| 6113 | pattern_height = xlfd_strip_height (regex); | ||
| 6114 | |||
| 6115 | /* Compare now, and don't bother doing expensive regexp matching | ||
| 6116 | if the heights differ. */ | ||
| 6117 | if (font_height && pattern_height && (font_height != pattern_height)) | ||
| 6118 | return FALSE; | ||
| 6119 | } | ||
| 6120 | |||
| 5978 | return (fast_c_string_match_ignore_case (build_string (regex), | 6121 | return (fast_c_string_match_ignore_case (build_string (regex), |
| 5979 | fontname) >= 0); | 6122 | font_name_copy) >= 0); |
| 5980 | } | 6123 | } |
| 5981 | 6124 | ||
| 5982 | /* Callback functions, and a structure holding info they need, for | 6125 | /* Callback functions, and a structure holding info they need, for |
| @@ -11622,7 +11765,7 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 11622 | XSETFRAME (frame, f); | 11765 | XSETFRAME (frame, f); |
| 11623 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 11766 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
| 11624 | 11767 | ||
| 11625 | f->output_method = output_x_window; | 11768 | f->output_method = output_w32; |
| 11626 | f->output_data.w32 = | 11769 | f->output_data.w32 = |
| 11627 | (struct w32_output *) xmalloc (sizeof (struct w32_output)); | 11770 | (struct w32_output *) xmalloc (sizeof (struct w32_output)); |
| 11628 | bzero (f->output_data.w32, sizeof (struct w32_output)); | 11771 | bzero (f->output_data.w32, sizeof (struct w32_output)); |