comparison lisp/international/fontset.el @ 22672:9cfa1a788a5a

(create-fontset-from-fontset-spec): Returns a created fontset. (create-fontset-from-ascii-font): New function.
author Kenichi Handa <handa@m17n.org>
date Fri, 03 Jul 1998 04:39:22 +0000
parents ed91f54d85b9
children ab4f30149aa0
comparison
equal deleted inserted replaced
22671:5dee1f64801f 22672:9cfa1a788a5a
454 FONTSET-NAME in styles are also created. An element of STYLE-VARIANT 454 FONTSET-NAME in styles are also created. An element of STYLE-VARIANT
455 may be cons of style and a font name. In this case, the style variant 455 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))
463 (name (match-string 0 fontset-spec)) 465 (name (match-string 0 fontset-spec))
464 fontlist full-fontlist ascii-font resolved-ascii-font charset) 466 fontlist full-fontlist ascii-font resolved-ascii-font charset)
538 nonascii-fontlist)) 540 nonascii-fontlist))
539 uninstantiated-fontset-alist)) 541 uninstantiated-fontset-alist))
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.
547 FONTSET should be in the variable `uninstantiated-fontset-alist' in advance. 607 FONTSET should be in the variable `uninstantiated-fontset-alist' in advance.
548 Return FONTSET if it is created successfully, else return nil." 608 Return FONTSET if it is created successfully, else return nil."