Changeset 2990

Show
Ignore:
Timestamp:
02/12/03 21:41:06 (6 years ago)
Author:
miyoshi
Message:

* international/mw32misc.el (w32-regist-initial-font): Rename
w32-charset-encoding-alist mw32-charset-windows-font-info-alist.
(set-font-from-logfont): Ditto.
(w32-enum-logfont-from-charset): Ditto.
(w32-modify-logfont-from-request): Modify italic component too.
(mw32-build-font-spec): New function.
(create-fontset-from-request): Build strict-spec of font requests.
(change-fontset-from-request): Ditto.

* international/meadow.el: Add BMP to image-type-regexps and
image-file-name-extensions.
Cache the result of w32-enum-logfont().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • work/cvs2svn/lisp/ChangeLog.Meadow

    r2977 r2990  
     12003-02-12  MIYOSHI Masanori  <miyoshi@boreas.dti.ne.jp> 
     2 
     3        * international/mw32misc.el (w32-regist-initial-font): Rename 
     4        w32-charset-encoding-alist mw32-charset-windows-font-info-alist. 
     5        (set-font-from-logfont): Ditto. 
     6        (w32-enum-logfont-from-charset): Ditto. 
     7        (w32-modify-logfont-from-request): Modify italic component too. 
     8        (mw32-build-font-spec): New function. 
     9        (create-fontset-from-request): Build strict-spec of font requests. 
     10        (change-fontset-from-request): Ditto. 
     11 
     12        * international/meadow.el: Add BMP to image-type-regexps and 
     13        image-file-name-extensions. 
     14        Cache the result of w32-enum-logfont(). 
     15 
    1162003-01-30  MIYOSHI Masanori  <miyoshi@boreas.dti.ne.jp> 
    217 
  • work/cvs2svn/lisp/international/meadow.el

    r2977 r2990  
    2626       (fboundp 'image-mask-p) 
    2727       (fboundp 'image-size))) 
     28 
     29;; BMP support 
     30(let (image-type) 
     31  (setq image-type 
     32        (cond ((memq 'bmp image-types) 'bmp) ; ImageMagick image decoder 
     33              ((memq 'BMP image-types) 'BMP))) ; built-in image decoder 
     34  (when image-type 
     35    (require 'image) 
     36    (require 'image-file) 
     37 
     38    (or (rassq 'bmp image-type-regexps) 
     39        (setq image-type-regexps 
     40              (cons (cons "\\`BM" image-type) image-type-regexps))) 
     41 
     42    (or (member "bmp" image-file-name-extensions) 
     43        (setq image-file-name-extensions 
     44              (cons "bmp" image-file-name-extensions))))) 
    2845 
    2946;;; 
     
    477494                       "MW32 System IME") 
    478495 
     496 
     497;;; 
     498;;; cache for enumerated logfonts 
     499;;; 
     500(defvar w32-enum-logfont-cache-file 
     501  nil 
     502  ;; "~/.w32_enum_logfont_cache" 
     503  "*The cache file that contains enumerated logfonts, if it is non-nil.") 
     504 
     505(defvar w32-enum-logfont-cache nil 
     506  "*The cache variable that contains enumerated logfonts.") 
     507 
     508(unless (fboundp 'w32-enum-logfont-original) 
     509  (fset 'w32-enum-logfont-original (symbol-function 'w32-enum-logfont)) 
     510  (defun w32-enum-logfont (&optional family device) 
     511    (if (or family device) 
     512        (w32-enum-logfont-original family device) 
     513      (if w32-enum-logfont-cache 
     514          w32-enum-logfont-cache 
     515        (if (null w32-enum-logfont-cache-file) 
     516            (setq w32-enum-logfont-cache 
     517                  (w32-enum-logfont-original family device)) 
     518          (setq w32-enum-logfont-cache-file 
     519                (expand-file-name w32-enum-logfont-cache-file)) 
     520          (when (file-exists-p w32-enum-logfont-cache-file) 
     521            (with-temp-buffer 
     522              (let ((coding-system-for-read 'iso-2022-7bit)) 
     523                (insert-file-contents w32-enum-logfont-cache-file)) 
     524              (condition-case nil 
     525                  (setq w32-enum-logfont-cache 
     526                        (read (current-buffer))) 
     527                (error nil))))) 
     528        (when (null w32-enum-logfont-cache) 
     529          (setq w32-enum-logfont-cache 
     530                (w32-enum-logfont-original family device)) 
     531          (with-temp-buffer 
     532            (let ((coding-system-for-write 'iso-2022-7bit) 
     533                  print-level print-length) 
     534              (prin1 w32-enum-logfont-cache (current-buffer)) 
     535              (write-file w32-enum-logfont-cache-file)))) 
     536        w32-enum-logfont-cache)))) 
     537 
    479538(provide 'meadow) 
    480539 
  • work/cvs2svn/lisp/international/mw32misc.el

    r2974 r2990  
    448448 
    449449(defun w32-automatic-fontset-regist (name orgfont) 
    450   (let ((encoding-alist w32-charset-encoding-alist) 
     450  (let ((encoding-alist mw32-charset-windows-font-info-alist) 
    451451        x ret) 
    452452    (while encoding-alist 
     
    547547        (progn 
    548548          (setq w32-logfont-info 
    549                 (assq charset w32-charset-encoding-alist)) 
     549                (assq charset mw32-charset-windows-font-info-alist)) 
    550550          (setq w32-alist 
    551551                (setq alist (nth 3 w32-logfont-info))) 
     
    599599      (setq ms-charset 
    600600            (nth 1 
    601                  (assq charset w32-charset-encoding-alist))) 
     601                 (assq charset mw32-charset-windows-font-info-alist))) 
    602602      (if (null ms-charset) 
    603603          nil 
     
    714714        (weight (or (assq 'weight required) 
    715715                    (assq 'weight recommended))) 
     716        (italic (or (assq 'italic required) 
     717                    (assq 'italic recommended))) 
    716718        result) 
    717719 
     
    743745        (setcar (nthcdr 4 result) 
    744746                (cdr weight))) 
     747    (if italic 
     748        (setcar (nthcdr 6 result) 
     749                (cdr italic))) 
    745750    result)) 
    746751 
     
    759764          (function w32-logfont-list-from-request)) 
    760765 
     766(defun mw32-build-font-spec (charset height weight slant) 
     767  (list :char-spec charset 
     768        :height (if height 
     769                    (/ (* height 720) 96) ; pixel -> 0.1 point 
     770                  'any) 
     771        :weight weight 
     772        :slant slant)) 
     773 
    761774(defun create-fontset-from-request 
    762775  (name required recommended) 
    763776  "Create fontset from your request." 
    764   (let* ((logfont-list (logfont-list-from-request 
    765                         required recommended)) 
    766          (curll logfont-list) 
    767          curle 
    768          logfont fontname charset) 
    769     (while (setq curle (car curll)) 
    770       (setq logfont (cdr curle) 
    771             charset (car curle) 
    772             fontname (concat name "-" (symbol-name charset))) 
    773       (set-font-from-logfont fontname logfont charset 0) 
    774       (setcdr curle fontname) 
    775       (setq curll (cdr curll))) 
    776     (new-fontset name logfont-list))) 
     777  (let ((logfont-list (logfont-list-from-request required recommended)) 
     778        (height (cdr (or (assq 'height required) 
     779                         (assq 'height recommended)))) 
     780        (spacing (cdr (or (assq 'spacing required) 
     781                          (assq 'spacing recommended)))) 
     782        charset logfont option font-request) 
     783    ;; build font option 
     784    (when (numberp spacing) 
     785      (setq option (list (cons 'spacing spacing)))) 
     786 
     787    (while logfont-list 
     788      (setq logfont (cdar logfont-list) 
     789            charset (caar logfont-list)) 
     790      (setq font-request 
     791            (cons (cons (mw32-build-font-spec charset height 'bold 'italic) 
     792                        (list logfont option)) 
     793                  font-request)) 
     794      (setq font-request 
     795            (cons (cons (mw32-build-font-spec charset height 'normal 'italic) 
     796                        (list logfont option)) 
     797                  font-request)) 
     798      (setq font-request 
     799            (cons (cons (mw32-build-font-spec charset height 'bold 'normal) 
     800                        (list logfont option)) 
     801                  font-request)) 
     802      (setq font-request 
     803            (cons (cons (mw32-build-font-spec charset height 'normal 'normal) 
     804                        (list logfont option)) 
     805                  font-request)) 
     806      (setq logfont-list (cdr logfont-list))) 
     807    (w32-add-font name (list (cons 'strict-spec font-request))))) 
    777808 
    778809(defun change-fontset-from-request 
    779810  (name required recommended &optional property) 
    780811  "Change fontset from your request." 
    781   (if (null property) (setq property 0)) 
    782   (let* ((fontset-font-data (aref (fontset-info name) 2)) 
    783          (logfont-list (logfont-list-from-request 
    784                         required recommended name)) 
    785          (curll logfont-list) 
    786          curle logfont fontname) 
    787     (while (setq curle (car curll)) 
    788       (setq logfont (cdr (car curll)) 
    789             fontname (nth 1 (assq (car (car curll)) fontset-font-data))) 
    790       (w32-change-font-logfont fontname property logfont) 
    791       (setq curll (cdr curll))))) 
     812  (let ((weight 'normal) 
     813        (slant 'normal) 
     814        (height (cdr (or (assq 'height required) 
     815                         (assq 'height recommended)))) 
     816        (spacing (cdr (or (assq 'spacing required) 
     817                          (assq 'spacing recommended)))) 
     818        (fr-old (cdr (assq 'strict-spec (w32-get-font-info name)))) 
     819        (fr-new (logfont-list-from-request required recommended)) 
     820        charset logfont spec option fr-cur elem) 
     821    ;; build spec-vec 
     822    (when (memq property '(1 3)) 
     823      (setq weight 'bold)) 
     824    (when (memq property '(2 3)) 
     825      (setq slant 'italic)) 
     826 
     827    ;; build font option 
     828    (when (numberp spacing) 
     829      (setq option (list (cons 'spacing spacing)))) 
     830    ;; 
     831    (while fr-new 
     832      (setq charset (caar fr-new)) 
     833      (setq logfont (cdar fr-new)) 
     834      (setq spec (mw32-build-font-spec charset height weight slant)) 
     835      (setq fr-cur 
     836            (car (cdr (assq 'strict-spec 
     837                            (mw32-convert-font-request-attribute  
     838                             (list (list 'strict-spec 
     839                                         (list spec logfont option)))))))) 
     840      (setq elem (assoc (car fr-cur) fr-old)) 
     841      (if elem 
     842          (setcdr elem (cdr fr-cur)) ; if exist, modify it. 
     843        (setq fr-old 
     844              (append fr-old (list fr-cur)))) ; if not exist, append 
     845                                              ; it at the tail of the 
     846                                              ; list. 
     847      (setq fr-new (cdr fr-new))) 
     848    (w32-change-font-attribute-internal 
     849     name (list (cons 'strict-spec fr-old))))) 
     850 
    792851 
    793852