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