Mercurial > emacs
comparison src/w32font.c @ 109152:e27859da5624
src/w32*.c: Convert function definitions to standard C.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 06 Jul 2010 16:22:29 +0200 |
parents | 2bc9a0c04c87 |
children | f8660b83cdbf |
comparison
equal
deleted
inserted
replaced
109151:004119b4b62e | 109152:e27859da5624 |
---|---|
151 style variations if the font name is not specified. */ | 151 style variations if the font name is not specified. */ |
152 static void list_all_matching_fonts (struct font_callback_data *); | 152 static void list_all_matching_fonts (struct font_callback_data *); |
153 | 153 |
154 | 154 |
155 static int | 155 static int |
156 memq_no_quit (elt, list) | 156 memq_no_quit (Lisp_Object elt, Lisp_Object list) |
157 Lisp_Object elt, list; | |
158 { | 157 { |
159 while (CONSP (list) && ! EQ (XCAR (list), elt)) | 158 while (CONSP (list) && ! EQ (XCAR (list), elt)) |
160 list = XCDR (list); | 159 list = XCDR (list); |
161 return (CONSP (list)); | 160 return (CONSP (list)); |
162 } | 161 } |
163 | 162 |
164 Lisp_Object | 163 Lisp_Object |
165 intern_font_name (string) | 164 intern_font_name (char * string) |
166 char * string; | |
167 { | 165 { |
168 Lisp_Object obarray, tem, str; | 166 Lisp_Object obarray, tem, str; |
169 int len; | 167 int len; |
170 | 168 |
171 str = DECODE_SYSTEM (build_string (string)); | 169 str = DECODE_SYSTEM (build_string (string)); |
183 | 181 |
184 /* w32 implementation of get_cache for font backend. | 182 /* w32 implementation of get_cache for font backend. |
185 Return a cache of font-entities on FRAME. The cache must be a | 183 Return a cache of font-entities on FRAME. The cache must be a |
186 cons whose cdr part is the actual cache area. */ | 184 cons whose cdr part is the actual cache area. */ |
187 Lisp_Object | 185 Lisp_Object |
188 w32font_get_cache (f) | 186 w32font_get_cache (FRAME_PTR f) |
189 FRAME_PTR f; | |
190 { | 187 { |
191 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 188 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
192 | 189 |
193 return (dpyinfo->name_list_element); | 190 return (dpyinfo->name_list_element); |
194 } | 191 } |
196 /* w32 implementation of list for font backend. | 193 /* w32 implementation of list for font backend. |
197 List fonts exactly matching with FONT_SPEC on FRAME. The value | 194 List fonts exactly matching with FONT_SPEC on FRAME. The value |
198 is a vector of font-entities. This is the sole API that | 195 is a vector of font-entities. This is the sole API that |
199 allocates font-entities. */ | 196 allocates font-entities. */ |
200 static Lisp_Object | 197 static Lisp_Object |
201 w32font_list (frame, font_spec) | 198 w32font_list (Lisp_Object frame, Lisp_Object font_spec) |
202 Lisp_Object frame, font_spec; | |
203 { | 199 { |
204 Lisp_Object fonts = w32font_list_internal (frame, font_spec, 0); | 200 Lisp_Object fonts = w32font_list_internal (frame, font_spec, 0); |
205 FONT_ADD_LOG ("w32font-list", font_spec, fonts); | 201 FONT_ADD_LOG ("w32font-list", font_spec, fonts); |
206 return fonts; | 202 return fonts; |
207 } | 203 } |
209 /* w32 implementation of match for font backend. | 205 /* w32 implementation of match for font backend. |
210 Return a font entity most closely matching with FONT_SPEC on | 206 Return a font entity most closely matching with FONT_SPEC on |
211 FRAME. The closeness is detemined by the font backend, thus | 207 FRAME. The closeness is detemined by the font backend, thus |
212 `face-font-selection-order' is ignored here. */ | 208 `face-font-selection-order' is ignored here. */ |
213 static Lisp_Object | 209 static Lisp_Object |
214 w32font_match (frame, font_spec) | 210 w32font_match (Lisp_Object frame, Lisp_Object font_spec) |
215 Lisp_Object frame, font_spec; | |
216 { | 211 { |
217 Lisp_Object entity = w32font_match_internal (frame, font_spec, 0); | 212 Lisp_Object entity = w32font_match_internal (frame, font_spec, 0); |
218 FONT_ADD_LOG ("w32font-match", font_spec, entity); | 213 FONT_ADD_LOG ("w32font-match", font_spec, entity); |
219 return entity; | 214 return entity; |
220 } | 215 } |
221 | 216 |
222 /* w32 implementation of list_family for font backend. | 217 /* w32 implementation of list_family for font backend. |
223 List available families. The value is a list of family names | 218 List available families. The value is a list of family names |
224 (symbols). */ | 219 (symbols). */ |
225 static Lisp_Object | 220 static Lisp_Object |
226 w32font_list_family (frame) | 221 w32font_list_family (Lisp_Object frame) |
227 Lisp_Object frame; | |
228 { | 222 { |
229 Lisp_Object list = Qnil; | 223 Lisp_Object list = Qnil; |
230 LOGFONT font_match_pattern; | 224 LOGFONT font_match_pattern; |
231 HDC dc; | 225 HDC dc; |
232 FRAME_PTR f = XFRAME (frame); | 226 FRAME_PTR f = XFRAME (frame); |
246 | 240 |
247 /* w32 implementation of open for font backend. | 241 /* w32 implementation of open for font backend. |
248 Open a font specified by FONT_ENTITY on frame F. | 242 Open a font specified by FONT_ENTITY on frame F. |
249 If the font is scalable, open it with PIXEL_SIZE. */ | 243 If the font is scalable, open it with PIXEL_SIZE. */ |
250 static Lisp_Object | 244 static Lisp_Object |
251 w32font_open (f, font_entity, pixel_size) | 245 w32font_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) |
252 FRAME_PTR f; | |
253 Lisp_Object font_entity; | |
254 int pixel_size; | |
255 { | 246 { |
256 Lisp_Object font_object | 247 Lisp_Object font_object |
257 = font_make_object (VECSIZE (struct w32font_info), | 248 = font_make_object (VECSIZE (struct w32font_info), |
258 font_entity, pixel_size); | 249 font_entity, pixel_size); |
259 struct w32font_info *w32_font | 250 struct w32font_info *w32_font |
273 } | 264 } |
274 | 265 |
275 /* w32 implementation of close for font_backend. | 266 /* w32 implementation of close for font_backend. |
276 Close FONT on frame F. */ | 267 Close FONT on frame F. */ |
277 void | 268 void |
278 w32font_close (f, font) | 269 w32font_close (FRAME_PTR f, struct font *font) |
279 FRAME_PTR f; | |
280 struct font *font; | |
281 { | 270 { |
282 int i; | 271 int i; |
283 struct w32font_info *w32_font = (struct w32font_info *) font; | 272 struct w32font_info *w32_font = (struct w32font_info *) font; |
284 | 273 |
285 /* Delete the GDI font object. */ | 274 /* Delete the GDI font object. */ |
301 Optional. | 290 Optional. |
302 If FONT_ENTITY has a glyph for character C (Unicode code point), | 291 If FONT_ENTITY has a glyph for character C (Unicode code point), |
303 return 1. If not, return 0. If a font must be opened to check | 292 return 1. If not, return 0. If a font must be opened to check |
304 it, return -1. */ | 293 it, return -1. */ |
305 int | 294 int |
306 w32font_has_char (entity, c) | 295 w32font_has_char (Lisp_Object entity, int c) |
307 Lisp_Object entity; | |
308 int c; | |
309 { | 296 { |
310 /* We can't be certain about which characters a font will support until | 297 /* We can't be certain about which characters a font will support until |
311 we open it. Checking the scripts that the font supports turns out | 298 we open it. Checking the scripts that the font supports turns out |
312 to not be reliable. */ | 299 to not be reliable. */ |
313 return -1; | 300 return -1; |
352 For speed, the gdi backend uses unicode (Emacs calls encode_char | 339 For speed, the gdi backend uses unicode (Emacs calls encode_char |
353 far too often for it to be efficient). But we still need to detect | 340 far too often for it to be efficient). But we still need to detect |
354 which characters are not supported by the font. | 341 which characters are not supported by the font. |
355 */ | 342 */ |
356 static unsigned | 343 static unsigned |
357 w32font_encode_char (font, c) | 344 w32font_encode_char (struct font *font, int c) |
358 struct font *font; | |
359 int c; | |
360 { | 345 { |
361 struct w32font_info * w32_font = (struct w32font_info *)font; | 346 struct w32font_info * w32_font = (struct w32font_info *)font; |
362 | 347 |
363 if (c < w32_font->metrics.tmFirstChar | 348 if (c < w32_font->metrics.tmFirstChar |
364 || c > w32_font->metrics.tmLastChar) | 349 || c > w32_font->metrics.tmLastChar) |
371 Perform the size computation of glyphs of FONT and fillin members | 356 Perform the size computation of glyphs of FONT and fillin members |
372 of METRICS. The glyphs are specified by their glyph codes in | 357 of METRICS. The glyphs are specified by their glyph codes in |
373 CODE (length NGLYPHS). Apparently metrics can be NULL, in this | 358 CODE (length NGLYPHS). Apparently metrics can be NULL, in this |
374 case just return the overall width. */ | 359 case just return the overall width. */ |
375 int | 360 int |
376 w32font_text_extents (font, code, nglyphs, metrics) | 361 w32font_text_extents (struct font *font, unsigned *code, |
377 struct font *font; | 362 int nglyphs, struct font_metrics *metrics) |
378 unsigned *code; | |
379 int nglyphs; | |
380 struct font_metrics *metrics; | |
381 { | 363 { |
382 int i; | 364 int i; |
383 HFONT old_font = NULL; | 365 HFONT old_font = NULL; |
384 HDC dc = NULL; | 366 HDC dc = NULL; |
385 struct frame * f; | 367 struct frame * f; |
550 the old font code setting it up. It may be safer to resolve faces | 532 the old font code setting it up. It may be safer to resolve faces |
551 and fonts in here and set them explicitly | 533 and fonts in here and set them explicitly |
552 */ | 534 */ |
553 | 535 |
554 int | 536 int |
555 w32font_draw (s, from, to, x, y, with_background) | 537 w32font_draw (struct glyph_string *s, int from, int to, |
556 struct glyph_string *s; | 538 int x, int y, int with_background) |
557 int from, to, x, y, with_background; | |
558 { | 539 { |
559 UINT options; | 540 UINT options; |
560 HRGN orig_clip = NULL; | 541 HRGN orig_clip = NULL; |
561 struct w32font_info *w32font = (struct w32font_info *) s->font; | 542 struct w32font_info *w32font = (struct w32font_info *) s->font; |
562 | 543 |
713 | 694 |
714 /* Internal implementation of w32font_list. | 695 /* Internal implementation of w32font_list. |
715 Additional parameter opentype_only restricts the returned fonts to | 696 Additional parameter opentype_only restricts the returned fonts to |
716 opentype fonts, which can be used with the Uniscribe backend. */ | 697 opentype fonts, which can be used with the Uniscribe backend. */ |
717 Lisp_Object | 698 Lisp_Object |
718 w32font_list_internal (frame, font_spec, opentype_only) | 699 w32font_list_internal (Lisp_Object frame, Lisp_Object font_spec, int opentype_only) |
719 Lisp_Object frame, font_spec; | |
720 int opentype_only; | |
721 { | 700 { |
722 struct font_callback_data match_data; | 701 struct font_callback_data match_data; |
723 HDC dc; | 702 HDC dc; |
724 FRAME_PTR f = XFRAME (frame); | 703 FRAME_PTR f = XFRAME (frame); |
725 | 704 |
768 | 747 |
769 /* Internal implementation of w32font_match. | 748 /* Internal implementation of w32font_match. |
770 Additional parameter opentype_only restricts the returned fonts to | 749 Additional parameter opentype_only restricts the returned fonts to |
771 opentype fonts, which can be used with the Uniscribe backend. */ | 750 opentype fonts, which can be used with the Uniscribe backend. */ |
772 Lisp_Object | 751 Lisp_Object |
773 w32font_match_internal (frame, font_spec, opentype_only) | 752 w32font_match_internal (Lisp_Object frame, Lisp_Object font_spec, int opentype_only) |
774 Lisp_Object frame, font_spec; | |
775 int opentype_only; | |
776 { | 753 { |
777 struct font_callback_data match_data; | 754 struct font_callback_data match_data; |
778 HDC dc; | 755 HDC dc; |
779 FRAME_PTR f = XFRAME (frame); | 756 FRAME_PTR f = XFRAME (frame); |
780 | 757 |
798 | 775 |
799 return NILP (match_data.list) ? Qnil : XCAR (match_data.list); | 776 return NILP (match_data.list) ? Qnil : XCAR (match_data.list); |
800 } | 777 } |
801 | 778 |
802 int | 779 int |
803 w32font_open_internal (f, font_entity, pixel_size, font_object) | 780 w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, |
804 FRAME_PTR f; | 781 int pixel_size, Lisp_Object font_object) |
805 Lisp_Object font_entity; | |
806 int pixel_size; | |
807 Lisp_Object font_object; | |
808 { | 782 { |
809 int len, size, i; | 783 int len, size, i; |
810 LOGFONT logfont; | 784 LOGFONT logfont; |
811 HDC dc; | 785 HDC dc; |
812 HFONT hfont, old_font; | 786 HFONT hfont, old_font; |
949 } | 923 } |
950 | 924 |
951 /* Callback function for EnumFontFamiliesEx. | 925 /* Callback function for EnumFontFamiliesEx. |
952 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */ | 926 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */ |
953 static int CALLBACK | 927 static int CALLBACK |
954 add_font_name_to_list (logical_font, physical_font, font_type, list_object) | 928 add_font_name_to_list (ENUMLOGFONTEX *logical_font, |
955 ENUMLOGFONTEX *logical_font; | 929 NEWTEXTMETRICEX *physical_font, |
956 NEWTEXTMETRICEX *physical_font; | 930 DWORD font_type, LPARAM list_object) |
957 DWORD font_type; | |
958 LPARAM list_object; | |
959 { | 931 { |
960 Lisp_Object* list = (Lisp_Object *) list_object; | 932 Lisp_Object* list = (Lisp_Object *) list_object; |
961 Lisp_Object family; | 933 Lisp_Object family; |
962 | 934 |
963 /* Skip vertical fonts (intended only for printing) */ | 935 /* Skip vertical fonts (intended only for printing) */ |
974 static int w32_decode_weight (int); | 946 static int w32_decode_weight (int); |
975 static int w32_encode_weight (int); | 947 static int w32_encode_weight (int); |
976 | 948 |
977 /* Convert an enumerated Windows font to an Emacs font entity. */ | 949 /* Convert an enumerated Windows font to an Emacs font entity. */ |
978 static Lisp_Object | 950 static Lisp_Object |
979 w32_enumfont_pattern_entity (frame, logical_font, physical_font, | 951 w32_enumfont_pattern_entity (Lisp_Object frame, |
980 font_type, requested_font, backend) | 952 ENUMLOGFONTEX *logical_font, |
981 Lisp_Object frame; | 953 NEWTEXTMETRICEX *physical_font, |
982 ENUMLOGFONTEX *logical_font; | 954 DWORD font_type, |
983 NEWTEXTMETRICEX *physical_font; | 955 LOGFONT *requested_font, |
984 DWORD font_type; | 956 Lisp_Object backend) |
985 LOGFONT *requested_font; | |
986 Lisp_Object backend; | |
987 { | 957 { |
988 Lisp_Object entity, tem; | 958 Lisp_Object entity, tem; |
989 LOGFONT *lf = (LOGFONT*) logical_font; | 959 LOGFONT *lf = (LOGFONT*) logical_font; |
990 BYTE generic_type; | 960 BYTE generic_type; |
991 DWORD full_type = physical_font->ntmTm.ntmFlags; | 961 DWORD full_type = physical_font->ntmTm.ntmFlags; |
1105 else | 1075 else |
1106 return FF_DONTCARE; | 1076 return FF_DONTCARE; |
1107 } | 1077 } |
1108 | 1078 |
1109 static int | 1079 static int |
1110 logfonts_match (font, pattern) | 1080 logfonts_match (LOGFONT *font, LOGFONT *pattern) |
1111 LOGFONT *font, *pattern; | |
1112 { | 1081 { |
1113 /* Only check height for raster fonts. */ | 1082 /* Only check height for raster fonts. */ |
1114 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS | 1083 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS |
1115 && font->lfHeight != pattern->lfHeight) | 1084 && font->lfHeight != pattern->lfHeight) |
1116 return 0; | 1085 return 0; |
1130 #define CSB_JAPANESE (1 << 17) | 1099 #define CSB_JAPANESE (1 << 17) |
1131 #define CSB_KOREAN ((1 << 19) | (1 << 21)) | 1100 #define CSB_KOREAN ((1 << 19) | (1 << 21)) |
1132 #define CSB_CHINESE ((1 << 18) | (1 << 20)) | 1101 #define CSB_CHINESE ((1 << 18) | (1 << 20)) |
1133 | 1102 |
1134 static int | 1103 static int |
1135 font_matches_spec (type, font, spec, backend, logfont) | 1104 font_matches_spec (DWORD type, NEWTEXTMETRICEX *font, |
1136 DWORD type; | 1105 Lisp_Object spec, Lisp_Object backend, |
1137 NEWTEXTMETRICEX *font; | 1106 LOGFONT *logfont) |
1138 Lisp_Object spec; | |
1139 Lisp_Object backend; | |
1140 LOGFONT *logfont; | |
1141 { | 1107 { |
1142 Lisp_Object extra, val; | 1108 Lisp_Object extra, val; |
1143 | 1109 |
1144 /* Check italic. Can't check logfonts, since it is a boolean field, | 1110 /* Check italic. Can't check logfonts, since it is a boolean field, |
1145 so there is no difference between "non-italic" and "don't care". */ | 1111 so there is no difference between "non-italic" and "don't care". */ |
1320 } | 1286 } |
1321 return 1; | 1287 return 1; |
1322 } | 1288 } |
1323 | 1289 |
1324 static int | 1290 static int |
1325 w32font_coverage_ok (coverage, charset) | 1291 w32font_coverage_ok (FONTSIGNATURE * coverage, BYTE charset) |
1326 FONTSIGNATURE * coverage; | |
1327 BYTE charset; | |
1328 { | 1292 { |
1329 DWORD subrange1 = coverage->fsUsb[1]; | 1293 DWORD subrange1 = coverage->fsUsb[1]; |
1330 | 1294 |
1331 #define SUBRANGE1_HAN_MASK 0x08000000 | 1295 #define SUBRANGE1_HAN_MASK 0x08000000 |
1332 #define SUBRANGE1_HANGEUL_MASK 0x01000000 | 1296 #define SUBRANGE1_HANGEUL_MASK 0x01000000 |
1348 return 1; | 1312 return 1; |
1349 } | 1313 } |
1350 | 1314 |
1351 | 1315 |
1352 static int | 1316 static int |
1353 check_face_name (font, full_name) | 1317 check_face_name (LOGFONT *font, char *full_name) |
1354 LOGFONT *font; | |
1355 char *full_name; | |
1356 { | 1318 { |
1357 char full_iname[LF_FULLFACESIZE+1]; | 1319 char full_iname[LF_FULLFACESIZE+1]; |
1358 | 1320 |
1359 /* Just check for names known to cause problems, since the full name | 1321 /* Just check for names known to cause problems, since the full name |
1360 can contain expanded abbreviations, prefixed foundry, postfixed | 1322 can contain expanded abbreviations, prefixed foundry, postfixed |
1395 * Checks if a font matches everything we are trying to check agaist, | 1357 * Checks if a font matches everything we are trying to check agaist, |
1396 * and if so, adds it to a list. Both the data we are checking against | 1358 * and if so, adds it to a list. Both the data we are checking against |
1397 * and the list to which the fonts are added are passed in via the | 1359 * and the list to which the fonts are added are passed in via the |
1398 * lparam argument, in the form of a font_callback_data struct. */ | 1360 * lparam argument, in the form of a font_callback_data struct. */ |
1399 static int CALLBACK | 1361 static int CALLBACK |
1400 add_font_entity_to_list (logical_font, physical_font, font_type, lParam) | 1362 add_font_entity_to_list (ENUMLOGFONTEX *logical_font, |
1401 ENUMLOGFONTEX *logical_font; | 1363 NEWTEXTMETRICEX *physical_font, |
1402 NEWTEXTMETRICEX *physical_font; | 1364 DWORD font_type, LPARAM lParam) |
1403 DWORD font_type; | |
1404 LPARAM lParam; | |
1405 { | 1365 { |
1406 struct font_callback_data *match_data | 1366 struct font_callback_data *match_data |
1407 = (struct font_callback_data *) lParam; | 1367 = (struct font_callback_data *) lParam; |
1408 Lisp_Object backend = match_data->opentype_only ? Quniscribe : Qgdi; | 1368 Lisp_Object backend = match_data->opentype_only ? Quniscribe : Qgdi; |
1409 Lisp_Object entity; | 1369 Lisp_Object entity; |
1508 } | 1468 } |
1509 | 1469 |
1510 /* Callback function for EnumFontFamiliesEx. | 1470 /* Callback function for EnumFontFamiliesEx. |
1511 * Terminates the search once we have a match. */ | 1471 * Terminates the search once we have a match. */ |
1512 static int CALLBACK | 1472 static int CALLBACK |
1513 add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam) | 1473 add_one_font_entity_to_list (ENUMLOGFONTEX *logical_font, |
1514 ENUMLOGFONTEX *logical_font; | 1474 NEWTEXTMETRICEX *physical_font, |
1515 NEWTEXTMETRICEX *physical_font; | 1475 DWORD font_type, LPARAM lParam) |
1516 DWORD font_type; | |
1517 LPARAM lParam; | |
1518 { | 1476 { |
1519 struct font_callback_data *match_data | 1477 struct font_callback_data *match_data |
1520 = (struct font_callback_data *) lParam; | 1478 = (struct font_callback_data *) lParam; |
1521 add_font_entity_to_list (logical_font, physical_font, font_type, lParam); | 1479 add_font_entity_to_list (logical_font, physical_font, font_type, lParam); |
1522 | 1480 |
1524 return NILP (match_data->list); | 1482 return NILP (match_data->list); |
1525 } | 1483 } |
1526 | 1484 |
1527 /* Old function to convert from x to w32 charset, from w32fns.c. */ | 1485 /* Old function to convert from x to w32 charset, from w32fns.c. */ |
1528 static LONG | 1486 static LONG |
1529 x_to_w32_charset (lpcs) | 1487 x_to_w32_charset (char * lpcs) |
1530 char * lpcs; | |
1531 { | 1488 { |
1532 Lisp_Object this_entry, w32_charset; | 1489 Lisp_Object this_entry, w32_charset; |
1533 char *charset; | 1490 char *charset; |
1534 int len = strlen (lpcs); | 1491 int len = strlen (lpcs); |
1535 | 1492 |
1607 } | 1564 } |
1608 | 1565 |
1609 | 1566 |
1610 /* Convert a Lisp font registry (symbol) to a windows charset. */ | 1567 /* Convert a Lisp font registry (symbol) to a windows charset. */ |
1611 static LONG | 1568 static LONG |
1612 registry_to_w32_charset (charset) | 1569 registry_to_w32_charset (Lisp_Object charset) |
1613 Lisp_Object charset; | |
1614 { | 1570 { |
1615 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp) | 1571 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp) |
1616 || EQ (charset, Qunicode_sip)) | 1572 || EQ (charset, Qunicode_sip)) |
1617 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */ | 1573 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */ |
1618 else if (EQ (charset, Qiso8859_1)) | 1574 else if (EQ (charset, Qiso8859_1)) |
1623 return DEFAULT_CHARSET; | 1579 return DEFAULT_CHARSET; |
1624 } | 1580 } |
1625 | 1581 |
1626 /* Old function to convert from w32 to x charset, from w32fns.c. */ | 1582 /* Old function to convert from w32 to x charset, from w32fns.c. */ |
1627 static char * | 1583 static char * |
1628 w32_to_x_charset (fncharset, matching) | 1584 w32_to_x_charset (int fncharset, char *matching) |
1629 int fncharset; | |
1630 char *matching; | |
1631 { | 1585 { |
1632 static char buf[32]; | 1586 static char buf[32]; |
1633 Lisp_Object charset_type; | 1587 Lisp_Object charset_type; |
1634 int match_len = 0; | 1588 int match_len = 0; |
1635 | 1589 |
1819 return buf; | 1773 return buf; |
1820 } | 1774 } |
1821 } | 1775 } |
1822 | 1776 |
1823 static Lisp_Object | 1777 static Lisp_Object |
1824 w32_registry (w32_charset, font_type) | 1778 w32_registry (LONG w32_charset, DWORD font_type) |
1825 LONG w32_charset; | |
1826 DWORD font_type; | |
1827 { | 1779 { |
1828 char *charset; | 1780 char *charset; |
1829 | 1781 |
1830 /* If charset is defaulted, charset is unicode or unknown, depending on | 1782 /* If charset is defaulted, charset is unicode or unknown, depending on |
1831 font type. */ | 1783 font type. */ |
1835 charset = w32_to_x_charset (w32_charset, NULL); | 1787 charset = w32_to_x_charset (w32_charset, NULL); |
1836 return font_intern_prop (charset, strlen(charset), 1); | 1788 return font_intern_prop (charset, strlen(charset), 1); |
1837 } | 1789 } |
1838 | 1790 |
1839 static int | 1791 static int |
1840 w32_decode_weight (fnweight) | 1792 w32_decode_weight (int fnweight) |
1841 int fnweight; | |
1842 { | 1793 { |
1843 if (fnweight >= FW_HEAVY) return 210; | 1794 if (fnweight >= FW_HEAVY) return 210; |
1844 if (fnweight >= FW_EXTRABOLD) return 205; | 1795 if (fnweight >= FW_EXTRABOLD) return 205; |
1845 if (fnweight >= FW_BOLD) return 200; | 1796 if (fnweight >= FW_BOLD) return 200; |
1846 if (fnweight >= FW_SEMIBOLD) return 180; | 1797 if (fnweight >= FW_SEMIBOLD) return 180; |
1850 if (fnweight > FW_THIN) return 20; | 1801 if (fnweight > FW_THIN) return 20; |
1851 return 0; | 1802 return 0; |
1852 } | 1803 } |
1853 | 1804 |
1854 static int | 1805 static int |
1855 w32_encode_weight (n) | 1806 w32_encode_weight (int n) |
1856 int n; | |
1857 { | 1807 { |
1858 if (n >= 210) return FW_HEAVY; | 1808 if (n >= 210) return FW_HEAVY; |
1859 if (n >= 205) return FW_EXTRABOLD; | 1809 if (n >= 205) return FW_EXTRABOLD; |
1860 if (n >= 200) return FW_BOLD; | 1810 if (n >= 200) return FW_BOLD; |
1861 if (n >= 180) return FW_SEMIBOLD; | 1811 if (n >= 180) return FW_SEMIBOLD; |
1867 } | 1817 } |
1868 | 1818 |
1869 /* Convert a Windows font weight into one of the weights supported | 1819 /* Convert a Windows font weight into one of the weights supported |
1870 by fontconfig (see font.c:font_parse_fcname). */ | 1820 by fontconfig (see font.c:font_parse_fcname). */ |
1871 static Lisp_Object | 1821 static Lisp_Object |
1872 w32_to_fc_weight (n) | 1822 w32_to_fc_weight (int n) |
1873 int n; | |
1874 { | 1823 { |
1875 if (n >= FW_EXTRABOLD) return intern ("black"); | 1824 if (n >= FW_EXTRABOLD) return intern ("black"); |
1876 if (n >= FW_BOLD) return intern ("bold"); | 1825 if (n >= FW_BOLD) return intern ("bold"); |
1877 if (n >= FW_SEMIBOLD) return intern ("demibold"); | 1826 if (n >= FW_SEMIBOLD) return intern ("demibold"); |
1878 if (n >= FW_NORMAL) return intern ("medium"); | 1827 if (n >= FW_NORMAL) return intern ("medium"); |
1879 return intern ("light"); | 1828 return intern ("light"); |
1880 } | 1829 } |
1881 | 1830 |
1882 /* Fill in all the available details of LOGFONT from FONT_SPEC. */ | 1831 /* Fill in all the available details of LOGFONT from FONT_SPEC. */ |
1883 static void | 1832 static void |
1884 fill_in_logfont (f, logfont, font_spec) | 1833 fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec) |
1885 FRAME_PTR f; | |
1886 LOGFONT *logfont; | |
1887 Lisp_Object font_spec; | |
1888 { | 1834 { |
1889 Lisp_Object tmp, extra; | 1835 Lisp_Object tmp, extra; |
1890 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy; | 1836 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy; |
1891 | 1837 |
1892 tmp = AREF (font_spec, FONT_DPI_INDEX); | 1838 tmp = AREF (font_spec, FONT_DPI_INDEX); |
2027 } | 1973 } |
2028 } | 1974 } |
2029 } | 1975 } |
2030 | 1976 |
2031 static void | 1977 static void |
2032 list_all_matching_fonts (match_data) | 1978 list_all_matching_fonts (struct font_callback_data *match_data) |
2033 struct font_callback_data *match_data; | |
2034 { | 1979 { |
2035 HDC dc; | 1980 HDC dc; |
2036 Lisp_Object families = w32font_list_family (match_data->frame); | 1981 Lisp_Object families = w32font_list_family (match_data->frame); |
2037 struct frame *f = XFRAME (match_data->frame); | 1982 struct frame *f = XFRAME (match_data->frame); |
2038 | 1983 |
2064 | 2009 |
2065 release_frame_dc (f, dc); | 2010 release_frame_dc (f, dc); |
2066 } | 2011 } |
2067 | 2012 |
2068 static Lisp_Object | 2013 static Lisp_Object |
2069 lispy_antialias_type (type) | 2014 lispy_antialias_type (BYTE type) |
2070 BYTE type; | |
2071 { | 2015 { |
2072 Lisp_Object lispy; | 2016 Lisp_Object lispy; |
2073 | 2017 |
2074 switch (type) | 2018 switch (type) |
2075 { | 2019 { |
2092 return lispy; | 2036 return lispy; |
2093 } | 2037 } |
2094 | 2038 |
2095 /* Convert antialiasing symbols to lfQuality */ | 2039 /* Convert antialiasing symbols to lfQuality */ |
2096 static BYTE | 2040 static BYTE |
2097 w32_antialias_type (type) | 2041 w32_antialias_type (Lisp_Object type) |
2098 Lisp_Object type; | |
2099 { | 2042 { |
2100 if (EQ (type, Qnone)) | 2043 if (EQ (type, Qnone)) |
2101 return NONANTIALIASED_QUALITY; | 2044 return NONANTIALIASED_QUALITY; |
2102 else if (EQ (type, Qstandard)) | 2045 else if (EQ (type, Qstandard)) |
2103 return ANTIALIASED_QUALITY; | 2046 return ANTIALIASED_QUALITY; |
2239 | 2182 |
2240 /* Generate a full name for a Windows font. | 2183 /* Generate a full name for a Windows font. |
2241 The full name is in fcname format, with weight, slant and antialiasing | 2184 The full name is in fcname format, with weight, slant and antialiasing |
2242 specified if they are not "normal". */ | 2185 specified if they are not "normal". */ |
2243 static int | 2186 static int |
2244 w32font_full_name (font, font_obj, pixel_size, name, nbytes) | 2187 w32font_full_name (LOGFONT * font, Lisp_Object font_obj, |
2245 LOGFONT * font; | 2188 int pixel_size, char *name, int nbytes) |
2246 Lisp_Object font_obj; | |
2247 int pixel_size; | |
2248 char *name; | |
2249 int nbytes; | |
2250 { | 2189 { |
2251 int len, height, outline; | 2190 int len, height, outline; |
2252 char *p; | 2191 char *p; |
2253 Lisp_Object antialiasing, weight = Qnil; | 2192 Lisp_Object antialiasing, weight = Qnil; |
2254 | 2193 |
2315 POINTSIZE is in tenths of points. | 2254 POINTSIZE is in tenths of points. |
2316 If SIZE indicates the size of buffer FCNAME, into which the font name | 2255 If SIZE indicates the size of buffer FCNAME, into which the font name |
2317 is written. If the buffer is not large enough to contain the name, | 2256 is written. If the buffer is not large enough to contain the name, |
2318 the function returns -1, otherwise it returns the number of bytes | 2257 the function returns -1, otherwise it returns the number of bytes |
2319 written to FCNAME. */ | 2258 written to FCNAME. */ |
2320 static int logfont_to_fcname(font, pointsize, fcname, size) | 2259 static int |
2321 LOGFONT* font; | 2260 logfont_to_fcname (LOGFONT* font, int pointsize, char *fcname, int size) |
2322 int pointsize; | |
2323 char *fcname; | |
2324 int size; | |
2325 { | 2261 { |
2326 int len, height; | 2262 int len, height; |
2327 char *p = fcname; | 2263 char *p = fcname; |
2328 Lisp_Object weight = Qnil; | 2264 Lisp_Object weight = Qnil; |
2329 | 2265 |
2358 | 2294 |
2359 return (p - fcname); | 2295 return (p - fcname); |
2360 } | 2296 } |
2361 | 2297 |
2362 static void | 2298 static void |
2363 compute_metrics (dc, w32_font, code, metrics) | 2299 compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code, |
2364 HDC dc; | 2300 struct w32_metric_cache *metrics) |
2365 struct w32font_info *w32_font; | |
2366 unsigned int code; | |
2367 struct w32_metric_cache *metrics; | |
2368 { | 2301 { |
2369 GLYPHMETRICS gm; | 2302 GLYPHMETRICS gm; |
2370 MAT2 transform; | 2303 MAT2 transform; |
2371 unsigned int options = GGO_METRICS; | 2304 unsigned int options = GGO_METRICS; |
2372 | 2305 |
2480 | 2413 |
2481 | 2414 |
2482 /* Initialize state that does not change between invocations. This is only | 2415 /* Initialize state that does not change between invocations. This is only |
2483 called when Emacs is dumped. */ | 2416 called when Emacs is dumped. */ |
2484 void | 2417 void |
2485 syms_of_w32font () | 2418 syms_of_w32font (void) |
2486 { | 2419 { |
2487 DEFSYM (Qgdi, "gdi"); | 2420 DEFSYM (Qgdi, "gdi"); |
2488 DEFSYM (Quniscribe, "uniscribe"); | 2421 DEFSYM (Quniscribe, "uniscribe"); |
2489 DEFSYM (QCformat, ":format"); | 2422 DEFSYM (QCformat, ":format"); |
2490 | 2423 |