/[emacs]/emacs/src/fontset.c
ViewVC logotype

Diff of /emacs/src/fontset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.77.4.4 by handa, Fri Oct 24 00:44:48 2003 UTC revision 1.77.4.5 by handa, Wed Oct 29 11:51:42 2003 UTC
# Line 627  fontset_face (fontset, c, face) Line 627  fontset_face (fontset, c, face)
627    
628   try_default:   try_default:
629    if (! EQ (base_fontset, Vdefault_fontset))    if (! EQ (base_fontset, Vdefault_fontset))
630      return fontset_face (FONTSET_FALLBACK (fontset), c, face);      {
631          if (NILP (FONTSET_FALLBACK (fontset)))
632            FONTSET_FALLBACK (fontset)
633              = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset);
634          return fontset_face (FONTSET_FALLBACK (fontset), c, face);
635        }
636    
637    /* We have tried all the fonts for C, but none of them can be opened    /* We have tried all the fonts for C, but none of them can be opened
638       nor can display C.  */       nor can display C.  */
# Line 691  make_fontset (frame, name, base) Line 696  make_fontset (frame, name, base)
696    
697    ASET (Vfontset_table, id, fontset);    ASET (Vfontset_table, id, fontset);
698    next_fontset_id = id + 1;    next_fontset_id = id + 1;
   if (! NILP (base) && ! EQ (base, Vdefault_fontset))  
     FONTSET_FALLBACK (fontset) = make_fontset (frame, Qnil, Vdefault_fontset);  
699    return fontset;    return fontset;
700  }  }
701    
# Line 737  free_face_fontset (f, face) Line 740  free_face_fontset (f, face)
740       FRAME_PTR f;       FRAME_PTR f;
741       struct face *face;       struct face *face;
742  {  {
743      Lisp_Object fontset;
744    
745      fontset = AREF (Vfontset_table, face->fontset);
746      xassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
747      xassert (f == XFRAME (FONTSET_FRAME (fontset)));
748    ASET (Vfontset_table, face->fontset, Qnil);    ASET (Vfontset_table, face->fontset, Qnil);
749    if (face->fontset < next_fontset_id)    if (face->fontset < next_fontset_id)
750      next_fontset_id = face->fontset;      next_fontset_id = face->fontset;
751      if (! NILP (FONTSET_FALLBACK (fontset)))
752        {
753          int id = FONTSET_ID (FONTSET_FALLBACK (fontset));
754          
755          fontset = AREF (Vfontset_table, id);
756          xassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
757          xassert (f == XFRAME (FONTSET_FRAME (fontset)));
758          ASET (Vfontset_table, id, Qnil);
759          if (id < next_fontset_id)
760            next_fontset_id = face->fontset;
761        }
762  }  }
763    
764    
# Line 1415  FONT-SPEC is a vector, a cons, or a stri Line 1434  FONT-SPEC is a vector, a cons, or a stri
1434  }  }
1435    
1436    
1437  /* Number of fontsets created from a fontname automatically.  */  /* Alist of automatically created fontsets.  Each element is a cons
1438  static int n_auto_fontsets;     (FONTNAME . FONTSET-ID).  */
1439    static Lisp_Object auto_fontset_alist;
1440    
1441  int  int
1442  new_fontset_from_font_name (Lisp_Object fontname)  new_fontset_from_font_name (Lisp_Object fontname)
1443  {  {
1444      Lisp_Object val;
1445    Lisp_Object name;    Lisp_Object name;
1446    Lisp_Object vec;    Lisp_Object vec;
1447      int id;
1448    
1449    fontname = Fdowncase (fontname);    fontname = Fdowncase (fontname);
1450      val = Fassoc (fontname, auto_fontset_alist);
1451      if (CONSP (val))
1452        return XINT (XCDR (val));
1453    
1454    vec = split_font_name_into_vector (fontname);    vec = split_font_name_into_vector (fontname);
1455    if ( NILP (vec))    if ( NILP (vec))
1456      vec = Fmake_vector (make_number (14), build_string (""));      vec = Fmake_vector (make_number (14), build_string (""));
1457    ASET (vec, 12, build_string ("fontset"));    ASET (vec, 12, build_string ("fontset"));
1458    if (n_auto_fontsets == 0)    if (NILP (auto_fontset_alist))
1459      {      {
1460        ASET (vec, 13, build_string ("startup"));        ASET (vec, 13, build_string ("startup"));
1461        name = build_font_name_from_vector (vec);        name = build_font_name_from_vector (vec);
       n_auto_fontsets++;  
1462      }      }
1463    else    else
1464      {      {
1465        char temp[20];        char temp[20];
1466          int len = Flength (auto_fontset_alist);
1467    
1468        do {        sprintf (temp, "auto%d", len);
1469          sprintf (temp, "auto%d", n_auto_fontsets);        ASET (vec, 13, build_string (temp));
1470          ASET (vec, 13, build_string (temp));        name = build_font_name_from_vector (vec);
1471          name = build_font_name_from_vector (vec);      }
1472          n_auto_fontsets++;    name = Fnew_fontset (name, Fcons (Fcons (Qascii, Fcons (fontname, Qnil)),
1473        } while (fs_query_fontset (name, 0) >= 0);                                      Qnil));
1474      }    id = fs_query_fontset (name, 0);
1475    name = Fnew_fontset (name,    auto_fontset_alist
1476                         Fcons (Fcons (Qascii, Fcons (fontname, Qnil)), Qnil));      = Fcons (Fcons (fontname, make_number (id)), auto_fontset_alist);
1477    Vfontset_alias_alist = Fcons (Fcons (name, fontname), Vfontset_alias_alist);    return id;
   return fs_query_fontset (name, 0);  
1478  }  }
1479    
1480    
# Line 1718  DEFUN ("fontset-list", Ffontset_list, Sf Line 1743  DEFUN ("fontset-list", Ffontset_list, Sf
1743    return list;    return list;
1744  }  }
1745    
1746    
1747    #ifdef FONTSET_DEBUG
1748    
1749    Lisp_Object
1750    dump_fontset (fontset)
1751         Lisp_Object fontset;
1752    {
1753      Lisp_Object vec;
1754    
1755      vec = Fmake_vector (make_number (3), Qnil);
1756      ASET (vec, 0, FONTSET_ID (fontset));
1757    
1758      if (BASE_FONTSET_P (fontset))
1759        {
1760          ASET (vec, 1, FONTSET_NAME (fontset));
1761        }
1762      else
1763        {
1764          Lisp_Object frame;
1765    
1766          frame = FONTSET_FRAME (fontset);
1767          if (FRAMEP (frame))
1768            {
1769              FRAME_PTR f = XFRAME (frame);
1770    
1771              if (FRAME_LIVE_P (f))
1772                ASET (vec, 1, f->name);
1773              else
1774                ASET (vec, 1, Qt);
1775            }
1776          if (!NILP (FONTSET_FALLBACK (fontset)))
1777            ASET (vec, 2, FONTSET_ID (FONTSET_FALLBACK (fontset)));
1778        }
1779      return vec;
1780    }
1781    
1782    DEFUN ("fontset-list-all", Ffontset_list_all, Sfontset_list_all, 0, 0, 0,
1783           doc: /* Return a brief summary of all fontsets for debug use.  */)
1784         ()
1785    {
1786      Lisp_Object val;
1787      int i;
1788    
1789      for (i = 0, val = Qnil; i < ASIZE (Vfontset_table); i++)
1790        if (! NILP (AREF (Vfontset_table, i)))
1791          val = Fcons (dump_fontset (AREF (Vfontset_table, i)), val);
1792      return (Fnreverse (val));
1793    }
1794    #endif  /* FONTSET_DEBUG */
1795    
1796  void  void
1797  syms_of_fontset ()  syms_of_fontset ()
1798  {  {
# Line 1762  syms_of_fontset () Line 1837  syms_of_fontset ()
1837    AREF (Vfontset_table, 0) = Vdefault_fontset;    AREF (Vfontset_table, 0) = Vdefault_fontset;
1838    next_fontset_id = 1;    next_fontset_id = 1;
1839    
1840      auto_fontset_alist = Qnil;
1841      staticpro (&auto_fontset_alist);
1842    
1843    DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,    DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
1844                 doc: /*                 doc: /*
1845  Alist of fontname patterns vs the corresponding encoding and repertory info.  Alist of fontname patterns vs the corresponding encoding and repertory info.
# Line 1827  at the vertical center of lines.  */); Line 1905  at the vertical center of lines.  */);
1905    defsubr (&Sfontset_info);    defsubr (&Sfontset_info);
1906    defsubr (&Sfontset_font);    defsubr (&Sfontset_font);
1907    defsubr (&Sfontset_list);    defsubr (&Sfontset_list);
1908  }  #ifdef FONTSET_DEBUG
1909      defsubr (&Sfontset_list_all);
1910  Lisp_Object  #endif
 dump_fontset (fontset)  
      Lisp_Object fontset;  
 {  
   Lisp_Object val;  
   
   if (NILP (FONTSET_FALLBACK (fontset)))  
     val = Fcons (Fcons (intern ("fallback-id"), Qnil), Qnil);  
   else  
     val = Fcons (Fcons (intern ("fallback-id"),  
                         FONTSET_ID (FONTSET_FALLBACK (fontset))),  
                  Qnil);  
   if (NILP (FONTSET_BASE (fontset)))  
     val = Fcons (Fcons (intern ("base"), Qnil), val);  
   else  
     val = Fcons (Fcons (intern ("base"),  
                         FONTSET_NAME (FONTSET_BASE (fontset))),  
                  val);  
   val = Fcons (Fcons (intern ("name"), FONTSET_NAME (fontset)), val);  
   val = Fcons (Fcons (intern ("id"), FONTSET_ID (fontset)), val);  
   return val;  
1911  }  }

Legend:
Removed from v.1.77.4.4  
changed lines
  Added in v.1.77.4.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26