aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/w32font.c95
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. */
34struct w32font_info 45struct w32font_info
35{ 46{
@@ -39,10 +50,16 @@ struct w32font_info
39 50
40extern struct font_driver w32font_driver; 51extern struct font_driver w32font_driver;
41 52
42Lisp_Object Qgdi, QCfamily; 53Lisp_Object Qgdi;
54extern Lisp_Object QCfamily; /* reuse from xfaces.c */
43static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; 55static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
44static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown; 56static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown;
45 57
58/* antialiasing */
59extern Lisp_Object QCantialias; /* defined in font.c */
60extern Lisp_Object Qnone; /* reuse from w32fns.c */
61static Lisp_Object Qstandard, Qsubpixel, Qnatural;
62
46/* scripts */ 63/* scripts */
47static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; 64static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
48static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; 65static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
@@ -61,6 +78,9 @@ extern Lisp_Object Qc, Qp, Qm;
61static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont, 78static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont,
62 Lisp_Object font_spec)); 79 Lisp_Object font_spec));
63 80
81static BYTE w32_antialias_type P_ ((Lisp_Object type));
82static Lisp_Object lispy_antialias_type P_ ((BYTE type));
83
64static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); 84static 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
133w32font_list (frame, font_spec) 153w32font_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. */
657static Lisp_Object 676static Lisp_Object
658w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type) 677w32_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
1233static Lisp_Object
1234lispy_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 */
1261static BYTE
1262w32_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. */
1203static Lisp_Object 1278static Lisp_Object
1204font_supported_scripts (FONTSIGNATURE * sig) 1279font_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");