diff options
| author | Kenichi Handa | 1997-08-22 01:22:49 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-08-22 01:22:49 +0000 |
| commit | 800d3b18acfb0a42fc43617fff46ace3085ee9ab (patch) | |
| tree | bc81cca452ee369cf45818a141668908c1083366 | |
| parent | 347617467920f4b02e2883daa879fd09860c5d68 (diff) | |
| download | emacs-800d3b18acfb0a42fc43617fff46ace3085ee9ab.tar.gz emacs-800d3b18acfb0a42fc43617fff46ace3085ee9ab.zip | |
(register-alternate-fontnames): New
funciton.
(x-complement-fontset-spec): Register alternate fontnames by
calling register-alternate-fontnames.
(instanciate-fontset): Likewise.
| -rw-r--r-- | lisp/international/fontset.el | 109 |
1 files changed, 67 insertions, 42 deletions
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el index 2aede0e2410..b35c1ab4935 100644 --- a/lisp/international/fontset.el +++ b/lisp/international/fontset.el | |||
| @@ -219,6 +219,47 @@ reduced to be one." | |||
| 219 | (x-reduce-font-name name) | 219 | (x-reduce-font-name name) |
| 220 | name))) | 220 | name))) |
| 221 | 221 | ||
| 222 | (defun register-alternate-fontnames (fontname) | ||
| 223 | "Register alternate fontnames for FONTNAME in `alternate-fontname-alist'. | ||
| 224 | When Emacs fails to open FONTNAME, it tries to open alternate font | ||
| 225 | registered in the variable `alternate-fontname-alist' (which see). | ||
| 226 | |||
| 227 | For FONTNAME, the following three alternate fontnames are registered: | ||
| 228 | fontname which ignores style specification of FONTNAME, | ||
| 229 | fontname which ignores size specification of FONTNAME, | ||
| 230 | fontname which ignores both style and size specification of FONTNAME." | ||
| 231 | (unless (assoc fontname alternate-fontname-alist) | ||
| 232 | (let ((xlfd-fields (x-decompose-font-name fontname)) | ||
| 233 | style-ignored size-ignored both-ignored) | ||
| 234 | (when xlfd-fields | ||
| 235 | (aset xlfd-fields xlfd-regexp-foundry-subnum nil) | ||
| 236 | (aset xlfd-fields xlfd-regexp-family-subnum nil) | ||
| 237 | |||
| 238 | (let ((temp (copy-sequence xlfd-fields))) | ||
| 239 | (aset temp xlfd-regexp-weight-subnum nil) | ||
| 240 | (aset temp xlfd-regexp-slant-subnum nil) | ||
| 241 | (aset temp xlfd-regexp-swidth-subnum nil) | ||
| 242 | (aset temp xlfd-regexp-adstyle-subnum nil) | ||
| 243 | (setq style-ignored (x-compose-font-name temp t))) | ||
| 244 | |||
| 245 | (aset xlfd-fields xlfd-regexp-pixelsize-subnum nil) | ||
| 246 | (aset xlfd-fields xlfd-regexp-pointsize-subnum nil) | ||
| 247 | (aset xlfd-fields xlfd-regexp-resx-subnum nil) | ||
| 248 | (aset xlfd-fields xlfd-regexp-resy-subnum nil) | ||
| 249 | (aset xlfd-fields xlfd-regexp-spacing-subnum nil) | ||
| 250 | (aset xlfd-fields xlfd-regexp-avgwidth-subnum nil) | ||
| 251 | (setq size-ignored (x-compose-font-name xlfd-fields t)) | ||
| 252 | |||
| 253 | (aset xlfd-fields xlfd-regexp-weight-subnum nil) | ||
| 254 | (aset xlfd-fields xlfd-regexp-slant-subnum nil) | ||
| 255 | (aset xlfd-fields xlfd-regexp-swidth-subnum nil) | ||
| 256 | (aset xlfd-fields xlfd-regexp-adstyle-subnum nil) | ||
| 257 | (setq both-ignored (x-compose-font-name xlfd-fields t)) | ||
| 258 | |||
| 259 | (setq alternate-fontname-alist | ||
| 260 | (cons (list fontname style-ignored size-ignored both-ignored) | ||
| 261 | alternate-fontname-alist)))))) | ||
| 262 | |||
| 222 | (defun x-complement-fontset-spec (xlfd-fields fontlist) | 263 | (defun x-complement-fontset-spec (xlfd-fields fontlist) |
| 223 | "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it. | 264 | "Complement FONTLIST for all charsets based on XLFD-FIELDS and return it. |
| 224 | XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. | 265 | XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. |
| @@ -227,48 +268,24 @@ FONTLIST is an alist of cons of charset and fontname. | |||
| 227 | Fontnames for charsets not listed in FONTLIST are generated from | 268 | Fontnames for charsets not listed in FONTLIST are generated from |
| 228 | XLFD-FIELDS and a property of x-charset-registry of each charset | 269 | XLFD-FIELDS and a property of x-charset-registry of each charset |
| 229 | automatically." | 270 | automatically." |
| 230 | (let ((charsets charset-list) | 271 | (let ((charsets charset-list)) |
| 231 | (style-ignored (copy-sequence xlfd-fields)) | ||
| 232 | (size-ignored (copy-sequence xlfd-fields))) | ||
| 233 | (aset style-ignored xlfd-regexp-weight-subnum nil) | ||
| 234 | (aset style-ignored xlfd-regexp-slant-subnum nil) | ||
| 235 | (aset style-ignored xlfd-regexp-swidth-subnum nil) | ||
| 236 | (aset style-ignored xlfd-regexp-adstyle-subnum nil) | ||
| 237 | (aset size-ignored xlfd-regexp-pixelsize-subnum nil) | ||
| 238 | (aset size-ignored xlfd-regexp-pointsize-subnum nil) | ||
| 239 | (aset size-ignored xlfd-regexp-resx-subnum nil) | ||
| 240 | (aset size-ignored xlfd-regexp-resy-subnum nil) | ||
| 241 | (aset size-ignored xlfd-regexp-spacing-subnum nil) | ||
| 242 | (aset size-ignored xlfd-regexp-avgwidth-subnum nil) | ||
| 243 | (while charsets | 272 | (while charsets |
| 244 | (let ((charset (car charsets))) | 273 | (let ((charset (car charsets))) |
| 245 | (if (null (assq charset fontlist)) | 274 | (unless (assq charset fontlist) |
| 246 | (let ((registry (get-charset-property charset | 275 | (let ((registry (get-charset-property charset |
| 247 | 'x-charset-registry)) | 276 | 'x-charset-registry)) |
| 248 | registry-val encoding-val fontname loose-fontname) | 277 | registry-val encoding-val fontname loose-fontname) |
| 249 | (if (string-match "-" registry) | 278 | (if (string-match "-" registry) |
| 250 | ;; REGISTRY contains `CHARSET_ENCODING' field. | 279 | ;; REGISTRY contains `CHARSET_ENCODING' field. |
| 251 | (setq registry-val (substring registry 0 (match-beginning 0)) | 280 | (setq registry-val (substring registry 0 (match-beginning 0)) |
| 252 | encoding-val (substring registry (match-end 0))) | 281 | encoding-val (substring registry (match-end 0))) |
| 253 | (setq registry-val (concat registry "*") | 282 | (setq registry-val (concat registry "*") |
| 254 | encoding-val "*")) | 283 | encoding-val "*")) |
| 255 | (aset xlfd-fields xlfd-regexp-registry-subnum registry-val) | 284 | (aset xlfd-fields xlfd-regexp-registry-subnum registry-val) |
| 256 | (aset xlfd-fields xlfd-regexp-encoding-subnum encoding-val) | 285 | (aset xlfd-fields xlfd-regexp-encoding-subnum encoding-val) |
| 257 | (aset style-ignored xlfd-regexp-registry-subnum registry-val) | 286 | (setq fontname (downcase (x-compose-font-name xlfd-fields))) |
| 258 | (aset style-ignored xlfd-regexp-encoding-subnum encoding-val) | 287 | (setq fontlist (cons (cons charset fontname) fontlist)) |
| 259 | (aset size-ignored xlfd-regexp-registry-subnum registry-val) | 288 | (register-alternate-fontnames fontname)))) |
| 260 | (aset size-ignored xlfd-regexp-encoding-subnum encoding-val) | ||
| 261 | (setq fontname (x-compose-font-name xlfd-fields t)) | ||
| 262 | (setq fontlist (cons (cons charset fontname) fontlist)) | ||
| 263 | (or (assoc fontname alternative-fontname-alist) | ||
| 264 | (setq alternative-fontname-alist | ||
| 265 | (cons (list | ||
| 266 | fontname | ||
| 267 | (x-compose-font-name style-ignored t) | ||
| 268 | (x-compose-font-name size-ignored t) | ||
| 269 | (concat "*-" registry-val "-" encoding-val)) | ||
| 270 | alternative-fontname-alist))) | ||
| 271 | ))) | ||
| 272 | (setq charsets (cdr charsets)))) | 289 | (setq charsets (cdr charsets)))) |
| 273 | 290 | ||
| 274 | ;; Here's a trick for the charset latin-iso8859-1. If font for | 291 | ;; Here's a trick for the charset latin-iso8859-1. If font for |
| @@ -460,8 +477,16 @@ Return FONTSET if it is created successfully, else return nil." | |||
| 460 | (funcall (car funcs) (car new-fontset-data))) | 477 | (funcall (car funcs) (car new-fontset-data))) |
| 461 | (let ((l (cdr new-fontset-data))) | 478 | (let ((l (cdr new-fontset-data))) |
| 462 | (while l | 479 | (while l |
| 463 | (if (setq font (funcall (car funcs) (cdr (car l)))) | 480 | (if (= (length funcs) 1) |
| 464 | (setcdr (car l) font)) | 481 | (setq font (funcall (car funcs) (cdr (car l)))) |
| 482 | (and (setq font (funcall (car funcs) (cdr (car l)))) | ||
| 483 | (not (equal font (cdr (car l)))) | ||
| 484 | (setq font2 (funcall (nth 1 funcs) font)) | ||
| 485 | (not (equal font2 font)) | ||
| 486 | (setq font font2))) | ||
| 487 | (when font | ||
| 488 | (setcdr (car l) font) | ||
| 489 | (register-alternate-fontnames font)) | ||
| 465 | (setq l (cdr l)))) | 490 | (setq l (cdr l)))) |
| 466 | (setq funcs (cdr funcs))) | 491 | (setq funcs (cdr funcs))) |
| 467 | (new-fontset (car new-fontset-data) (cdr new-fontset-data)) | 492 | (new-fontset (car new-fontset-data) (cdr new-fontset-data)) |