Subject: Re: bug#17486: 24.4.50; set-face-font problem on OSX

From: Dmitry Antipov <[email-masked]>
Date: Sun, 18 May 2014 20:17:53 +0400

On 05/18/2014 11:19 AM, Jan Djärv wrote:

>> Could you please check whether set-face-font hits one of the following extra easserts?
>>
>
> ../../current/src/font.c:3311: Emacs fatal error: assertion failed: NILP (entity) || FONT_ENTITY_P (entity)
>
> (gdb) pp entity
> [#<font-entity ns apple Menlo nil iso10646-1 medium normal normal 0 nil 100 0 nil>]

Hm... so font_matching_entity sometimes returns [#<font-entity>] instead of #<font-entity>.
Something may be wrong with font cache or with font driver-specific match routine.
An output of (frame-font-cache) looks correct, so let's check both cases with the following
patch. My output looks like:

font_matching_entity: matched entity nil
font_matching_entity: matched entity #<font-entity x Misc Fixed ## JISX0201\.1976-0 medium r normal 14 75 110 70 nil>
font_matching_entity: matched entity nil
font_matching_entity: matched entity #<font-entity x Misc Fixed ## JISX0201\.1976-0 medium r normal 14 75 110 70 nil>
font_matching_entity: matched entity nil
font_matching_entity: matched entity #<font-entity x Sony Fixed ## JISX0201\.1976-0 medium r normal 16 100 110 80 nil>
font_matching_entity: matched entity nil
font_matching_entity: matched entity #<font-entity x Sony Fixed ## JISX0201\.1976-0 medium r normal 24 100 110 120 nil>
font_matching_entity: matched entity nil

and I do not see 1-item vectors here.

Dmitry

=== modified file 'src/font.c'
--- src/font.c	2014-04-05 19:30:36 +0000
+++ src/font.c	2014-05-18 16:11:09 +0000
@@ -2803,10 +2803,16 @@
 	ASET (work, FONT_TYPE_INDEX, driver_list->driver->type);
 	entity = assoc_no_quit (work, XCDR (cache));
 	if (CONSP (entity))
-	  entity = XCDR (entity);
+	  {
+	    entity = XCDR (entity);
+	    fprintf (stderr, "%s: cached entity ", __func__);
+	    debug_print (entity);
+	  }
 	else
 	  {
 	    entity = driver_list->driver->match (f, work);
+	    fprintf (stderr, "%s: matched entity ", __func__);
+	    debug_print (entity);
 	    if (!NILP (entity))
 	      {
 		Lisp_Object copy = copy_font_spec (work);
@@ -3299,6 +3305,7 @@
   Lisp_Object entity, name;
 
   entity = font_find_for_lface (f, attrs, spec, -1);
+  eassert (NILP (entity) || FONT_ENTITY_P (entity));  
   if (NILP (entity))
     {
       /* No font is listed for SPEC, but each font-backend may have
@@ -3307,6 +3314,7 @@
       if (NILP (entity))
 	return Qnil;
     }
+  eassert (NILP (entity) || FONT_ENTITY_P (entity));
   /* Don't lose the original name that was put in initially.  We need
      it to re-apply the font when font parameters (like hinting or dpi) have
      changed.  */