]> code.delx.au - gnu-emacs/blobdiff - lisp/international/fontset.el
Merged from emacs@sv.gnu.org
[gnu-emacs] / lisp / international / fontset.el
index 90e98dba8f57a10acf89233e43449a6a3b315313..81665ffd1ce2b312c5e83ea17600b3b49ed94e0d 100644 (file)
@@ -1,8 +1,11 @@
 ;;; fontset.el --- commands for handling fontset
 
-;; Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
-;; Copyright (C) 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: mule, multilingual, fontset
 
@@ -20,8 +23,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
             (latin-iso8859-2 . (nil . "ISO8859-2"))
             (latin-iso8859-3 . (nil . "ISO8859-3"))
             (latin-iso8859-4 . (nil . "ISO8859-4"))
+            ;; Setting "*" family is for a workaround of the problem
+            ;; that a font of wrong size is preferred if the font
+            ;; family matches with a requested one.
             (thai-tis620 . ("*" . "TIS620"))
-            (greek-iso8859-7 . ("*" . "ISO8859-7"))
-            (arabic-iso8859-6 . ("*" . "ISO8859-6"))
-            (hebrew-iso8859-8 . ("*" . "ISO8859-8"))
-            (katakana-jisx0201 . ("*" . "JISX0201"))
+            (greek-iso8859-7 . (nil . "ISO8859-7"))
+            (arabic-iso8859-6 . (nil . "ISO8859-6"))
+            (hebrew-iso8859-8 . (nil . "ISO8859-8"))
+            (katakana-jisx0201 . (nil . "JISX0201"))
             (latin-jisx0201 . (nil . "JISX0201"))
-            (cyrillic-iso8859-5 . ("*" . "ISO8859-5"))
+            (cyrillic-iso8859-5 . (nil . "ISO8859-5"))
             (latin-iso8859-9 . (nil . "ISO8859-9"))
-            (japanese-jisx0208-1978 . ("*" . "JISX0208.1978"))
-            (chinese-gb2312 . ("*" . "GB2312.1980"))
-            (japanese-jisx0208 . ("*" . "JISX0208.1990"))
-            (korean-ksc5601 . ("*" . "KSC5601.1989"))
-            (japanese-jisx0212 . ("*" . "JISX0212"))
-            (chinese-cns11643-1 . ("*" . "CNS11643.1992-1"))
-            (chinese-cns11643-2 . ("*" . "CNS11643.1992-2"))
-            (chinese-cns11643-3 . ("*" . "CNS11643.1992-3"))
-            (chinese-cns11643-4 . ("*" . "CNS11643.1992-4"))
-            (chinese-cns11643-5 . ("*" . "CNS11643.1992-5"))
-            (chinese-cns11643-6 . ("*" . "CNS11643.1992-6"))
-            (chinese-cns11643-7 . ("*" . "CNS11643.1992-7"))
-            (chinese-big5-1 . ("*" . "Big5"))
-            (chinese-big5-2 . ("*" . "Big5"))
+            (japanese-jisx0208-1978 . (nil . "JISX0208.1978"))
+            (chinese-gb2312 . (nil . "GB2312.1980"))
+            (japanese-jisx0208 . (nil . "JISX0208.1990"))
+            (korean-ksc5601 . (nil . "KSC5601.1989"))
+            (japanese-jisx0212 . (nil . "JISX0212"))
+            (chinese-cns11643-1 . (nil . "CNS11643.1992-1"))
+            (chinese-cns11643-2 . (nil . "CNS11643.1992-2"))
+            (chinese-cns11643-3 . (nil . "CNS11643.1992-3"))
+            (chinese-cns11643-4 . (nil . "CNS11643.1992-4"))
+            (chinese-cns11643-5 . (nil . "CNS11643.1992-5"))
+            (chinese-cns11643-6 . (nil . "CNS11643.1992-6"))
+            (chinese-cns11643-7 . (nil . "CNS11643.1992-7"))
+            (chinese-big5-1 . (nil . "Big5"))
+            (chinese-big5-2 . (nil . "Big5"))
             (chinese-sisheng . (nil . "sisheng_cwnn"))
             (vietnamese-viscii-lower . (nil . "VISCII1.1"))
             (vietnamese-viscii-upper . (nil . "VISCII1.1"))
-            (arabic-digit . ("*" . "MuleArabic-0"))
-            (arabic-1-column . ("*" . "MuleArabic-1"))
-            (arabic-2-column . ("*" . "MuleArabic-2"))
+            (arabic-digit . (nil . "MuleArabic-0"))
+            (arabic-1-column . (nil . "MuleArabic-1"))
+            (arabic-2-column . (nil . "MuleArabic-2"))
             (ipa . (nil . "MuleIPA"))
-            (ethiopic . ("*" . "Ethiopic-Unicode"))
+            (ethiopic . (nil . "Ethiopic-Unicode"))
             (ascii-right-to-left . (nil . "ISO8859-1"))
-            (indian-is13194 . ("*" . "IS13194-Devanagari"))
-            (indian-2-column . ("*" . "MuleIndian-2"))
-            (lao . ("*" . "MuleLao-1"))
+            (indian-is13194 . (nil . "IS13194-Devanagari"))
+            (indian-2-column . (nil . "MuleIndian-2"))
+            (lao . (nil . "MuleLao-1"))
             (tibetan . ("proportional" . "MuleTibetan-2"))
-            (tibetan-1-column . ("*" . "MuleTibetan-1"))
+            (tibetan-1-column . (nil . "MuleTibetan-1"))
             (latin-iso8859-14 . (nil . "ISO8859-14"))
             (latin-iso8859-15 . (nil . "ISO8859-15"))
             (mule-unicode-0100-24ff . (nil . "ISO10646-1"))
             (mule-unicode-2500-33ff . (nil . "ISO10646-1"))
             (mule-unicode-e000-ffff . (nil . "ISO10646-1"))
-            (japanese-jisx0213-1 . ("*" . "JISX0213.2000-1"))
-            (japanese-jisx0213-2 . ("*" . "JISX0213.2000-2"))
+            (japanese-jisx0213-1 . (nil . "JISX0213.2000-1"))
+            (japanese-jisx0213-2 . (nil . "JISX0213.2000-2"))
             ;; unicode
             ((,(decode-char 'ucs #x0900) . ,(decode-char 'ucs #x097F))
-             . ("*" . "ISO10646.indian-1"))
+             . (nil . "ISO10646.indian-1"))
             ;; Indian CDAC
             (,(indian-font-char-range 'cdac:dv-ttsurekh)
-             . ("*" . "Devanagari-CDAC"))
+             . (nil . "Devanagari-CDAC"))
             (,(indian-font-char-range 'cdac:sd-ttsurekh)
-             . ("*" . "Sanskrit-CDAC"))
+             . (nil . "Sanskrit-CDAC"))
             (,(indian-font-char-range 'cdac:bn-ttdurga)
-             . ("*" . "Bengali-CDAC"))
+             . (nil . "Bengali-CDAC"))
             (,(indian-font-char-range 'cdac:as-ttdurga)
-             . ("*" . "Assamese-CDAC"))
+             . (nil . "Assamese-CDAC"))
             (,(indian-font-char-range 'cdac:pn-ttamar)
-             . ("*" . "Punjabi-CDAC"))
+             . (nil . "Punjabi-CDAC"))
             (,(indian-font-char-range 'cdac:gj-ttavantika)
-             . ("*" . "Gujarati-CDAC"))
+             . (nil . "Gujarati-CDAC"))
             (,(indian-font-char-range 'cdac:or-ttsarala)
-             . ("*" . "Oriya-CDAC"))
+             . (nil . "Oriya-CDAC"))
             (,(indian-font-char-range 'cdac:tm-ttvalluvar)
-             . ("*" . "Tamil-CDAC"))
+             . (nil . "Tamil-CDAC"))
             (,(indian-font-char-range 'cdac:tl-tthemalatha)
-             . ("*" . "Telugu-CDAC"))
+             . (nil . "Telugu-CDAC"))
             (,(indian-font-char-range 'cdac:kn-ttuma)
-             . ("*" . "Kannada-CDAC"))
+             . (nil . "Kannada-CDAC"))
             (,(indian-font-char-range 'cdac:ml-ttkarthika)
-             . ("*" . "Malayalam-CDAC"))
+             . (nil . "Malayalam-CDAC"))
             ;; Indian AKRUTI
             (,(indian-font-char-range 'akruti:dev)
-             . ("*" . "Devanagari-Akruti"))
+             . (nil . "Devanagari-Akruti"))
             (,(indian-font-char-range 'akruti:bng)
-             . ("*" . "Bengali-Akruti"))
+             . (nil . "Bengali-Akruti"))
             (,(indian-font-char-range 'akruti:pnj)
-             . ("*" . "Punjabi-Akruti"))
+             . (nil . "Punjabi-Akruti"))
             (,(indian-font-char-range 'akruti:guj)
-             . ("*" . "Gujarati-Akruti"))
+             . (nil . "Gujarati-Akruti"))
             (,(indian-font-char-range 'akruti:ori)
-             . ("*" . "Oriay-Akruti"))
+             . (nil . "Oriya-Akruti"))
             (,(indian-font-char-range 'akruti:tml)
-             . ("*" . "Tamil-Akruti"))
+             . (nil . "Tamil-Akruti"))
             (,(indian-font-char-range 'akruti:tlg)
-             . ("*" . "Telugu-Akruti"))
+             . (nil . "Telugu-Akruti"))
             (,(indian-font-char-range 'akruti:knd)
-             . ("*" . "Kannada-Akruti"))
+             . (nil . "Kannada-Akruti"))
             (,(indian-font-char-range 'akruti:mal)
-             . ("*" . "Malayalam-Akruti"))
+             . (nil . "Malayalam-Akruti"))
             ))
     (set-fontset-font "fontset-default" (car elt) (cdr elt))))
 
        ((if (r2 >= 0)
            ;; This is a 2D charset.
            (r1 = ((r1 << 7) | r2)))
-       (lookup-character ucs-mule-cjk-to-unicode r0 r1)
+       (lookup-character utf-subst-table-for-encode r0 r1)
        (if r7
            ;; We got it!
            ((r1 = (r0 >> 8))
             (r2 = (r0 & #xFF)))
          ;; Look for a translation for non-ASCII chars.
          ((translate-character ucs-mule-to-mule-unicode r0 r1)
-          (if (r0 == ,(charset-id 'latin-iso8859-1))
-              ((r2 = (r1 + 128))
+          (if (r0 == ,(charset-id 'ascii))
+              ((r2 = r1)
                (r1 = 0))
-            ((r2 = (r1 & #x7F))
-             (r1 >>= 7)
-             (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
-                 ((r1 *= 96)
-                  (r1 += r2)
-                  (r1 += ,(- #x100 (* 32 96) 32))
-                  (r1 >8= 0)
-                  (r2 = r7))
-               (if (r0 == ,(charset-id 'mule-unicode-2500-33ff))
-                   ((r1 *= 96)
-                    (r1 += r2)
-                    (r1 += ,(- #x2500 (* 32 96) 32))
-                    (r1 >8= 0)
-                    (r2 = r7))
-                 (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))
-                     ((r1 *= 96)
-                      (r1 += r2)
-                      (r1 += ,(- #xe000 (* 32 96) 32))
-                      (r1 >8= 0)
-                      (r2 = r7))
-                   ;; No way, use the glyph for U+FFFD.
-                   ((r1 = #xFF)
-                    (r2 = #xFD)))))))))))))
+            ((if (r0 == ,(charset-id 'latin-iso8859-1))
+                 ((r2 = (r1 + 128))
+                  (r1 = 0))
+               ((r2 = (r1 & #x7F))
+                (r1 >>= 7)
+                (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
+                    ((r1 *= 96)
+                     (r1 += r2)
+                     (r1 += ,(- #x100 (* 32 96) 32))
+                     (r1 >8= 0)
+                     (r2 = r7))
+                  (if (r0 == ,(charset-id 'mule-unicode-2500-33ff))
+                      ((r1 *= 96)
+                       (r1 += r2)
+                       (r1 += ,(- #x2500 (* 32 96) 32))
+                       (r1 >8= 0)
+                       (r2 = r7))
+                    (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))
+                        ((r1 *= 96)
+                         (r1 += r2)
+                         (r1 += ,(- #xe000 (* 32 96) 32))
+                         (r1 >8= 0)
+                         (r2 = r7))
+                      ;; No way, use the glyph for U+FFFD.
+                      ((r1 = #xFF)
+                       (r2 = #xFD)))))))))))))))
   "Encode characters for display with iso10646 font.
 Translate through the translation-hash-table named
 `ucs-mule-cjk-to-unicode' and the translation-table named
@@ -375,10 +384,10 @@ PATTERN.  If no full XLFD name is gotten, return nil."
 
 (defun x-compose-font-name (fields &optional reduce)
   "Compose X's fontname from FIELDS.
-FIELDS is a vector of XLFD fields, the length 14.
+FIELDS is a vector of XLFD fields, of length 14.
 If a field is nil, wild-card letter `*' is embedded.
-Optional argument REDUCE is always ignored.  It exists just for
-backward compatibility."
+Optional argument REDUCE exists just for backward compatibility,
+and is always ignored."
   (concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
 
 
@@ -456,7 +465,7 @@ variable `x-font-name-charset-alist'), add that information to FONTLIST."
 (defun fontset-name-p (fontset)
   "Return non-nil if FONTSET is valid as fontset name.
 A valid fontset name should conform to XLFD (X Logical Font Description)
-with \"fontset\" in `<CHARSET_REGISTRY> field."
+with \"fontset\" in `<CHARSET_REGISTRY>' field."
   (and (string-match xlfd-tight-regexp fontset)
        (string= (match-string (1+ xlfd-regexp-registry-subnum) fontset)
                "fontset")))
@@ -488,7 +497,7 @@ with \"fontset\" in `<CHARSET_REGISTRY> field."
              name)
          (if (not (string= "fontset" charset))
              fontset
-           (if (> (string-to-int size) 0)
+           (if (> (string-to-number size) 0)
                (setq name (format "%s: %s-dot" nickname size))
              (setq name nickname))
            (cond ((string-match "^medium$" weight)
@@ -511,13 +520,12 @@ with \"fontset\" in `<CHARSET_REGISTRY> field."
                                         &optional style-variant noerror)
   "Create a fontset from fontset specification string FONTSET-SPEC.
 FONTSET-SPEC is a string of the format:
-       FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ...
+       FONTSET-NAME,CHARSET0:FONT0,CHARSET1:FONT1, ...
 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
 
-Optional 2nd argument is ignored.  It exists just for backward
-compatibility.
+Optional 2nd arg exists just for backward compatibility, and is ignored.
 
-If this function attempts to create already existing fontset, error is
+If this function attempts to create already existing fontset, an error is
 signaled unless the optional 3rd argument NOERROR is non-nil.
 
 It returns a name of the created fontset."
@@ -535,7 +543,8 @@ It returns a name of the created fontset."
          (error "Fontset \"%s\" not conforming to XLFD" name))
 
       ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
-      (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx)
+      (while (string-match "[, \t\n]*\\([^:]+\\):[ \t]*\\([^,]+\\)"
+                          fontset-spec idx)
        (setq idx (match-end 0))
        (setq charset (intern (match-string 1 fontset-spec)))
        (if (charsetp charset)
@@ -570,11 +579,11 @@ It returns a name of the created fontset."
                                            fontset-name)
   "Create a fontset from an ASCII font FONT.
 
-Optional 1st arg RESOLVED-FONT is a resolved name of FONT.  If
-omitted, `x-resolve-font-name' is called to get the resolved name.  At
-this time, if FONT is not available, error is signaled.
+Optional 2nd arg RESOLVED-FONT is a resolved name of FONT.
+If omitted, `x-resolve-font-name' is called to get the resolved name.
+At this time, if FONT is not available, an error is signaled.
 
-Optional 2nd arg FONTSET-NAME is a string to be used in
+Optional 3rd arg FONTSET-NAME is a string to be used in
 `<CHARSET_ENCODING>' fields of a new fontset name.  If it is omitted,
 an appropriate name is generated automatically.
 
@@ -638,4 +647,5 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
 ;;
 (provide 'fontset)
 
+;;; arch-tag: bb53e629-0234-403c-950e-551e61554849
 ;;; fontset.el ends here