emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/font.c,v


From: Kenichi Handa
Subject: [Emacs-diffs] Changes to emacs/src/font.c,v
Date: Fri, 30 May 2008 02:34:47 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Kenichi Handa <handa>   08/05/30 02:34:46

Index: font.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/font.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- font.c      28 May 2008 11:47:01 -0000      1.30
+++ font.c      30 May 2008 02:34:46 -0000      1.31
@@ -296,7 +296,7 @@
 
   if (SYMBOLP (val))
     {
-      char *s;
+      unsigned char *s;
       Lisp_Object args[2], elt;
 
       /* At first try exact match.  */
@@ -306,12 +306,12 @@
            return ((XINT (AREF (AREF (table, i), 0)) << 8)
                    | (i << 4) | (j - 1));
       /* Try also with case-folding match.  */
-      s = (char *) SDATA (SYMBOL_NAME (val));
+      s = SDATA (SYMBOL_NAME (val));
       for (i = 0; i < len; i++)
        for (j = 1; j < ASIZE (AREF (table, i)); j++)
          {
            elt = AREF (AREF (table, i), j);
-           if (xstrcasecmp (s, (char *) SDATA (SYMBOL_NAME (elt))) == 0)
+           if (xstrcasecmp (s, SDATA (SYMBOL_NAME (elt))) == 0)
              return ((XINT (AREF (AREF (table, i), 0)) << 8)
                      | (i << 4) | (j - 1));
          }
@@ -1980,8 +1980,7 @@
        Lisp_Object entity_str = SYMBOL_NAME (AREF (entity, i));
        Lisp_Object spec_str = SYMBOL_NAME (spec_prop[i]);
 
-       if (xstrcasecmp ((char *) SDATA (spec_str),
-                         (char *) SDATA (entity_str)))
+       if (xstrcasecmp (SDATA (spec_str), SDATA (entity_str)))
          {
            if (i == FONT_FAMILY_INDEX && CONSP (alternate_families))
              {
@@ -1991,10 +1990,8 @@
                     j++, alternate_families = XCDR (alternate_families))
                  {
                    spec_str = XCAR (alternate_families);
-                   if (xstrcasecmp ((char *) SDATA (spec_str),
-                                     (char *) SDATA (entity_str)) == 0)
+                   if (xstrcasecmp (SDATA (spec_str), SDATA (entity_str)) == 0)
                      break;
-
                  }
                if (j > 3)
                  j = 3;
@@ -3095,6 +3092,7 @@
     f->font_driver_list = list;
   else
     font_driver_list = list;
+  if (! f)
   num_font_drivers++;
 }
 
@@ -4351,6 +4349,78 @@
 
 #endif /* FONT_DEBUG */
 
+DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0,
+       doc: /* Return information about a font named NAME on frame FRAME.
+If FRAME is omitted or nil, use the selected frame.
+The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,
+  HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,
+where
+  OPENED-NAME is the name used for opening the font,
+  FULL-NAME is the full name of the font,
+  SIZE is the maximum bound width of the font,
+  HEIGHT is the height of the font,
+  BASELINE-OFFSET is the upward offset pixels from ASCII baseline,
+  RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling
+    how to compose characters.
+If the named font is not yet loaded, return nil.  */)
+     (name, frame)
+     Lisp_Object name, frame;
+{
+  FRAME_PTR f;
+  struct font *font;
+  Lisp_Object info;
+  Lisp_Object font_object;
+
+  (*check_window_system_func) ();
+
+  if (! FONTP (name))
+    CHECK_STRING (name);
+  if (NILP (frame))
+    frame = selected_frame;
+  CHECK_LIVE_FRAME (frame);
+  f = XFRAME (frame);
+
+  if (STRINGP (name))
+    {
+      int fontset = fs_query_fontset (name, 0);
+
+      if (fontset >= 0)
+       name = fontset_ascii (fontset);
+      font_object = font_open_by_name (f, (char *) SDATA (name));
+    }
+  else if (FONT_OBJECT_P (name))
+    font_object = name;
+  else if (FONT_ENTITY_P (name))
+    font_object = font_open_entity (f, name, 0);
+  else
+    {
+      struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+      Lisp_Object entity = font_matching_entity (f, face->lface, name);
+
+      font_object = ! NILP (entity) ? font_open_entity (f, entity, 0) : Qnil;
+    }
+  if (NILP (font_object))
+    return Qnil;
+  font = XFONT_OBJECT (font_object);
+
+  info = Fmake_vector (make_number (7), Qnil);
+  XVECTOR (info)->contents[0] = AREF (font_object, FONT_NAME_INDEX);
+  XVECTOR (info)->contents[1] = AREF (font_object, FONT_NAME_INDEX);
+  XVECTOR (info)->contents[2] = make_number (font->pixel_size);
+  XVECTOR (info)->contents[3] = make_number (font->height);
+  XVECTOR (info)->contents[4] = make_number (font->baseline_offset);
+  XVECTOR (info)->contents[5] = make_number (font->relative_compose);
+  XVECTOR (info)->contents[6] = make_number (font->default_ascent);
+
+#if 0
+  /* As font_object is still in FONT_OBJLIST of the entity, we can't
+     close it now.  Perhaps, we should manage font-objects
+     by `reference-count'.  */
+  font_close_object (f, font_object);
+#endif
+  return info;
+}
+
 
 #define BUILD_STYLE_TABLE(TBL) \
   build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry))
@@ -4521,6 +4591,7 @@
   defsubr (&Sdraw_string);
 #endif
 #endif /* FONT_DEBUG */
+  defsubr (&Sfont_info);
 
   DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
               doc: /*




reply via email to

[Prev in Thread] Current Thread [Next in Thread]