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

Diff of /emacs/src/xfns.c

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

revision 1.633 by jhd, Thu Mar 10 19:08:01 2005 UTC revision 1.634 by monnier, Sat Mar 12 23:25:42 2005 UTC
# Line 1959  static XIMStyle supported_xim_styles[] = Line 1959  static XIMStyle supported_xim_styles[] =
1959    
1960  /* Create an X fontset on frame F with base font name BASE_FONTNAME.  */  /* Create an X fontset on frame F with base font name BASE_FONTNAME.  */
1961    
1962    char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
1963    
1964    char *
1965    xic_create_fontsetname (base_fontname)
1966         char *base_fontname;
1967    {
1968      /* Make a fontset name from the base font name.  */
1969      if (xic_defaut_fontset == base_fontname)
1970        /* There is no base font name, use the default.  */
1971        return base_fontname;
1972      else
1973        {
1974          /* Make a fontset name from the base font name.
1975             The font set will be made of the following elements:
1976             - the base font.
1977             - the base font where the charset spec is replaced by -*-*.
1978             - the same but with the family also replaced with -*-*-.  */
1979          char *p = base_fontname;
1980          char *fontsetname;
1981          int i;
1982            
1983          for (i = 0; *p; p++)
1984            if (*p == '-') i++;
1985          if (i != 14)
1986            { /* As the font name doesn't conform to XLFD, we can't
1987                 modify it to generalize it to allcs and allfamilies.
1988                 Use the specified font plus the default.  */
1989              int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 2;
1990              fontsetname = xmalloc (len);
1991              bzero (fontsetname, len);
1992              strcpy (fontsetname, base_fontname);
1993              strcat (fontsetname, ",");
1994              strcat (fontsetname, xic_defaut_fontset);
1995            }
1996          else
1997            {
1998              int len;
1999              char *p1 = NULL;
2000              char *font_allcs = NULL;
2001              char *font_allfamilies = NULL;
2002              char *allcs = "*-*-*-*-*-*-*";
2003              char *allfamilies = "-*-*-";
2004              
2005              for (i = 0, p = base_fontname; i < 8; p++)
2006                {
2007                  if (*p == '-')
2008                    {
2009                      i++;
2010                      if (i == 3)
2011                        p1 = p + 1;
2012                    }
2013                }
2014              /* Build the font spec that matches all charsets.  */
2015              len = p - base_fontname + strlen (allcs) + 1;
2016              font_allcs = (char *) alloca (len);
2017              bzero (font_allcs, len);
2018              bcopy (base_fontname, font_allcs, p - base_fontname);
2019              strcat (font_allcs, allcs);
2020    
2021              /* Build the font spec that matches all families.  */
2022              len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1;
2023              font_allfamilies = (char *) alloca (len);
2024              bzero (font_allfamilies, len);
2025              strcpy (font_allfamilies, allfamilies);
2026              bcopy (p1, font_allfamilies + (strlen (allfamilies)), p - p1);
2027              strcat (font_allfamilies, allcs);
2028    
2029              /* Build the actual font set name.  */
2030              len = strlen (base_fontname) + strlen (font_allcs)
2031                + strlen (font_allfamilies) + 3;
2032              fontsetname = xmalloc (len);
2033              bzero (fontsetname, len);
2034              strcpy (fontsetname, base_fontname);
2035              strcat (fontsetname, ",");
2036              strcat (fontsetname, font_allcs);
2037              strcat (fontsetname, ",");
2038              strcat (fontsetname, font_allfamilies);
2039            }
2040          return fontsetname;
2041        }
2042    }
2043    
2044  static XFontSet  static XFontSet
2045  xic_create_xfontset (f, base_fontname)  xic_create_xfontset (f, base_fontname)
2046       struct frame *f;       struct frame *f;
# Line 1970  xic_create_xfontset (f, base_fontname) Line 2052  xic_create_xfontset (f, base_fontname)
2052    char *def_string;    char *def_string;
2053    Lisp_Object rest, frame;    Lisp_Object rest, frame;
2054    
2055      if (!base_fontname)
2056        base_fontname = xic_defaut_fontset;
2057    
2058    /* See if there is another frame already using same fontset.  */    /* See if there is another frame already using same fontset.  */
2059    FOR_EACH_FRAME (rest, frame)    FOR_EACH_FRAME (rest, frame)
2060      {      {
# Line 1986  xic_create_xfontset (f, base_fontname) Line 2071  xic_create_xfontset (f, base_fontname)
2071    
2072    if (!xfs)    if (!xfs)
2073      {      {
2074          char *fontsetname = xic_create_fontsetname (base_fontname);
2075    
2076        /* New fontset.  */        /* New fontset.  */
2077        xfs = XCreateFontSet (FRAME_X_DISPLAY (f),        xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
2078                              base_fontname, &missing_list,                              fontsetname, &missing_list,
2079                              &missing_count, &def_string);                              &missing_count, &def_string);
2080        if (missing_list)        if (missing_list)
2081          XFreeStringList (missing_list);          XFreeStringList (missing_list);
2082          if (fontsetname != base_fontname)
2083            xfree (fontsetname);
2084      }      }
2085    
2086    if (FRAME_XIC_BASE_FONTNAME (f))    if (FRAME_XIC_BASE_FONTNAME (f))
# Line 2073  create_frame_xic (f) Line 2162  create_frame_xic (f)
2162    if (FRAME_XIC (f))    if (FRAME_XIC (f))
2163      return;      return;
2164    
2165      /* Create X fontset. */
2166      xfs = xic_create_xfontset
2167        (f, (FRAME_FONTSET (f) < 0) ? NULL
2168            : (char *) SDATA (fontset_ascii (FRAME_FONTSET (f))));
2169    
2170    xim = FRAME_X_XIM (f);    xim = FRAME_X_XIM (f);
2171    if (xim)    if (xim)
2172      {      {
# Line 2080  create_frame_xic (f) Line 2174  create_frame_xic (f)
2174        XPoint spot;        XPoint spot;
2175        XVaNestedList preedit_attr;        XVaNestedList preedit_attr;
2176        XVaNestedList status_attr;        XVaNestedList status_attr;
       char *base_fontname;  
       int fontset;  
2177    
2178        s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;        s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
2179        spot.x = 0; spot.y = 1;        spot.x = 0; spot.y = 1;
       /* Create X fontset. */  
       fontset = FRAME_FONTSET (f);  
       if (fontset < 0)  
         base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";  
       else  
         {  
           /* Determine the base fontname from the ASCII font name of  
              FONTSET.  */  
           char *ascii_font = (char *) SDATA (fontset_ascii (fontset));  
           char *p = ascii_font;  
           int i;  
   
           for (i = 0; *p; p++)  
             if (*p == '-') i++;  
           if (i != 14)  
             /* As the font name doesn't conform to XLFD, we can't  
                modify it to get a suitable base fontname for the  
                frame.  */  
             base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";  
           else  
             {  
               int len = strlen (ascii_font) + 1;  
               char *p1 = NULL;  
   
               for (i = 0, p = ascii_font; i < 8; p++)  
                 {  
                   if (*p == '-')  
                     {  
                       i++;  
                       if (i == 3)  
                         p1 = p + 1;  
                     }  
                 }  
               base_fontname = (char *) alloca (len);  
               bzero (base_fontname, len);  
               strcpy (base_fontname, "-*-*-");  
               bcopy (p1, base_fontname + 5, p - p1);  
               strcat (base_fontname, "*-*-*-*-*-*-*");  
             }  
         }  
       xfs = xic_create_xfontset (f, base_fontname);  
2180    
2181        /* Determine XIC style.  */        /* Determine XIC style.  */
2182        if (xic_style == 0)        if (xic_style == 0)

Legend:
Removed from v.1.633  
changed lines
  Added in v.1.634

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