changeset 91260:75f89f349f70

(w32font_text_extents): Dereference selected_frame. (w32_enumfont_pattern_entity): Map generic family to adstyle using most common hyphenless variation. (logfonts_match): Check generic family. (font_matches_spec): Don't check generic family here. (fill_in_logfont): Set generic family based on adstyle. + changes to sans-serif constants to avoid hyphen (for xfld compatibility)
author Jason Rumney <jasonr@gnu.org>
date Thu, 20 Dec 2007 00:10:57 +0000
parents 51863d34f0f1
children 2e5bb6a0a787
files src/w32font.c
diffstat 1 files changed, 27 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32font.c	Wed Dec 19 22:27:46 2007 +0000
+++ b/src/w32font.c	Thu Dec 20 00:10:57 2007 +0000
@@ -45,9 +45,9 @@
 extern struct font_driver w32font_driver;
 
 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 Qscript, Qdecorative, Qraster, Qoutline, Qunknown;
+static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif;
+static Lisp_Object Qserif, Qscript, Qdecorative;
+static Lisp_Object Qraster, Qoutline, Qunknown;
 
 /* antialiasing  */
 extern Lisp_Object QCantialias; /* defined in font.c  */
@@ -298,7 +298,7 @@
      particularly troublesome with tooltip frames, and causes crashes.  */
   f = ((struct w32font_info *)font)->owning_frame;
 #else
-  f = selected_frame;
+  f = XFRAME (selected_frame);
 #endif
 
   dc = get_frame_dc (f);
@@ -771,18 +771,17 @@
   if (generic_type == FF_DECORATIVE)
     tem = Qdecorative;
   else if (generic_type == FF_MODERN)
-    tem = Qmonospace;
+    tem = Qmono;
   else if (generic_type == FF_ROMAN)
     tem = Qserif;
   else if (generic_type == FF_SCRIPT)
     tem = Qscript;
   else if (generic_type == FF_SWISS)
-    tem = Qsans_serif;
+    tem = Qsans;
   else
-    tem = Qnil;
-    
-  if (! NILP (tem))
-    font_put_extra (entity, QCfamily, tem);
+    tem = null_string;
+
+  ASET (entity, FONT_ADSTYLE_INDEX, tem);
 
   if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
     font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL));
@@ -827,8 +826,7 @@
   /* Generic families.  */
   if (EQ (name, Qmonospace) || EQ (name, Qmono))
     return FF_MODERN;
-  else if (EQ (name, Qsans_serif) || EQ (name, Qsans__serif)
-           || EQ (name, Qsans))
+  else if (EQ (name, Qsans) || EQ (name, Qsans_serif) || EQ (name, Qsansserif))
     return FF_SWISS;
   else if (EQ (name, Qserif))
     return FF_ROMAN;
@@ -855,6 +853,10 @@
           || font->lfWeight > (pattern->lfWeight + 150)))
       return 0;
 
+  if (pattern->lfPitchAndFamily & 0xF0 != FF_DONTCARE
+      && pattern->lfPitchAndFamily & 0xF0 != font->lfPitchAndFamily & 0xF0)
+    return 0;
+
   /* Charset and face should be OK.  Italic has to be checked
      against the original spec, in case we don't have any preference.  */
   return 1;
@@ -889,22 +891,7 @@
         {
           Lisp_Object key = XCAR (extra_entry);
           val = XCDR (extra_entry);
-          if (EQ (key, QCfamily))
-            {
-              /* Generic family. Most useful when there is no font name
-                 specified. eg, if a script does not exist in the default
-                 font, we could look for a font with the same generic family
-                 that does support the script. Full PANOSE support would
-                 be better, but we need to open the font to get that.  */
-              BYTE w32_family = w32_generic_family (val);
-
-              /* Reject if FF_DONTCARE is returned, as it means the
-                 font spec is bad.  */
-              if (w32_family == FF_DONTCARE
-                  || w32_family != (font->ntmTm.tmPitchAndFamily & 0xF0))
-                return 0;
-            }
-          else if (EQ (key, QCspacing))
+          if (EQ (key, QCspacing))
             {
               int proportional;
               if (INTEGERP (val))
@@ -1176,6 +1163,15 @@
         strncpy (logfont->lfFaceName, SDATA (tmp), LF_FACESIZE);
     }
 
+  tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);
+  if (!NILP (tmp))
+    {
+      /* Override generic family.  */
+      BYTE family = w32_generic_family (tmp);
+      if (family != FF_DONTCARE)
+        logfont->lfPitchAndFamily = family | DEFAULT_PITCH;
+    }
+
   /* Process EXTRA info.  */
   for ( ; CONSP (extra); extra = XCDR (extra))
     {
@@ -1184,15 +1180,7 @@
         {
           Lisp_Object key, val;
           key = XCAR (tmp), val = XCDR (tmp);
-          if (EQ (key, QCfamily))
-            {
-              /* Override generic family.  */
-              BYTE family = w32_generic_family (val);
-              if (family != FF_DONTCARE)
-                logfont->lfPitchAndFamily
-                  = logfont->lfPitchAndFamily & 0x0F | family;
-            }
-          else if (EQ (key, QCspacing))
+          if (EQ (key, QCspacing))
             {
               /* Set pitch based on the spacing property.  */
               if (INTEGERP (val))
@@ -1454,11 +1442,11 @@
   /* Generic font families.  */
   DEFSYM (Qmonospace, "monospace");
   DEFSYM (Qserif, "serif");
-  DEFSYM (Qsans_serif, "sans-serif");
+  DEFSYM (Qsansserif, "sansserif");
   DEFSYM (Qscript, "script");
   DEFSYM (Qdecorative, "decorative");
   /* Aliases.  */
-  DEFSYM (Qsans__serif, "sans_serif");
+  DEFSYM (Qsans_serif, "sans_serif");
   DEFSYM (Qsans, "sans");
   DEFSYM (Qmono, "mono");