diff options
| author | Jason Rumney | 2007-11-23 02:09:19 +0000 |
|---|---|---|
| committer | Jason Rumney | 2007-11-23 02:09:19 +0000 |
| commit | 9158328107acc9897c4e1d778b99ac4dfa069a20 (patch) | |
| tree | e9618d07bee7362659702b31a0ece2f97ea052bc | |
| parent | 7d5cb920d08d07a3e44c6893f1524352bc207ce3 (diff) | |
| download | emacs-9158328107acc9897c4e1d778b99ac4dfa069a20.tar.gz emacs-9158328107acc9897c4e1d778b99ac4dfa069a20.zip | |
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
if not already.
(QCfamily): Share with xfaces.c.
(Qstandard, Qsubpixel, Qnatural): New symbols.
(syms_of_w32font): Define them. Don't define QCfamily here.
(w32_antialias_type, lispy_antialias_type): New functions.
(w32_enumfont_pattern_entity): New arg requested_font.
Set antialias parameter if non-default was requested.
(fill_in_logfont): Fill in lfQuality if :antialias specified.
| -rw-r--r-- | src/w32font.c | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/src/w32font.c b/src/w32font.c index 5c3f6b7af08..e8e9b4ce2f8 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -30,6 +30,17 @@ Boston, MA 02110-1301, USA. */ | |||
| 30 | #include "fontset.h" | 30 | #include "fontset.h" |
| 31 | #include "font.h" | 31 | #include "font.h" |
| 32 | 32 | ||
| 33 | /* Cleartype available on Windows XP, cleartype_natural from XP SP1. | ||
| 34 | The latter does not try to fit cleartype smoothed fonts into the | ||
| 35 | same bounding box as the non-antialiased version of the font. | ||
| 36 | */ | ||
| 37 | #ifndef CLEARTYPE_QUALITY | ||
| 38 | #define CLEARTYPE_QUALITY 5 | ||
| 39 | #endif | ||
| 40 | #ifndef CLEARTYPE_NATURAL_QUALITY | ||
| 41 | #define CLEARTYPE_NATURAL_QUALITY 6 | ||
| 42 | #endif | ||
| 43 | |||
| 33 | /* The actual structure for a w32 font, that can be cast to struct font. */ | 44 | /* The actual structure for a w32 font, that can be cast to struct font. */ |
| 34 | struct w32font_info | 45 | struct w32font_info |
| 35 | { | 46 | { |
| @@ -39,10 +50,16 @@ struct w32font_info | |||
| 39 | 50 | ||
| 40 | extern struct font_driver w32font_driver; | 51 | extern struct font_driver w32font_driver; |
| 41 | 52 | ||
| 42 | Lisp_Object Qgdi, QCfamily; | 53 | Lisp_Object Qgdi; |
| 54 | extern Lisp_Object QCfamily; /* reuse from xfaces.c */ | ||
| 43 | static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; | 55 | static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; |
| 44 | static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown; | 56 | static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown; |
| 45 | 57 | ||
| 58 | /* antialiasing */ | ||
| 59 | extern Lisp_Object QCantialias; /* defined in font.c */ | ||
| 60 | extern Lisp_Object Qnone; /* reuse from w32fns.c */ | ||
| 61 | static Lisp_Object Qstandard, Qsubpixel, Qnatural; | ||
| 62 | |||
| 46 | /* scripts */ | 63 | /* scripts */ |
| 47 | static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; | 64 | static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; |
| 48 | static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; | 65 | static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; |
| @@ -61,6 +78,9 @@ extern Lisp_Object Qc, Qp, Qm; | |||
| 61 | static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont, | 78 | static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont, |
| 62 | Lisp_Object font_spec)); | 79 | Lisp_Object font_spec)); |
| 63 | 80 | ||
| 81 | static BYTE w32_antialias_type P_ ((Lisp_Object type)); | ||
| 82 | static Lisp_Object lispy_antialias_type P_ ((BYTE type)); | ||
| 83 | |||
| 64 | static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); | 84 | static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); |
| 65 | 85 | ||
| 66 | /* From old font code in w32fns.c */ | 86 | /* From old font code in w32fns.c */ |
| @@ -133,7 +153,6 @@ static Lisp_Object | |||
| 133 | w32font_list (frame, font_spec) | 153 | w32font_list (frame, font_spec) |
| 134 | Lisp_Object frame, font_spec; | 154 | Lisp_Object frame, font_spec; |
| 135 | { | 155 | { |
| 136 | Lisp_Object tem; | ||
| 137 | struct font_callback_data match_data; | 156 | struct font_callback_data match_data; |
| 138 | HDC dc; | 157 | HDC dc; |
| 139 | FRAME_PTR f = XFRAME (frame); | 158 | FRAME_PTR f = XFRAME (frame); |
| @@ -655,11 +674,13 @@ add_font_name_to_list (logical_font, physical_font, font_type, list_object) | |||
| 655 | 674 | ||
| 656 | /* Convert an enumerated Windows font to an Emacs font entity. */ | 675 | /* Convert an enumerated Windows font to an Emacs font entity. */ |
| 657 | static Lisp_Object | 676 | static Lisp_Object |
| 658 | w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type) | 677 | w32_enumfont_pattern_entity (frame, logical_font, physical_font, |
| 678 | font_type, requested_font) | ||
| 659 | Lisp_Object frame; | 679 | Lisp_Object frame; |
| 660 | ENUMLOGFONTEX *logical_font; | 680 | ENUMLOGFONTEX *logical_font; |
| 661 | NEWTEXTMETRICEX *physical_font; | 681 | NEWTEXTMETRICEX *physical_font; |
| 662 | DWORD font_type; | 682 | DWORD font_type; |
| 683 | LOGFONT *requested_font; | ||
| 663 | { | 684 | { |
| 664 | Lisp_Object entity, tem; | 685 | Lisp_Object entity, tem; |
| 665 | LOGFONT *lf = (LOGFONT*) logical_font; | 686 | LOGFONT *lf = (LOGFONT*) logical_font; |
| @@ -703,12 +724,16 @@ w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type) | |||
| 703 | if (! NILP (tem)) | 724 | if (! NILP (tem)) |
| 704 | font_put_extra (entity, QCfamily, tem); | 725 | font_put_extra (entity, QCfamily, tem); |
| 705 | 726 | ||
| 706 | |||
| 707 | if (physical_font->ntmTm.tmPitchAndFamily & 0x01) | 727 | if (physical_font->ntmTm.tmPitchAndFamily & 0x01) |
| 708 | font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL)); | 728 | font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL)); |
| 709 | else | 729 | else |
| 710 | font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO)); | 730 | font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO)); |
| 711 | 731 | ||
| 732 | if (requested_font->lfQuality != DEFAULT_QUALITY) | ||
| 733 | { | ||
| 734 | font_put_extra (entity, QCantialias, | ||
| 735 | lispy_antialias_type (requested_font->lfQuality)); | ||
| 736 | } | ||
| 712 | ASET (entity, FONT_FAMILY_INDEX, | 737 | ASET (entity, FONT_FAMILY_INDEX, |
| 713 | intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName))); | 738 | intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName))); |
| 714 | 739 | ||
| @@ -955,7 +980,8 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam) | |||
| 955 | { | 980 | { |
| 956 | Lisp_Object entity | 981 | Lisp_Object entity |
| 957 | = w32_enumfont_pattern_entity (match_data->frame, logical_font, | 982 | = w32_enumfont_pattern_entity (match_data->frame, logical_font, |
| 958 | physical_font, font_type); | 983 | physical_font, font_type, |
| 984 | &match_data->pattern); | ||
| 959 | if (!NILP (entity)) | 985 | if (!NILP (entity)) |
| 960 | match_data->list = Fcons (entity, match_data->list); | 986 | match_data->list = Fcons (entity, match_data->list); |
| 961 | } | 987 | } |
| @@ -1069,9 +1095,10 @@ fill_in_logfont (f, logfont, font_spec) | |||
| 1069 | logfont->lfCharSet = registry_to_w32_charset (tmp); | 1095 | logfont->lfCharSet = registry_to_w32_charset (tmp); |
| 1070 | 1096 | ||
| 1071 | /* Out Precision */ | 1097 | /* Out Precision */ |
| 1098 | |||
| 1072 | /* Clip Precision */ | 1099 | /* Clip Precision */ |
| 1073 | /* Quality TODO: Allow different quality to be specified, so user | 1100 | |
| 1074 | can enable/disable anti-aliasing for individual fonts. */ | 1101 | /* Quality */ |
| 1075 | logfont->lfQuality = DEFAULT_QUALITY; | 1102 | logfont->lfQuality = DEFAULT_QUALITY; |
| 1076 | 1103 | ||
| 1077 | /* Generic Family and Face Name */ | 1104 | /* Generic Family and Face Name */ |
| @@ -1160,6 +1187,10 @@ fill_in_logfont (f, logfont, font_spec) | |||
| 1160 | else if (EQ (val, Qsymbol)) | 1187 | else if (EQ (val, Qsymbol)) |
| 1161 | logfont->lfCharSet = SYMBOL_CHARSET; | 1188 | logfont->lfCharSet = SYMBOL_CHARSET; |
| 1162 | } | 1189 | } |
| 1190 | else if (EQ (key, QCantialias) && SYMBOLP (val)) | ||
| 1191 | { | ||
| 1192 | logfont->lfQuality = w32_antialias_type (val); | ||
| 1193 | } | ||
| 1163 | } | 1194 | } |
| 1164 | } | 1195 | } |
| 1165 | } | 1196 | } |
| @@ -1199,6 +1230,50 @@ list_all_matching_fonts (match_data) | |||
| 1199 | release_frame_dc (f, dc); | 1230 | release_frame_dc (f, dc); |
| 1200 | } | 1231 | } |
| 1201 | 1232 | ||
| 1233 | static Lisp_Object | ||
| 1234 | lispy_antialias_type (type) | ||
| 1235 | BYTE type; | ||
| 1236 | { | ||
| 1237 | Lisp_Object lispy; | ||
| 1238 | |||
| 1239 | switch (type) | ||
| 1240 | { | ||
| 1241 | case NONANTIALIASED_QUALITY: | ||
| 1242 | lispy = Qnone; | ||
| 1243 | break; | ||
| 1244 | case ANTIALIASED_QUALITY: | ||
| 1245 | lispy = Qstandard; | ||
| 1246 | break; | ||
| 1247 | case CLEARTYPE_QUALITY: | ||
| 1248 | lispy = Qsubpixel; | ||
| 1249 | break; | ||
| 1250 | case CLEARTYPE_NATURAL_QUALITY: | ||
| 1251 | lispy = Qnatural; | ||
| 1252 | break; | ||
| 1253 | default: | ||
| 1254 | lispy = Qnil; | ||
| 1255 | break; | ||
| 1256 | } | ||
| 1257 | return lispy; | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | /* Convert antialiasing symbols to lfQuality */ | ||
| 1261 | static BYTE | ||
| 1262 | w32_antialias_type (type) | ||
| 1263 | Lisp_Object type; | ||
| 1264 | { | ||
| 1265 | if (EQ (type, Qnone)) | ||
| 1266 | return NONANTIALIASED_QUALITY; | ||
| 1267 | else if (EQ (type, Qstandard)) | ||
| 1268 | return ANTIALIASED_QUALITY; | ||
| 1269 | else if (EQ (type, Qsubpixel)) | ||
| 1270 | return CLEARTYPE_QUALITY; | ||
| 1271 | else if (EQ (type, Qnatural)) | ||
| 1272 | return CLEARTYPE_NATURAL_QUALITY; | ||
| 1273 | else | ||
| 1274 | return DEFAULT_QUALITY; | ||
| 1275 | } | ||
| 1276 | |||
| 1202 | /* Return a list of all the scripts that the font supports. */ | 1277 | /* Return a list of all the scripts that the font supports. */ |
| 1203 | static Lisp_Object | 1278 | static Lisp_Object |
| 1204 | font_supported_scripts (FONTSIGNATURE * sig) | 1279 | font_supported_scripts (FONTSIGNATURE * sig) |
| @@ -1331,8 +1406,10 @@ syms_of_w32font () | |||
| 1331 | DEFSYM (Qoutline, "outline"); | 1406 | DEFSYM (Qoutline, "outline"); |
| 1332 | DEFSYM (Qunknown, "unknown"); | 1407 | DEFSYM (Qunknown, "unknown"); |
| 1333 | 1408 | ||
| 1334 | /* Indexes for extra info. */ | 1409 | /* Antialiasing. */ |
| 1335 | DEFSYM (QCfamily, ":family"); | 1410 | DEFSYM (Qstandard, "standard"); |
| 1411 | DEFSYM (Qsubpixel, "subpixel"); | ||
| 1412 | DEFSYM (Qnatural, "natural"); | ||
| 1336 | 1413 | ||
| 1337 | /* Scripts */ | 1414 | /* Scripts */ |
| 1338 | DEFSYM (Qlatin, "latin"); | 1415 | DEFSYM (Qlatin, "latin"); |