emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/w32fns.c [emacs-unicode-2]


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/src/w32fns.c [emacs-unicode-2]
Date: Sun, 12 Oct 2003 18:47:34 -0400

Index: emacs/src/w32fns.c
diff -c emacs/src/w32fns.c:1.219.2.1 emacs/src/w32fns.c:1.219.2.2
*** emacs/src/w32fns.c:1.219.2.1        Sat Oct 11 18:35:25 2003
--- emacs/src/w32fns.c  Sun Oct 12 18:47:33 2003
***************
*** 4791,4797 ****
      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
      bcopy (fontname, fontp->name, strlen (fontname) + 1);
  
!     fontp->charset = charset_unicode;
      charset = xlfd_charset_of_font (fontname);
  
    /* Cache the W32 codepage for a font.  This makes w32_encode_char
--- 4791,4797 ----
      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
      bcopy (fontname, fontp->name, strlen (fontname) + 1);
  
!     fontp->charset = -1;
      charset = xlfd_charset_of_font (fontname);
  
    /* Cache the W32 codepage for a font.  This makes w32_encode_char
***************
*** 4970,4981 ****
    if (strncmp (lpcs, "*-#", 3) == 0)
      return atoi (lpcs + 3);
  
    /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5".  */
    charset = alloca (len + 1);
    strcpy (charset, lpcs);
    lpcs = strchr (charset, '*');
    if (lpcs)
!     *lpcs = 0;
  
    /* Look through w32-charset-info-alist for the character set.
       Format of each entry is
--- 4970,4985 ----
    if (strncmp (lpcs, "*-#", 3) == 0)
      return atoi (lpcs + 3);
  
+   /* All Windows fonts qualify as unicode.  */
+   if (!strncmp (lpcs, "iso10646", 8))
+     return DEFAULT_CHARSET;
+ 
    /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5".  */
    charset = alloca (len + 1);
    strcpy (charset, lpcs);
    lpcs = strchr (charset, '*');
    if (lpcs)
!     *lpcs = '\0';
  
    /* Look through w32-charset-info-alist for the character set.
       Format of each entry is
***************
*** 5043,5053 ****
  
  
  static char *
! w32_to_x_charset (fncharset)
      int fncharset;
  {
    static char buf[32];
    Lisp_Object charset_type;
  
    switch (fncharset)
      {
--- 5047,5072 ----
  
  
  static char *
! w32_to_x_charset (fncharset, matching)
      int fncharset;
+     char *matching;
  {
    static char buf[32];
    Lisp_Object charset_type;
+   int match_len = 0;
+ 
+   if (matching)
+     {
+       /* If fully specified, accept it as it is.  Otherwise use a
+        substring match. */
+       char *wildcard = strchr (matching, '*');
+       if (wildcard)
+       *wildcard = '\0';
+       else if (strchr (matching, '-'))
+       return matching;
+ 
+       match_len = strlen (matching);
+     }
  
    switch (fncharset)
      {
***************
*** 5132,5137 ****
--- 5151,5157 ----
    {
      Lisp_Object rest;
      char * best_match = NULL;
+     int matching_found = 0;
  
      /* Look through w32-charset-info-alist for the character set.
         Prefer ISO codepages, and prefer lower numbers in the ISO
***************
*** 5167,5178 ****
              /* If we don't have a match already, then this is the
                 best.  */
              if (!best_match)
!               best_match = x_charset;
!             /* If this is an ISO codepage, and the best so far isn't,
!                then this is better.  */
!             else if (strnicmp (best_match, "iso", 3) != 0
!                      && strnicmp (x_charset, "iso", 3) == 0)
!               best_match = x_charset;
              /* If both are ISO8859 codepages, choose the one with the
                 lowest number in the encoding field.  */
              else if (strnicmp (best_match, "iso8859-", 8) == 0
--- 5187,5220 ----
              /* If we don't have a match already, then this is the
                 best.  */
              if (!best_match)
!             {
!               best_match = x_charset;
!               if (matching && !strnicmp (x_charset, matching, match_len))
!                 matching_found = 1;
!             }
!           /* If we already found a match for MATCHING, then
!              only consider other matches.  */
!           else if (matching_found
!                    && strnicmp (x_charset, matching, match_len))
!             continue;
!           /* If this matches what we want, and the best so far doesn't,
!              then this is better.  */
!           else if (!matching_found && matching
!                    && !strnicmp (x_charset, matching, match_len))
!             {
!               best_match = x_charset;
!               matching_found = 1;
!             }
!           /* If this is fully specified, and the best so far isn't,
!              then this is better.  */
!           else if ((!strchr (best_match, '-') && strchr (x_charset, '-'))
!           /* If this is an ISO codepage, and the best so far isn't,
!              then this is better, but only if it fully specifies the
!              encoding.  */
!               || (strnicmp (best_match, "iso", 3) != 0
!                   && strnicmp (x_charset, "iso", 3) == 0
!                   && strchr (x_charset, '-')))
!               best_match = x_charset;
              /* If both are ISO8859 codepages, choose the one with the
                 lowest number in the encoding field.  */
              else if (strnicmp (best_match, "iso8859-", 8) == 0
***************
*** 5193,5199 ****
          return buf;
        }
  
!     strncpy(buf, best_match, 31);
      buf[31] = '\0';
      return buf;
    }
--- 5235,5252 ----
          return buf;
        }
  
!     strncpy (buf, best_match, 31);
!     /* If the charset is not fully specified, put -0 on the end.  */
!     if (!strchr (best_match, '-'))
!       {
!       int pos = strlen (best_match);
!       /* Charset specifiers shouldn't be very long.  If it is a made
!          up one, truncating it should not do any harm since it isn't
!          recognized anyway.  */
!       if (pos > 29)
!         pos = 29;
!       strcpy (buf + pos, "-0");
!       }
      buf[31] = '\0';
      return buf;
    }
***************
*** 5293,5299 ****
    {
      Lisp_Object rest;
      /* Look through w32-charset-info-alist for the character set.
!        Only return charsets for codepages which are installed.
  
         Format of each entry in Vw32_charset_info_alist is
           (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
--- 5346,5353 ----
    {
      Lisp_Object rest;
      /* Look through w32-charset-info-alist for the character set.
!        Only return fully specified charsets for codepages which are
!        installed.
  
         Format of each entry in Vw32_charset_info_alist is
           (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
***************
*** 5316,5321 ****
--- 5370,5378 ----
          w32_charset = XCAR (XCDR (this_entry));
          codepage = XCDR (XCDR (this_entry));
  
+       if (!strchr (SDATA (x_charset), '-'))
+         continue;
+ 
          /* Look for Same charset and a valid codepage (or non-int
             which means ignore).  */
          if (w32_charset == charset_type
***************
*** 5346,5354 ****
    Lisp_Object codepage, entry;
    char *charset_str, *charset, *end;
  
-   if (NILP (Vw32_charset_info_alist))
-     return CP_DEFAULT;
- 
    /* Extract charset part of font string.  */
    charset = xlfd_charset_of_font (fontname);
  
--- 5403,5408 ----
***************
*** 5374,5379 ****
--- 5428,5439 ----
          *end = '\0';
        }
  
+   if (!strcmp (charset, "iso10646"))
+     return CP_UNICODE;
+ 
+   if (NILP (Vw32_charset_info_alist))
+     return CP_DEFAULT;
+ 
    entry = Fassoc (build_string(charset), Vw32_charset_info_alist);
    if (NILP (entry))
      return CP_UNKNOWN;
***************
*** 5474,5481 ****
             ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH)
               ? 'p' : 'c',                            /* spacing */
             width_pixels,                           /* avg width */
!            specific_charset ? specific_charset
!              : w32_to_x_charset (lplogfont->lfCharSet)
               /* charset registry and encoding */
             );
  
--- 5534,5540 ----
             ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH)
               ? 'p' : 'c',                            /* spacing */
             width_pixels,                           /* avg width */
!              w32_to_x_charset (lplogfont->lfCharSet, specific_charset)
               /* charset registry and encoding */
             );
  
***************
*** 5946,5959 ****
        if (charset
            && strncmp (charset, "*-*", 3) != 0
            && lpef->logfont.lfCharSet == DEFAULT_CHARSET
!           && strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET)) != 0)
          return 1;
        }
  
      if (charset)
        charset_list = Fcons (build_string (charset), Qnil);
      else
!       charset_list = w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet);
  
      /* Loop through the charsets.  */
      for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list))
--- 6005,6021 ----
        if (charset
            && strncmp (charset, "*-*", 3) != 0
            && lpef->logfont.lfCharSet == DEFAULT_CHARSET
!           && strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET, NULL)) != 0)
          return 1;
        }
  
      if (charset)
        charset_list = Fcons (build_string (charset), Qnil);
      else
!       /* Always prefer unicode.  */
!       charset_list
!       = Fcons (build_string ("iso10646-1"),
!                w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet));
  
      /* Loop through the charsets.  */
      for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list))
***************
*** 5961,5974 ****
        Lisp_Object this_charset = Fcar (charset_list);
        charset = SDATA (this_charset);
  
        /* List bold and italic variations if w32-enable-synthesized-fonts
           is non-nil and this is a plain font.  */
        if (w32_enable_synthesized_fonts
            && lplf->elfLogFont.lfWeight == FW_NORMAL
            && lplf->elfLogFont.lfItalic == FALSE)
          {
-           enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
-                                        charset, width);
            /* bold.  */
            lplf->elfLogFont.lfWeight = FW_BOLD;
            enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
--- 6023,6037 ----
        Lisp_Object this_charset = Fcar (charset_list);
        charset = SDATA (this_charset);
  
+       enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
+                                    charset, width);
+ 
        /* List bold and italic variations if w32-enable-synthesized-fonts
           is non-nil and this is a plain font.  */
        if (w32_enable_synthesized_fonts
            && lplf->elfLogFont.lfWeight == FW_NORMAL
            && lplf->elfLogFont.lfItalic == FALSE)
          {
            /* bold.  */
            lplf->elfLogFont.lfWeight = FW_BOLD;
            enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
***************
*** 5982,5990 ****
            enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
                                         charset, width);
          }
-       else
-         enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont),
-                                      charset, width);
        }
    }
  
--- 6045,6050 ----




reply via email to

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