Mercurial > emacs
annotate src/w32font.c @ 93123:38f18130d057
(vc-git-status-result): New variable.
(vc-git-dir-status): Split out ...
(vc-git-after-dir-status-stage1, vc-git-after-dir-status-stage2):
... these new functions and work asynchronously.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Fri, 21 Mar 2008 06:29:04 +0000 |
parents | fb1da73bc0c4 |
children | 6b92cdd67bfb |
rev | line source |
---|---|
90869 | 1 /* Font backend for the Microsoft W32 API. |
91447
15ea95e2d57b
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91264
diff
changeset
|
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. |
90869 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
91447
15ea95e2d57b
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91264
diff
changeset
|
8 the Free Software Foundation; either version 3, or (at your option) |
90869 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
19 Boston, MA 02110-1301, USA. */ | |
20 | |
92472
dba28a9d071a
Wrap in USE_FONT_BACKEND conditional
Jason Rumney <jasonr@gnu.org>
parents:
92413
diff
changeset
|
21 #ifdef USE_FONT_BACKEND |
dba28a9d071a
Wrap in USE_FONT_BACKEND conditional
Jason Rumney <jasonr@gnu.org>
parents:
92413
diff
changeset
|
22 |
90869 | 23 #include <config.h> |
24 #include <windows.h> | |
92413 | 25 #include <math.h> |
90869 | 26 |
27 #include "lisp.h" | |
28 #include "w32term.h" | |
29 #include "frame.h" | |
30 #include "dispextern.h" | |
31 #include "character.h" | |
32 #include "charset.h" | |
33 #include "fontset.h" | |
34 #include "font.h" | |
91208 | 35 #include "w32font.h" |
90869 | 36 |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
37 /* Cleartype available on Windows XP, cleartype_natural from XP SP1. |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
38 The latter does not try to fit cleartype smoothed fonts into the |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
39 same bounding box as the non-antialiased version of the font. |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
40 */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
41 #ifndef CLEARTYPE_QUALITY |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
42 #define CLEARTYPE_QUALITY 5 |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
43 #endif |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
44 #ifndef CLEARTYPE_NATURAL_QUALITY |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
45 #define CLEARTYPE_NATURAL_QUALITY 6 |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
46 #endif |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
47 |
90869 | 48 extern struct font_driver w32font_driver; |
49 | |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
50 Lisp_Object Qgdi; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
51 Lisp_Object Quniscribe; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
52 static Lisp_Object QCformat; |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
53 static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif; |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
54 static Lisp_Object Qserif, Qscript, Qdecorative; |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
55 static Lisp_Object Qraster, Qoutline, Qunknown; |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
56 |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
57 /* antialiasing */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
58 extern Lisp_Object QCantialias; /* defined in font.c */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
59 extern Lisp_Object Qnone; /* reuse from w32fns.c */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
60 static Lisp_Object Qstandard, Qsubpixel, Qnatural; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
61 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
62 /* scripts */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
63 static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
64 static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
65 static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
66 static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
67 static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
68 static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
69 static Lisp_Object Qkhmer, Qmongolian, Qsymbol, Qbraille, Qhan; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
70 static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
71 static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
72 static Lisp_Object Qmusical_symbol, Qmathematical; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
73 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
74 /* Font spacing symbols - defined in font.c. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
75 extern Lisp_Object Qc, Qp, Qm; |
90869 | 76 |
77 static void fill_in_logfont P_ ((FRAME_PTR f, LOGFONT *logfont, | |
78 Lisp_Object font_spec)); | |
79 | |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
80 static BYTE w32_antialias_type P_ ((Lisp_Object type)); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
81 static Lisp_Object lispy_antialias_type P_ ((BYTE type)); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
82 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
83 static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
84 static int w32font_full_name P_ ((LOGFONT * font, Lisp_Object font_obj, |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
85 int pixel_size, char *name, int nbytes)); |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
86 static void recompute_cached_metrics P_ ((HDC dc, struct w32font_info * font)); |
90869 | 87 |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
88 static Lisp_Object w32_registry P_ ((LONG w32_charset, DWORD font_type)); |
90869 | 89 |
90 /* EnumFontFamiliesEx callbacks. */ | |
91 static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *, | |
92 NEWTEXTMETRICEX *, | |
93 DWORD, LPARAM)); | |
94 static int CALLBACK add_one_font_entity_to_list P_ ((ENUMLOGFONTEX *, | |
95 NEWTEXTMETRICEX *, | |
96 DWORD, LPARAM)); | |
97 static int CALLBACK add_font_name_to_list P_ ((ENUMLOGFONTEX *, | |
98 NEWTEXTMETRICEX *, | |
99 DWORD, LPARAM)); | |
100 | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
101 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
102 of what we really want. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
103 struct font_callback_data |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
104 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
105 /* The logfont we are matching against. EnumFontFamiliesEx only matches |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
106 face name and charset, so we need to manually match everything else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
107 in the callback function. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
108 LOGFONT pattern; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
109 /* The original font spec or entity. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
110 Lisp_Object orig_font_spec; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
111 /* The frame the font is being loaded on. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
112 Lisp_Object frame; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
113 /* The list to add matches to. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
114 Lisp_Object list; |
91208 | 115 /* Whether to match only opentype fonts. */ |
116 int opentype_only; | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
117 }; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
118 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
119 /* Handles the problem that EnumFontFamiliesEx will not return all |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
120 style variations if the font name is not specified. */ |
91182
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
121 static void list_all_matching_fonts P_ ((struct font_callback_data *match)); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
122 |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
123 /* From old font code in w32fns.c */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
124 char * w32_to_x_charset P_ ((int charset, char * matching)); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
125 |
90869 | 126 |
127 static int | |
128 memq_no_quit (elt, list) | |
129 Lisp_Object elt, list; | |
130 { | |
131 while (CONSP (list) && ! EQ (XCAR (list), elt)) | |
132 list = XCDR (list); | |
133 return (CONSP (list)); | |
134 } | |
135 | |
136 /* w32 implementation of get_cache for font backend. | |
137 Return a cache of font-entities on FRAME. The cache must be a | |
138 cons whose cdr part is the actual cache area. */ | |
91208 | 139 Lisp_Object |
91246
3a1805edf0b5
(w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91211
diff
changeset
|
140 w32font_get_cache (f) |
3a1805edf0b5
(w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91211
diff
changeset
|
141 FRAME_PTR f; |
90869 | 142 { |
91246
3a1805edf0b5
(w32font_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91211
diff
changeset
|
143 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
90869 | 144 |
145 return (dpyinfo->name_list_element); | |
146 } | |
147 | |
148 /* w32 implementation of list for font backend. | |
149 List fonts exactly matching with FONT_SPEC on FRAME. The value | |
150 is a vector of font-entities. This is the sole API that | |
151 allocates font-entities. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
152 static Lisp_Object |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
153 w32font_list (frame, font_spec) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
154 Lisp_Object frame, font_spec; |
90869 | 155 { |
91208 | 156 return w32font_list_internal (frame, font_spec, 0); |
90869 | 157 } |
158 | |
159 /* w32 implementation of match for font backend. | |
160 Return a font entity most closely matching with FONT_SPEC on | |
161 FRAME. The closeness is detemined by the font backend, thus | |
162 `face-font-selection-order' is ignored here. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
163 static Lisp_Object |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
164 w32font_match (frame, font_spec) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
165 Lisp_Object frame, font_spec; |
90869 | 166 { |
91208 | 167 return w32font_match_internal (frame, font_spec, 0); |
90869 | 168 } |
169 | |
170 /* w32 implementation of list_family for font backend. | |
171 List available families. The value is a list of family names | |
172 (symbols). */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
173 static Lisp_Object |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
174 w32font_list_family (frame) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
175 Lisp_Object frame; |
90869 | 176 { |
177 Lisp_Object list = Qnil; | |
178 LOGFONT font_match_pattern; | |
179 HDC dc; | |
180 FRAME_PTR f = XFRAME (frame); | |
181 | |
182 bzero (&font_match_pattern, sizeof (font_match_pattern)); | |
183 | |
184 dc = get_frame_dc (f); | |
185 | |
186 EnumFontFamiliesEx (dc, &font_match_pattern, | |
187 (FONTENUMPROC) add_font_name_to_list, | |
188 (LPARAM) &list, 0); | |
189 release_frame_dc (f, dc); | |
190 | |
191 return list; | |
192 } | |
193 | |
194 /* w32 implementation of open for font backend. | |
195 Open a font specified by FONT_ENTITY on frame F. | |
196 If the font is scalable, open it with PIXEL_SIZE. */ | |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
197 static struct font * |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
198 w32font_open (f, font_entity, pixel_size) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
199 FRAME_PTR f; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
200 Lisp_Object font_entity; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
201 int pixel_size; |
90869 | 202 { |
203 struct w32font_info *w32_font = xmalloc (sizeof (struct w32font_info)); | |
204 | |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
205 if (w32_font == NULL) |
90869 | 206 return NULL; |
207 | |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
208 if (!w32font_open_internal (f, font_entity, pixel_size, w32_font)) |
90869 | 209 { |
210 xfree (w32_font); | |
211 return NULL; | |
212 } | |
213 | |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
214 return (struct font *) w32_font; |
90869 | 215 } |
216 | |
217 /* w32 implementation of close for font_backend. | |
218 Close FONT on frame F. */ | |
91208 | 219 void |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
220 w32font_close (f, font) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
221 FRAME_PTR f; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
222 struct font *font; |
90869 | 223 { |
224 if (font->font.font) | |
225 { | |
226 W32FontStruct *old_w32_font = (W32FontStruct *)font->font.font; | |
90933
bd1251472ab9
(w32font_close): Delete the GDI font object.
Jason Rumney <jasonr@gnu.org>
parents:
90915
diff
changeset
|
227 DeleteObject (old_w32_font->hfont); |
90869 | 228 xfree (old_w32_font); |
229 font->font.font = 0; | |
230 } | |
231 | |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
232 if (font->font.full_name && font->font.full_name != font->font.name) |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
233 xfree (font->font.full_name); |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
234 |
90869 | 235 if (font->font.name) |
236 xfree (font->font.name); | |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
237 |
90869 | 238 xfree (font); |
239 } | |
240 | |
241 /* w32 implementation of has_char for font backend. | |
242 Optional. | |
243 If FONT_ENTITY has a glyph for character C (Unicode code point), | |
244 return 1. If not, return 0. If a font must be opened to check | |
245 it, return -1. */ | |
91208 | 246 int |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
247 w32font_has_char (entity, c) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
248 Lisp_Object entity; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
249 int c; |
90869 | 250 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
251 Lisp_Object supported_scripts, extra, script; |
90869 | 252 DWORD mask; |
253 | |
90887
aa7f1d212e78
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90879
diff
changeset
|
254 extra = AREF (entity, FONT_EXTRA_INDEX); |
aa7f1d212e78
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90879
diff
changeset
|
255 if (!CONSP (extra)) |
aa7f1d212e78
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90879
diff
changeset
|
256 return -1; |
aa7f1d212e78
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90879
diff
changeset
|
257 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
258 supported_scripts = assq_no_quit (QCscript, extra); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
259 if (!CONSP (supported_scripts)) |
90869 | 260 return -1; |
261 | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
262 supported_scripts = XCDR (supported_scripts); |
90869 | 263 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
264 script = CHAR_TABLE_REF (Vchar_script_table, c); |
90869 | 265 |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
266 return (memq_no_quit (script, supported_scripts)) ? -1 : 0; |
90869 | 267 } |
268 | |
269 /* w32 implementation of encode_char for font backend. | |
270 Return a glyph code of FONT for characer C (Unicode code point). | |
271 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */ | |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
272 static unsigned |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
273 w32font_encode_char (font, c) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
274 struct font *font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
275 int c; |
90869 | 276 { |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
277 struct frame *f; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
278 HDC dc; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
279 HFONT old_font; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
280 DWORD retval; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
281 GCP_RESULTSW result; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
282 wchar_t in[2]; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
283 wchar_t out[2]; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
284 int len; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
285 struct w32font_info *w32_font = (struct w32font_info *) font; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
286 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
287 /* If glyph indexing is not working for this font, just return the |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
288 unicode code-point. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
289 if (!w32_font->glyph_idx) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
290 return c; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
291 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
292 if (c > 0xFFFF) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
293 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
294 /* TODO: Encode as surrogate pair and lookup the glyph. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
295 return FONT_INVALID_CODE; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
296 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
297 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
298 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
299 in[0] = (wchar_t) c; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
300 len = 1; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
301 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
302 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
303 bzero (&result, sizeof (result)); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
304 result.lStructSize = sizeof (result); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
305 result.lpGlyphs = out; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
306 result.nGlyphs = 2; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
307 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
308 f = XFRAME (selected_frame); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
309 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
310 dc = get_frame_dc (f); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
311 old_font = SelectObject (dc, ((W32FontStruct *) (font->font.font))->hfont); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
312 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
313 retval = GetCharacterPlacementW (dc, in, len, 0, &result, 0); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
314 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
315 SelectObject (dc, old_font); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
316 release_frame_dc (f, dc); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
317 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
318 if (retval) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
319 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
320 if (result.nGlyphs != 1 || !result.lpGlyphs[0]) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
321 return FONT_INVALID_CODE; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
322 return result.lpGlyphs[0]; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
323 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
324 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
325 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
326 int i; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
327 /* Mark this font as not supporting glyph indices. This can happen |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
328 on Windows9x, and maybe with non-Truetype fonts on NT etc. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
329 w32_font->glyph_idx = 0; |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
330 recompute_cached_metrics (dc, w32_font); |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
331 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
332 return c; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
333 } |
90869 | 334 } |
335 | |
336 /* w32 implementation of text_extents for font backend. | |
337 Perform the size computation of glyphs of FONT and fillin members | |
338 of METRICS. The glyphs are specified by their glyph codes in | |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
339 CODE (length NGLYPHS). Apparently metrics can be NULL, in this |
90869 | 340 case just return the overall width. */ |
91208 | 341 int |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
342 w32font_text_extents (font, code, nglyphs, metrics) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
343 struct font *font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
344 unsigned *code; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
345 int nglyphs; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
346 struct font_metrics *metrics; |
90869 | 347 { |
348 int i; | |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
349 HFONT old_font = NULL; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
350 HDC dc = NULL; |
91208 | 351 struct frame * f; |
90869 | 352 int total_width = 0; |
353 WORD *wcode = alloca(nglyphs * sizeof (WORD)); | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
354 SIZE size; |
90869 | 355 |
91593
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
356 /* TODO: Frames can come and go, and their fonts outlive them. So we |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
357 can't cache the frame in the font structure. Use selected_frame |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
358 until the API is updated to pass in a frame. */ |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
359 f = XFRAME (selected_frame); |
91258 | 360 |
90869 | 361 if (metrics) |
362 { | |
363 GLYPHMETRICS gm; | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
364 MAT2 transform; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
365 struct w32font_info *w32_font = (struct w32font_info *) font; |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
366 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
367 /* Set transform to the identity matrix. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
368 bzero (&transform, sizeof (transform)); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
369 transform.eM11.value = 1; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
370 transform.eM22.value = 1; |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
371 metrics->width = 0; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
372 metrics->ascent = 0; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
373 metrics->descent = 0; |
91593
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
374 metrics->lbearing = 0; |
90869 | 375 |
376 for (i = 0; i < nglyphs; i++) | |
377 { | |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
378 if (*(code + i) < 128) |
91593
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
379 { |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
380 /* Use cached metrics for ASCII. */ |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
381 struct font_metrics *char_metric |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
382 = &w32_font->ascii_metrics[*(code+i)]; |
91593
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
383 |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
384 /* If we couldn't get metrics when caching, use fallback. */ |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
385 if (char_metric->width == 0) |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
386 break; |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
387 |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
388 metrics->lbearing = max (metrics->lbearing, |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
389 char_metric->lbearing - metrics->width); |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
390 metrics->rbearing = max (metrics->rbearing, |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
391 metrics->width + char_metric->rbearing); |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
392 metrics->width += char_metric->width; |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
393 metrics->ascent = max (metrics->ascent, char_metric->ascent); |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
394 metrics->descent = max (metrics->descent, char_metric->descent); |
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
395 } |
90869 | 396 else |
397 { | |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
398 if (dc == NULL) |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
399 { |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
400 dc = get_frame_dc (f); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
401 old_font = SelectObject (dc, ((W32FontStruct *) |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
402 (font->font.font))->hfont); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
403 } |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
404 if (GetGlyphOutlineW (dc, *(code + i), |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
405 GGO_METRICS |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
406 | w32_font->glyph_idx |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
407 ? GGO_GLYPH_INDEX : 0, |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
408 &gm, 0, NULL, &transform) != GDI_ERROR) |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
409 { |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
410 int new_val = metrics->width + gm.gmBlackBoxX |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
411 + gm.gmptGlyphOrigin.x; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
412 metrics->rbearing = max (metrics->rbearing, new_val); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
413 new_val = -gm.gmptGlyphOrigin.x - metrics->width; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
414 metrics->lbearing = max (metrics->lbearing, new_val); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
415 metrics->width += gm.gmCellIncX; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
416 new_val = -gm.gmptGlyphOrigin.y; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
417 metrics->ascent = max (metrics->ascent, new_val); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
418 new_val = gm.gmBlackBoxY + gm.gmptGlyphOrigin.y; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
419 metrics->descent = max (metrics->descent, new_val); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
420 } |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
421 else |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
422 { |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
423 if (w32_font->glyph_idx) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
424 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
425 /* Disable glyph indexing for this font, as we can't |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
426 handle the metrics. Abort this run, our recovery |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
427 strategies rely on having unicode code points here. |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
428 This will cause a glitch in display, but in practice, |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
429 any problems should be caught when initialising the |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
430 metrics cache. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
431 w32_font->glyph_idx = 0; |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
432 recompute_cached_metrics (dc, w32_font); |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
433 SelectObject (dc, old_font); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
434 release_frame_dc (f, dc); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
435 return 0; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
436 } |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
437 /* Rely on an estimate based on the overall font metrics. */ |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
438 break; |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
439 } |
90869 | 440 } |
441 } | |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
442 |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
443 /* If we got through everything, return. */ |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
444 if (i == nglyphs) |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
445 { |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
446 if (dc != NULL) |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
447 { |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
448 /* Restore state and release DC. */ |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
449 SelectObject (dc, old_font); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
450 release_frame_dc (f, dc); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
451 } |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
452 |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
453 return metrics->width; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
454 } |
90869 | 455 } |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
456 |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
457 for (i = 0; i < nglyphs; i++) |
90869 | 458 { |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
459 if (code[i] < 0x10000) |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
460 wcode[i] = code[i]; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
461 else |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
462 { |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
463 /* TODO: Convert to surrogate, reallocating array if needed */ |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
464 wcode[i] = 0xffff; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
465 } |
90869 | 466 } |
467 | |
92151
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
468 if (dc == NULL) |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
469 { |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
470 dc = get_frame_dc (f); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
471 old_font = SelectObject (dc, ((W32FontStruct *) |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
472 (font->font.font))->hfont); |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
473 } |
664a09af03dc
(w32font_text_extents): Avoid getting HDC and selecting
Jason Rumney <jasonr@gnu.org>
parents:
91593
diff
changeset
|
474 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
475 if (GetTextExtentPoint32W (dc, wcode, nglyphs, &size)) |
90869 | 476 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
477 total_width = size.cx; |
90869 | 478 } |
479 | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
480 if (!total_width) |
90869 | 481 { |
482 RECT rect; | |
483 rect.top = 0; rect.bottom = font->font.height; rect.left = 0; rect.right = 1; | |
484 DrawTextW (dc, wcode, nglyphs, &rect, | |
485 DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE); | |
486 total_width = rect.right; | |
487 } | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
488 |
91034
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
489 if (metrics) |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
490 { |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
491 metrics->width = total_width; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
492 metrics->ascent = font->ascent; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
493 metrics->descent = font->descent; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
494 metrics->lbearing = 0; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
495 metrics->rbearing = total_width |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
496 + ((struct w32font_info *) font)->metrics.tmOverhang; |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
497 } |
fe9053c62d68
(w32font_text_extents): Calculate metrics for the whole string.
Jason Rumney <jasonr@gnu.org>
parents:
91030
diff
changeset
|
498 |
90869 | 499 /* Restore state and release DC. */ |
500 SelectObject (dc, old_font); | |
91208 | 501 release_frame_dc (f, dc); |
90869 | 502 |
503 return total_width; | |
504 } | |
505 | |
506 /* w32 implementation of draw for font backend. | |
507 Optional. | |
508 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel | |
509 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND | |
510 is nonzero, fill the background in advance. It is assured that | |
91182
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
511 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
512 |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
513 TODO: Currently this assumes that the colors and fonts are already |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
514 set in the DC. This seems to be true now, but maybe only due to |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
515 the old font code setting it up. It may be safer to resolve faces |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
516 and fonts in here and set them explicitly |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
517 */ |
bbdb7226d848
(add_font_entity_to_list): Compare only the beginning of full name.
Jason Rumney <jasonr@gnu.org>
parents:
91158
diff
changeset
|
518 |
91208 | 519 int |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
520 w32font_draw (s, from, to, x, y, with_background) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
521 struct glyph_string *s; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
522 int from, to, x, y, with_background; |
90869 | 523 { |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
524 UINT options; |
91030
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
525 HRGN orig_clip; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
526 struct w32font_info *w32font = (struct w32font_info *) s->face->font_info; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
527 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
528 options = w32font->glyph_idx; |
91030
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
529 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
530 /* Save clip region for later restoration. */ |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
531 GetClipRgn(s->hdc, orig_clip); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
532 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
533 if (s->num_clips > 0) |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
534 { |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
535 HRGN new_clip = CreateRectRgnIndirect (s->clip); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
536 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
537 if (s->num_clips > 1) |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
538 { |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
539 HRGN clip2 = CreateRectRgnIndirect (s->clip + 1); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
540 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
541 CombineRgn (new_clip, new_clip, clip2, RGN_OR); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
542 DeleteObject (clip2); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
543 } |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
544 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
545 SelectClipRgn (s->hdc, new_clip); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
546 DeleteObject (new_clip); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
547 } |
90869 | 548 |
91128
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
549 /* Using OPAQUE background mode can clear more background than expected |
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
550 when Cleartype is used. Draw the background manually to avoid this. */ |
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
551 SetBkMode (s->hdc, TRANSPARENT); |
90869 | 552 if (with_background) |
553 { | |
90908
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
554 HBRUSH brush; |
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
555 RECT rect; |
91128
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
556 struct font *font = (struct font *) s->face->font_info; |
90908
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
557 |
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
558 brush = CreateSolidBrush (s->gc->background); |
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
559 rect.left = x; |
91128
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
560 rect.top = y - font->ascent; |
90908
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
561 rect.right = x + s->width; |
91128
8eb56b57e4a0
(w32font_draw): Fill background manually.
Jason Rumney <jasonr@gnu.org>
parents:
91124
diff
changeset
|
562 rect.bottom = y + font->descent; |
90908
523a5c7f67ea
(w32font_open): Don't set font_idx.
Jason Rumney <jasonr@gnu.org>
parents:
90906
diff
changeset
|
563 FillRect (s->hdc, &rect, brush); |
90915
9aac5aff0dda
(w32font_draw): Delete brush after using it.
Jason Rumney <jasonr@gnu.org>
parents:
90908
diff
changeset
|
564 DeleteObject (brush); |
90869 | 565 } |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
566 |
92187
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
567 if (s->padding_p) |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
568 { |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
569 int len = to - from, i; |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
570 |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
571 for (i = 0; i < len; i++) |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
572 ExtTextOutW (s->hdc, x + i, y, options, NULL, |
92199
8324a41d50a9
(w32font_draw): Draw one character at a time when padding.
Jason Rumney <jasonr@gnu.org>
parents:
92187
diff
changeset
|
573 s->char2b + from + i, 1, NULL); |
92187
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
574 } |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
575 else |
b7277e09e943
(w32font_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
92151
diff
changeset
|
576 ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, to - from, NULL); |
91030
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
577 |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
578 /* Restore clip region. */ |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
579 if (s->num_clips > 0) |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
580 { |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
581 SelectClipRgn (s->hdc, orig_clip); |
8be09e8e2c97
(w32font_draw): Do clipping here.
Jason Rumney <jasonr@gnu.org>
parents:
90964
diff
changeset
|
582 } |
90869 | 583 } |
584 | |
585 /* w32 implementation of free_entity for font backend. | |
586 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value). | |
587 Free FONT_EXTRA_INDEX field of FONT_ENTITY. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
588 static void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
589 w32font_free_entity (Lisp_Object entity); |
90869 | 590 */ |
591 | |
592 /* w32 implementation of prepare_face for font backend. | |
593 Optional (if FACE->extra is not used). | |
594 Prepare FACE for displaying characters by FONT on frame F by | |
595 storing some data in FACE->extra. If successful, return 0. | |
596 Otherwise, return -1. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
597 static int |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
598 w32font_prepare_face (FRAME_PTR f, struct face *face); |
90869 | 599 */ |
600 /* w32 implementation of done_face for font backend. | |
601 Optional. | |
602 Done FACE for displaying characters by FACE->font on frame F. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
603 static void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
604 w32font_done_face (FRAME_PTR f, struct face *face); */ |
90869 | 605 |
606 /* w32 implementation of get_bitmap for font backend. | |
607 Optional. | |
608 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is | |
90915
9aac5aff0dda
(w32font_draw): Delete brush after using it.
Jason Rumney <jasonr@gnu.org>
parents:
90908
diff
changeset
|
609 intended that this method is called from the other font-driver |
90869 | 610 for actual drawing. |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
611 static int |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
612 w32font_get_bitmap (struct font *font, unsigned code, |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
613 struct font_bitmap *bitmap, int bits_per_pixel); |
90869 | 614 */ |
615 /* w32 implementation of free_bitmap for font backend. | |
616 Optional. | |
617 Free bitmap data in BITMAP. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
618 static void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
619 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap); |
90869 | 620 */ |
621 /* w32 implementation of get_outline for font backend. | |
622 Optional. | |
623 Return an outline data for glyph-code CODE of FONT. The format | |
624 of the outline data depends on the font-driver. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
625 static void * |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
626 w32font_get_outline (struct font *font, unsigned code); |
90869 | 627 */ |
628 /* w32 implementation of free_outline for font backend. | |
629 Optional. | |
630 Free OUTLINE (that is obtained by the above method). | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
631 static void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
632 w32font_free_outline (struct font *font, void *outline); |
90869 | 633 */ |
634 /* w32 implementation of anchor_point for font backend. | |
635 Optional. | |
636 Get coordinates of the INDEXth anchor point of the glyph whose | |
637 code is CODE. Store the coordinates in *X and *Y. Return 0 if | |
638 the operations was successfull. Otherwise return -1. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
639 static int |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
640 w32font_anchor_point (struct font *font, unsigned code, |
90869 | 641 int index, int *x, int *y); |
642 */ | |
643 /* w32 implementation of otf_capability for font backend. | |
644 Optional. | |
645 Return a list describing which scripts/languages FONT | |
646 supports by which GSUB/GPOS features of OpenType tables. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
647 static Lisp_Object |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
648 w32font_otf_capability (struct font *font); |
90869 | 649 */ |
650 /* w32 implementation of otf_drive for font backend. | |
651 Optional. | |
652 Apply FONT's OTF-FEATURES to the glyph string. | |
653 | |
654 FEATURES specifies which OTF features to apply in this format: | |
655 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE) | |
656 See the documentation of `font-drive-otf' for the detail. | |
657 | |
658 This method applies the specified features to the codes in the | |
659 elements of GSTRING-IN (between FROMth and TOth). The output | |
660 codes are stored in GSTRING-OUT at the IDXth element and the | |
661 following elements. | |
662 | |
663 Return the number of output codes. If none of the features are | |
664 applicable to the input data, return 0. If GSTRING-OUT is too | |
665 short, return -1. | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
666 static int |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
667 w32font_otf_drive (struct font *font, Lisp_Object features, |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
668 Lisp_Object gstring_in, int from, int to, |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
669 Lisp_Object gstring_out, int idx, |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
670 int alternate_subst); |
90869 | 671 */ |
672 | |
91208 | 673 /* Internal implementation of w32font_list. |
674 Additional parameter opentype_only restricts the returned fonts to | |
675 opentype fonts, which can be used with the Uniscribe backend. */ | |
676 Lisp_Object | |
677 w32font_list_internal (frame, font_spec, opentype_only) | |
678 Lisp_Object frame, font_spec; | |
679 int opentype_only; | |
680 { | |
681 struct font_callback_data match_data; | |
682 HDC dc; | |
683 FRAME_PTR f = XFRAME (frame); | |
684 | |
685 match_data.orig_font_spec = font_spec; | |
686 match_data.list = Qnil; | |
687 match_data.frame = frame; | |
688 | |
689 bzero (&match_data.pattern, sizeof (LOGFONT)); | |
690 fill_in_logfont (f, &match_data.pattern, font_spec); | |
691 | |
692 match_data.opentype_only = opentype_only; | |
693 if (opentype_only) | |
694 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS; | |
695 | |
696 if (match_data.pattern.lfFaceName[0] == '\0') | |
697 { | |
698 /* EnumFontFamiliesEx does not take other fields into account if | |
699 font name is blank, so need to use two passes. */ | |
700 list_all_matching_fonts (&match_data); | |
701 } | |
702 else | |
703 { | |
704 dc = get_frame_dc (f); | |
705 | |
706 EnumFontFamiliesEx (dc, &match_data.pattern, | |
707 (FONTENUMPROC) add_font_entity_to_list, | |
708 (LPARAM) &match_data, 0); | |
709 release_frame_dc (f, dc); | |
710 } | |
711 | |
712 return NILP (match_data.list) ? null_vector : Fvconcat (1, &match_data.list); | |
713 } | |
714 | |
715 /* Internal implementation of w32font_match. | |
716 Additional parameter opentype_only restricts the returned fonts to | |
717 opentype fonts, which can be used with the Uniscribe backend. */ | |
718 Lisp_Object | |
719 w32font_match_internal (frame, font_spec, opentype_only) | |
720 Lisp_Object frame, font_spec; | |
721 int opentype_only; | |
722 { | |
723 struct font_callback_data match_data; | |
724 HDC dc; | |
725 FRAME_PTR f = XFRAME (frame); | |
726 | |
727 match_data.orig_font_spec = font_spec; | |
728 match_data.frame = frame; | |
729 match_data.list = Qnil; | |
730 | |
731 bzero (&match_data.pattern, sizeof (LOGFONT)); | |
732 fill_in_logfont (f, &match_data.pattern, font_spec); | |
733 | |
734 match_data.opentype_only = opentype_only; | |
735 if (opentype_only) | |
736 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS; | |
737 | |
738 dc = get_frame_dc (f); | |
739 | |
740 EnumFontFamiliesEx (dc, &match_data.pattern, | |
741 (FONTENUMPROC) add_one_font_entity_to_list, | |
742 (LPARAM) &match_data, 0); | |
743 release_frame_dc (f, dc); | |
744 | |
745 return NILP (match_data.list) ? Qnil : XCAR (match_data.list); | |
746 } | |
747 | |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
748 int |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
749 w32font_open_internal (f, font_entity, pixel_size, w32_font) |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
750 FRAME_PTR f; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
751 Lisp_Object font_entity; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
752 int pixel_size; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
753 struct w32font_info *w32_font; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
754 { |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
755 int len, size; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
756 LOGFONT logfont; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
757 HDC dc; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
758 HFONT hfont, old_font; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
759 Lisp_Object val, extra; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
760 /* For backwards compatibility. */ |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
761 W32FontStruct *compat_w32_font; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
762 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
763 struct font * font = (struct font *) w32_font; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
764 if (!font) |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
765 return 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
766 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
767 bzero (&logfont, sizeof (logfont)); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
768 fill_in_logfont (f, &logfont, font_entity); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
769 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
770 size = XINT (AREF (font_entity, FONT_SIZE_INDEX)); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
771 if (!size) |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
772 size = pixel_size; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
773 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
774 logfont.lfHeight = -size; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
775 hfont = CreateFontIndirect (&logfont); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
776 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
777 if (hfont == NULL) |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
778 return 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
779 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
780 /* Get the metrics for this font. */ |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
781 dc = get_frame_dc (f); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
782 old_font = SelectObject (dc, hfont); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
783 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
784 GetTextMetrics (dc, &w32_font->metrics); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
785 |
92712
fb1da73bc0c4
(w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents:
92539
diff
changeset
|
786 w32_font->glyph_idx = ETO_GLYPH_INDEX; |
fb1da73bc0c4
(w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents:
92539
diff
changeset
|
787 |
91593
3081b8f848bc
* w32font.c (w32font_text_extents): Fill in lbearing metric.
Jason Rumney <jasonr@gnu.org>
parents:
91545
diff
changeset
|
788 /* Cache ASCII metrics. */ |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
789 recompute_cached_metrics (dc, w32_font); |
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
790 |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
791 SelectObject (dc, old_font); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
792 release_frame_dc (f, dc); |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
793 |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
794 /* W32FontStruct - we should get rid of this, and use the w32font_info |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
795 struct for any W32 specific fields. font->font.font can then be hfont. */ |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
796 font->font.font = xmalloc (sizeof (W32FontStruct)); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
797 compat_w32_font = (W32FontStruct *) font->font.font; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
798 bzero (compat_w32_font, sizeof (W32FontStruct)); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
799 compat_w32_font->font_type = UNICODE_FONT; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
800 /* Duplicate the text metrics. */ |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
801 bcopy (&w32_font->metrics, &compat_w32_font->tm, sizeof (TEXTMETRIC)); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
802 compat_w32_font->hfont = hfont; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
803 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
804 len = strlen (logfont.lfFaceName); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
805 font->font.name = (char *) xmalloc (len + 1); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
806 bcopy (logfont.lfFaceName, font->font.name, len); |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
807 font->font.name[len] = '\0'; |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
808 |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
809 { |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
810 char *name; |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
811 |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
812 /* We don't know how much space we need for the full name, so start with |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
813 96 bytes and go up in steps of 32. */ |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
814 len = 96; |
91521
e96ff7166c81
(w32font_open_internal): Use xmalloc, xrealloc, xfree.
Jason Rumney <jasonr@gnu.org>
parents:
91496
diff
changeset
|
815 name = xmalloc (len); |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
816 while (name && w32font_full_name (&logfont, font_entity, pixel_size, |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
817 name, len) < 0) |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
818 { |
91521
e96ff7166c81
(w32font_open_internal): Use xmalloc, xrealloc, xfree.
Jason Rumney <jasonr@gnu.org>
parents:
91496
diff
changeset
|
819 char *new = xrealloc (name, len += 32); |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
820 |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
821 if (! new) |
91521
e96ff7166c81
(w32font_open_internal): Use xmalloc, xrealloc, xfree.
Jason Rumney <jasonr@gnu.org>
parents:
91496
diff
changeset
|
822 xfree (name); |
91496
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
823 name = new; |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
824 } |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
825 if (name) |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
826 font->font.full_name = name; |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
827 else |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
828 font->font.full_name = font->font.name; |
d3d1ab7e6e35
(w32font_open_internal): Use font_unparse_fcname to set full_name.
Jason Rumney <jasonr@gnu.org>
parents:
91447
diff
changeset
|
829 } |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
830 font->font.charset = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
831 font->font.codepage = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
832 font->font.size = w32_font->metrics.tmMaxCharWidth; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
833 font->font.height = w32_font->metrics.tmHeight |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
834 + w32_font->metrics.tmExternalLeading; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
835 font->font.space_width = font->font.average_width |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
836 = w32_font->metrics.tmAveCharWidth; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
837 |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
838 font->font.vertical_centering = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
839 font->font.encoding_type = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
840 font->font.baseline_offset = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
841 font->font.relative_compose = 0; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
842 font->font.default_ascent = w32_font->metrics.tmAscent; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
843 font->font.font_encoder = NULL; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
844 font->entity = font_entity; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
845 font->pixel_size = size; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
846 font->driver = &w32font_driver; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
847 /* Use format cached during list, as the information we have access to |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
848 here is incomplete. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
849 extra = AREF (font_entity, FONT_EXTRA_INDEX); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
850 if (CONSP (extra)) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
851 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
852 val = assq_no_quit (QCformat, extra); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
853 if (CONSP (val)) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
854 font->format = XCDR (val); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
855 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
856 font->format = Qunknown; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
857 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
858 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
859 font->format = Qunknown; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
860 |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
861 font->file_name = NULL; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
862 font->encoding_charset = -1; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
863 font->repertory_charset = -1; |
91545
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
864 /* TODO: do we really want the minimum width here, which could be negative? */ |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
865 font->min_width = font->font.space_width; |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
866 font->ascent = w32_font->metrics.tmAscent; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
867 font->descent = w32_font->metrics.tmDescent; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
868 font->scalable = w32_font->metrics.tmPitchAndFamily & TMPF_VECTOR; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
869 |
91545
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
870 /* Set global flag fonts_changed_p to non-zero if the font loaded |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
871 has a character with a smaller width than any other character |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
872 before, or if the font loaded has a smaller height than any other |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
873 font loaded before. If this happens, it will make a glyph matrix |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
874 reallocation necessary. */ |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
875 { |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
876 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
877 dpyinfo->n_fonts++; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
878 |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
879 if (dpyinfo->n_fonts == 1) |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
880 { |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
881 dpyinfo->smallest_font_height = font->font.height; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
882 dpyinfo->smallest_char_width = font->min_width; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
883 } |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
884 else |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
885 { |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
886 if (dpyinfo->smallest_font_height > font->font.height) |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
887 { |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
888 dpyinfo->smallest_font_height = font->font.height; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
889 fonts_changed_p |= 1; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
890 } |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
891 if (dpyinfo->smallest_char_width > font->min_width) |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
892 { |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
893 dpyinfo->smallest_char_width = font->min_width; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
894 fonts_changed_p |= 1; |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
895 } |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
896 } |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
897 } |
572ea0c7c071
(w32font_open_internal): Fill min_width with tmAveCharWidth.
Jason Rumney <jasonr@gnu.org>
parents:
91521
diff
changeset
|
898 |
91211
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
899 return 1; |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
900 } |
abd06276f55a
(w32font_open_internal): New function.
Jason Rumney <jasonr@gnu.org>
parents:
91208
diff
changeset
|
901 |
90869 | 902 /* Callback function for EnumFontFamiliesEx. |
903 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
904 static int CALLBACK |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
905 add_font_name_to_list (logical_font, physical_font, font_type, list_object) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
906 ENUMLOGFONTEX *logical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
907 NEWTEXTMETRICEX *physical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
908 DWORD font_type; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
909 LPARAM list_object; |
90869 | 910 { |
911 Lisp_Object* list = (Lisp_Object *) list_object; | |
91070
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
912 Lisp_Object family; |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
913 |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
914 /* Skip vertical fonts (intended only for printing) */ |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
915 if (logical_font->elfLogFont.lfFaceName[0] == '@') |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
916 return 1; |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
917 |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
918 family = intern_downcase (logical_font->elfLogFont.lfFaceName, |
2060802cc53f
(add_font_name_to_list): Avoid vertical fonts.
Jason Rumney <jasonr@gnu.org>
parents:
91034
diff
changeset
|
919 strlen (logical_font->elfLogFont.lfFaceName)); |
90869 | 920 if (! memq_no_quit (family, *list)) |
921 *list = Fcons (family, *list); | |
922 | |
923 return 1; | |
924 } | |
925 | |
926 /* Convert an enumerated Windows font to an Emacs font entity. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
927 static Lisp_Object |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
928 w32_enumfont_pattern_entity (frame, logical_font, physical_font, |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
929 font_type, requested_font, backend) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
930 Lisp_Object frame; |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
931 ENUMLOGFONTEX *logical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
932 NEWTEXTMETRICEX *physical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
933 DWORD font_type; |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
934 LOGFONT *requested_font; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
935 Lisp_Object backend; |
90869 | 936 { |
937 Lisp_Object entity, tem; | |
938 LOGFONT *lf = (LOGFONT*) logical_font; | |
939 BYTE generic_type; | |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
940 BYTE full_type = physical_font->ntmTm.ntmFlags; |
90869 | 941 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
942 entity = Fmake_vector (make_number (FONT_ENTITY_MAX), Qnil); |
90869 | 943 |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
944 ASET (entity, FONT_TYPE_INDEX, backend); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
945 ASET (entity, FONT_FRAME_INDEX, frame); |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
946 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet, font_type)); |
90869 | 947 ASET (entity, FONT_OBJLIST_INDEX, Qnil); |
948 | |
949 /* Foundry is difficult to get in readable form on Windows. | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
950 But Emacs crashes if it is not set, so set it to something more |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
951 generic. Thes values make xflds compatible with Emacs 22. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
952 if (lf->lfOutPrecision == OUT_STRING_PRECIS) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
953 tem = Qraster; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
954 else if (lf->lfOutPrecision == OUT_STROKE_PRECIS) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
955 tem = Qoutline; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
956 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
957 tem = Qunknown; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
958 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
959 ASET (entity, FONT_FOUNDRY_INDEX, tem); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
960 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
961 /* Save the generic family in the extra info, as it is likely to be |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
962 useful to users looking for a close match. */ |
90869 | 963 generic_type = physical_font->ntmTm.tmPitchAndFamily & 0xF0; |
964 if (generic_type == FF_DECORATIVE) | |
965 tem = Qdecorative; | |
966 else if (generic_type == FF_MODERN) | |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
967 tem = Qmono; |
90869 | 968 else if (generic_type == FF_ROMAN) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
969 tem = Qserif; |
90869 | 970 else if (generic_type == FF_SCRIPT) |
971 tem = Qscript; | |
972 else if (generic_type == FF_SWISS) | |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
973 tem = Qsans; |
90869 | 974 else |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
975 tem = null_string; |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
976 |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
977 ASET (entity, FONT_ADSTYLE_INDEX, tem); |
90869 | 978 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
979 if (physical_font->ntmTm.tmPitchAndFamily & 0x01) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
980 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL)); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
981 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
982 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO)); |
90869 | 983 |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
984 if (requested_font->lfQuality != DEFAULT_QUALITY) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
985 { |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
986 font_put_extra (entity, QCantialias, |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
987 lispy_antialias_type (requested_font->lfQuality)); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
988 } |
90869 | 989 ASET (entity, FONT_FAMILY_INDEX, |
990 intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName))); | |
991 | |
992 ASET (entity, FONT_WEIGHT_INDEX, make_number (lf->lfWeight)); | |
993 ASET (entity, FONT_SLANT_INDEX, make_number (lf->lfItalic ? 200 : 100)); | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
994 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
995 to get it. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
996 ASET (entity, FONT_WIDTH_INDEX, make_number (100)); |
90869 | 997 |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
998 if (font_type & RASTER_FONTTYPE) |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
999 ASET (entity, FONT_SIZE_INDEX, make_number (physical_font->ntmTm.tmHeight)); |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1000 else |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1001 ASET (entity, FONT_SIZE_INDEX, make_number (0)); |
90869 | 1002 |
1003 /* Cache unicode codepoints covered by this font, as there is no other way | |
1004 of getting this information easily. */ | |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1005 if (font_type & TRUETYPE_FONTTYPE) |
90869 | 1006 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1007 font_put_extra (entity, QCscript, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1008 font_supported_scripts (&physical_font->ntmFontSig)); |
90869 | 1009 } |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1010 |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1011 /* This information is not fully available when opening fonts, so |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1012 save it here. Only Windows 2000 and later return information |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1013 about opentype and type1 fonts, so need a fallback for detecting |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1014 truetype so that this information is not any worse than we could |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1015 have obtained later. */ |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1016 if (full_type & NTM_TT_OPENTYPE || font_type & TRUETYPE_FONTTYPE) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1017 tem = intern ("truetype"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1018 else if (full_type & NTM_TYPE1) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1019 tem = intern ("type1"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1020 else if (full_type & NTM_PS_OPENTYPE) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1021 tem = intern ("postscript"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1022 else if (font_type & RASTER_FONTTYPE) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1023 tem = intern ("w32bitmap"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1024 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1025 tem = intern ("w32vector"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1026 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1027 font_put_extra (entity, QCformat, tem); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1028 |
90869 | 1029 return entity; |
1030 } | |
1031 | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1032 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1033 /* Convert generic families to the family portion of lfPitchAndFamily. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1034 BYTE |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1035 w32_generic_family (Lisp_Object name) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1036 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1037 /* Generic families. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1038 if (EQ (name, Qmonospace) || EQ (name, Qmono)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1039 return FF_MODERN; |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1040 else if (EQ (name, Qsans) || EQ (name, Qsans_serif) || EQ (name, Qsansserif)) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1041 return FF_SWISS; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1042 else if (EQ (name, Qserif)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1043 return FF_ROMAN; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1044 else if (EQ (name, Qdecorative)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1045 return FF_DECORATIVE; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1046 else if (EQ (name, Qscript)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1047 return FF_SCRIPT; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1048 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1049 return FF_DONTCARE; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1050 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1051 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1052 static int |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1053 logfonts_match (font, pattern) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1054 LOGFONT *font, *pattern; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1055 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1056 /* Only check height for raster fonts. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1057 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1058 && font->lfHeight != pattern->lfHeight) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1059 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1060 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1061 /* Have some flexibility with weights. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1062 if (pattern->lfWeight |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1063 && ((font->lfWeight < (pattern->lfWeight - 150)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1064 || font->lfWeight > (pattern->lfWeight + 150))) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1065 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1066 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1067 /* Charset and face should be OK. Italic has to be checked |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1068 against the original spec, in case we don't have any preference. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1069 return 1; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1070 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1071 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1072 static int |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1073 font_matches_spec (type, font, spec) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1074 DWORD type; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1075 NEWTEXTMETRICEX *font; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1076 Lisp_Object spec; |
90869 | 1077 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1078 Lisp_Object extra, val; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1079 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1080 /* Check italic. Can't check logfonts, since it is a boolean field, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1081 so there is no difference between "non-italic" and "don't care". */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1082 val = AREF (spec, FONT_SLANT_INDEX); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1083 if (INTEGERP (val)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1084 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1085 int slant = XINT (val); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1086 if ((slant > 150 && !font->ntmTm.tmItalic) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1087 || (slant <= 150 && font->ntmTm.tmItalic)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1088 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1089 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1090 |
91264
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1091 /* Check adstyle against generic family. */ |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1092 val = AREF (spec, FONT_ADSTYLE_INDEX); |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1093 if (!NILP (val)) |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1094 { |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1095 BYTE family = w32_generic_family (val); |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1096 if (family != FF_DONTCARE |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1097 && family != (font->ntmTm.tmPitchAndFamily & 0xF0)) |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1098 return 0; |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1099 } |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1100 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1101 /* Check extra parameters. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1102 for (extra = AREF (spec, FONT_EXTRA_INDEX); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1103 CONSP (extra); extra = XCDR (extra)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1104 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1105 Lisp_Object extra_entry; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1106 extra_entry = XCAR (extra); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1107 if (CONSP (extra_entry)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1108 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1109 Lisp_Object key = XCAR (extra_entry); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1110 val = XCDR (extra_entry); |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1111 if (EQ (key, QCspacing)) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1112 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1113 int proportional; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1114 if (INTEGERP (val)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1115 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1116 int spacing = XINT (val); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1117 proportional = (spacing < FONT_SPACING_MONO); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1118 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1119 else if (EQ (val, Qp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1120 proportional = 1; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1121 else if (EQ (val, Qc) || EQ (val, Qm)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1122 proportional = 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1123 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1124 return 0; /* Bad font spec. */ |
90869 | 1125 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1126 if ((proportional && !(font->ntmTm.tmPitchAndFamily & 0x01)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1127 || (!proportional && (font->ntmTm.tmPitchAndFamily & 0x01))) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1128 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1129 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1130 else if (EQ (key, QCscript) && SYMBOLP (val)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1131 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1132 /* Only truetype fonts will have information about what |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1133 scripts they support. This probably means the user |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1134 will have to force Emacs to use raster, postscript |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1135 or atm fonts for non-ASCII text. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1136 if (type & TRUETYPE_FONTTYPE) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1137 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1138 Lisp_Object support |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1139 = font_supported_scripts (&font->ntmFontSig); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1140 if (! memq_no_quit (val, support)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1141 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1142 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1143 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1144 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1145 /* Return specific matches, but play it safe. Fonts |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1146 that cover more than their charset would suggest |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1147 are likely to be truetype or opentype fonts, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1148 covered above. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1149 if (EQ (val, Qlatin)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1150 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1151 /* Although every charset but symbol, thai and |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1152 arabic contains the basic ASCII set of latin |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1153 characters, Emacs expects much more. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1154 if (font->ntmTm.tmCharSet != ANSI_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1155 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1156 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1157 else if (EQ (val, Qsymbol)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1158 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1159 if (font->ntmTm.tmCharSet != SYMBOL_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1160 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1161 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1162 else if (EQ (val, Qcyrillic)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1163 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1164 if (font->ntmTm.tmCharSet != RUSSIAN_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1165 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1166 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1167 else if (EQ (val, Qgreek)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1168 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1169 if (font->ntmTm.tmCharSet != GREEK_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1170 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1171 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1172 else if (EQ (val, Qarabic)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1173 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1174 if (font->ntmTm.tmCharSet != ARABIC_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1175 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1176 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1177 else if (EQ (val, Qhebrew)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1178 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1179 if (font->ntmTm.tmCharSet != HEBREW_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1180 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1181 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1182 else if (EQ (val, Qthai)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1183 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1184 if (font->ntmTm.tmCharSet != THAI_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1185 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1186 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1187 else if (EQ (val, Qkana)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1188 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1189 if (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1190 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1191 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1192 else if (EQ (val, Qbopomofo)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1193 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1194 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1195 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1196 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1197 else if (EQ (val, Qhangul)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1198 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1199 if (font->ntmTm.tmCharSet != HANGUL_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1200 && font->ntmTm.tmCharSet != JOHAB_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1201 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1202 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1203 else if (EQ (val, Qhan)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1204 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1205 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1206 && font->ntmTm.tmCharSet != GB2312_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1207 && font->ntmTm.tmCharSet != HANGUL_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1208 && font->ntmTm.tmCharSet != JOHAB_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1209 && font->ntmTm.tmCharSet != SHIFTJIS_CHARSET) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1210 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1211 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1212 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1213 /* Other scripts unlikely to be handled. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1214 return 0; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1215 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1216 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1217 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1218 } |
90869 | 1219 return 1; |
1220 } | |
1221 | |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1222 static int |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1223 w32font_coverage_ok (coverage, charset) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1224 FONTSIGNATURE * coverage; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1225 BYTE charset; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1226 { |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1227 DWORD subrange1 = coverage->fsUsb[1]; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1228 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1229 #define SUBRANGE1_HAN_MASK 0x08000000 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1230 #define SUBRANGE1_HANGEUL_MASK 0x01000000 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1231 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1232 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1233 if (charset == GB2312_CHARSET || charset == CHINESEBIG5_CHARSET) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1234 { |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1235 return (subrange1 & SUBRANGE1_HAN_MASK) == SUBRANGE1_HAN_MASK; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1236 } |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1237 else if (charset == SHIFTJIS_CHARSET) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1238 { |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1239 return (subrange1 & SUBRANGE1_JAPANESE_MASK) == SUBRANGE1_JAPANESE_MASK; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1240 } |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1241 else if (charset == HANGEUL_CHARSET) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1242 { |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1243 return (subrange1 & SUBRANGE1_HANGEUL_MASK) == SUBRANGE1_HANGEUL_MASK; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1244 } |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1245 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1246 return 1; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1247 } |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1248 |
90869 | 1249 /* Callback function for EnumFontFamiliesEx. |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1250 * Checks if a font matches everything we are trying to check agaist, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1251 * and if so, adds it to a list. Both the data we are checking against |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1252 * and the list to which the fonts are added are passed in via the |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1253 * lparam argument, in the form of a font_callback_data struct. */ |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1254 static int CALLBACK |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1255 add_font_entity_to_list (logical_font, physical_font, font_type, lParam) |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1256 ENUMLOGFONTEX *logical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1257 NEWTEXTMETRICEX *physical_font; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1258 DWORD font_type; |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1259 LPARAM lParam; |
90869 | 1260 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1261 struct font_callback_data *match_data |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1262 = (struct font_callback_data *) lParam; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1263 |
91208 | 1264 if ((!match_data->opentype_only |
1265 || (physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)) | |
1266 && logfonts_match (&logical_font->elfLogFont, &match_data->pattern) | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1267 && font_matches_spec (font_type, physical_font, |
91264
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1268 match_data->orig_font_spec) |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1269 && w32font_coverage_ok (&physical_font->ntmFontSig, |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1270 match_data->pattern.lfCharSet) |
91264
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1271 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif) |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1272 We limit this to raster fonts, because the test can catch some |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1273 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1274 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1275 therefore get through this test. Since full names can be prefixed |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1276 by a foundry, we accept raster fonts if the font name is found |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1277 anywhere within the full name. */ |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1278 && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1279 || strstr (logical_font->elfFullName, |
9112e263c11f
(logfonts_match): Don't check adstyle here.
Jason Rumney <jasonr@gnu.org>
parents:
91260
diff
changeset
|
1280 logical_font->elfLogFont.lfFaceName))) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1281 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1282 Lisp_Object entity |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1283 = w32_enumfont_pattern_entity (match_data->frame, logical_font, |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1284 physical_font, font_type, |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1285 &match_data->pattern, |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1286 match_data->opentype_only |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1287 ? Quniscribe : Qgdi); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1288 if (!NILP (entity)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1289 match_data->list = Fcons (entity, match_data->list); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1290 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1291 return 1; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1292 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1293 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1294 /* Callback function for EnumFontFamiliesEx. |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1295 * Terminates the search once we have a match. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1296 static int CALLBACK |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1297 add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1298 ENUMLOGFONTEX *logical_font; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1299 NEWTEXTMETRICEX *physical_font; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1300 DWORD font_type; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1301 LPARAM lParam; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1302 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1303 struct font_callback_data *match_data |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1304 = (struct font_callback_data *) lParam; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1305 add_font_entity_to_list (logical_font, physical_font, font_type, lParam); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1306 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1307 /* If we have a font in the list, terminate the search. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1308 return !NILP (match_data->list); |
90869 | 1309 } |
1310 | |
1311 /* Convert a Lisp font registry (symbol) to a windows charset. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1312 static LONG |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1313 registry_to_w32_charset (charset) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1314 Lisp_Object charset; |
90869 | 1315 { |
1316 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp) | |
1317 || EQ (charset, Qunicode_sip)) | |
1318 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */ | |
1319 else if (EQ (charset, Qiso8859_1)) | |
1320 return ANSI_CHARSET; | |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1321 else if (SYMBOLP (charset)) |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1322 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset))); |
90869 | 1323 else if (STRINGP (charset)) |
1324 return x_to_w32_charset (SDATA (charset)); | |
1325 else | |
1326 return DEFAULT_CHARSET; | |
1327 } | |
1328 | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1329 static Lisp_Object |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1330 w32_registry (w32_charset, font_type) |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1331 LONG w32_charset; |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1332 DWORD font_type; |
90869 | 1333 { |
92539
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1334 /* If charset is defaulted, use ANSI (unicode for truetype fonts). */ |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1335 if (w32_charset == DEFAULT_CHARSET) |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1336 w32_charset = ANSI_CHARSET; |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1337 |
d4cf72c99c2f
(w32_registry): Take font_type argument. Use ANSI
Jason Rumney <jasonr@gnu.org>
parents:
92472
diff
changeset
|
1338 if (font_type == TRUETYPE_FONTTYPE && w32_charset == ANSI_CHARSET) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1339 return Qiso10646_1; |
90869 | 1340 else |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1341 { |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1342 char * charset = w32_to_x_charset (w32_charset, NULL); |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1343 return intern_downcase (charset, strlen(charset)); |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1344 } |
90869 | 1345 } |
1346 | |
1347 /* Fill in all the available details of LOGFONT from FONT_SPEC. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1348 static void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1349 fill_in_logfont (f, logfont, font_spec) |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1350 FRAME_PTR f; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1351 LOGFONT *logfont; |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1352 Lisp_Object font_spec; |
90869 | 1353 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1354 Lisp_Object tmp, extra; |
90869 | 1355 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy; |
1356 | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1357 extra = AREF (font_spec, FONT_EXTRA_INDEX); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1358 /* Allow user to override dpi settings. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1359 if (CONSP (extra)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1360 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1361 tmp = assq_no_quit (QCdpi, extra); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1362 if (CONSP (tmp) && INTEGERP (XCDR (tmp))) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1363 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1364 dpi = XINT (XCDR (tmp)); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1365 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1366 else if (CONSP (tmp) && FLOATP (XCDR (tmp))) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1367 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1368 dpi = (int) (XFLOAT_DATA (XCDR (tmp)) + 0.5); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1369 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1370 } |
90869 | 1371 |
1372 /* Height */ | |
1373 tmp = AREF (font_spec, FONT_SIZE_INDEX); | |
1374 if (INTEGERP (tmp)) | |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1375 logfont->lfHeight = -1 * XINT (tmp); |
90869 | 1376 else if (FLOATP (tmp)) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1377 logfont->lfHeight = (int) (-1.0 * dpi * XFLOAT_DATA (tmp) / 72.27 + 0.5); |
90869 | 1378 |
1379 /* Escapement */ | |
1380 | |
1381 /* Orientation */ | |
1382 | |
1383 /* Weight */ | |
1384 tmp = AREF (font_spec, FONT_WEIGHT_INDEX); | |
1385 if (INTEGERP (tmp)) | |
1386 logfont->lfWeight = XINT (tmp); | |
1387 | |
1388 /* Italic */ | |
1389 tmp = AREF (font_spec, FONT_SLANT_INDEX); | |
1390 if (INTEGERP (tmp)) | |
1391 { | |
1392 int slant = XINT (tmp); | |
1393 logfont->lfItalic = slant > 150 ? 1 : 0; | |
1394 } | |
1395 | |
1396 /* Underline */ | |
1397 | |
1398 /* Strikeout */ | |
1399 | |
1400 /* Charset */ | |
1401 tmp = AREF (font_spec, FONT_REGISTRY_INDEX); | |
1402 if (! NILP (tmp)) | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1403 logfont->lfCharSet = registry_to_w32_charset (tmp); |
90869 | 1404 |
1405 /* Out Precision */ | |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1406 |
90869 | 1407 /* Clip Precision */ |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1408 |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1409 /* Quality */ |
90879
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1410 logfont->lfQuality = DEFAULT_QUALITY; |
82b86c925f88
* w32font.c (w32font_open): Handle size, height and pixel_size better.
Jason Rumney <jasonr@gnu.org>
parents:
90869
diff
changeset
|
1411 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1412 /* Generic Family and Face Name */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1413 logfont->lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1414 |
90869 | 1415 tmp = AREF (font_spec, FONT_FAMILY_INDEX); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1416 if (! NILP (tmp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1417 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1418 logfont->lfPitchAndFamily = w32_generic_family (tmp) | DEFAULT_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1419 if ((logfont->lfPitchAndFamily & 0xF0) != FF_DONTCARE) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1420 ; /* Font name was generic, don't fill in font name. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1421 /* Font families are interned, but allow for strings also in case of |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1422 user input. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1423 else if (SYMBOLP (tmp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1424 strncpy (logfont->lfFaceName, SDATA (SYMBOL_NAME (tmp)), LF_FACESIZE); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1425 else if (STRINGP (tmp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1426 strncpy (logfont->lfFaceName, SDATA (tmp), LF_FACESIZE); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1427 } |
90869 | 1428 |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1429 tmp = AREF (font_spec, FONT_ADSTYLE_INDEX); |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1430 if (!NILP (tmp)) |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1431 { |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1432 /* Override generic family. */ |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1433 BYTE family = w32_generic_family (tmp); |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1434 if (family != FF_DONTCARE) |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1435 logfont->lfPitchAndFamily = family | DEFAULT_PITCH; |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1436 } |
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1437 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1438 /* Process EXTRA info. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1439 for ( ; CONSP (extra); extra = XCDR (extra)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1440 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1441 tmp = XCAR (extra); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1442 if (CONSP (tmp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1443 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1444 Lisp_Object key, val; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1445 key = XCAR (tmp), val = XCDR (tmp); |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1446 if (EQ (key, QCspacing)) |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1447 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1448 /* Set pitch based on the spacing property. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1449 if (INTEGERP (val)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1450 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1451 int spacing = XINT (val); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1452 if (spacing < FONT_SPACING_MONO) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1453 logfont->lfPitchAndFamily |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1454 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1455 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1456 logfont->lfPitchAndFamily |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1457 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1458 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1459 else if (EQ (val, Qp)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1460 logfont->lfPitchAndFamily |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1461 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1462 else if (EQ (val, Qc) || EQ (val, Qm)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1463 logfont->lfPitchAndFamily |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1464 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1465 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1466 /* Only use QCscript if charset is not provided, or is unicode |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1467 and a single script is specified. This is rather crude, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1468 and is only used to narrow down the fonts returned where |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1469 there is a definite match. Some scripts, such as latin, han, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1470 cjk-misc match multiple lfCharSet values, so we can't pre-filter |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1471 them. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1472 else if (EQ (key, QCscript) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1473 && logfont->lfCharSet == DEFAULT_CHARSET |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1474 && SYMBOLP (val)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1475 { |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1476 if (EQ (val, Qgreek)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1477 logfont->lfCharSet = GREEK_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1478 else if (EQ (val, Qhangul)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1479 logfont->lfCharSet = HANGUL_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1480 else if (EQ (val, Qkana) || EQ (val, Qkanbun)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1481 logfont->lfCharSet = SHIFTJIS_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1482 else if (EQ (val, Qbopomofo)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1483 logfont->lfCharSet = CHINESEBIG5_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1484 /* GB 18030 supports tibetan, yi, mongolian, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1485 fonts that support it should show up if we ask for |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1486 GB2312 fonts. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1487 else if (EQ (val, Qtibetan) || EQ (val, Qyi) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1488 || EQ (val, Qmongolian)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1489 logfont->lfCharSet = GB2312_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1490 else if (EQ (val, Qhebrew)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1491 logfont->lfCharSet = HEBREW_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1492 else if (EQ (val, Qarabic)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1493 logfont->lfCharSet = ARABIC_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1494 else if (EQ (val, Qthai)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1495 logfont->lfCharSet = THAI_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1496 else if (EQ (val, Qsymbol)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1497 logfont->lfCharSet = SYMBOL_CHARSET; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1498 } |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1499 else if (EQ (key, QCantialias) && SYMBOLP (val)) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1500 { |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1501 logfont->lfQuality = w32_antialias_type (val); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1502 } |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1503 } |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1504 } |
90869 | 1505 } |
1506 | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1507 static void |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1508 list_all_matching_fonts (match_data) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1509 struct font_callback_data *match_data; |
90869 | 1510 { |
1511 HDC dc; | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1512 Lisp_Object families = w32font_list_family (match_data->frame); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1513 struct frame *f = XFRAME (match_data->frame); |
90869 | 1514 |
1515 dc = get_frame_dc (f); | |
1516 | |
1517 while (!NILP (families)) | |
1518 { | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1519 /* TODO: Use the Unicode versions of the W32 APIs, so we can |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1520 handle non-ASCII font names. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1521 char *name; |
90869 | 1522 Lisp_Object family = CAR (families); |
1523 families = CDR (families); | |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1524 if (NILP (family)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1525 continue; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1526 else if (STRINGP (family)) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1527 name = SDATA (family); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1528 else |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1529 name = SDATA (SYMBOL_NAME (family)); |
90869 | 1530 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1531 strncpy (match_data->pattern.lfFaceName, name, LF_FACESIZE); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1532 match_data->pattern.lfFaceName[LF_FACESIZE - 1] = '\0'; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1533 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1534 EnumFontFamiliesEx (dc, &match_data->pattern, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1535 (FONTENUMPROC) add_font_entity_to_list, |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1536 (LPARAM) match_data, 0); |
90869 | 1537 } |
1538 | |
1539 release_frame_dc (f, dc); | |
1540 } | |
1541 | |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1542 static Lisp_Object |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1543 lispy_antialias_type (type) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1544 BYTE type; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1545 { |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1546 Lisp_Object lispy; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1547 |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1548 switch (type) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1549 { |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1550 case NONANTIALIASED_QUALITY: |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1551 lispy = Qnone; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1552 break; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1553 case ANTIALIASED_QUALITY: |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1554 lispy = Qstandard; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1555 break; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1556 case CLEARTYPE_QUALITY: |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1557 lispy = Qsubpixel; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1558 break; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1559 case CLEARTYPE_NATURAL_QUALITY: |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1560 lispy = Qnatural; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1561 break; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1562 default: |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1563 lispy = Qnil; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1564 break; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1565 } |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1566 return lispy; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1567 } |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1568 |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1569 /* Convert antialiasing symbols to lfQuality */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1570 static BYTE |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1571 w32_antialias_type (type) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1572 Lisp_Object type; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1573 { |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1574 if (EQ (type, Qnone)) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1575 return NONANTIALIASED_QUALITY; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1576 else if (EQ (type, Qstandard)) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1577 return ANTIALIASED_QUALITY; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1578 else if (EQ (type, Qsubpixel)) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1579 return CLEARTYPE_QUALITY; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1580 else if (EQ (type, Qnatural)) |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1581 return CLEARTYPE_NATURAL_QUALITY; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1582 else |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1583 return DEFAULT_QUALITY; |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1584 } |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1585 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1586 /* Return a list of all the scripts that the font supports. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1587 static Lisp_Object |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1588 font_supported_scripts (FONTSIGNATURE * sig) |
90869 | 1589 { |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1590 DWORD * subranges = sig->fsUsb; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1591 Lisp_Object supported = Qnil; |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1592 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1593 /* Match a single subrange. SYM is set if bit N is set in subranges. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1594 #define SUBRANGE(n,sym) \ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1595 if (subranges[(n) / 32] & (1 << ((n) % 32))) \ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1596 supported = Fcons ((sym), supported) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1597 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1598 /* Match multiple subranges. SYM is set if any MASK bit is set in |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1599 subranges[0 - 3]. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1600 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1601 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1602 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1603 supported = Fcons ((sym), supported) |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1604 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1605 SUBRANGE (0, Qlatin); /* There are many others... */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1606 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1607 SUBRANGE (7, Qgreek); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1608 SUBRANGE (8, Qcoptic); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1609 SUBRANGE (9, Qcyrillic); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1610 SUBRANGE (10, Qarmenian); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1611 SUBRANGE (11, Qhebrew); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1612 SUBRANGE (13, Qarabic); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1613 SUBRANGE (14, Qnko); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1614 SUBRANGE (15, Qdevanagari); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1615 SUBRANGE (16, Qbengali); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1616 SUBRANGE (17, Qgurmukhi); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1617 SUBRANGE (18, Qgujarati); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1618 SUBRANGE (19, Qoriya); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1619 SUBRANGE (20, Qtamil); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1620 SUBRANGE (21, Qtelugu); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1621 SUBRANGE (22, Qkannada); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1622 SUBRANGE (23, Qmalayalam); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1623 SUBRANGE (24, Qthai); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1624 SUBRANGE (25, Qlao); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1625 SUBRANGE (26, Qgeorgian); |
90869 | 1626 |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1627 SUBRANGE (48, Qcjk_misc); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1628 SUBRANGE (51, Qbopomofo); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1629 SUBRANGE (54, Qkanbun); /* Is this right? */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1630 SUBRANGE (56, Qhangul); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1631 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1632 SUBRANGE (59, Qhan); /* There are others, but this is the main one. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1633 SUBRANGE (59, Qideographic_description); /* Windows lumps this in */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1634 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1635 SUBRANGE (70, Qtibetan); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1636 SUBRANGE (71, Qsyriac); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1637 SUBRANGE (72, Qthaana); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1638 SUBRANGE (73, Qsinhala); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1639 SUBRANGE (74, Qmyanmar); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1640 SUBRANGE (75, Qethiopic); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1641 SUBRANGE (76, Qcherokee); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1642 SUBRANGE (77, Qcanadian_aboriginal); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1643 SUBRANGE (78, Qogham); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1644 SUBRANGE (79, Qrunic); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1645 SUBRANGE (80, Qkhmer); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1646 SUBRANGE (81, Qmongolian); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1647 SUBRANGE (82, Qbraille); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1648 SUBRANGE (83, Qyi); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1649 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1650 SUBRANGE (88, Qbyzantine_musical_symbol); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1651 SUBRANGE (88, Qmusical_symbol); /* Windows doesn't distinguish these. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1652 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1653 SUBRANGE (89, Qmathematical); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1654 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1655 /* Match either katakana or hiragana for kana. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1656 MASK_ANY (0, 0x00060000, 0, 0, Qkana); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1657 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1658 /* There isn't really a main symbol range, so include symbol if any |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1659 relevant range is set. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1660 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1661 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1662 #undef SUBRANGE |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1663 #undef MASK_ANY |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1664 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1665 return supported; |
90869 | 1666 } |
1667 | |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1668 /* Generate a full name for a Windows font. |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1669 The full name is in fcname format, with weight, slant and antialiasing |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1670 specified if they are not "normal". */ |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1671 static int |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1672 w32font_full_name (font, font_obj, pixel_size, name, nbytes) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1673 LOGFONT * font; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1674 Lisp_Object font_obj; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1675 int pixel_size; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1676 char *name; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1677 int nbytes; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1678 { |
92394
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1679 int len, height, outline; |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1680 char *p; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1681 Lisp_Object antialiasing, weight = Qnil; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1682 |
92394
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1683 len = strlen (font->lfFaceName); |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1684 |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1685 outline = EQ (AREF (font_obj, FONT_FOUNDRY_INDEX), Qoutline); |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1686 |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1687 /* Represent size of scalable fonts by point size. But use pixelsize for |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1688 raster fonts to indicate that they are exactly that size. */ |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1689 if (outline) |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1690 len += 11; /* -SIZE */ |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1691 else |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1692 len = strlen (font->lfFaceName) + 21; |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1693 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1694 if (font->lfItalic) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1695 len += 7; /* :italic */ |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1696 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1697 if (font->lfWeight && font->lfWeight != FW_NORMAL) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1698 { |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1699 weight = font_symbolic_weight (font_obj); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1700 len += 8 + SBYTES (SYMBOL_NAME (weight)); /* :weight=NAME */ |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1701 } |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1702 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1703 antialiasing = lispy_antialias_type (font->lfQuality); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1704 if (! NILP (antialiasing)) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1705 len += 11 + SBYTES (SYMBOL_NAME (antialiasing)); /* :antialias=NAME */ |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1706 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1707 /* Check that the buffer is big enough */ |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1708 if (len > nbytes) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1709 return -1; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1710 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1711 p = name; |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1712 p += sprintf (p, "%s", font->lfFaceName); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1713 |
92394
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1714 height = font->lfHeight ? eabs (font->lfHeight) : pixel_size; |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1715 |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1716 if (height > 0) |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1717 { |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1718 if (outline) |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1719 { |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1720 float pointsize = height * 72.0 / one_w32_display_info.resy; |
92712
fb1da73bc0c4
(w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents:
92539
diff
changeset
|
1721 /* Round to nearest half point. floor is used, since round is not |
fb1da73bc0c4
(w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents:
92539
diff
changeset
|
1722 supported in MS library. */ |
fb1da73bc0c4
(w32font_full_name): Use floor to round.
Jason Rumney <jasonr@gnu.org>
parents:
92539
diff
changeset
|
1723 pointsize = floor (pointsize * 2 + 0.5) / 2; |
92394
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1724 p += sprintf (p, "-%1.1f", pointsize); |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1725 } |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1726 else |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1727 p += sprintf (p, ":pixelsize=%d", height); |
7701acfc2ec5
(w32font_full_name): Report point size for scalable fonts.
Jason Rumney <jasonr@gnu.org>
parents:
92390
diff
changeset
|
1728 } |
92390
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1729 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1730 if (font->lfItalic) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1731 p += sprintf (p, ":italic"); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1732 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1733 if (SYMBOLP (weight) && ! NILP (weight)) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1734 p += sprintf (p, ":weight=%s", SDATA (SYMBOL_NAME (weight))); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1735 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1736 if (SYMBOLP (antialiasing) && ! NILP (antialiasing)) |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1737 p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing))); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1738 |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1739 return (p - name); |
9b14fb0bae09
(w32font_full_name): New function.
Jason Rumney <jasonr@gnu.org>
parents:
92199
diff
changeset
|
1740 } |
90869 | 1741 |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1742 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1743 static void |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1744 recompute_cached_metrics (dc, w32_font) |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1745 HDC dc; |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1746 struct w32font_info *w32_font; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1747 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1748 GLYPHMETRICS gm; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1749 MAT2 transform; |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1750 unsigned int i; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1751 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1752 bzero (&transform, sizeof (transform)); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1753 transform.eM11.value = 1; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1754 transform.eM22.value = 1; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1755 |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1756 for (i = 0; i < 128; i++) |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1757 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1758 struct font_metrics* char_metric = &w32_font->ascii_metrics[i]; |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1759 unsigned int options = GGO_METRICS; |
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1760 if (w32_font->glyph_idx) |
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1761 options |= GGO_GLYPH_INDEX; |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1762 |
92411
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1763 if (GetGlyphOutlineW (dc, i, options, &gm, 0, NULL, &transform) |
133560a77a09
(recompute_cached_metrics): Change font arg to w32font_info.
Jason Rumney <jasonr@gnu.org>
parents:
92409
diff
changeset
|
1764 != GDI_ERROR) |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1765 { |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1766 char_metric->lbearing = -gm.gmptGlyphOrigin.x; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1767 char_metric->rbearing = gm.gmBlackBoxX + gm.gmptGlyphOrigin.x; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1768 char_metric->width = gm.gmCellIncX; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1769 char_metric->ascent = -gm.gmptGlyphOrigin.y; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1770 char_metric->descent = gm.gmBlackBoxY + gm.gmptGlyphOrigin.y; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1771 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1772 else |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1773 char_metric->width = 0; |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1774 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1775 } |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1776 |
90869 | 1777 struct font_driver w32font_driver = |
1778 { | |
90964 | 1779 0, /* Qgdi */ |
90869 | 1780 w32font_get_cache, |
1781 w32font_list, | |
1782 w32font_match, | |
1783 w32font_list_family, | |
1784 NULL, /* free_entity */ | |
1785 w32font_open, | |
1786 w32font_close, | |
1787 NULL, /* prepare_face */ | |
1788 NULL, /* done_face */ | |
1789 w32font_has_char, | |
1790 w32font_encode_char, | |
1791 w32font_text_extents, | |
1792 w32font_draw, | |
1793 NULL, /* get_bitmap */ | |
1794 NULL, /* free_bitmap */ | |
1795 NULL, /* get_outline */ | |
1796 NULL, /* free_outline */ | |
1797 NULL, /* anchor_point */ | |
1798 NULL, /* otf_capability */ | |
91158
5e7347695108
(w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents:
91128
diff
changeset
|
1799 NULL, /* otf_drive */ |
5e7347695108
(w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents:
91128
diff
changeset
|
1800 NULL, /* start_for_frame */ |
5e7347695108
(w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents:
91128
diff
changeset
|
1801 NULL, /* end_for_frame */ |
5e7347695108
(w32font_driver): Add new fields.
Jason Rumney <jasonr@gnu.org>
parents:
91128
diff
changeset
|
1802 NULL /* shape */ |
90869 | 1803 }; |
1804 | |
1805 | |
1806 /* Initialize state that does not change between invocations. This is only | |
1807 called when Emacs is dumped. */ | |
90889
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1808 void |
0df73c71020b
* w32font.c (QCsubranges): New symbol.
Jason Rumney <jasonr@gnu.org>
parents:
90887
diff
changeset
|
1809 syms_of_w32font () |
90869 | 1810 { |
90964 | 1811 DEFSYM (Qgdi, "gdi"); |
92409
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1812 DEFSYM (Quniscribe, "uniscribe"); |
8171649adf8a
(Quniscribe, QCformat): New symbols.
Jason Rumney <jasonr@gnu.org>
parents:
92394
diff
changeset
|
1813 DEFSYM (QCformat, ":format"); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1814 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1815 /* Generic font families. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1816 DEFSYM (Qmonospace, "monospace"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1817 DEFSYM (Qserif, "serif"); |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1818 DEFSYM (Qsansserif, "sansserif"); |
90869 | 1819 DEFSYM (Qscript, "script"); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1820 DEFSYM (Qdecorative, "decorative"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1821 /* Aliases. */ |
91260
75f89f349f70
(w32font_text_extents): Dereference selected_frame.
Jason Rumney <jasonr@gnu.org>
parents:
91259
diff
changeset
|
1822 DEFSYM (Qsans_serif, "sans_serif"); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1823 DEFSYM (Qsans, "sans"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1824 DEFSYM (Qmono, "mono"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1825 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1826 /* Fake foundries. */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1827 DEFSYM (Qraster, "raster"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1828 DEFSYM (Qoutline, "outline"); |
90869 | 1829 DEFSYM (Qunknown, "unknown"); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1830 |
91124
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1831 /* Antialiasing. */ |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1832 DEFSYM (Qstandard, "standard"); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1833 DEFSYM (Qsubpixel, "subpixel"); |
b656aee8436b
(CLEARTYPE_QUALITY, CLEARTYPE_NATURAL_QUALITY): Define
Jason Rumney <jasonr@gnu.org>
parents:
91070
diff
changeset
|
1834 DEFSYM (Qnatural, "natural"); |
90906
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1835 |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1836 /* Scripts */ |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1837 DEFSYM (Qlatin, "latin"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1838 DEFSYM (Qgreek, "greek"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1839 DEFSYM (Qcoptic, "coptic"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1840 DEFSYM (Qcyrillic, "cyrillic"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1841 DEFSYM (Qarmenian, "armenian"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1842 DEFSYM (Qhebrew, "hebrew"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1843 DEFSYM (Qarabic, "arabic"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1844 DEFSYM (Qsyriac, "syriac"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1845 DEFSYM (Qnko, "nko"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1846 DEFSYM (Qthaana, "thaana"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1847 DEFSYM (Qdevanagari, "devanagari"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1848 DEFSYM (Qbengali, "bengali"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1849 DEFSYM (Qgurmukhi, "gurmukhi"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1850 DEFSYM (Qgujarati, "gujarati"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1851 DEFSYM (Qoriya, "oriya"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1852 DEFSYM (Qtamil, "tamil"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1853 DEFSYM (Qtelugu, "telugu"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1854 DEFSYM (Qkannada, "kannada"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1855 DEFSYM (Qmalayalam, "malayalam"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1856 DEFSYM (Qsinhala, "sinhala"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1857 DEFSYM (Qthai, "thai"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1858 DEFSYM (Qlao, "lao"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1859 DEFSYM (Qtibetan, "tibetan"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1860 DEFSYM (Qmyanmar, "myanmar"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1861 DEFSYM (Qgeorgian, "georgian"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1862 DEFSYM (Qhangul, "hangul"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1863 DEFSYM (Qethiopic, "ethiopic"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1864 DEFSYM (Qcherokee, "cherokee"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1865 DEFSYM (Qcanadian_aboriginal, "canadian-aboriginal"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1866 DEFSYM (Qogham, "ogham"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1867 DEFSYM (Qrunic, "runic"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1868 DEFSYM (Qkhmer, "khmer"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1869 DEFSYM (Qmongolian, "mongolian"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1870 DEFSYM (Qsymbol, "symbol"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1871 DEFSYM (Qbraille, "braille"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1872 DEFSYM (Qhan, "han"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1873 DEFSYM (Qideographic_description, "ideographic-description"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1874 DEFSYM (Qcjk_misc, "cjk-misc"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1875 DEFSYM (Qkana, "kana"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1876 DEFSYM (Qbopomofo, "bopomofo"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1877 DEFSYM (Qkanbun, "kanbun"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1878 DEFSYM (Qyi, "yi"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1879 DEFSYM (Qbyzantine_musical_symbol, "byzantine-musical-symbol"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1880 DEFSYM (Qmusical_symbol, "musical-symbol"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1881 DEFSYM (Qmathematical, "mathematical"); |
f8694254fa1d
(w32font_info): Remove subranges.
Jason Rumney <jasonr@gnu.org>
parents:
90898
diff
changeset
|
1882 |
90964 | 1883 w32font_driver.type = Qgdi; |
90869 | 1884 register_font_driver (&w32font_driver, NULL); |
1885 } | |
92472
dba28a9d071a
Wrap in USE_FONT_BACKEND conditional
Jason Rumney <jasonr@gnu.org>
parents:
92413
diff
changeset
|
1886 #endif /* USE_FONT_BACKEND */ |
90898 | 1887 |
1888 /* arch-tag: 65b8a3cd-46aa-4c0d-a1f3-99e75b9c07ee | |
1889 (do not change this comment) */ |