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

Diff of /emacs/src/w32fns.c

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

revision 1.219.2.1 by jasonr, Sat Oct 11 22:35:25 2003 UTC revision 1.219.2.2 by jasonr, Sun Oct 12 22:47:33 2003 UTC
# Line 4791  w32_load_system_font (f,fontname,size) Line 4791  w32_load_system_font (f,fontname,size)
4791      fontp->name = (char *) xmalloc (strlen (fontname) + 1);      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
4792      bcopy (fontname, fontp->name, strlen (fontname) + 1);      bcopy (fontname, fontp->name, strlen (fontname) + 1);
4793    
4794      fontp->charset = charset_unicode;      fontp->charset = -1;
4795      charset = xlfd_charset_of_font (fontname);      charset = xlfd_charset_of_font (fontname);
4796    
4797    /* Cache the W32 codepage for a font.  This makes w32_encode_char    /* Cache the W32 codepage for a font.  This makes w32_encode_char
# Line 4970  x_to_w32_charset (lpcs) Line 4970  x_to_w32_charset (lpcs)
4970    if (strncmp (lpcs, "*-#", 3) == 0)    if (strncmp (lpcs, "*-#", 3) == 0)
4971      return atoi (lpcs + 3);      return atoi (lpcs + 3);
4972    
4973      /* All Windows fonts qualify as unicode.  */
4974      if (!strncmp (lpcs, "iso10646", 8))
4975        return DEFAULT_CHARSET;
4976    
4977    /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5".  */    /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5".  */
4978    charset = alloca (len + 1);    charset = alloca (len + 1);
4979    strcpy (charset, lpcs);    strcpy (charset, lpcs);
4980    lpcs = strchr (charset, '*');    lpcs = strchr (charset, '*');
4981    if (lpcs)    if (lpcs)
4982      *lpcs = 0;      *lpcs = '\0';
4983    
4984    /* Look through w32-charset-info-alist for the character set.    /* Look through w32-charset-info-alist for the character set.
4985       Format of each entry is       Format of each entry is
# Line 5043  x_to_w32_charset (lpcs) Line 5047  x_to_w32_charset (lpcs)
5047    
5048    
5049  static char *  static char *
5050  w32_to_x_charset (fncharset)  w32_to_x_charset (fncharset, matching)
5051      int fncharset;      int fncharset;
5052        char *matching;
5053  {  {
5054    static char buf[32];    static char buf[32];
5055    Lisp_Object charset_type;    Lisp_Object charset_type;
5056      int match_len = 0;
5057    
5058      if (matching)
5059        {
5060          /* If fully specified, accept it as it is.  Otherwise use a
5061             substring match. */
5062          char *wildcard = strchr (matching, '*');
5063          if (wildcard)
5064            *wildcard = '\0';
5065          else if (strchr (matching, '-'))
5066            return matching;
5067    
5068          match_len = strlen (matching);
5069        }
5070    
5071    switch (fncharset)    switch (fncharset)
5072      {      {
# Line 5132  w32_to_x_charset (fncharset) Line 5151  w32_to_x_charset (fncharset)
5151    {    {
5152      Lisp_Object rest;      Lisp_Object rest;
5153      char * best_match = NULL;      char * best_match = NULL;
5154        int matching_found = 0;
5155    
5156      /* Look through w32-charset-info-alist for the character set.      /* Look through w32-charset-info-alist for the character set.
5157         Prefer ISO codepages, and prefer lower numbers in the ISO         Prefer ISO codepages, and prefer lower numbers in the ISO
# Line 5167  w32_to_x_charset (fncharset) Line 5187  w32_to_x_charset (fncharset)
5187              /* If we don't have a match already, then this is the              /* If we don't have a match already, then this is the
5188                 best.  */                 best.  */
5189              if (!best_match)              if (!best_match)
5190                best_match = x_charset;                {
5191              /* If this is an ISO codepage, and the best so far isn't,                  best_match = x_charset;
5192                 then this is better.  */                  if (matching && !strnicmp (x_charset, matching, match_len))
5193              else if (strnicmp (best_match, "iso", 3) != 0                    matching_found = 1;
5194                       && strnicmp (x_charset, "iso", 3) == 0)                }
5195                best_match = x_charset;              /* If we already found a match for MATCHING, then
5196                   only consider other matches.  */
5197                else if (matching_found
5198                         && strnicmp (x_charset, matching, match_len))
5199                  continue;
5200                /* If this matches what we want, and the best so far doesn't,
5201                   then this is better.  */
5202                else if (!matching_found && matching
5203                         && !strnicmp (x_charset, matching, match_len))
5204                  {
5205                    best_match = x_charset;
5206                    matching_found = 1;
5207                  }
5208                /* If this is fully specified, and the best so far isn't,
5209                   then this is better.  */
5210                else if ((!strchr (best_match, '-') && strchr (x_charset, '-'))
5211                /* If this is an ISO codepage, and the best so far isn't,
5212                   then this is better, but only if it fully specifies the
5213                   encoding.  */
5214                    || (strnicmp (best_match, "iso", 3) != 0
5215                        && strnicmp (x_charset, "iso", 3) == 0
5216                        && strchr (x_charset, '-')))
5217                    best_match = x_charset;
5218              /* If both are ISO8859 codepages, choose the one with the              /* If both are ISO8859 codepages, choose the one with the
5219                 lowest number in the encoding field.  */                 lowest number in the encoding field.  */
5220              else if (strnicmp (best_match, "iso8859-", 8) == 0              else if (strnicmp (best_match, "iso8859-", 8) == 0
# Line 5193  w32_to_x_charset (fncharset) Line 5235  w32_to_x_charset (fncharset)
5235          return buf;          return buf;
5236        }        }
5237    
5238      strncpy(buf, best_match, 31);      strncpy (buf, best_match, 31);
5239        /* If the charset is not fully specified, put -0 on the end.  */
5240        if (!strchr (best_match, '-'))
5241          {
5242            int pos = strlen (best_match);
5243            /* Charset specifiers shouldn't be very long.  If it is a made
5244               up one, truncating it should not do any harm since it isn't
5245               recognized anyway.  */
5246            if (pos > 29)
5247              pos = 29;
5248            strcpy (buf + pos, "-0");
5249          }
5250      buf[31] = '\0';      buf[31] = '\0';
5251      return buf;      return buf;
5252    }    }
# Line 5293  w32_to_all_x_charsets (fncharset) Line 5346  w32_to_all_x_charsets (fncharset)
5346    {    {
5347      Lisp_Object rest;      Lisp_Object rest;
5348      /* Look through w32-charset-info-alist for the character set.      /* Look through w32-charset-info-alist for the character set.
5349         Only return charsets for codepages which are installed.         Only return fully specified charsets for codepages which are
5350           installed.
5351    
5352         Format of each entry in Vw32_charset_info_alist is         Format of each entry in Vw32_charset_info_alist is
5353           (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).           (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
# Line 5316  w32_to_all_x_charsets (fncharset) Line 5370  w32_to_all_x_charsets (fncharset)
5370          w32_charset = XCAR (XCDR (this_entry));          w32_charset = XCAR (XCDR (this_entry));
5371          codepage = XCDR (XCDR (this_entry));          codepage = XCDR (XCDR (this_entry));
5372    
5373            if (!strchr (SDATA (x_charset), '-'))
5374              continue;
5375    
5376          /* Look for Same charset and a valid codepage (or non-int          /* Look for Same charset and a valid codepage (or non-int
5377             which means ignore).  */             which means ignore).  */
5378          if (w32_charset == charset_type          if (w32_charset == charset_type
# Line 5346  w32_codepage_for_font (char *fontname) Line 5403  w32_codepage_for_font (char *fontname)
5403    Lisp_Object codepage, entry;    Lisp_Object codepage, entry;
5404    char *charset_str, *charset, *end;    char *charset_str, *charset, *end;
5405    
   if (NILP (Vw32_charset_info_alist))  
     return CP_DEFAULT;  
   
5406    /* Extract charset part of font string.  */    /* Extract charset part of font string.  */
5407    charset = xlfd_charset_of_font (fontname);    charset = xlfd_charset_of_font (fontname);
5408    
# Line 5374  w32_codepage_for_font (char *fontname) Line 5428  w32_codepage_for_font (char *fontname)
5428          *end = '\0';          *end = '\0';
5429        }        }
5430    
5431      if (!strcmp (charset, "iso10646"))
5432        return CP_UNICODE;
5433    
5434      if (NILP (Vw32_charset_info_alist))
5435        return CP_DEFAULT;
5436    
5437    entry = Fassoc (build_string(charset), Vw32_charset_info_alist);    entry = Fassoc (build_string(charset), Vw32_charset_info_alist);
5438    if (NILP (entry))    if (NILP (entry))
5439      return CP_UNKNOWN;      return CP_UNKNOWN;
# Line 5474  w32_to_x_font (lplogfont, lpxstr, len, s Line 5534  w32_to_x_font (lplogfont, lpxstr, len, s
5534               ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH)               ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH)
5535               ? 'p' : 'c',                            /* spacing */               ? 'p' : 'c',                            /* spacing */
5536               width_pixels,                           /* avg width */               width_pixels,                           /* avg width */
5537               specific_charset ? specific_charset               w32_to_x_charset (lplogfont->lfCharSet, specific_charset)
              : w32_to_x_charset (lplogfont->lfCharSet)  
5538               /* charset registry and encoding */               /* charset registry and encoding */
5539               );               );
5540    
# Line 5946  enum_font_cb2 (lplf, lptm, FontType, lpe Line 6005  enum_font_cb2 (lplf, lptm, FontType, lpe
6005          if (charset          if (charset
6006              && strncmp (charset, "*-*", 3) != 0              && strncmp (charset, "*-*", 3) != 0
6007              && lpef->logfont.lfCharSet == DEFAULT_CHARSET              && lpef->logfont.lfCharSet == DEFAULT_CHARSET
6008              && strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET)) != 0)              && strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET, NULL)) != 0)
6009            return 1;            return 1;
6010        }        }
6011    
6012      if (charset)      if (charset)
6013        charset_list = Fcons (build_string (charset), Qnil);        charset_list = Fcons (build_string (charset), Qnil);
6014      else      else
6015        charset_list = w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet);        /* Always prefer unicode.  */
6016          charset_list
6017            = Fcons (build_string ("iso10646-1"),
6018                     w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet));
6019    
6020      /* Loop through the charsets.  */      /* Loop through the charsets.  */
6021      for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list))      for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list))
# Line 5961  enum_font_cb2 (lplf, lptm, FontType, lpe Line 6023  enum_font_cb2 (lplf, lptm, FontType, lpe
6023          Lisp_Object this_charset = Fcar (charset_list);          Lisp_Object this_charset = Fcar (charset_list);
6024          charset = SDATA (this_charset);          charset = SDATA (this_charset);
6025    
6026            enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
6027                                         charset, width);
6028    
6029          /* List bold and italic variations if w32-enable-synthesized-fonts          /* List bold and italic variations if w32-enable-synthesized-fonts
6030             is non-nil and this is a plain font.  */             is non-nil and this is a plain font.  */
6031          if (w32_enable_synthesized_fonts          if (w32_enable_synthesized_fonts
6032              && lplf->elfLogFont.lfWeight == FW_NORMAL              && lplf->elfLogFont.lfWeight == FW_NORMAL
6033              && lplf->elfLogFont.lfItalic == FALSE)              && lplf->elfLogFont.lfItalic == FALSE)
6034            {            {
             enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),  
                                          charset, width);  
6035              /* bold.  */              /* bold.  */
6036              lplf->elfLogFont.lfWeight = FW_BOLD;              lplf->elfLogFont.lfWeight = FW_BOLD;
6037              enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),              enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
# Line 5982  enum_font_cb2 (lplf, lptm, FontType, lpe Line 6045  enum_font_cb2 (lplf, lptm, FontType, lpe
6045              enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),              enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
6046                                           charset, width);                                           charset, width);
6047            }            }
         else  
           enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),  
                                        charset, width);  
6048        }        }
6049    }    }
6050    

Legend:
Removed from v.1.219.2.1  
changed lines
  Added in v.1.219.2.2

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