diff options
| author | Jason Rumney | 2003-10-12 22:55:45 +0000 |
|---|---|---|
| committer | Jason Rumney | 2003-10-12 22:55:45 +0000 |
| commit | 41375f89f7dcb3ce0a9b82237509b78a7227a475 (patch) | |
| tree | 78805db2b452bad73be4bc67f482ab6563e4b463 /src | |
| parent | f1de3410d2982719628a0d6c7e4119a6bcd08422 (diff) | |
| download | emacs-41375f89f7dcb3ce0a9b82237509b78a7227a475.tar.gz emacs-41375f89f7dcb3ce0a9b82237509b78a7227a475.zip | |
(GLYPHSET, WCRANGE): Define if system headers don't.
(pfnGetFontUnicodeRanges): New dynamically loaded function.
(w32_initialize): Try to load it.
(x_get_font_repertory): Use it if available.
(w32_encode_char): Add shortcut for unicode output.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 124 |
1 files changed, 90 insertions, 34 deletions
diff --git a/src/w32term.c b/src/w32term.c index d800a9cca5f..f21f42bfb9c 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -113,6 +113,31 @@ struct w32_display_info *x_display_list; | |||
| 113 | FONT-LIST-CACHE records previous values returned by x-list-fonts. */ | 113 | FONT-LIST-CACHE records previous values returned by x-list-fonts. */ |
| 114 | Lisp_Object w32_display_name_list; | 114 | Lisp_Object w32_display_name_list; |
| 115 | 115 | ||
| 116 | |||
| 117 | #ifndef GLYPHSET | ||
| 118 | /* Pre Windows 2000, this was not available, but define it here so | ||
| 119 | that Emacs compiled on such a platform will run on newer versions. */ | ||
| 120 | |||
| 121 | typedef struct tagWCRANGE | ||
| 122 | { | ||
| 123 | WCHAR wcLow; | ||
| 124 | USHORT cGlyphs; | ||
| 125 | } WCRANGE; | ||
| 126 | |||
| 127 | typedef struct tagGLYPHSET | ||
| 128 | { | ||
| 129 | DWORD cbThis; | ||
| 130 | DWORD flAccel; | ||
| 131 | DWORD cGlyphsSupported; | ||
| 132 | DWORD cRanges; | ||
| 133 | WCRANGE ranges[1]; | ||
| 134 | } GLYPHSET; | ||
| 135 | |||
| 136 | #endif | ||
| 137 | |||
| 138 | /* Dynamic linking to GetFontUnicodeRanges (not available on 95, 98, ME). */ | ||
| 139 | DWORD (PASCAL *pfnGetFontUnicodeRanges) (HDC device, GLYPHSET *ranges); | ||
| 140 | |||
| 116 | /* Frame being updated by update_frame. This is declared in term.c. | 141 | /* Frame being updated by update_frame. This is declared in term.c. |
| 117 | This is set by update_begin and looked at by all the | 142 | This is set by update_begin and looked at by all the |
| 118 | w32 functions. It is zero while not inside an update. | 143 | w32 functions. It is zero while not inside an update. |
| @@ -1019,11 +1044,21 @@ w32_encode_char (c, char2b, font_info, charset, two_byte_p) | |||
| 1019 | XFontStruct *font = font_info->font; | 1044 | XFontStruct *font = font_info->font; |
| 1020 | 1045 | ||
| 1021 | internal_two_byte_p = w32_font_is_double_byte (font); | 1046 | internal_two_byte_p = w32_font_is_double_byte (font); |
| 1047 | codepage = font_info->codepage; | ||
| 1048 | |||
| 1049 | /* If font can output unicode, use the original unicode character. */ | ||
| 1050 | if ( font && !font->bdf && w32_use_unicode_for_codepage (codepage) | ||
| 1051 | && c >= 0x100) | ||
| 1052 | { | ||
| 1053 | *char2b = c; | ||
| 1054 | unicode_p = 1; | ||
| 1055 | internal_two_byte_p = 1; | ||
| 1056 | } | ||
| 1022 | 1057 | ||
| 1023 | /* FONT_INFO may define a scheme by which to encode byte1 and byte2. | 1058 | /* FONT_INFO may define a scheme by which to encode byte1 and byte2. |
| 1024 | This may be either a program in a special encoder language or a | 1059 | This may be either a program in a special encoder language or a |
| 1025 | fixed encoding. */ | 1060 | fixed encoding. */ |
| 1026 | if (font_info->font_encoder) | 1061 | else if (font_info->font_encoder) |
| 1027 | { | 1062 | { |
| 1028 | /* It's a program. */ | 1063 | /* It's a program. */ |
| 1029 | struct ccl_program *ccl = font_info->font_encoder; | 1064 | struct ccl_program *ccl = font_info->font_encoder; |
| @@ -1060,38 +1095,16 @@ w32_encode_char (c, char2b, font_info, charset, two_byte_p) | |||
| 1060 | && CHARSET_DIMENSION (charset) == 2) | 1095 | && CHARSET_DIMENSION (charset) == 2) |
| 1061 | STORE_XCHAR2B (char2b, XCHAR2B_BYTE1 (char2b) | 0x80, XCHAR2B_BYTE2 (char2b)); | 1096 | STORE_XCHAR2B (char2b, XCHAR2B_BYTE1 (char2b) | 0x80, XCHAR2B_BYTE2 (char2b)); |
| 1062 | 1097 | ||
| 1063 | if (enc == 1 || enc == 3 | 1098 | if (enc == 1 || enc == 3 || (enc == 4 && CHARSET_DIMENSION (charset) == 1)) |
| 1064 | || (enc == 4 && CHARSET_DIMENSION (charset) == 1)) | ||
| 1065 | STORE_XCHAR2B (char2b, XCHAR2B_BYTE1 (char2b), XCHAR2B_BYTE2 (char2b) | 0x80); | 1099 | STORE_XCHAR2B (char2b, XCHAR2B_BYTE1 (char2b), XCHAR2B_BYTE2 (char2b) | 0x80); |
| 1066 | else if (enc == 4) | 1100 | else if (enc == 4) |
| 1067 | { | 1101 | { |
| 1068 | int code = (int) char2b; | 1102 | int code = (int) (*char2b); |
| 1069 | 1103 | ||
| 1070 | JIS_TO_SJIS (code); | 1104 | JIS_TO_SJIS (code); |
| 1071 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 1105 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); |
| 1072 | } | 1106 | } |
| 1073 | } | 1107 | } |
| 1074 | codepage = font_info->codepage; | ||
| 1075 | |||
| 1076 | /* If charset is not ASCII or Latin-1, may need to move it into | ||
| 1077 | Unicode space. */ | ||
| 1078 | if ( font && !font->bdf && w32_use_unicode_for_codepage (codepage) | ||
| 1079 | && c >= 0x100) | ||
| 1080 | { | ||
| 1081 | char temp[3]; | ||
| 1082 | temp[0] = XCHAR2B_BYTE1 (char2b); | ||
| 1083 | temp[1] = XCHAR2B_BYTE2 (char2b); | ||
| 1084 | temp[2] = '\0'; | ||
| 1085 | if (codepage != CP_UNICODE) | ||
| 1086 | { | ||
| 1087 | if (temp[0]) | ||
| 1088 | MultiByteToWideChar (codepage, 0, temp, 2, char2b, 1); | ||
| 1089 | else | ||
| 1090 | MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1); | ||
| 1091 | } | ||
| 1092 | unicode_p = 1; | ||
| 1093 | internal_two_byte_p = 1; | ||
| 1094 | } | ||
| 1095 | 1108 | ||
| 1096 | if (two_byte_p) | 1109 | if (two_byte_p) |
| 1097 | *two_byte_p = internal_two_byte_p; | 1110 | *two_byte_p = internal_two_byte_p; |
| @@ -1120,13 +1133,56 @@ x_get_font_repertory (f, font_info) | |||
| 1120 | FRAME_PTR f; | 1133 | FRAME_PTR f; |
| 1121 | struct font_info *font_info; | 1134 | struct font_info *font_info; |
| 1122 | { | 1135 | { |
| 1123 | #if 0 /* TODO: New function, convert to Windows. */ | ||
| 1124 | XFontStruct *font = (XFontStruct *) font_info->font; | 1136 | XFontStruct *font = (XFontStruct *) font_info->font; |
| 1125 | Lisp_Object table; | 1137 | Lisp_Object table; |
| 1126 | int min_byte1, max_byte1, min_byte2, max_byte2; | 1138 | int min_byte1, max_byte1, min_byte2, max_byte2; |
| 1127 | 1139 | ||
| 1128 | table = Fmake_char_table (Qnil, Qnil); | 1140 | table = Fmake_char_table (Qnil, Qnil); |
| 1129 | 1141 | ||
| 1142 | if (!font->bdf && pfnGetFontUnicodeRanges) | ||
| 1143 | { | ||
| 1144 | GLYPHSET *glyphset; | ||
| 1145 | DWORD glyphset_size; | ||
| 1146 | HDC display = get_frame_dc (f); | ||
| 1147 | HFONT prev_font; | ||
| 1148 | int i; | ||
| 1149 | |||
| 1150 | prev_font = SelectObject (display, font->hfont); | ||
| 1151 | |||
| 1152 | /* First call GetFontUnicodeRanges to find out how big a structure | ||
| 1153 | we need. */ | ||
| 1154 | glyphset_size = pfnGetFontUnicodeRanges (display, NULL); | ||
| 1155 | if (glyphset_size) | ||
| 1156 | { | ||
| 1157 | glyphset = (GLYPHSET *) alloca (glyphset_size); | ||
| 1158 | glyphset->cbThis = glyphset_size; | ||
| 1159 | |||
| 1160 | /* Now call it again to get the ranges. */ | ||
| 1161 | glyphset_size = pfnGetFontUnicodeRanges (display, glyphset); | ||
| 1162 | |||
| 1163 | if (glyphset_size) | ||
| 1164 | { | ||
| 1165 | /* Store the ranges in TABLE. */ | ||
| 1166 | for (i = 0; i < glyphset->cRanges; i++) | ||
| 1167 | { | ||
| 1168 | int from = glyphset->ranges[i].wcLow; | ||
| 1169 | int to = from + glyphset->ranges[i].cGlyphs - 1; | ||
| 1170 | char_table_set_range (table, from, to, Qt); | ||
| 1171 | } | ||
| 1172 | } | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | SelectObject (display, prev_font); | ||
| 1176 | release_frame_dc (f, display); | ||
| 1177 | |||
| 1178 | /* If we got the information we wanted above, then return it. */ | ||
| 1179 | if (glyphset_size) | ||
| 1180 | return table; | ||
| 1181 | } | ||
| 1182 | |||
| 1183 | #if 0 /* TODO: Convert to work on Windows so BDF and older platforms work. */ | ||
| 1184 | /* When GetFontUnicodeRanges is not available or does not work, | ||
| 1185 | work it out manually. */ | ||
| 1130 | min_byte1 = font->min_byte1; | 1186 | min_byte1 = font->min_byte1; |
| 1131 | max_byte1 = font->max_byte1; | 1187 | max_byte1 = font->max_byte1; |
| 1132 | min_byte2 = font->min_char_or_byte2; | 1188 | min_byte2 = font->min_char_or_byte2; |
| @@ -1199,11 +1255,8 @@ x_get_font_repertory (f, font_info) | |||
| 1199 | } | 1255 | } |
| 1200 | } | 1256 | } |
| 1201 | } | 1257 | } |
| 1202 | |||
| 1203 | return table; | ||
| 1204 | #else | ||
| 1205 | return Fmake_char_table (Qnil, Qnil); | ||
| 1206 | #endif | 1258 | #endif |
| 1259 | return table; | ||
| 1207 | } | 1260 | } |
| 1208 | 1261 | ||
| 1209 | 1262 | ||
| @@ -6538,16 +6591,19 @@ w32_initialize () | |||
| 6538 | /* Dynamically link to optional system components. */ | 6591 | /* Dynamically link to optional system components. */ |
| 6539 | { | 6592 | { |
| 6540 | HANDLE user_lib = LoadLibrary ("user32.dll"); | 6593 | HANDLE user_lib = LoadLibrary ("user32.dll"); |
| 6594 | HANDLE gdi_lib = LoadLibrary ("gdi32.dll"); | ||
| 6541 | 6595 | ||
| 6542 | #define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn) | 6596 | #define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn) |
| 6543 | 6597 | ||
| 6544 | /* New proportional scroll bar functions. */ | 6598 | /* New proportional scroll bar functions. */ |
| 6545 | LOAD_PROC (SetScrollInfo); | 6599 | LOAD_PROC (user_lib, SetScrollInfo); |
| 6546 | LOAD_PROC (GetScrollInfo); | 6600 | LOAD_PROC (user_lib, GetScrollInfo); |
| 6547 | 6601 | LOAD_PROC (gdi_lib, GetFontUnicodeRanges); | |
| 6602 | |||
| 6548 | #undef LOAD_PROC | 6603 | #undef LOAD_PROC |
| 6549 | 6604 | ||
| 6550 | FreeLibrary (user_lib); | 6605 | FreeLibrary (user_lib); |
| 6606 | FreeLibrary (gdi_lib); | ||
| 6551 | 6607 | ||
| 6552 | /* If using proportional scroll bars, ensure handle is at least 5 pixels; | 6608 | /* If using proportional scroll bars, ensure handle is at least 5 pixels; |
| 6553 | otherwise use the fixed height. */ | 6609 | otherwise use the fixed height. */ |