changeset 90510:69dc5ab6d693

(ftfont_list): Handle QCotf property. (ftfont_open): Set charset related members to -1.
author Kenichi Handa <handa@m17n.org>
date Mon, 03 Jul 2006 00:51:17 +0000
parents c1ec6b950928
children 2cd8e24f656a
files src/ftfont.c
diffstat 1 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ftfont.c	Mon Jul 03 00:50:10 2006 +0000
+++ b/src/ftfont.c	Mon Jul 03 00:51:17 2006 +0000
@@ -315,6 +315,7 @@
   double dpi = -1;
   int spacing = -1;
   int scalable = -1;
+  char otf_script[15];		/* For "otlayout\:XXXX" */
   
   val = null_vector;
 
@@ -348,8 +349,11 @@
 
   extra = AREF (spec, FONT_EXTRA_INDEX);
   font_name = Qnil;
+  otf_script[0] = '\0';
   if (CONSP (extra))
     {
+      Lisp_Object script = Qnil;
+
       tmp = assq_no_quit (QCname, extra);
       if (CONSP (tmp))
 	{
@@ -358,8 +362,15 @@
 	    return val;
 	}
       tmp = assq_no_quit (QCotf, extra);
-      if (! NILP (tmp))
-	return val;
+      if (CONSP (tmp) && SYMBOLP (XCDR (tmp)))
+	{
+	  tmp = XCDR (tmp);
+	  script = assq_no_quit (tmp, Votf_script_alist);
+	  if (CONSP (script) && SYMBOLP (XCDR (script)))
+	    script = XCDR (script);
+	  tmp = SYMBOL_NAME (tmp);
+	  sprintf (otf_script, "otlayout:%s", (char *) SDATA (tmp));
+	}
       tmp = assq_no_quit (QClanguage, extra);
       if (CONSP (tmp))
 	{
@@ -382,11 +393,12 @@
 	      }
 	}
       tmp = assq_no_quit (QCscript, extra);
-      if (CONSP (tmp) && ! charset)
+      if (CONSP (tmp))
+	script = XCDR (tmp);
+      if (! NILP (script) && ! charset)
 	{
-	  Lisp_Object script = XCDR (tmp);
-	  Lisp_Object chars = assq_no_quit (script,
-					    Vscript_representative_chars);
+	  Lisp_Object chars
+	    = assq_no_quit (script, Vscript_representative_chars);
 
 	  if (CONSP (chars))
 	    {
@@ -461,6 +473,8 @@
 			     FC_CHARSET, FC_FILE, NULL);
   if (! objset)
     goto err;
+  if (otf_script[0] && ! FcObjectSetAdd (objset, FC_CAPABILITY))
+    goto err;
 
   fontset = FcFontList (NULL, pattern, objset);
   if (! fontset)
@@ -501,6 +515,15 @@
 			  || this > FC_WEIGHT_MEDIUM)))
 		continue;
 	    }
+	  if (otf_script[0])
+	    {
+	      FcChar8 *this;
+
+	      if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0,
+				      &this) != FcResultMatch
+		  || ! strstr ((char *) this, otf_script))
+		continue;
+	    }
 	  entity = ftfont_pattern_entity (fontset->fonts[i], frame, registry);
 	  if (! NILP (entity))
 	    val = Fcons (entity, val);
@@ -652,6 +675,7 @@
   font->font.name = font->font.full_name = NULL;
   font->file_name = (char *) file;
   font->font.size = ft_face->size->metrics.max_advance >> 6;
+  font->font.charset = font->encoding_charset = font->repertory_charset = -1;
   font->ascent = ft_face->size->metrics.ascender >> 6;
   font->descent = - ft_face->size->metrics.descender >> 6;
   font->font.height = ft_face->size->metrics.height >> 6;