annotate lisp/msw-faces.el @ 414:da8ed4261e83 r21-2-15

Import from CVS: tag r21-2-15
author cvs
date Mon, 13 Aug 2007 11:21:38 +0200
parents 697ef44129c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1 ;;; msw-faces.el --- mswindows-specific face stuff.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
2
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
4 ;;; Copyright (C) 1995, 1996 Ben Wing.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
5
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
6 ;; Author: Jamie Zawinski
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
7 ;; Modified by: Chuck Thompson
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
8 ;; Modified by: Ben Wing
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
9 ;; Modified by: Martin Buchholz
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
10 ;; Rewritten for mswindows by: Jonathan Harris
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
11
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
12 ;; This file is part of XEmacs.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
13
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
15 ;; under the terms of the GNU General Public License as published by
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
17 ;; any later version.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
18
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
19 ;; XEmacs is distributed in the hope that it will be useful, but
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
22 ;; General Public License for more details.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
23
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
25 ;; along with XEmacs; see the file COPYING. If not, write to the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
27 ;; Boston, MA 02111-1307, USA.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
28
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
29 ;; This file does the magic to parse mswindows font names, and make sure that
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
30 ;; the default and modeline attributes of new frames are specified enough.
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
31
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 400
diff changeset
32 ;;; Force creation of the default face font so that if it fails we get an
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 400
diff changeset
33 ;;; error now instead of a crash at frame creation.
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
34 (defun mswindows-init-device-faces (device)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 400
diff changeset
35 (unless (face-font-instance 'default device)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 400
diff changeset
36 (error "Can't find a suitable default font")))
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 400
diff changeset
37
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
38
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
39 (defun mswindows-init-frame-faces (frame)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
40 )
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
41
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
42 ;; Other functions expect these regexps
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
43 (defconst mswindows-font-regexp
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
44 (let
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
45 ((- ":")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
46 (fontname "\\([a-zA-Z ]+\\)")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
47 (weight "\\([a-zA-Z]*\\)?")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
48 (style "\\( [a-zA-Z]*\\)?")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
49 (pointsize "\\([0-9]+\\)?")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
50 (effects "\\([a-zA-Z ]*\\)?")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
51 (charset "\\([a-zA-Z 0-9]*\\)")
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
52 )
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
53 (concat "^"
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
54 fontname - weight style - pointsize - effects - charset "$")))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
55
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
56 ;;; Fill in missing parts of a font spec. This is primarily intended as a
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
57 ;;; helper function for the functions below.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
58 ;;; mswindows fonts look like:
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 290
diff changeset
59 ;;; fontname[:[weight][ style][:pointsize[:effects]]][:charset]
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
60 ;;; A minimal mswindows font spec looks like:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
61 ;;; Courier New
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
62 ;;; A maximal mswindows font spec looks like:
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
63 ;;; Courier New:Bold Italic:10:underline strikeout:Western
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
64 ;;; Missing parts of the font spec should be filled in with these values:
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
65 ;;; Courier New:Regular:10::Western
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
66 (defun mswindows-font-canonicalize-name (font)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
67 "Given a mswindows font or font name, this returns its name in
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
68 canonical form."
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
69 (if (or (font-instance-p font)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
70 (stringp font))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
71 (let ((name (if (font-instance-p font)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
72 (font-instance-name font)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
73 font)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
74 (cond ((string-match
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
75 "^[a-zA-Z ]+:[a-zA-Z ]*:[0-9]+:[a-zA-Z ]*:[a-zA-Z 0-9]*$"
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
76 name) name)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
77 ((string-match "^[a-zA-Z ]+:[a-zA-Z ]*:[0-9]+:[a-zA-Z ]*$"
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
78 name) (concat name ":Western"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
79 ((string-match "^[a-zA-Z ]+:[a-zA-Z ]*:[0-9]+$" name)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
80 (concat name "::Western"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
81 ((string-match "^[a-zA-Z ]+:[a-zA-Z ]*$" name)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
82 (concat name ":10::Western"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 265
diff changeset
83 ((string-match "^[a-zA-Z ]+$" name)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
84 (concat name ":Regular:10::Western"))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
85 (t "Courier New:Regular:10::Western")))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
86
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
87 (defun mswindows-make-font-bold (font &optional device)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
88 "Given a mswindows font specification, this attempts to make a bold font.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
89 If it fails, it returns nil."
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
90 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
91 (let ((name (mswindows-font-canonicalize-name font))
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
92 (oldwidth (font-instance-width font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
93 (string-match "^[a-zA-Z ]+:\\([a-zA-Z ]*\\):" name)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
94 (let ((newfont (make-font-instance
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
95 (concat (substring name 0 (match-beginning 1))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
96 "Bold" (substring name (match-end 1)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
97 device t)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
98 ; Hack! on mswindows, bold fonts (even monospaced) are often wider than the
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
99 ; equivalent non-bold font. Making the bold font one point smaller usually
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
100 ; makes it the same width (maybe at the expense of making it one pixel shorter)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
101 (if (font-instance-p newfont)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
102 (if (> (font-instance-width newfont) oldwidth)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
103 (mswindows-find-smaller-font newfont device)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
104 newfont))))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
105
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
106 (defun mswindows-make-font-unbold (font &optional device)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
107 "Given a mswindows font specification, this attempts to make a non-bold font.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
108 If it fails, it returns nil."
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
109 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
110 (let ((name (mswindows-font-canonicalize-name font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
111 (string-match "^[a-zA-Z ]+:\\([a-zA-Z ]*\\):" name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
112 (make-font-instance (concat
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
113 (substring name 0 (match-beginning 1))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
114 "Regular" (substring name (match-end 1)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
115 device t))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
116
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
117 (defun mswindows-make-font-italic (font &optional device)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
118 "Given a mswindows font specification, this attempts to make an `italic'
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
119 font. If it fails, it returns nil."
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
120 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
121 (let ((name (mswindows-font-canonicalize-name font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
122 (string-match "^[a-zA-Z ]+:\\([a-zA-Z ]*\\):" name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
123 (make-font-instance (concat
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
124 (substring name 0 (match-beginning 1))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
125 "Italic" (substring name (match-end 1)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
126 device t))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
127
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
128 (defun mswindows-make-font-unitalic (font &optional device)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
129 "Given a mswindows font specification, this attempts to make a non-italic
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
130 font. If it fails, it returns nil."
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
131 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
132 (let ((name (mswindows-font-canonicalize-name font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
133 (string-match "^[a-zA-Z ]+:\\([a-zA-Z ]*\\):" name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
134 (make-font-instance (concat
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
135 (substring name 0 (match-beginning 1))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
136 "Regular" (substring name (match-end 1)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
137 device t))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
138
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
139 (defun mswindows-make-font-bold-italic (font &optional device)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
140 "Given a mswindows font specification, this attempts to make a `bold-italic'
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
141 font. If it fails, it returns nil."
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
142 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
143 (let ((name (mswindows-font-canonicalize-name font))
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
144 (oldwidth (font-instance-width font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
145 (string-match "^[a-zA-Z ]+:\\([a-zA-Z ]*\\):" name)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
146 (let ((newfont (make-font-instance
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
147 (concat (substring name 0 (match-beginning 1))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
148 "Bold Italic" (substring name (match-end 1)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
149 device t)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
150 ; Hack! on mswindows, bold fonts (even monospaced) are often wider than the
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
151 ; equivalent non-bold font. Making the bold font one point smaller usually
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
152 ; makes it the same width (maybe at the expense of making it one pixel shorter)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
153 (if (font-instance-p newfont)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
154 (if (> (font-instance-width newfont) oldwidth)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
155 (mswindows-find-smaller-font newfont device)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
156 newfont))))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
157
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
158 (defun mswindows-find-smaller-font (font &optional device)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
159 "Loads a new version of the given font (or font name) 1 point smaller.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
160 Returns the font if it succeeds, nil otherwise."
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
161 (if (stringp font) (setq font (make-font-instance font device)))
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
162 (if (font-instance-p font) (setq font (font-instance-truename font)))
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
163 (if (stringp font) (setq font (make-font-instance font device)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
164 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
165 (let (old-size (name (mswindows-font-canonicalize-name font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
166 (string-match "^[a-zA-Z ]+:[a-zA-Z ]*:\\([0-9]+\\):" name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
167 (setq old-size (string-to-int
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
168 (substring name (match-beginning 1) (match-end 1))))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
169 (if (> old-size 0)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
170 (make-font-instance (concat
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
171 (substring name 0 (match-beginning 1))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
172 (int-to-string (- old-size 1))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
173 (substring name (match-end 1)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
174 device t)))))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
175
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
176 (defun mswindows-find-larger-font (font &optional device)
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
177 "Loads a new version of the given font (or font name) 1 point larger.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 215
diff changeset
178 Returns the font if it succeeds, nil otherwise."
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
179 (if (stringp font) (setq font (make-font-instance font device)))
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
180 (if (font-instance-p font) (setq font (font-instance-truename font)))
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
181 (if (stringp font) (setq font (make-font-instance font device)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
182 (if (font-instance-p font)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
183 (let (old-size (name (mswindows-font-canonicalize-name font)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
184 (string-match "^[a-zA-Z ]+:[a-zA-Z ]*:\\([0-9]+\\):" name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
185 (setq old-size (string-to-int
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
186 (substring name (match-beginning 1) (match-end 1))))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
187 (make-font-instance (concat
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
188 (substring name 0 (match-beginning 1))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
189 (int-to-string (+ old-size 1))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
190 (substring name (match-end 1)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
191 device t))))