changeset 17999:5e325c8057c8

(fs_load_font): Before using a fontset, be sure to load the ASCII font of the fontset. Size and height of a fontset is set to the same as those of the ASCII font of the fontset. Use macro FONT_ENCODING_NOT_DECIDED.
author Kenichi Handa <handa@m17n.org>
date Wed, 28 May 1997 04:36:21 +0000
parents 9b98ddd07fe5
children 2873e0dabbc1
files src/fontset.c
diffstat 1 files changed, 51 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/fontset.c	Wed May 28 04:36:20 1997 +0000
+++ b/src/fontset.c	Wed May 28 04:36:21 1997 +0000
@@ -149,11 +149,23 @@
     /* No way to get fontname.  */
     return 0;
 
-  /* If a fontset is specified and we have already loaded some fonts
-     in the fontset, we need a font of appropriate size to be used
-     with the fonts.  */
-  if (fontsetp && fontsetp->size)
-    size = fontsetp->size * CHARSET_WIDTH (charset);
+  /* If CHARSET is not ASCII and FONTSET is specified, we must load a
+     font of appropriate size to be used with other fonts in this
+     fontset.  */
+  if (charset != CHARSET_ASCII && fontsetp)
+    {
+      /* If we have not yet loaded ASCII font of FONTSET, we must load
+	 it now to decided the size and height of this fontset.  */
+      if (fontsetp->size == 0)
+	{
+	  fontp = fs_load_font (f, font_table, CHARSET_ASCII, 0, fontset);
+	  if (!fontp)
+	    /* Any fontset should contain avairable ASCII.  */
+	    return 0;
+	}
+      /* Now we have surely decided the size of this fontset.  */
+      size = fontsetp->size * CHARSET_WIDTH (charset);
+    }
 
   fontp = (*load_font_func) (f, fontname, size);
 
@@ -168,7 +180,7 @@
      not set by (*load_font_func).  */
   fontp->charset = charset;
 
-  if (fontp->encoding[1] != 4)
+  if (fontp->encoding[1] != FONT_ENCODING_NOT_DECIDED)
     {
       /* The font itself tells which code points to be used.  Use this
 	 encoding for all other charsets.  */
@@ -225,46 +237,51 @@
 	}
     }
 
+  /* If FONTSET is specified, setup various fields of it.  */
   if (fontsetp)
     {
       fontsetp->font_indexes[charset] = fontp->font_idx;
-      if (fontsetp->size == 0)
-	fontsetp->size = fontp->size / CHARSET_WIDTH (charset);
-
-      if (charset == CHARSET_ASCII
-	  && fontsetp->size != fontp->size)
+      if (charset == CHARSET_ASCII)
 	{
-	  /* When loading ASCII font of the different size from the
-	     size of FONTSET, we have to update the size of FONTSET.
-	     Since changing the size of FONTSET may make some fonts
-	     already loaded inappropriate to be used in FONTSET, we
-	     must delete the record of such fonts.  In that case, we
-	     also have to calculate the height of FONTSET from the
-	     remaining fonts.  */
-	  int i;
+	  /* Decide or change the size and height of this fontset.  */
+	  if (fontsetp->size == 0)
+	    {
+	      fontsetp->size = fontp->size;
+	      fontsetp->height = fontp->height;
+	    }
+	  else if (fontsetp->size != fontp->size
+		   || fontsetp->height != fontp->height)
+	    {
+	      /* When loading ASCII font of the different size from
+		 the size of FONTSET, we have to update the size of
+		 FONTSET.  Since changing the size of FONTSET may make
+		 some fonts already loaded inappropriate to be used in
+		 FONTSET, we must delete the record of such fonts.  In
+		 that case, we also have to calculate the height of
+		 FONTSET from the remaining fonts.  */
+	      int i;
 
-	  fontsetp->size = fontp->size;
-	  fontsetp->height = fontp->height;
-	  for (i = CHARSET_ASCII + 1; i <= MAX_CHARSET; i++)
-	    {
-	      font_idx = fontsetp->font_indexes[i];
-	      if (font_idx >= 0)
+	      fontsetp->size = fontp->size;
+	      fontsetp->height = fontp->height;
+	      for (i = CHARSET_ASCII + 1; i <= MAX_CHARSET; i++)
 		{
-		  struct font_info *fontp2 = font_table + font_idx;
+		  font_idx = fontsetp->font_indexes[i];
+		  if (font_idx >= 0)
+		    {
+		      struct font_info *fontp2 = font_table + font_idx;
 
-		  if (fontp2->size != fontp->size * CHARSET_WIDTH (i))
-		    fontsetp->font_indexes[i] = FONT_NOT_OPENED;
-		  /* The following code should be disabled until Emacs
-		     supports variable height lines.  */
+		      if (fontp2->size != fontp->size * CHARSET_WIDTH (i))
+			fontsetp->font_indexes[i] = FONT_NOT_OPENED;
+		      /* The following code should be disabled until
+			 Emacs supports variable height lines.  */
 #if 0
-		  else if (fontsetp->height < fontp->height)
-		    fontsetp->height = fontp->height;
+		      else if (fontsetp->height < fontp->height)
+			fontsetp->height = fontp->height;
 #endif
+		    }
 		}
 	    }
 	}
-      else if (fontsetp->height < fontp->height)
-	fontsetp->height = fontp->height;
     }
 
   return fontp;