changeset 91264:9112e263c11f

(logfonts_match): Don't check adstyle here. (font_matches_spec): Check here against physical font instead. (add_font_entity_to_list): Avoid some substitutions.
author Jason Rumney <jasonr@gnu.org>
date Thu, 20 Dec 2007 14:28:53 +0000
parents a3dec2a13232
children 82309bc51831
files src/w32font.c
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32font.c	Thu Dec 20 12:38:58 2007 +0000
+++ b/src/w32font.c	Thu Dec 20 14:28:53 2007 +0000
@@ -853,10 +853,6 @@
           || 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;
@@ -881,6 +877,16 @@
         return 0;
     }
 
+  /* Check adstyle against generic family.  */
+  val = AREF (spec, FONT_ADSTYLE_INDEX);
+  if (!NILP (val))
+    {
+      BYTE family = w32_generic_family (val);
+      if (family != FF_DONTCARE
+          && family != (font->ntmTm.tmPitchAndFamily & 0xF0))
+        return 0;
+    }
+
   /* Check extra parameters.  */
   for (extra = AREF (spec, FONT_EXTRA_INDEX);
        CONSP (extra); extra = XCDR (extra))
@@ -1021,7 +1027,17 @@
        || (physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE))
       && logfonts_match (&logical_font->elfLogFont, &match_data->pattern)
       && font_matches_spec (font_type, physical_font,
-                            match_data->orig_font_spec))
+                            match_data->orig_font_spec)
+      /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
+         We limit this to raster fonts, because the test can catch some
+         genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
+         DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
+         therefore get through this test.  Since full names can be prefixed
+         by a foundry, we accept raster fonts if the font name is found
+         anywhere within the full name.  */
+      && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS
+          || strstr (logical_font->elfFullName,
+                     logical_font->elfLogFont.lfFaceName)))
     {
       Lisp_Object entity
         = w32_enumfont_pattern_entity (match_data->frame, logical_font,