Commit 91583281 authored by Jason Rumney's avatar Jason Rumney
Browse files

(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.
parent 7d5cb920
...@@ -30,6 +30,17 @@ Boston, MA 02110-1301, USA. */ ...@@ -30,6 +30,17 @@ Boston, MA 02110-1301, USA. */
#include "fontset.h" #include "fontset.h"
#include "font.h" #include "font.h"
/* Cleartype available on Windows XP, cleartype_natural from XP SP1.
The latter does not try to fit cleartype smoothed fonts into the
same bounding box as the non-antialiased version of the font.
*/
#ifndef CLEARTYPE_QUALITY
#define CLEARTYPE_QUALITY 5
#endif
#ifndef CLEARTYPE_NATURAL_QUALITY
#define CLEARTYPE_NATURAL_QUALITY 6
#endif
/* The actual structure for a w32 font, that can be cast to struct font. */ /* The actual structure for a w32 font, that can be cast to struct font. */
struct w32font_info struct w32font_info
{ {
...@@ -39,10 +50,16 @@ struct w32font_info ...@@ -39,10 +50,16 @@ struct w32font_info
extern struct font_driver w32font_driver; extern struct font_driver w32font_driver;
Lisp_Object Qgdi, QCfamily; Lisp_Object Qgdi;
extern Lisp_Object QCfamily; /* reuse from xfaces.c */
static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown; static Lisp_Object Qscript, Qdecorative, Qraster, Qoutline, Qunknown;
/* antialiasing */
extern Lisp_Object QCantialias; /* defined in font.c */
extern Lisp_Object Qnone; /* reuse from w32fns.c */
static Lisp_Object Qstandard, Qsubpixel, Qnatural;
/* scripts */ /* scripts */
static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
...@@ -61,6 +78,9 @@ extern Lisp_Object Qc, Qp, Qm; ...@@ -61,6 +78,9 @@ extern Lisp_Object Qc, Qp, Qm;
static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont, static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont,
Lisp_Object font_spec)); Lisp_Object font_spec));
static BYTE w32_antialias_type P_ ((Lisp_Object type));
static Lisp_Object lispy_antialias_type P_ ((BYTE type));
static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig));
/* From old font code in w32fns.c */ /* From old font code in w32fns.c */
...@@ -133,7 +153,6 @@ static Lisp_Object ...@@ -133,7 +153,6 @@ static Lisp_Object
w32font_list (frame, font_spec) w32font_list (frame, font_spec)
Lisp_Object frame, font_spec; Lisp_Object frame, font_spec;
{ {
Lisp_Object tem;
struct font_callback_data match_data; struct font_callback_data match_data;
HDC dc; HDC dc;
FRAME_PTR f = XFRAME (frame); FRAME_PTR f = XFRAME (frame);
...@@ -655,11 +674,13 @@ add_font_name_to_list (logical_font, physical_font, font_type, list_object) ...@@ -655,11 +674,13 @@ add_font_name_to_list (logical_font, physical_font, font_type, list_object)
/* Convert an enumerated Windows font to an Emacs font entity. */ /* Convert an enumerated Windows font to an Emacs font entity. */
static Lisp_Object static Lisp_Object
w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type) w32_enumfont_pattern_entity (frame, logical_font, physical_font,
font_type, requested_font)
Lisp_Object frame; Lisp_Object frame;
ENUMLOGFONTEX *logical_font; ENUMLOGFONTEX *logical_font;
NEWTEXTMETRICEX *physical_font; NEWTEXTMETRICEX *physical_font;
DWORD font_type; DWORD font_type;
LOGFONT *requested_font;
{ {
Lisp_Object entity, tem; Lisp_Object entity, tem;
LOGFONT *lf = (LOGFONT*) logical_font; LOGFONT *lf = (LOGFONT*) logical_font;
...@@ -703,12 +724,16 @@ w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type) ...@@ -703,12 +724,16 @@ w32_enumfont_pattern_entity (frame, logical_font, physical_font, font_type)
if (! NILP (tem)) if (! NILP (tem))
font_put_extra (entity, QCfamily, tem); font_put_extra (entity, QCfamily, tem);
if (physical_font->ntmTm.tmPitchAndFamily & 0x01) if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL)); font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL));
else else
font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO)); font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO));
if (requested_font->lfQuality != DEFAULT_QUALITY)
{
font_put_extra (entity, QCantialias,
lispy_antialias_type (requested_font->lfQuality));
}
ASET (entity, FONT_FAMILY_INDEX, ASET (entity, FONT_FAMILY_INDEX,
intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName))); intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName)));
...@@ -955,7 +980,8 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam) ...@@ -955,7 +980,8 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam)
{ {
Lisp_Object entity Lisp_Object entity
= w32_enumfont_pattern_entity (match_data->frame, logical_font, = w32_enumfont_pattern_entity (match_data->frame, logical_font,
physical_font, font_type); physical_font, font_type,
&match_data->pattern);
if (!NILP (entity)) if (!NILP (entity))
match_data->list = Fcons (entity, match_data->list); match_data->list = Fcons (entity, match_data->list);
} }
...@@ -1069,9 +1095,10 @@ fill_in_logfont (f, logfont, font_spec) ...@@ -1069,9 +1095,10 @@ fill_in_logfont (f, logfont, font_spec)
logfont->lfCharSet = registry_to_w32_charset (tmp); logfont->lfCharSet = registry_to_w32_charset (tmp);
/* Out Precision */ /* Out Precision */
/* Clip Precision */ /* Clip Precision */
/* Quality TODO: Allow different quality to be specified, so user
can enable/disable anti-aliasing for individual fonts. */ /* Quality */
logfont->lfQuality = DEFAULT_QUALITY; logfont->lfQuality = DEFAULT_QUALITY;
/* Generic Family and Face Name */ /* Generic Family and Face Name */
...@@ -1160,6 +1187,10 @@ fill_in_logfont (f, logfont, font_spec) ...@@ -1160,6 +1187,10 @@ fill_in_logfont (f, logfont, font_spec)
else if (EQ (val, Qsymbol)) else if (EQ (val, Qsymbol))
logfont->lfCharSet = SYMBOL_CHARSET; logfont->lfCharSet = SYMBOL_CHARSET;
} }
else if (EQ (key, QCantialias) && SYMBOLP (val))
{
logfont->lfQuality = w32_antialias_type (val);
}
} }
} }
} }
...@@ -1199,6 +1230,50 @@ list_all_matching_fonts (match_data) ...@@ -1199,6 +1230,50 @@ list_all_matching_fonts (match_data)
release_frame_dc (f, dc); release_frame_dc (f, dc);
} }
static Lisp_Object
lispy_antialias_type (type)
BYTE type;
{
Lisp_Object lispy;
switch (type)
{
case NONANTIALIASED_QUALITY:
lispy = Qnone;
break;
case ANTIALIASED_QUALITY:
lispy = Qstandard;
break;
case CLEARTYPE_QUALITY:
lispy = Qsubpixel;
break;
case CLEARTYPE_NATURAL_QUALITY:
lispy = Qnatural;
break;
default:
lispy = Qnil;
break;
}
return lispy;
}
/* Convert antialiasing symbols to lfQuality */
static BYTE
w32_antialias_type (type)
Lisp_Object type;
{
if (EQ (type, Qnone))
return NONANTIALIASED_QUALITY;
else if (EQ (type, Qstandard))
return ANTIALIASED_QUALITY;
else if (EQ (type, Qsubpixel))
return CLEARTYPE_QUALITY;
else if (EQ (type, Qnatural))
return CLEARTYPE_NATURAL_QUALITY;
else
return DEFAULT_QUALITY;
}
/* Return a list of all the scripts that the font supports. */ /* Return a list of all the scripts that the font supports. */
static Lisp_Object static Lisp_Object
font_supported_scripts (FONTSIGNATURE * sig) font_supported_scripts (FONTSIGNATURE * sig)
...@@ -1331,8 +1406,10 @@ syms_of_w32font () ...@@ -1331,8 +1406,10 @@ syms_of_w32font ()
DEFSYM (Qoutline, "outline"); DEFSYM (Qoutline, "outline");
DEFSYM (Qunknown, "unknown"); DEFSYM (Qunknown, "unknown");
/* Indexes for extra info. */ /* Antialiasing. */
DEFSYM (QCfamily, ":family"); DEFSYM (Qstandard, "standard");
DEFSYM (Qsubpixel, "subpixel");
DEFSYM (Qnatural, "natural");
/* Scripts */ /* Scripts */
DEFSYM (Qlatin, "latin"); DEFSYM (Qlatin, "latin");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment