aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1997-05-12 06:56:20 +0000
committerKenichi Handa1997-05-12 06:56:20 +0000
commit494ec9bc1048acac8636d82d277bf4cc1d8ce9f7 (patch)
treec87db860be4733c6a8fe0939775821b303c75a08
parentc3016c969ca0bd0a4feb30ce66645f4accd0dcb0 (diff)
downloademacs-494ec9bc1048acac8636d82d277bf4cc1d8ce9f7.tar.gz
emacs-494ec9bc1048acac8636d82d277bf4cc1d8ce9f7.zip
(x-decompose-font-name): While seting each field of
XLFD, set "*" instead of nil to a field which is omitted in the original font name. (generate-fontset-menu): Delete code for handling alias (or nickname). It is now handled in fontset-plain-name. (fontset-plain-name): Handle alias of fontset name, show more user-friendy names. (create-fontset-from-fontset-spec): Add an optional arg STYLE to create bold, italic, and bold-italic variants of a fonset.
-rw-r--r--lisp/international/fontset.el112
1 files changed, 72 insertions, 40 deletions
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el
index 2e5545576b3..e3dd5e1c063 100644
--- a/lisp/international/fontset.el
+++ b/lisp/international/fontset.el
@@ -195,7 +195,7 @@ PATTERN. If no full XLFD name is gotten, return nil."
195 (setq i (1+ i))) 195 (setq i (1+ i)))
196 (if (< (car (aref xlfd-fields i)) (car (cdr l))) 196 (if (< (car (aref xlfd-fields i)) (car (cdr l)))
197 (progn 197 (progn
198 (aset xlfd-fields i nil) 198 (aset xlfd-fields i "*")
199 (setq i (1+ i))) 199 (setq i (1+ i)))
200 (setq l (cdr (cdr l)))))) 200 (setq l (cdr (cdr l))))))
201 xlfd-fields))))) 201 xlfd-fields)))))
@@ -272,63 +272,95 @@ automatically."
272 l) 272 l)
273 (while fontsets 273 (while fontsets
274 (setq fontset-name (car (car fontsets)) fontsets (cdr fontsets)) 274 (setq fontset-name (car (car fontsets)) fontsets (cdr fontsets))
275 (if (string-match "fontset-\\([^-]+\\)" fontset-name) 275 (setq l (cons (list (fontset-plain-name fontset-name) fontset-name) l)))
276 ;; This fontset has a nickname. Just show it.
277 (let ((nickname (match-string 1 fontset-name)))
278 (setq l (cons (list (concat ".." nickname) fontset-name) l)))
279 (setq l (cons (list fontset-name fontset-name) l))))
280 (cons "Fontset" l))) 276 (cons "Fontset" l)))
281 277
282(defun fontset-plain-name (fontset) 278(defun fontset-plain-name (fontset)
283 "Return a plain and descriptive name of FONTSET." 279 "Return a plain and descriptive name of FONTSET."
280 (if (not (setq fontset (query-fontset fontset)))
281 (error "Invalid fontset: %s" fontset))
284 (let ((xlfd-fields (x-decompose-font-name fontset))) 282 (let ((xlfd-fields (x-decompose-font-name fontset)))
285 (if xlfd-fields 283 (if xlfd-fields
286 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) 284 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum))
287 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)) 285 (slant (aref xlfd-fields xlfd-regexp-slant-subnum))
288 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum)) 286 (swidth (aref xlfd-fields xlfd-regexp-swidth-subnum))
289 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum)) 287 (size (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
288 (charset (aref xlfd-fields xlfd-regexp-registry-subnum))
289 (nickname (aref xlfd-fields xlfd-regexp-encoding-subnum))
290 name) 290 name)
291 (if (> (string-to-int size) 0) 291 (if (not (string= "fontset" charset))
292 (setq name (format "%s " size))
293 (setq name ""))
294 (if (string-match "bold\\|demibold" weight)
295 (setq name (concat name weight " ")))
296 (cond ((string= slant "i")
297 (setq name (concat name "italic ")))
298 ((string= slant "o")
299 (setq name (concat name "slant ")))
300 ((string= slant "ri")
301 (setq name (concat name "reverse italic ")))
302 ((string= slant "ro")
303 (setq name (concat name "reverse slant "))))
304 (if (= (length name) 0)
305 ;; No descriptive fields found.
306 fontset 292 fontset
293 (if (> (string-to-int size) 0)
294 (setq name (format "%s: %s-dot" nickname size))
295 (setq name nickname))
296 (cond ((string-match "^medium$" weight)
297 (setq name (concat name " " "medium")))
298 ((string-match "^bold$\\|^demibold$" weight)
299 (setq name (concat name " " weight))))
300 (cond ((string-match "^i$" slant)
301 (setq name (concat name " " "italic")))
302 ((string-match "^o$" slant)
303 (setq name (concat name " " "slant")))
304 ((string-match "^ri$" slant)
305 (setq name (concat name " " "reverse italic")))
306 ((string-match "^ro$" slant)
307 (setq name (concat name " " "reverse slant"))))
307 name)) 308 name))
308 fontset))) 309 fontset)))
309 310
310(defun create-fontset-from-fontset-spec (fontset-spec) 311(defun create-fontset-from-fontset-spec (fontset-spec &optional style)
311 "Create a fontset from fontset specification string FONTSET-SPEC. 312 "Create a fontset from fontset specification string FONTSET-SPEC.
312FONTSET-SPEC is a string of the format: 313FONTSET-SPEC is a string of the format:
313 FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ... 314 FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ...
314Any number of SPACE, TAB, and NEWLINE can be put before and after commas." 315Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
315 (if (string-match "[^,]+" fontset-spec) 316If optional argument STYLE is specified, create a fontset of STYLE
316 (let* ((idx2 (match-end 0)) 317by modifying FONTSET-SPEC appropriately. STYLE can be one of `bold',
317 (name (match-string 0 fontset-spec)) 318`italic', and `bold-italic'."
318 fontlist charset xlfd-fields) 319 (if (not (string-match "^[^,]+" fontset-spec))
319 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" 320 (error "Invalid fontset spec: %s" fontset-spec))
320 fontset-spec idx2) 321 (let ((idx (match-end 0))
321 (setq idx2 (match-end 0)) 322 (name (match-string 0 fontset-spec))
322 (setq charset (intern (match-string 1 fontset-spec))) 323 fontlist charset)
323 (if (charsetp charset) 324 ;; At first, extract pairs of charset and fontname from FONTSET-SPEC.
324 (setq fontlist (cons (cons charset (match-string 2 fontset-spec)) 325 (while (string-match "[, \t\n]*\\([^:]+\\):\\([^,]+\\)" fontset-spec idx)
325 fontlist)))) 326 (setq idx (match-end 0))
326 (if (setq xlfd-fields (x-decompose-font-name name)) 327 (setq charset (intern (match-string 1 fontset-spec)))
327 ;; If NAME conforms to XLFD, complement FONTLIST for 328 (if (charsetp charset)
328 ;; charsets not specified in FONTSET-SPEC. 329 (setq fontlist (cons (cons charset (match-string 2 fontset-spec))
329 (setq fontlist 330 fontlist))))
330 (x-complement-fontset-spec xlfd-fields fontlist))) 331
331 (new-fontset name fontlist)))) 332 ;; If STYLE is specified, modify fontset name (NAME) and FONTLIST.
333 (let ((func (cdr (assq style '((bold . x-make-font-bold)
334 (italic . x-make-font-italic)
335 (bold-italic . x-make-font-bold-italic)))))
336 (l fontlist)
337 new-name)
338 (if (and func
339 (setq new-name (funcall func name)))
340 (progn
341 (setq name new-name)
342 (while l
343 (if (setq new-name (funcall func (cdr (car l))))
344 (setcdr (car l) new-name))
345 (setq l (cdr l))))))
346
347 ;; If NAME conforms to XLFD, complement FONTLIST for charsets not
348 ;; specified in FONTSET-SPEC.
349 (let ((xlfd-fields (x-decompose-font-name name)))
350 (if xlfd-fields
351 (setq fontlist
352 (x-complement-fontset-spec xlfd-fields fontlist))))
353
354 ;; Create the fontset, and define the alias if appropriate.
355 (new-fontset name fontlist)
356 (if (and (not style)
357 (not (assoc name fontset-alias-alist))
358 (string-match "fontset-.*$" name))
359 (let ((alias (match-string 0 name)))
360 (or (rassoc alias fontset-alias-alist)
361 (setq fontset-alias-alist
362 (cons (cons name alias) fontset-alias-alist)))))
363 ))
332 364
333 365
334;; Create default fontset from 16 dots fonts which are the most widely 366;; Create default fontset from 16 dots fonts which are the most widely