;;; fontset.el --- commands for handling fontset
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
-;; Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+;; 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
-;; Copyright (C) 2003
+;; Copyright (C) 2003, 2006
;; National Institute of Advanced Industrial Science and Technology (AIST)
;; Registration Number H13PRO009
("iso8859-15$" . iso-8859-15)
("gb2312.1980" . chinese-gb2312)
("gbk" . chinese-gbk)
+ ("gb18030" . gb18030)
("jisx0208.1978" . japanese-jisx0208-1978)
("jisx0208" . japanese-jisx0208)
("jisx0201" . jisx0201)
("viscii" . viscii)
("tis620" . tis620-2533)
("microsoft-cp1251" . windows-1251)
+ ("koi8-r" . koi8-r)
("mulearabic-0" . arabic-digit)
("mulearabic-1" . arabic-1-column)
("mulearabic-2" . arabic-2-column)
("muleipa" . ipa)
- ("ethiopic-unicode" . ethiopic)
+ ("ethiopic-unicode" . (unicode-bmp . ethiopic))
("is13194-devanagari" . indian-is13194)
("Devanagari-CDAC" . devanagari-cdac)
("Sanskrit-CDAC" . sanskrit-cdac)
("iso10646-1$" . (unicode-bmp . nil))
("iso10646.indian-1" . (unicode-bmp . nil))))
+(setq script-representative-chars
+ '((latin ?A ?Z ?a ?z)
+ (greek #x3A9)
+ (coptic #x3E2)
+ (cyrillic #x42F)
+ (armenian #x531)
+ (hebrew #x5D0)
+ (arabic #x628)
+ (syriac #x710)
+ (thaana #x78C)
+ (devanagari #x915)
+ (bengali #x995)
+ (gurmukhi #xA15)
+ (gujarati #xA95)
+ (oriya #xB15)
+ (tamil #xB95)
+ (telugu #xC15)
+ (kannada #xC95)
+ (malayalam #xD15)
+ (sinhala #xD95)
+ (thai #xE17)
+ (lao #xEA5)
+ (tibetan #xF40)
+ (myanmar #x1000)
+ (georgian #x10D3)
+ (ethiopic #x1208)
+ (cherokee #x13B6)
+ (canadian-aboriginal #x14C0)
+ (ogham #x168F)
+ (runic #x16A0)
+ (khmer #x1780)
+ (mongolian #x1826)
+ (braille #x2800)
+ (ideographic-description #x2FF0)
+ (cjk-misc #x300E)
+ (kana #x304B)
+ (bopomofo #x3105)
+ (kanbun #x319D)
+ (han #x5B57)
+ (yi #xA288)
+ (hangul #xAC00)))
+
+(setq otf-script-alist
+ '((arab . arabic)
+ (armn . armenian)
+ (bali . balinese)
+ (beng . bengali)
+ (bopo . bopomofo)
+ (brai . braille)
+ (bugi . buginese)
+ (buhd . buhid)
+ (byzm . byzantine-musical-symbol)
+ (cans . canadian_aboliginal)
+ (cher . cherokee)
+ (copt . coptic)
+ (xsux . cuneiform)
+ (cyrl . cyrillic)
+ (cprt . cypriot)
+ (dsrt . deseret)
+ (deva . devanagari)
+ (ethi . ethiopic)
+ (geor . georgian)
+ (glag . glagolitic)
+ (goth . gothic)
+ (grek . greek)
+ (gujr . gujarati)
+ (guru . gurmukhi)
+ (hani . han)
+ (hang . hangul)
+ (hano . hanunoo)
+ (hebr . hebrew)
+ (kana . kana)
+ (knda . kannada)
+ (khar . kharoshthi)
+ (khmr . khmer)
+ (lao . lao)
+ (latn . latin)
+ (limb . limbu)
+ (linb . linear_b)
+ (mlym . malayalam)
+ (math . mathematical)
+ (mong . mongolian)
+ (musc . musical-symbol)
+ (mymr . myanmar)
+ (nko . nko)
+ (ogam . ogham)
+ (ital . old_italic)
+ (xpeo . old_persian)
+ (orya . oriya)
+ (osma . osmanya)
+ (phag . phags-pa)
+ (phnx . phoenician)
+ (runr . runic)
+ (shaw . shavian)
+ (sinh . sinhala)
+ (sylo . syloti_nagri)
+ (syrc . syriac)
+ (tglg . tagalog)
+ (tagb . tagbanwa)
+ (taml . tamil)
+ (tale . tai_le)
+ (telu . telugu)
+ (thaa . thaana)
+ (thai . thai)
+ (tibt . tibetan)
+ (tfng . tifinagh)
+ (ugar . ugaritic)
+ (yi . yi)))
;; Set standard fontname specification of characters in the default
;; fontset to find an appropriate font for each script/charset. The
(nil . "CNS11643.1992-6")
(nil . "CNS11643.1992-7")
(nil . "gbk-0")
+ (nil . "gb18030")
(nil . "JISX0213.2000-1")
(nil . "JISX0213.2000-2")
(nil . "JISX0213.2004-1"))
(nil . "CNS11643.1992-6")
(nil . "CNS11643.1992-7")
(nil . "gbk-0")
+ (nil . "gb18030")
(nil . "JISX0213.2000-1")
(nil . "JISX0213.2000-2"))
;; Fallback fonts
(nil (nil . "gb2312.1980")
+ (nil . "gbk-0")
+ (nil . "gb18030")
(nil . "jisx0208")
(nil . "ksc5601.1987")
(nil . "CNS11643.1992-1")
;; Setting for suppressing XLoadQueryFont on big fonts.
(setq x-pixel-size-width-font-regexp
- "gb2312\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
+ "gb2312\\|gbk\\|gb18030\\|jisx0208\\|ksc5601\\|cns11643\\|big5")
;; These fonts require vertical centering.
(setq vertical-centering-font-regexp
- "gb2312\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5")
+ "gb2312\\|gbk\\|gb18030\\|jisx0208\\|jisx0212\\|ksc5601\\|cns11643\\|big5")
;; CDAC fonts are actually smaller than their design sizes.
(setq face-font-rescale-alist
(defun x-compose-font-name (fields &optional reduce)
"Compose X fontname from FIELDS.
-FIELDS is a vector of XLFD fields, the length 12.
+FIELDS is a vector of XLFD fields, of length 12.
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 "-")))
+
(defun x-must-resolve-font-name (xlfd-fields)
"Like `x-resolve-font-name', but always return a font name.
XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
(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")))
(if (not (string-match "^fontset-\\(.*\\)$" nickname))
(setq nickname family)
(setq nickname (match-string 1 nickname)))
- (if (and size (> (string-to-int size) 0))
+ (if (and size (> (string-to-number size) 0))
(setq name (format "%s: %s-dot" nickname size))
(setq name nickname))
(and weight
(katakana-jisx0201 . kana)
(chinese-gb2312 . han)
(chinese-gbk . han)
+ (gb18030-2-byte . han)
+ (gb18030-4-byte-bmp . han)
+ (gb18030-4-byte-ext-1 . han)
+ (gb18030-4-byte-ext-2 . han)
+ (gb18030-4-byte-smp . han)
(chinese-big5-1 . han)
(chinese-big5-2 . han)
(chinese-cns11643-1 . han)
&optional style-variant noerror)
"Create a fontset from fontset specification string FONTSET-SPEC.
FONTSET-SPEC is a string of the format:
- FONTSET-NAME,SCRIPT-NAME0:FONT-NAME0,SCRIPT-NAME1:FONT-NAME1, ...
+ FONTSET-NAME,SCRIPT0:FONT0,SCRIPT1:FONT1, ...
Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
When a frame uses the fontset as the `font' parameter, the frame's
is \"ascii\", use the corresponding FONT-NAMEn as the default font
name.
-Optional 2nd and 3rd arguments are ignored. They exist just for
-backward compatibility.
+Optional 2nd and 3rd arguments exist just for backward compatibility,
+and are ignored.
It returns a name of the created fontset.
(error "Invalid fontset spec: %s" fontset-spec))
(let ((idx (match-end 0))
(name (match-string 0 fontset-spec))
- xlfd-fields script fontlist)
+ xlfd-fields target script fontlist)
(setq xlfd-fields (x-decompose-font-name name))
(or xlfd-fields
(error "Fontset name \"%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 script (intern (match-string 1 fontset-spec)))
- (if (or (eq script 'ascii)
- (memq script (char-table-extra-slot char-script-table 0))
- (setq script (cdr (assq script charset-script-alist))))
- (setq fontlist (cons (list script (match-string 2 fontset-spec))
- fontlist))))
+ (setq target (intern (match-string 1 fontset-spec)))
+ (cond ((or (eq target 'ascii)
+ (memq target (char-table-extra-slot char-script-table 0)))
+ (push (list target (match-string 2 fontset-spec)) fontlist))
+ ((setq script (cdr (assq target charset-script-alist)))
+ (push (list script (match-string 2 fontset-spec)) fontlist))
+ ((charsetp target)
+ (push (list target (match-string 2 fontset-spec)) fontlist))))
;; Complement FONTLIST.
(setq fontlist (x-complement-fontset-spec xlfd-fields fontlist))
;; Create a fontset.
- (new-fontset name fontlist)))
+ (new-fontset name (nreverse fontlist))))
(defun create-fontset-from-ascii-font (font &optional resolved-font
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, an 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.