diff options
| author | Kenichi Handa | 1998-07-03 04:39:22 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-07-03 04:39:22 +0000 |
| commit | 1f50fef973836bafda8d77a61948d0f0924bd97c (patch) | |
| tree | a777faacf56dbde6cfddac72ab63e9a026d5d874 | |
| parent | 68404bed20162f179145dc2d033a2713e86a278f (diff) | |
| download | emacs-1f50fef973836bafda8d77a61948d0f0924bd97c.tar.gz emacs-1f50fef973836bafda8d77a61948d0f0924bd97c.zip | |
(create-fontset-from-fontset-spec):
Returns a created fontset.
(create-fontset-from-ascii-font): New function.
| -rw-r--r-- | lisp/international/fontset.el | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el index 684495bc57d..035c0fb4953 100644 --- a/lisp/international/fontset.el +++ b/lisp/international/fontset.el | |||
| @@ -456,7 +456,9 @@ may be cons of style and a font name. In this case, the style variant | |||
| 456 | fontset uses the font for ASCII character set. | 456 | fontset uses the font for ASCII character set. |
| 457 | 457 | ||
| 458 | If this function attempts to create already existing fontset, error is | 458 | If this function attempts to create already existing fontset, error is |
| 459 | signaled unless the optional 3rd argument NOERROR is non-nil." | 459 | signaled unless the optional 3rd argument NOERROR is non-nil. |
| 460 | |||
| 461 | It returns a name of the created fontset." | ||
| 460 | (if (not (string-match "^[^,]+" fontset-spec)) | 462 | (if (not (string-match "^[^,]+" fontset-spec)) |
| 461 | (error "Invalid fontset spec: %s" fontset-spec)) | 463 | (error "Invalid fontset spec: %s" fontset-spec)) |
| 462 | (let ((idx (match-end 0)) | 464 | (let ((idx (match-end 0)) |
| @@ -540,7 +542,65 @@ signaled unless the optional 3rd argument NOERROR is non-nil." | |||
| 540 | (setq fontset-alias-alist | 542 | (setq fontset-alias-alist |
| 541 | (cons (cons new-name new-ascii-font) | 543 | (cons (cons new-name new-ascii-font) |
| 542 | fontset-alias-alist))) | 544 | fontset-alias-alist))) |
| 543 | (setq style-variant (cdr style-variant))))))))) | 545 | (setq style-variant (cdr style-variant))))))) |
| 546 | name)) | ||
| 547 | |||
| 548 | (defun create-fontset-from-ascii-font (font &optional resolved-font | ||
| 549 | fontset-name) | ||
| 550 | "Create a fontset from an ASCII font FONT. | ||
| 551 | |||
| 552 | Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If | ||
| 553 | omitted, x-resolve-font-name is called to get the resolved name. At | ||
| 554 | this time, if FONT is not avairable, error is signaled. | ||
| 555 | |||
| 556 | Optional 2nd arg FONTSET-NAME is a string to be used in | ||
| 557 | `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted, | ||
| 558 | an appropriate name is generated automatically. | ||
| 559 | |||
| 560 | Style variants of the fontset is created too. Font names in the | ||
| 561 | variants are generated automatially from FONT unless X resources | ||
| 562 | XXX.attribyteFont explicitly specify them. | ||
| 563 | |||
| 564 | It returns a name of the created fontset." | ||
| 565 | (or resolved-font | ||
| 566 | (setq resolved-font (x-resolve-font-name font))) | ||
| 567 | (let* ((faces (copy-sequence fontset-default-styles)) | ||
| 568 | (styles faces) | ||
| 569 | (xlfd (x-decompose-font-name font)) | ||
| 570 | (resolved-xlfd (x-decompose-font-name resolved-font)) | ||
| 571 | face face-font fontset fontset-spec) | ||
| 572 | (while faces | ||
| 573 | (setq face (car faces)) | ||
| 574 | (setq face-font (x-get-resource (concat (symbol-name face) | ||
| 575 | ".attributeFont") | ||
| 576 | "Face.AttributeFont")) | ||
| 577 | (if face-font | ||
| 578 | (setcar faces (cons face face-font))) | ||
| 579 | (setq faces (cdr faces))) | ||
| 580 | (aset xlfd xlfd-regexp-foundry-subnum nil) | ||
| 581 | (aset xlfd xlfd-regexp-family-subnum nil) | ||
| 582 | (aset xlfd xlfd-regexp-registry-subnum "fontset") | ||
| 583 | (or fontset-name | ||
| 584 | (setq fontset-name | ||
| 585 | (format "%s_%s_%s" | ||
| 586 | (aref resolved-xlfd xlfd-regexp-registry-subnum) | ||
| 587 | (aref resolved-xlfd xlfd-regexp-encoding-subnum) | ||
| 588 | (aref resolved-xlfd xlfd-regexp-pixelsize-subnum)))) | ||
| 589 | (aset xlfd xlfd-regexp-encoding-subnum fontset-name) | ||
| 590 | ;; The fontset name should have concrete values in weight and | ||
| 591 | ;; slant field. | ||
| 592 | (let ((weight (aref xlfd xlfd-regexp-weight-subnum)) | ||
| 593 | (slant (aref xlfd xlfd-regexp-slant-subnum))) | ||
| 594 | (if (or (not weight) (string-match "[*?]*" weight)) | ||
| 595 | (aset xlfd xlfd-regexp-weight-subnum | ||
| 596 | (aref resolved-xlfd xlfd-regexp-weight-subnum))) | ||
| 597 | (if (or (not slant) (string-match "[*?]*" slant)) | ||
| 598 | (aset xlfd xlfd-regexp-slant-subnum | ||
| 599 | (aref resolved-xlfd xlfd-regexp-slant-subnum)))) | ||
| 600 | (setq fontset (x-compose-font-name xlfd)) | ||
| 601 | (or (query-fontset fontset) | ||
| 602 | (create-fontset-from-fontset-spec (concat fontset ", ascii:" font) | ||
| 603 | styles)))) | ||
| 544 | 604 | ||
| 545 | (defun instantiate-fontset (fontset) | 605 | (defun instantiate-fontset (fontset) |
| 546 | "Make FONTSET be readly to use. | 606 | "Make FONTSET be readly to use. |