(codepage-setup): Fix typo in obsolescence declaration.
[emacs.git] / src / w32font.c
blobed53ff9c4b1993ccd774e5376a769ae5aa3a4a68
1 /* Font backend for the Microsoft W32 API.
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
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.
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. */
21 #ifdef USE_FONT_BACKEND
23 #include <config.h>
24 #include <windows.h>
25 #include <math.h>
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"
35 #include "w32font.h"
37 /* Cleartype available on Windows XP, cleartype_natural from XP SP1.
38 The latter does not try to fit cleartype smoothed fonts into the
39 same bounding box as the non-antialiased version of the font.
41 #ifndef CLEARTYPE_QUALITY
42 #define CLEARTYPE_QUALITY 5
43 #endif
44 #ifndef CLEARTYPE_NATURAL_QUALITY
45 #define CLEARTYPE_NATURAL_QUALITY 6
46 #endif
48 extern struct font_driver w32font_driver;
50 Lisp_Object Qgdi;
51 Lisp_Object Quniscribe;
52 static Lisp_Object QCformat;
53 static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif;
54 static Lisp_Object Qserif, Qscript, Qdecorative;
55 static Lisp_Object Qraster, Qoutline, Qunknown;
57 /* antialiasing */
58 extern Lisp_Object QCantialias, QCotf, QClanguage; /* defined in font.c */
59 extern Lisp_Object Qnone; /* reuse from w32fns.c */
60 static Lisp_Object Qstandard, Qsubpixel, Qnatural;
62 /* languages */
63 static Lisp_Object Qja, Qko, Qzh;
65 /* scripts */
66 static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
67 static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
68 static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu;
69 static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao;
70 static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic;
71 static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic;
72 static Lisp_Object Qkhmer, Qmongolian, Qsymbol, Qbraille, Qhan;
73 static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo;
74 static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol;
75 static Lisp_Object Qmusical_symbol, Qmathematical;
76 /* Not defined in characters.el, but referenced in fontset.el. */
77 static Lisp_Object Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot;
78 static Lisp_Object Qdeseret, Qglagolitic, Qgothic, Qhanunoo, Qkharoshthi;
79 static Lisp_Object Qlimbu, Qlinear_b, Qold_italic, Qold_persian, Qosmanya;
80 static Lisp_Object Qphags_pa, Qphoenician, Qshavian, Qsyloti_nagri;
81 static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic;
82 /* Only defined here, but useful for distinguishing IPA capable fonts. */
83 static Lisp_Object Qphonetic;
85 /* Font spacing symbols - defined in font.c. */
86 extern Lisp_Object Qc, Qp, Qm;
88 static void fill_in_logfont P_ ((FRAME_PTR, LOGFONT *, Lisp_Object));
90 static BYTE w32_antialias_type P_ ((Lisp_Object));
91 static Lisp_Object lispy_antialias_type P_ ((BYTE));
93 static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE *));
94 static int w32font_full_name P_ ((LOGFONT *, Lisp_Object, int, char *, int));
95 static void compute_metrics P_ ((HDC, struct w32font_info *, unsigned int,
96 struct w32_metric_cache *));
97 static void clear_cached_metrics P_ ((struct w32font_info *));
99 static Lisp_Object w32_registry P_ ((LONG, DWORD));
101 /* EnumFontFamiliesEx callbacks. */
102 static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *,
103 NEWTEXTMETRICEX *,
104 DWORD, LPARAM));
105 static int CALLBACK add_one_font_entity_to_list P_ ((ENUMLOGFONTEX *,
106 NEWTEXTMETRICEX *,
107 DWORD, LPARAM));
108 static int CALLBACK add_font_name_to_list P_ ((ENUMLOGFONTEX *,
109 NEWTEXTMETRICEX *,
110 DWORD, LPARAM));
112 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
113 of what we really want. */
114 struct font_callback_data
116 /* The logfont we are matching against. EnumFontFamiliesEx only matches
117 face name and charset, so we need to manually match everything else
118 in the callback function. */
119 LOGFONT pattern;
120 /* The original font spec or entity. */
121 Lisp_Object orig_font_spec;
122 /* The frame the font is being loaded on. */
123 Lisp_Object frame;
124 /* The list to add matches to. */
125 Lisp_Object list;
126 /* Whether to match only opentype fonts. */
127 int opentype_only;
130 /* Handles the problem that EnumFontFamiliesEx will not return all
131 style variations if the font name is not specified. */
132 static void list_all_matching_fonts P_ ((struct font_callback_data *));
134 /* From old font code in w32fns.c */
135 char * w32_to_x_charset P_ ((int, char *));
138 static int
139 memq_no_quit (elt, list)
140 Lisp_Object elt, list;
142 while (CONSP (list) && ! EQ (XCAR (list), elt))
143 list = XCDR (list);
144 return (CONSP (list));
147 /* w32 implementation of get_cache for font backend.
148 Return a cache of font-entities on FRAME. The cache must be a
149 cons whose cdr part is the actual cache area. */
150 Lisp_Object
151 w32font_get_cache (f)
152 FRAME_PTR f;
154 struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
156 return (dpyinfo->name_list_element);
159 /* w32 implementation of list for font backend.
160 List fonts exactly matching with FONT_SPEC on FRAME. The value
161 is a vector of font-entities. This is the sole API that
162 allocates font-entities. */
163 static Lisp_Object
164 w32font_list (frame, font_spec)
165 Lisp_Object frame, font_spec;
167 return w32font_list_internal (frame, font_spec, 0);
170 /* w32 implementation of match for font backend.
171 Return a font entity most closely matching with FONT_SPEC on
172 FRAME. The closeness is detemined by the font backend, thus
173 `face-font-selection-order' is ignored here. */
174 static Lisp_Object
175 w32font_match (frame, font_spec)
176 Lisp_Object frame, font_spec;
178 return w32font_match_internal (frame, font_spec, 0);
181 /* w32 implementation of list_family for font backend.
182 List available families. The value is a list of family names
183 (symbols). */
184 static Lisp_Object
185 w32font_list_family (frame)
186 Lisp_Object frame;
188 Lisp_Object list = Qnil;
189 LOGFONT font_match_pattern;
190 HDC dc;
191 FRAME_PTR f = XFRAME (frame);
193 bzero (&font_match_pattern, sizeof (font_match_pattern));
194 font_match_pattern.lfCharSet = DEFAULT_CHARSET;
196 dc = get_frame_dc (f);
198 EnumFontFamiliesEx (dc, &font_match_pattern,
199 (FONTENUMPROC) add_font_name_to_list,
200 (LPARAM) &list, 0);
201 release_frame_dc (f, dc);
203 return list;
206 /* w32 implementation of open for font backend.
207 Open a font specified by FONT_ENTITY on frame F.
208 If the font is scalable, open it with PIXEL_SIZE. */
209 static struct font *
210 w32font_open (f, font_entity, pixel_size)
211 FRAME_PTR f;
212 Lisp_Object font_entity;
213 int pixel_size;
215 struct w32font_info *w32_font = xmalloc (sizeof (struct w32font_info));
217 if (w32_font == NULL)
218 return NULL;
220 if (!w32font_open_internal (f, font_entity, pixel_size, w32_font))
222 xfree (w32_font);
223 return NULL;
226 return (struct font *) w32_font;
229 /* w32 implementation of close for font_backend.
230 Close FONT on frame F. */
231 void
232 w32font_close (f, font)
233 FRAME_PTR f;
234 struct font *font;
236 if (font->font.font)
238 W32FontStruct *old_w32_font = (W32FontStruct *)font->font.font;
239 DeleteObject (old_w32_font->hfont);
240 xfree (old_w32_font);
241 font->font.font = 0;
244 if (font->font.full_name && font->font.full_name != font->font.name)
245 xfree (font->font.full_name);
247 if (font->font.name)
248 xfree (font->font.name);
250 xfree (font);
253 /* w32 implementation of has_char for font backend.
254 Optional.
255 If FONT_ENTITY has a glyph for character C (Unicode code point),
256 return 1. If not, return 0. If a font must be opened to check
257 it, return -1. */
259 w32font_has_char (entity, c)
260 Lisp_Object entity;
261 int c;
263 Lisp_Object supported_scripts, extra, script;
264 DWORD mask;
266 extra = AREF (entity, FONT_EXTRA_INDEX);
267 if (!CONSP (extra))
268 return -1;
270 supported_scripts = assq_no_quit (QCscript, extra);
271 if (!CONSP (supported_scripts))
272 return -1;
274 supported_scripts = XCDR (supported_scripts);
276 script = CHAR_TABLE_REF (Vchar_script_table, c);
278 return (memq_no_quit (script, supported_scripts)) ? -1 : 0;
281 /* w32 implementation of encode_char for font backend.
282 Return a glyph code of FONT for characer C (Unicode code point).
283 If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
284 static unsigned
285 w32font_encode_char (font, c)
286 struct font *font;
287 int c;
289 struct frame *f;
290 HDC dc;
291 HFONT old_font;
292 DWORD retval;
293 GCP_RESULTSW result;
294 wchar_t in[2];
295 wchar_t out[2];
296 int len;
297 struct w32font_info *w32_font = (struct w32font_info *) font;
299 /* If glyph indexing is not working for this font, just return the
300 unicode code-point. */
301 if (!w32_font->glyph_idx)
302 return c;
304 if (c > 0xFFFF)
306 /* TODO: Encode as surrogate pair and lookup the glyph. */
307 return FONT_INVALID_CODE;
309 else
311 in[0] = (wchar_t) c;
312 len = 1;
315 bzero (&result, sizeof (result));
316 result.lStructSize = sizeof (result);
317 result.lpGlyphs = out;
318 result.nGlyphs = 2;
320 f = XFRAME (selected_frame);
322 dc = get_frame_dc (f);
323 old_font = SelectObject (dc, ((W32FontStruct *) (font->font.font))->hfont);
325 retval = GetCharacterPlacementW (dc, in, len, 0, &result, 0);
327 SelectObject (dc, old_font);
328 release_frame_dc (f, dc);
330 if (retval)
332 if (result.nGlyphs != 1 || !result.lpGlyphs[0])
333 return FONT_INVALID_CODE;
334 return result.lpGlyphs[0];
336 else
338 int i;
339 /* Mark this font as not supporting glyph indices. This can happen
340 on Windows9x, and maybe with non-Truetype fonts on NT etc. */
341 w32_font->glyph_idx = 0;
342 /* Clear metrics cache. */
343 clear_cached_metrics (w32_font);
345 return c;
349 /* w32 implementation of text_extents for font backend.
350 Perform the size computation of glyphs of FONT and fillin members
351 of METRICS. The glyphs are specified by their glyph codes in
352 CODE (length NGLYPHS). Apparently metrics can be NULL, in this
353 case just return the overall width. */
355 w32font_text_extents (font, code, nglyphs, metrics)
356 struct font *font;
357 unsigned *code;
358 int nglyphs;
359 struct font_metrics *metrics;
361 int i;
362 HFONT old_font = NULL;
363 HDC dc = NULL;
364 struct frame * f;
365 int total_width = 0;
366 WORD *wcode = NULL;
367 SIZE size;
369 if (metrics)
371 struct w32font_info *w32_font = (struct w32font_info *) font;
373 metrics->width = 0;
374 metrics->ascent = font->ascent;
375 metrics->descent = font->descent;
376 metrics->lbearing = 0;
378 for (i = 0; i < nglyphs; i++)
380 struct w32_metric_cache *char_metric;
381 int block = *(code + i) / CACHE_BLOCKSIZE;
382 int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
384 if (block >= w32_font->n_cache_blocks)
386 if (!w32_font->cached_metrics)
387 w32_font->cached_metrics
388 = xmalloc ((block + 1)
389 * sizeof (struct w32_cached_metric *));
390 else
391 w32_font->cached_metrics
392 = xrealloc (w32_font->cached_metrics,
393 (block + 1)
394 * sizeof (struct w32_cached_metric *));
395 bzero (w32_font->cached_metrics + w32_font->n_cache_blocks,
396 ((block + 1 - w32_font->n_cache_blocks)
397 * sizeof (struct w32_cached_metric *)));
398 w32_font->n_cache_blocks = block + 1;
401 if (!w32_font->cached_metrics[block])
403 w32_font->cached_metrics[block]
404 = xmalloc (CACHE_BLOCKSIZE * sizeof (struct font_metrics));
405 bzero (w32_font->cached_metrics[block],
406 CACHE_BLOCKSIZE * sizeof (struct font_metrics));
409 char_metric = w32_font->cached_metrics[block] + pos_in_block;
411 if (char_metric->status == W32METRIC_NO_ATTEMPT)
413 if (dc == NULL)
415 /* TODO: Frames can come and go, and their fonts
416 outlive them. So we can't cache the frame in the
417 font structure. Use selected_frame until the API
418 is updated to pass in a frame. */
419 f = XFRAME (selected_frame);
421 dc = get_frame_dc (f);
422 old_font = SelectObject (dc, ((W32FontStruct *)
423 (font->font.font))->hfont);
425 compute_metrics (dc, w32_font, *(code + i), char_metric);
428 if (char_metric->status == W32METRIC_SUCCESS)
430 metrics->lbearing = min (metrics->lbearing,
431 metrics->width + char_metric->lbearing);
432 metrics->rbearing = max (metrics->rbearing,
433 metrics->width + char_metric->rbearing);
434 metrics->width += char_metric->width;
436 else
437 /* If we couldn't get metrics for a char,
438 use alternative method. */
439 break;
441 /* If we got through everything, return. */
442 if (i == nglyphs)
444 if (dc != NULL)
446 /* Restore state and release DC. */
447 SelectObject (dc, old_font);
448 release_frame_dc (f, dc);
451 return metrics->width;
455 /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
456 fallback on other methods that will at least give some of the metric
457 information. */
458 if (!wcode) {
459 wcode = alloca (nglyphs * sizeof (WORD));
460 for (i = 0; i < nglyphs; i++)
462 if (code[i] < 0x10000)
463 wcode[i] = code[i];
464 else
466 /* TODO: Convert to surrogate, reallocating array if needed */
467 wcode[i] = 0xffff;
471 if (dc == NULL)
473 /* TODO: Frames can come and go, and their fonts outlive
474 them. So we can't cache the frame in the font structure. Use
475 selected_frame until the API is updated to pass in a
476 frame. */
477 f = XFRAME (selected_frame);
479 dc = get_frame_dc (f);
480 old_font = SelectObject (dc, ((W32FontStruct *)
481 (font->font.font))->hfont);
484 if (GetTextExtentPoint32W (dc, wcode, nglyphs, &size))
486 total_width = size.cx;
489 /* On 95/98/ME, only some unicode functions are available, so fallback
490 on doing a dummy draw to find the total width. */
491 if (!total_width)
493 RECT rect;
494 rect.top = 0; rect.bottom = font->font.height; rect.left = 0; rect.right = 1;
495 DrawTextW (dc, wcode, nglyphs, &rect,
496 DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
497 total_width = rect.right;
500 /* Give our best estimate of the metrics, based on what we know. */
501 if (metrics)
503 metrics->width = total_width;
504 metrics->lbearing = 0;
505 metrics->rbearing = total_width
506 + ((struct w32font_info *) font)->metrics.tmOverhang;
509 /* Restore state and release DC. */
510 SelectObject (dc, old_font);
511 release_frame_dc (f, dc);
513 return total_width;
516 /* w32 implementation of draw for font backend.
517 Optional.
518 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
519 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
520 is nonzero, fill the background in advance. It is assured that
521 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).
523 TODO: Currently this assumes that the colors and fonts are already
524 set in the DC. This seems to be true now, but maybe only due to
525 the old font code setting it up. It may be safer to resolve faces
526 and fonts in here and set them explicitly
530 w32font_draw (s, from, to, x, y, with_background)
531 struct glyph_string *s;
532 int from, to, x, y, with_background;
534 UINT options;
535 HRGN orig_clip;
536 struct w32font_info *w32font = (struct w32font_info *) s->face->font_info;
538 options = w32font->glyph_idx;
540 /* Save clip region for later restoration. */
541 GetClipRgn(s->hdc, orig_clip);
543 if (s->num_clips > 0)
545 HRGN new_clip = CreateRectRgnIndirect (s->clip);
547 if (s->num_clips > 1)
549 HRGN clip2 = CreateRectRgnIndirect (s->clip + 1);
551 CombineRgn (new_clip, new_clip, clip2, RGN_OR);
552 DeleteObject (clip2);
555 SelectClipRgn (s->hdc, new_clip);
556 DeleteObject (new_clip);
559 /* Using OPAQUE background mode can clear more background than expected
560 when Cleartype is used. Draw the background manually to avoid this. */
561 SetBkMode (s->hdc, TRANSPARENT);
562 if (with_background)
564 HBRUSH brush;
565 RECT rect;
566 struct font *font = (struct font *) s->face->font_info;
568 brush = CreateSolidBrush (s->gc->background);
569 rect.left = x;
570 rect.top = y - font->ascent;
571 rect.right = x + s->width;
572 rect.bottom = y + font->descent;
573 FillRect (s->hdc, &rect, brush);
574 DeleteObject (brush);
577 if (s->padding_p)
579 int len = to - from, i;
581 for (i = 0; i < len; i++)
582 ExtTextOutW (s->hdc, x + i, y, options, NULL,
583 s->char2b + from + i, 1, NULL);
585 else
586 ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, to - from, NULL);
588 /* Restore clip region. */
589 if (s->num_clips > 0)
591 SelectClipRgn (s->hdc, orig_clip);
595 /* w32 implementation of free_entity for font backend.
596 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
597 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
598 static void
599 w32font_free_entity (Lisp_Object entity);
602 /* w32 implementation of prepare_face for font backend.
603 Optional (if FACE->extra is not used).
604 Prepare FACE for displaying characters by FONT on frame F by
605 storing some data in FACE->extra. If successful, return 0.
606 Otherwise, return -1.
607 static int
608 w32font_prepare_face (FRAME_PTR f, struct face *face);
610 /* w32 implementation of done_face for font backend.
611 Optional.
612 Done FACE for displaying characters by FACE->font on frame F.
613 static void
614 w32font_done_face (FRAME_PTR f, struct face *face); */
616 /* w32 implementation of get_bitmap for font backend.
617 Optional.
618 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
619 intended that this method is called from the other font-driver
620 for actual drawing.
621 static int
622 w32font_get_bitmap (struct font *font, unsigned code,
623 struct font_bitmap *bitmap, int bits_per_pixel);
625 /* w32 implementation of free_bitmap for font backend.
626 Optional.
627 Free bitmap data in BITMAP.
628 static void
629 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
631 /* w32 implementation of get_outline for font backend.
632 Optional.
633 Return an outline data for glyph-code CODE of FONT. The format
634 of the outline data depends on the font-driver.
635 static void *
636 w32font_get_outline (struct font *font, unsigned code);
638 /* w32 implementation of free_outline for font backend.
639 Optional.
640 Free OUTLINE (that is obtained by the above method).
641 static void
642 w32font_free_outline (struct font *font, void *outline);
644 /* w32 implementation of anchor_point for font backend.
645 Optional.
646 Get coordinates of the INDEXth anchor point of the glyph whose
647 code is CODE. Store the coordinates in *X and *Y. Return 0 if
648 the operations was successfull. Otherwise return -1.
649 static int
650 w32font_anchor_point (struct font *font, unsigned code,
651 int index, int *x, int *y);
653 /* w32 implementation of otf_capability for font backend.
654 Optional.
655 Return a list describing which scripts/languages FONT
656 supports by which GSUB/GPOS features of OpenType tables.
657 static Lisp_Object
658 w32font_otf_capability (struct font *font);
660 /* w32 implementation of otf_drive for font backend.
661 Optional.
662 Apply FONT's OTF-FEATURES to the glyph string.
664 FEATURES specifies which OTF features to apply in this format:
665 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
666 See the documentation of `font-drive-otf' for the detail.
668 This method applies the specified features to the codes in the
669 elements of GSTRING-IN (between FROMth and TOth). The output
670 codes are stored in GSTRING-OUT at the IDXth element and the
671 following elements.
673 Return the number of output codes. If none of the features are
674 applicable to the input data, return 0. If GSTRING-OUT is too
675 short, return -1.
676 static int
677 w32font_otf_drive (struct font *font, Lisp_Object features,
678 Lisp_Object gstring_in, int from, int to,
679 Lisp_Object gstring_out, int idx,
680 int alternate_subst);
683 /* Internal implementation of w32font_list.
684 Additional parameter opentype_only restricts the returned fonts to
685 opentype fonts, which can be used with the Uniscribe backend. */
686 Lisp_Object
687 w32font_list_internal (frame, font_spec, opentype_only)
688 Lisp_Object frame, font_spec;
689 int opentype_only;
691 struct font_callback_data match_data;
692 HDC dc;
693 FRAME_PTR f = XFRAME (frame);
695 match_data.orig_font_spec = font_spec;
696 match_data.list = Qnil;
697 match_data.frame = frame;
699 bzero (&match_data.pattern, sizeof (LOGFONT));
700 fill_in_logfont (f, &match_data.pattern, font_spec);
702 match_data.opentype_only = opentype_only;
703 if (opentype_only)
704 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;
706 if (match_data.pattern.lfFaceName[0] == '\0')
708 /* EnumFontFamiliesEx does not take other fields into account if
709 font name is blank, so need to use two passes. */
710 list_all_matching_fonts (&match_data);
712 else
714 dc = get_frame_dc (f);
716 EnumFontFamiliesEx (dc, &match_data.pattern,
717 (FONTENUMPROC) add_font_entity_to_list,
718 (LPARAM) &match_data, 0);
719 release_frame_dc (f, dc);
722 return NILP (match_data.list) ? null_vector : Fvconcat (1, &match_data.list);
725 /* Internal implementation of w32font_match.
726 Additional parameter opentype_only restricts the returned fonts to
727 opentype fonts, which can be used with the Uniscribe backend. */
728 Lisp_Object
729 w32font_match_internal (frame, font_spec, opentype_only)
730 Lisp_Object frame, font_spec;
731 int opentype_only;
733 struct font_callback_data match_data;
734 HDC dc;
735 FRAME_PTR f = XFRAME (frame);
737 match_data.orig_font_spec = font_spec;
738 match_data.frame = frame;
739 match_data.list = Qnil;
741 bzero (&match_data.pattern, sizeof (LOGFONT));
742 fill_in_logfont (f, &match_data.pattern, font_spec);
744 match_data.opentype_only = opentype_only;
745 if (opentype_only)
746 match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;
748 dc = get_frame_dc (f);
750 EnumFontFamiliesEx (dc, &match_data.pattern,
751 (FONTENUMPROC) add_one_font_entity_to_list,
752 (LPARAM) &match_data, 0);
753 release_frame_dc (f, dc);
755 return NILP (match_data.list) ? Qnil : XCAR (match_data.list);
759 w32font_open_internal (f, font_entity, pixel_size, w32_font)
760 FRAME_PTR f;
761 Lisp_Object font_entity;
762 int pixel_size;
763 struct w32font_info *w32_font;
765 int len, size;
766 LOGFONT logfont;
767 HDC dc;
768 HFONT hfont, old_font;
769 Lisp_Object val, extra;
770 /* For backwards compatibility. */
771 W32FontStruct *compat_w32_font;
773 struct font * font = (struct font *) w32_font;
774 if (!font)
775 return 0;
777 bzero (&logfont, sizeof (logfont));
778 fill_in_logfont (f, &logfont, font_entity);
780 size = XINT (AREF (font_entity, FONT_SIZE_INDEX));
781 if (!size)
782 size = pixel_size;
784 logfont.lfHeight = -size;
785 hfont = CreateFontIndirect (&logfont);
787 if (hfont == NULL)
788 return 0;
790 /* Get the metrics for this font. */
791 dc = get_frame_dc (f);
792 old_font = SelectObject (dc, hfont);
794 GetTextMetrics (dc, &w32_font->metrics);
796 w32_font->glyph_idx = ETO_GLYPH_INDEX;
798 w32_font->cached_metrics = NULL;
799 w32_font->n_cache_blocks = 0;
801 SelectObject (dc, old_font);
802 release_frame_dc (f, dc);
804 /* W32FontStruct - we should get rid of this, and use the w32font_info
805 struct for any W32 specific fields. font->font.font can then be hfont. */
806 font->font.font = xmalloc (sizeof (W32FontStruct));
807 compat_w32_font = (W32FontStruct *) font->font.font;
808 bzero (compat_w32_font, sizeof (W32FontStruct));
809 compat_w32_font->font_type = UNICODE_FONT;
810 /* Duplicate the text metrics. */
811 bcopy (&w32_font->metrics, &compat_w32_font->tm, sizeof (TEXTMETRIC));
812 compat_w32_font->hfont = hfont;
814 len = strlen (logfont.lfFaceName);
815 font->font.name = (char *) xmalloc (len + 1);
816 bcopy (logfont.lfFaceName, font->font.name, len);
817 font->font.name[len] = '\0';
820 char *name;
822 /* We don't know how much space we need for the full name, so start with
823 96 bytes and go up in steps of 32. */
824 len = 96;
825 name = xmalloc (len);
826 while (name && w32font_full_name (&logfont, font_entity, pixel_size,
827 name, len) < 0)
829 char *new = xrealloc (name, len += 32);
831 if (! new)
832 xfree (name);
833 name = new;
835 if (name)
836 font->font.full_name = name;
837 else
838 font->font.full_name = font->font.name;
840 font->font.charset = 0;
841 font->font.codepage = 0;
842 font->font.size = w32_font->metrics.tmMaxCharWidth;
843 font->font.height = w32_font->metrics.tmHeight
844 + w32_font->metrics.tmExternalLeading;
845 font->font.space_width = font->font.average_width
846 = w32_font->metrics.tmAveCharWidth;
848 font->font.vertical_centering = 0;
849 font->font.encoding_type = 0;
850 font->font.baseline_offset = 0;
851 font->font.relative_compose = 0;
852 font->font.default_ascent = w32_font->metrics.tmAscent;
853 font->font.font_encoder = NULL;
854 font->entity = font_entity;
855 font->pixel_size = size;
856 font->driver = &w32font_driver;
857 /* Use format cached during list, as the information we have access to
858 here is incomplete. */
859 extra = AREF (font_entity, FONT_EXTRA_INDEX);
860 if (CONSP (extra))
862 val = assq_no_quit (QCformat, extra);
863 if (CONSP (val))
864 font->format = XCDR (val);
865 else
866 font->format = Qunknown;
868 else
869 font->format = Qunknown;
871 font->file_name = NULL;
872 font->encoding_charset = -1;
873 font->repertory_charset = -1;
874 /* TODO: do we really want the minimum width here, which could be negative? */
875 font->min_width = font->font.space_width;
876 font->ascent = w32_font->metrics.tmAscent;
877 font->descent = w32_font->metrics.tmDescent;
878 font->scalable = w32_font->metrics.tmPitchAndFamily & TMPF_VECTOR;
880 /* max_descent is used for underlining in w32term.c. Hopefully this
881 is temporary, as we'll want to get rid of the old compatibility
882 stuff later. */
883 compat_w32_font->max_bounds.descent = font->descent;
885 /* Set global flag fonts_changed_p to non-zero if the font loaded
886 has a character with a smaller width than any other character
887 before, or if the font loaded has a smaller height than any other
888 font loaded before. If this happens, it will make a glyph matrix
889 reallocation necessary. */
891 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
892 dpyinfo->n_fonts++;
894 if (dpyinfo->n_fonts == 1)
896 dpyinfo->smallest_font_height = font->font.height;
897 dpyinfo->smallest_char_width = font->min_width;
899 else
901 if (dpyinfo->smallest_font_height > font->font.height)
903 dpyinfo->smallest_font_height = font->font.height;
904 fonts_changed_p |= 1;
906 if (dpyinfo->smallest_char_width > font->min_width)
908 dpyinfo->smallest_char_width = font->min_width;
909 fonts_changed_p |= 1;
914 return 1;
917 /* Callback function for EnumFontFamiliesEx.
918 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */
919 static int CALLBACK
920 add_font_name_to_list (logical_font, physical_font, font_type, list_object)
921 ENUMLOGFONTEX *logical_font;
922 NEWTEXTMETRICEX *physical_font;
923 DWORD font_type;
924 LPARAM list_object;
926 Lisp_Object* list = (Lisp_Object *) list_object;
927 Lisp_Object family;
929 /* Skip vertical fonts (intended only for printing) */
930 if (logical_font->elfLogFont.lfFaceName[0] == '@')
931 return 1;
933 family = intern_downcase (logical_font->elfLogFont.lfFaceName,
934 strlen (logical_font->elfLogFont.lfFaceName));
935 if (! memq_no_quit (family, *list))
936 *list = Fcons (family, *list);
938 return 1;
941 /* Convert an enumerated Windows font to an Emacs font entity. */
942 static Lisp_Object
943 w32_enumfont_pattern_entity (frame, logical_font, physical_font,
944 font_type, requested_font, backend)
945 Lisp_Object frame;
946 ENUMLOGFONTEX *logical_font;
947 NEWTEXTMETRICEX *physical_font;
948 DWORD font_type;
949 LOGFONT *requested_font;
950 Lisp_Object backend;
952 Lisp_Object entity, tem;
953 LOGFONT *lf = (LOGFONT*) logical_font;
954 BYTE generic_type;
955 DWORD full_type = physical_font->ntmTm.ntmFlags;
957 entity = Fmake_vector (make_number (FONT_ENTITY_MAX), Qnil);
959 ASET (entity, FONT_TYPE_INDEX, backend);
960 ASET (entity, FONT_FRAME_INDEX, frame);
961 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet, font_type));
962 ASET (entity, FONT_OBJLIST_INDEX, Qnil);
964 /* Foundry is difficult to get in readable form on Windows.
965 But Emacs crashes if it is not set, so set it to something more
966 generic. Thes values make xflds compatible with Emacs 22. */
967 if (lf->lfOutPrecision == OUT_STRING_PRECIS)
968 tem = Qraster;
969 else if (lf->lfOutPrecision == OUT_STROKE_PRECIS)
970 tem = Qoutline;
971 else
972 tem = Qunknown;
974 ASET (entity, FONT_FOUNDRY_INDEX, tem);
976 /* Save the generic family in the extra info, as it is likely to be
977 useful to users looking for a close match. */
978 generic_type = physical_font->ntmTm.tmPitchAndFamily & 0xF0;
979 if (generic_type == FF_DECORATIVE)
980 tem = Qdecorative;
981 else if (generic_type == FF_MODERN)
982 tem = Qmono;
983 else if (generic_type == FF_ROMAN)
984 tem = Qserif;
985 else if (generic_type == FF_SCRIPT)
986 tem = Qscript;
987 else if (generic_type == FF_SWISS)
988 tem = Qsans;
989 else
990 tem = null_string;
992 ASET (entity, FONT_ADSTYLE_INDEX, tem);
994 if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
995 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_PROPORTIONAL));
996 else
997 font_put_extra (entity, QCspacing, make_number (FONT_SPACING_MONO));
999 if (requested_font->lfQuality != DEFAULT_QUALITY)
1001 font_put_extra (entity, QCantialias,
1002 lispy_antialias_type (requested_font->lfQuality));
1004 ASET (entity, FONT_FAMILY_INDEX,
1005 intern_downcase (lf->lfFaceName, strlen (lf->lfFaceName)));
1007 ASET (entity, FONT_WEIGHT_INDEX, make_number (lf->lfWeight));
1008 ASET (entity, FONT_SLANT_INDEX, make_number (lf->lfItalic ? 200 : 100));
1009 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
1010 to get it. */
1011 ASET (entity, FONT_WIDTH_INDEX, make_number (100));
1013 if (font_type & RASTER_FONTTYPE)
1014 ASET (entity, FONT_SIZE_INDEX, make_number (physical_font->ntmTm.tmHeight));
1015 else
1016 ASET (entity, FONT_SIZE_INDEX, make_number (0));
1018 /* Cache unicode codepoints covered by this font, as there is no other way
1019 of getting this information easily. */
1020 if (font_type & TRUETYPE_FONTTYPE)
1022 font_put_extra (entity, QCscript,
1023 font_supported_scripts (&physical_font->ntmFontSig));
1026 /* This information is not fully available when opening fonts, so
1027 save it here. Only Windows 2000 and later return information
1028 about opentype and type1 fonts, so need a fallback for detecting
1029 truetype so that this information is not any worse than we could
1030 have obtained later. */
1031 if (EQ (backend, Quniscribe) && (full_type & NTMFLAGS_OPENTYPE))
1032 tem = intern ("opentype");
1033 else if (font_type & TRUETYPE_FONTTYPE)
1034 tem = intern ("truetype");
1035 else if (full_type & NTM_PS_OPENTYPE)
1036 tem = intern ("postscript");
1037 else if (full_type & NTM_TYPE1)
1038 tem = intern ("type1");
1039 else if (font_type & RASTER_FONTTYPE)
1040 tem = intern ("w32bitmap");
1041 else
1042 tem = intern ("w32vector");
1044 font_put_extra (entity, QCformat, tem);
1046 return entity;
1050 /* Convert generic families to the family portion of lfPitchAndFamily. */
1051 BYTE
1052 w32_generic_family (Lisp_Object name)
1054 /* Generic families. */
1055 if (EQ (name, Qmonospace) || EQ (name, Qmono))
1056 return FF_MODERN;
1057 else if (EQ (name, Qsans) || EQ (name, Qsans_serif) || EQ (name, Qsansserif))
1058 return FF_SWISS;
1059 else if (EQ (name, Qserif))
1060 return FF_ROMAN;
1061 else if (EQ (name, Qdecorative))
1062 return FF_DECORATIVE;
1063 else if (EQ (name, Qscript))
1064 return FF_SCRIPT;
1065 else
1066 return FF_DONTCARE;
1069 static int
1070 logfonts_match (font, pattern)
1071 LOGFONT *font, *pattern;
1073 /* Only check height for raster fonts. */
1074 if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS
1075 && font->lfHeight != pattern->lfHeight)
1076 return 0;
1078 /* Have some flexibility with weights. */
1079 if (pattern->lfWeight
1080 && ((font->lfWeight < (pattern->lfWeight - 150))
1081 || font->lfWeight > (pattern->lfWeight + 150)))
1082 return 0;
1084 /* Charset and face should be OK. Italic has to be checked
1085 against the original spec, in case we don't have any preference. */
1086 return 1;
1089 static int
1090 font_matches_spec (type, font, spec, backend, logfont)
1091 DWORD type;
1092 NEWTEXTMETRICEX *font;
1093 Lisp_Object spec;
1094 Lisp_Object backend;
1095 LOGFONT *logfont;
1097 Lisp_Object extra, val;
1099 /* Check italic. Can't check logfonts, since it is a boolean field,
1100 so there is no difference between "non-italic" and "don't care". */
1101 val = AREF (spec, FONT_SLANT_INDEX);
1102 if (INTEGERP (val))
1104 int slant = XINT (val);
1105 if ((slant > 150 && !font->ntmTm.tmItalic)
1106 || (slant <= 150 && font->ntmTm.tmItalic))
1107 return 0;
1110 /* Check adstyle against generic family. */
1111 val = AREF (spec, FONT_ADSTYLE_INDEX);
1112 if (!NILP (val))
1114 BYTE family = w32_generic_family (val);
1115 if (family != FF_DONTCARE
1116 && family != (font->ntmTm.tmPitchAndFamily & 0xF0))
1117 return 0;
1120 /* Check extra parameters. */
1121 for (extra = AREF (spec, FONT_EXTRA_INDEX);
1122 CONSP (extra); extra = XCDR (extra))
1124 Lisp_Object extra_entry;
1125 extra_entry = XCAR (extra);
1126 if (CONSP (extra_entry))
1128 Lisp_Object key = XCAR (extra_entry);
1129 val = XCDR (extra_entry);
1130 if (EQ (key, QCspacing))
1132 int proportional;
1133 if (INTEGERP (val))
1135 int spacing = XINT (val);
1136 proportional = (spacing < FONT_SPACING_MONO);
1138 else if (EQ (val, Qp))
1139 proportional = 1;
1140 else if (EQ (val, Qc) || EQ (val, Qm))
1141 proportional = 0;
1142 else
1143 return 0; /* Bad font spec. */
1145 if ((proportional && !(font->ntmTm.tmPitchAndFamily & 0x01))
1146 || (!proportional && (font->ntmTm.tmPitchAndFamily & 0x01)))
1147 return 0;
1149 else if (EQ (key, QCscript) && SYMBOLP (val))
1151 /* Only truetype fonts will have information about what
1152 scripts they support. This probably means the user
1153 will have to force Emacs to use raster, postscript
1154 or atm fonts for non-ASCII text. */
1155 if (type & TRUETYPE_FONTTYPE)
1157 Lisp_Object support
1158 = font_supported_scripts (&font->ntmFontSig);
1159 if (! memq_no_quit (val, support))
1160 return 0;
1162 else
1164 /* Return specific matches, but play it safe. Fonts
1165 that cover more than their charset would suggest
1166 are likely to be truetype or opentype fonts,
1167 covered above. */
1168 if (EQ (val, Qlatin))
1170 /* Although every charset but symbol, thai and
1171 arabic contains the basic ASCII set of latin
1172 characters, Emacs expects much more. */
1173 if (font->ntmTm.tmCharSet != ANSI_CHARSET)
1174 return 0;
1176 else if (EQ (val, Qsymbol))
1178 if (font->ntmTm.tmCharSet != SYMBOL_CHARSET)
1179 return 0;
1181 else if (EQ (val, Qcyrillic))
1183 if (font->ntmTm.tmCharSet != RUSSIAN_CHARSET)
1184 return 0;
1186 else if (EQ (val, Qgreek))
1188 if (font->ntmTm.tmCharSet != GREEK_CHARSET)
1189 return 0;
1191 else if (EQ (val, Qarabic))
1193 if (font->ntmTm.tmCharSet != ARABIC_CHARSET)
1194 return 0;
1196 else if (EQ (val, Qhebrew))
1198 if (font->ntmTm.tmCharSet != HEBREW_CHARSET)
1199 return 0;
1201 else if (EQ (val, Qthai))
1203 if (font->ntmTm.tmCharSet != THAI_CHARSET)
1204 return 0;
1206 else if (EQ (val, Qkana))
1208 if (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
1209 return 0;
1211 else if (EQ (val, Qbopomofo))
1213 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET)
1214 return 0;
1216 else if (EQ (val, Qhangul))
1218 if (font->ntmTm.tmCharSet != HANGUL_CHARSET
1219 && font->ntmTm.tmCharSet != JOHAB_CHARSET)
1220 return 0;
1222 else if (EQ (val, Qhan))
1224 if (font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET
1225 && font->ntmTm.tmCharSet != GB2312_CHARSET
1226 && font->ntmTm.tmCharSet != HANGUL_CHARSET
1227 && font->ntmTm.tmCharSet != JOHAB_CHARSET
1228 && font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
1229 return 0;
1231 else
1232 /* Other scripts unlikely to be handled by non-truetype
1233 fonts. */
1234 return 0;
1237 else if (EQ (key, QClanguage) && SYMBOLP (val))
1239 /* Just handle the CJK languages here, as the language
1240 parameter is used to select a font with appropriate
1241 glyphs in the cjk unified ideographs block. Other fonts
1242 support for a language can be solely determined by
1243 its character coverage. */
1244 if (EQ (val, Qja))
1246 if (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET)
1247 return 0;
1249 else if (EQ (val, Qko))
1251 if (font->ntmTm.tmCharSet != HANGUL_CHARSET
1252 && font->ntmTm.tmCharSet != JOHAB_CHARSET)
1253 return 0;
1255 else if (EQ (val, Qzh))
1257 if (font->ntmTm.tmCharSet != GB2312_CHARSET
1258 && font->ntmTm.tmCharSet != CHINESEBIG5_CHARSET)
1259 return 0;
1261 else
1262 /* Any other language, we don't recognize it. Fontset
1263 spec should have a fallback, as some backends do
1264 not recognize language at all. */
1265 return 0;
1267 else if (EQ (key, QCotf) && CONSP (val))
1269 /* OTF features only supported by the uniscribe backend. */
1270 if (EQ (backend, Quniscribe))
1272 if (!uniscribe_check_otf (logfont, val))
1273 return 0;
1275 else
1276 return 0;
1280 return 1;
1283 static int
1284 w32font_coverage_ok (coverage, charset)
1285 FONTSIGNATURE * coverage;
1286 BYTE charset;
1288 DWORD subrange1 = coverage->fsUsb[1];
1290 #define SUBRANGE1_HAN_MASK 0x08000000
1291 #define SUBRANGE1_HANGEUL_MASK 0x01000000
1292 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
1294 if (charset == GB2312_CHARSET || charset == CHINESEBIG5_CHARSET)
1296 return (subrange1 & SUBRANGE1_HAN_MASK) == SUBRANGE1_HAN_MASK;
1298 else if (charset == SHIFTJIS_CHARSET)
1300 return (subrange1 & SUBRANGE1_JAPANESE_MASK) == SUBRANGE1_JAPANESE_MASK;
1302 else if (charset == HANGEUL_CHARSET)
1304 return (subrange1 & SUBRANGE1_HANGEUL_MASK) == SUBRANGE1_HANGEUL_MASK;
1307 return 1;
1310 /* Callback function for EnumFontFamiliesEx.
1311 * Checks if a font matches everything we are trying to check agaist,
1312 * and if so, adds it to a list. Both the data we are checking against
1313 * and the list to which the fonts are added are passed in via the
1314 * lparam argument, in the form of a font_callback_data struct. */
1315 static int CALLBACK
1316 add_font_entity_to_list (logical_font, physical_font, font_type, lParam)
1317 ENUMLOGFONTEX *logical_font;
1318 NEWTEXTMETRICEX *physical_font;
1319 DWORD font_type;
1320 LPARAM lParam;
1322 struct font_callback_data *match_data
1323 = (struct font_callback_data *) lParam;
1324 Lisp_Object backend = match_data->opentype_only ? Quniscribe : Qgdi;
1326 if ((!match_data->opentype_only
1327 || (physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)
1328 || (font_type & TRUETYPE_FONTTYPE))
1329 && logfonts_match (&logical_font->elfLogFont, &match_data->pattern)
1330 && font_matches_spec (font_type, physical_font,
1331 match_data->orig_font_spec, backend,
1332 &logical_font->elfLogFont)
1333 && w32font_coverage_ok (&physical_font->ntmFontSig,
1334 match_data->pattern.lfCharSet)
1335 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
1336 We limit this to raster fonts, because the test can catch some
1337 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
1338 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
1339 therefore get through this test. Since full names can be prefixed
1340 by a foundry, we accept raster fonts if the font name is found
1341 anywhere within the full name. */
1342 && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS
1343 || strstr (logical_font->elfFullName,
1344 logical_font->elfLogFont.lfFaceName)))
1346 Lisp_Object entity
1347 = w32_enumfont_pattern_entity (match_data->frame, logical_font,
1348 physical_font, font_type,
1349 &match_data->pattern,
1350 backend);
1351 if (!NILP (entity))
1352 match_data->list = Fcons (entity, match_data->list);
1354 return 1;
1357 /* Callback function for EnumFontFamiliesEx.
1358 * Terminates the search once we have a match. */
1359 static int CALLBACK
1360 add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam)
1361 ENUMLOGFONTEX *logical_font;
1362 NEWTEXTMETRICEX *physical_font;
1363 DWORD font_type;
1364 LPARAM lParam;
1366 struct font_callback_data *match_data
1367 = (struct font_callback_data *) lParam;
1368 add_font_entity_to_list (logical_font, physical_font, font_type, lParam);
1370 /* If we have a font in the list, terminate the search. */
1371 return !NILP (match_data->list);
1374 /* Convert a Lisp font registry (symbol) to a windows charset. */
1375 static LONG
1376 registry_to_w32_charset (charset)
1377 Lisp_Object charset;
1379 if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp)
1380 || EQ (charset, Qunicode_sip))
1381 return DEFAULT_CHARSET; /* UNICODE_CHARSET not defined in MingW32 */
1382 else if (EQ (charset, Qiso8859_1))
1383 return ANSI_CHARSET;
1384 else if (SYMBOLP (charset))
1385 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset)));
1386 else
1387 return DEFAULT_CHARSET;
1390 static Lisp_Object
1391 w32_registry (w32_charset, font_type)
1392 LONG w32_charset;
1393 DWORD font_type;
1395 /* If charset is defaulted, use ANSI (unicode for truetype fonts). */
1396 if (w32_charset == DEFAULT_CHARSET)
1397 w32_charset = ANSI_CHARSET;
1399 if (font_type == TRUETYPE_FONTTYPE && w32_charset == ANSI_CHARSET)
1400 return Qiso10646_1;
1401 else
1403 char * charset = w32_to_x_charset (w32_charset, NULL);
1404 return intern_downcase (charset, strlen(charset));
1408 /* Fill in all the available details of LOGFONT from FONT_SPEC. */
1409 static void
1410 fill_in_logfont (f, logfont, font_spec)
1411 FRAME_PTR f;
1412 LOGFONT *logfont;
1413 Lisp_Object font_spec;
1415 Lisp_Object tmp, extra;
1416 int dpi = FRAME_W32_DISPLAY_INFO (f)->resy;
1418 extra = AREF (font_spec, FONT_EXTRA_INDEX);
1419 /* Allow user to override dpi settings. */
1420 if (CONSP (extra))
1422 tmp = assq_no_quit (QCdpi, extra);
1423 if (CONSP (tmp) && INTEGERP (XCDR (tmp)))
1425 dpi = XINT (XCDR (tmp));
1427 else if (CONSP (tmp) && FLOATP (XCDR (tmp)))
1429 dpi = (int) (XFLOAT_DATA (XCDR (tmp)) + 0.5);
1433 /* Height */
1434 tmp = AREF (font_spec, FONT_SIZE_INDEX);
1435 if (INTEGERP (tmp))
1436 logfont->lfHeight = -1 * XINT (tmp);
1437 else if (FLOATP (tmp))
1438 logfont->lfHeight = (int) (-1.0 * dpi * XFLOAT_DATA (tmp) / 72.27 + 0.5);
1440 /* Escapement */
1442 /* Orientation */
1444 /* Weight */
1445 tmp = AREF (font_spec, FONT_WEIGHT_INDEX);
1446 if (INTEGERP (tmp))
1447 logfont->lfWeight = XINT (tmp);
1449 /* Italic */
1450 tmp = AREF (font_spec, FONT_SLANT_INDEX);
1451 if (INTEGERP (tmp))
1453 int slant = XINT (tmp);
1454 logfont->lfItalic = slant > 150 ? 1 : 0;
1457 /* Underline */
1459 /* Strikeout */
1461 /* Charset */
1462 tmp = AREF (font_spec, FONT_REGISTRY_INDEX);
1463 if (! NILP (tmp))
1464 logfont->lfCharSet = registry_to_w32_charset (tmp);
1465 else
1466 logfont->lfCharSet = DEFAULT_CHARSET;
1468 /* Out Precision */
1470 /* Clip Precision */
1472 /* Quality */
1473 logfont->lfQuality = DEFAULT_QUALITY;
1475 /* Generic Family and Face Name */
1476 logfont->lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
1478 tmp = AREF (font_spec, FONT_FAMILY_INDEX);
1479 if (! NILP (tmp))
1481 logfont->lfPitchAndFamily = w32_generic_family (tmp) | DEFAULT_PITCH;
1482 if ((logfont->lfPitchAndFamily & 0xF0) != FF_DONTCARE)
1483 ; /* Font name was generic, don't fill in font name. */
1484 /* Font families are interned, but allow for strings also in case of
1485 user input. */
1486 else if (SYMBOLP (tmp))
1487 strncpy (logfont->lfFaceName, SDATA (SYMBOL_NAME (tmp)), LF_FACESIZE);
1490 tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);
1491 if (!NILP (tmp))
1493 /* Override generic family. */
1494 BYTE family = w32_generic_family (tmp);
1495 if (family != FF_DONTCARE)
1496 logfont->lfPitchAndFamily = family | DEFAULT_PITCH;
1499 /* Process EXTRA info. */
1500 for ( ; CONSP (extra); extra = XCDR (extra))
1502 tmp = XCAR (extra);
1503 if (CONSP (tmp))
1505 Lisp_Object key, val;
1506 key = XCAR (tmp), val = XCDR (tmp);
1507 if (EQ (key, QCspacing))
1509 /* Set pitch based on the spacing property. */
1510 if (INTEGERP (val))
1512 int spacing = XINT (val);
1513 if (spacing < FONT_SPACING_MONO)
1514 logfont->lfPitchAndFamily
1515 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH;
1516 else
1517 logfont->lfPitchAndFamily
1518 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH;
1520 else if (EQ (val, Qp))
1521 logfont->lfPitchAndFamily
1522 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH;
1523 else if (EQ (val, Qc) || EQ (val, Qm))
1524 logfont->lfPitchAndFamily
1525 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH;
1527 /* Only use QCscript if charset is not provided, or is unicode
1528 and a single script is specified. This is rather crude,
1529 and is only used to narrow down the fonts returned where
1530 there is a definite match. Some scripts, such as latin, han,
1531 cjk-misc match multiple lfCharSet values, so we can't pre-filter
1532 them. */
1533 else if (EQ (key, QCscript)
1534 && logfont->lfCharSet == DEFAULT_CHARSET
1535 && SYMBOLP (val))
1537 if (EQ (val, Qgreek))
1538 logfont->lfCharSet = GREEK_CHARSET;
1539 else if (EQ (val, Qhangul))
1540 logfont->lfCharSet = HANGUL_CHARSET;
1541 else if (EQ (val, Qkana) || EQ (val, Qkanbun))
1542 logfont->lfCharSet = SHIFTJIS_CHARSET;
1543 else if (EQ (val, Qbopomofo))
1544 logfont->lfCharSet = CHINESEBIG5_CHARSET;
1545 /* GB 18030 supports tibetan, yi, mongolian,
1546 fonts that support it should show up if we ask for
1547 GB2312 fonts. */
1548 else if (EQ (val, Qtibetan) || EQ (val, Qyi)
1549 || EQ (val, Qmongolian))
1550 logfont->lfCharSet = GB2312_CHARSET;
1551 else if (EQ (val, Qhebrew))
1552 logfont->lfCharSet = HEBREW_CHARSET;
1553 else if (EQ (val, Qarabic))
1554 logfont->lfCharSet = ARABIC_CHARSET;
1555 else if (EQ (val, Qthai))
1556 logfont->lfCharSet = THAI_CHARSET;
1557 else if (EQ (val, Qsymbol))
1558 logfont->lfCharSet = SYMBOL_CHARSET;
1560 else if (EQ (key, QCantialias) && SYMBOLP (val))
1562 logfont->lfQuality = w32_antialias_type (val);
1568 static void
1569 list_all_matching_fonts (match_data)
1570 struct font_callback_data *match_data;
1572 HDC dc;
1573 Lisp_Object families = w32font_list_family (match_data->frame);
1574 struct frame *f = XFRAME (match_data->frame);
1576 dc = get_frame_dc (f);
1578 while (!NILP (families))
1580 /* TODO: Use the Unicode versions of the W32 APIs, so we can
1581 handle non-ASCII font names. */
1582 char *name;
1583 Lisp_Object family = CAR (families);
1584 families = CDR (families);
1585 if (NILP (family))
1586 continue;
1587 else if (SYMBOLP (family))
1588 name = SDATA (SYMBOL_NAME (family));
1589 else
1590 continue;
1592 strncpy (match_data->pattern.lfFaceName, name, LF_FACESIZE);
1593 match_data->pattern.lfFaceName[LF_FACESIZE - 1] = '\0';
1595 EnumFontFamiliesEx (dc, &match_data->pattern,
1596 (FONTENUMPROC) add_font_entity_to_list,
1597 (LPARAM) match_data, 0);
1600 release_frame_dc (f, dc);
1603 static Lisp_Object
1604 lispy_antialias_type (type)
1605 BYTE type;
1607 Lisp_Object lispy;
1609 switch (type)
1611 case NONANTIALIASED_QUALITY:
1612 lispy = Qnone;
1613 break;
1614 case ANTIALIASED_QUALITY:
1615 lispy = Qstandard;
1616 break;
1617 case CLEARTYPE_QUALITY:
1618 lispy = Qsubpixel;
1619 break;
1620 case CLEARTYPE_NATURAL_QUALITY:
1621 lispy = Qnatural;
1622 break;
1623 default:
1624 lispy = Qnil;
1625 break;
1627 return lispy;
1630 /* Convert antialiasing symbols to lfQuality */
1631 static BYTE
1632 w32_antialias_type (type)
1633 Lisp_Object type;
1635 if (EQ (type, Qnone))
1636 return NONANTIALIASED_QUALITY;
1637 else if (EQ (type, Qstandard))
1638 return ANTIALIASED_QUALITY;
1639 else if (EQ (type, Qsubpixel))
1640 return CLEARTYPE_QUALITY;
1641 else if (EQ (type, Qnatural))
1642 return CLEARTYPE_NATURAL_QUALITY;
1643 else
1644 return DEFAULT_QUALITY;
1647 /* Return a list of all the scripts that the font supports. */
1648 static Lisp_Object
1649 font_supported_scripts (FONTSIGNATURE * sig)
1651 DWORD * subranges = sig->fsUsb;
1652 Lisp_Object supported = Qnil;
1654 /* Match a single subrange. SYM is set if bit N is set in subranges. */
1655 #define SUBRANGE(n,sym) \
1656 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
1657 supported = Fcons ((sym), supported)
1659 /* Match multiple subranges. SYM is set if any MASK bit is set in
1660 subranges[0 - 3]. */
1661 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
1662 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
1663 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
1664 supported = Fcons ((sym), supported)
1666 SUBRANGE (0, Qlatin);
1667 /* The following count as latin too, ASCII should be present in these fonts,
1668 so don't need to mark them separately. */
1669 /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */
1670 SUBRANGE (4, Qphonetic);
1671 /* 5: Spacing and tone modifiers, 6: Combining Diacriticals. */
1672 SUBRANGE (7, Qgreek);
1673 SUBRANGE (8, Qcoptic);
1674 SUBRANGE (9, Qcyrillic);
1675 SUBRANGE (10, Qarmenian);
1676 SUBRANGE (11, Qhebrew);
1677 SUBRANGE (13, Qarabic);
1678 SUBRANGE (14, Qnko);
1679 SUBRANGE (15, Qdevanagari);
1680 SUBRANGE (16, Qbengali);
1681 SUBRANGE (17, Qgurmukhi);
1682 SUBRANGE (18, Qgujarati);
1683 SUBRANGE (19, Qoriya);
1684 SUBRANGE (20, Qtamil);
1685 SUBRANGE (21, Qtelugu);
1686 SUBRANGE (22, Qkannada);
1687 SUBRANGE (23, Qmalayalam);
1688 SUBRANGE (24, Qthai);
1689 SUBRANGE (25, Qlao);
1690 SUBRANGE (26, Qgeorgian);
1691 SUBRANGE (27, Qbalinese);
1692 /* 28: Hangul Jamo. */
1693 /* 29: Latin Extended, 30: Greek Extended, 31: Punctuation. */
1694 /* 32-47: Symbols (defined below). */
1695 SUBRANGE (48, Qcjk_misc);
1696 /* Match either 49: katakana or 50: hiragana for kana. */
1697 MASK_ANY (0, 0x00060000, 0, 0, Qkana);
1698 SUBRANGE (51, Qbopomofo);
1699 /* 52: Compatibility Jamo */
1700 SUBRANGE (53, Qphags_pa);
1701 /* 54: Enclosed CJK letters and months, 55: CJK Compatibility. */
1702 SUBRANGE (56, Qhangul);
1703 /* 57: Surrogates. */
1704 SUBRANGE (58, Qphoenician);
1705 SUBRANGE (59, Qhan); /* There are others, but this is the main one. */
1706 SUBRANGE (59, Qideographic_description); /* Windows lumps this in. */
1707 SUBRANGE (59, Qkanbun); /* And this. */
1708 /* 60: Private use, 61: CJK strokes and compatibility. */
1709 /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */
1710 /* 64: Combining half marks, 65: Vertical and CJK compatibility. */
1711 /* 66: Small forms, 67: Arabic Presentation B, 68: Half and Full width. */
1712 /* 69: Specials. */
1713 SUBRANGE (70, Qtibetan);
1714 SUBRANGE (71, Qsyriac);
1715 SUBRANGE (72, Qthaana);
1716 SUBRANGE (73, Qsinhala);
1717 SUBRANGE (74, Qmyanmar);
1718 SUBRANGE (75, Qethiopic);
1719 SUBRANGE (76, Qcherokee);
1720 SUBRANGE (77, Qcanadian_aboriginal);
1721 SUBRANGE (78, Qogham);
1722 SUBRANGE (79, Qrunic);
1723 SUBRANGE (80, Qkhmer);
1724 SUBRANGE (81, Qmongolian);
1725 SUBRANGE (82, Qbraille);
1726 SUBRANGE (83, Qyi);
1727 SUBRANGE (84, Qbuhid);
1728 SUBRANGE (84, Qhanunoo);
1729 SUBRANGE (84, Qtagalog);
1730 SUBRANGE (84, Qtagbanwa);
1731 SUBRANGE (85, Qold_italic);
1732 SUBRANGE (86, Qgothic);
1733 SUBRANGE (87, Qdeseret);
1734 SUBRANGE (88, Qbyzantine_musical_symbol);
1735 SUBRANGE (88, Qmusical_symbol); /* Windows doesn't distinguish these. */
1736 SUBRANGE (89, Qmathematical);
1737 /* 90: Private use, 91: Variation selectors, 92: Tags. */
1738 SUBRANGE (93, Qlimbu);
1739 SUBRANGE (94, Qtai_le);
1740 /* 95: New Tai Le */
1741 SUBRANGE (90, Qbuginese);
1742 SUBRANGE (97, Qglagolitic);
1743 SUBRANGE (98, Qtifinagh);
1744 /* 99: Yijing Hexagrams. */
1745 SUBRANGE (100, Qsyloti_nagri);
1746 SUBRANGE (101, Qlinear_b);
1747 /* 102: Ancient Greek Numbers. */
1748 SUBRANGE (103, Qugaritic);
1749 SUBRANGE (104, Qold_persian);
1750 SUBRANGE (105, Qshavian);
1751 SUBRANGE (106, Qosmanya);
1752 SUBRANGE (107, Qcypriot);
1753 SUBRANGE (108, Qkharoshthi);
1754 /* 109: Tai Xuan Jing. */
1755 SUBRANGE (110, Qcuneiform);
1756 /* 111: Counting Rods. */
1758 /* There isn't really a main symbol range, so include symbol if any
1759 relevant range is set. */
1760 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol);
1762 /* Missing: Tai Viet (U+AA80) and Cham (U+AA00) . */
1763 #undef SUBRANGE
1764 #undef MASK_ANY
1766 return supported;
1769 /* Generate a full name for a Windows font.
1770 The full name is in fcname format, with weight, slant and antialiasing
1771 specified if they are not "normal". */
1772 static int
1773 w32font_full_name (font, font_obj, pixel_size, name, nbytes)
1774 LOGFONT * font;
1775 Lisp_Object font_obj;
1776 int pixel_size;
1777 char *name;
1778 int nbytes;
1780 int len, height, outline;
1781 char *p;
1782 Lisp_Object antialiasing, weight = Qnil;
1784 len = strlen (font->lfFaceName);
1786 outline = EQ (AREF (font_obj, FONT_FOUNDRY_INDEX), Qoutline);
1788 /* Represent size of scalable fonts by point size. But use pixelsize for
1789 raster fonts to indicate that they are exactly that size. */
1790 if (outline)
1791 len += 11; /* -SIZE */
1792 else
1793 len = strlen (font->lfFaceName) + 21;
1795 if (font->lfItalic)
1796 len += 7; /* :italic */
1798 if (font->lfWeight && font->lfWeight != FW_NORMAL)
1800 weight = font_symbolic_weight (font_obj);
1801 len += 8 + SBYTES (SYMBOL_NAME (weight)); /* :weight=NAME */
1804 antialiasing = lispy_antialias_type (font->lfQuality);
1805 if (! NILP (antialiasing))
1806 len += 11 + SBYTES (SYMBOL_NAME (antialiasing)); /* :antialias=NAME */
1808 /* Check that the buffer is big enough */
1809 if (len > nbytes)
1810 return -1;
1812 p = name;
1813 p += sprintf (p, "%s", font->lfFaceName);
1815 height = font->lfHeight ? eabs (font->lfHeight) : pixel_size;
1817 if (height > 0)
1819 if (outline)
1821 float pointsize = height * 72.0 / one_w32_display_info.resy;
1822 /* Round to nearest half point. floor is used, since round is not
1823 supported in MS library. */
1824 pointsize = floor (pointsize * 2 + 0.5) / 2;
1825 p += sprintf (p, "-%1.1f", pointsize);
1827 else
1828 p += sprintf (p, ":pixelsize=%d", height);
1831 if (font->lfItalic)
1832 p += sprintf (p, ":italic");
1834 if (SYMBOLP (weight) && ! NILP (weight))
1835 p += sprintf (p, ":weight=%s", SDATA (SYMBOL_NAME (weight)));
1837 if (SYMBOLP (antialiasing) && ! NILP (antialiasing))
1838 p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing)));
1840 return (p - name);
1844 static void compute_metrics (dc, w32_font, code, metrics)
1845 HDC dc;
1846 struct w32font_info *w32_font;
1847 unsigned int code;
1848 struct w32_metric_cache *metrics;
1850 GLYPHMETRICS gm;
1851 MAT2 transform;
1852 unsigned int options = GGO_METRICS;
1854 if (w32_font->glyph_idx)
1855 options |= GGO_GLYPH_INDEX;
1857 bzero (&transform, sizeof (transform));
1858 transform.eM11.value = 1;
1859 transform.eM22.value = 1;
1861 if (GetGlyphOutlineW (dc, code, options, &gm, 0, NULL, &transform)
1862 != GDI_ERROR)
1864 metrics->lbearing = gm.gmptGlyphOrigin.x;
1865 metrics->rbearing = gm.gmptGlyphOrigin.x + gm.gmBlackBoxX;
1866 metrics->width = gm.gmCellIncX;
1867 metrics->status = W32METRIC_SUCCESS;
1869 else
1871 if (w32_font->glyph_idx)
1873 /* Can't use glyph indexes after all.
1874 Avoid it in future, and clear any metrics that were based on
1875 glyph indexes. */
1876 w32_font->glyph_idx = 0;
1877 clear_cached_metrics (w32_font);
1879 metrics->status = W32METRIC_FAIL;
1883 static void
1884 clear_cached_metrics (w32_font)
1885 struct w32font_info *w32_font;
1887 int i;
1888 for (i = 0; i < w32_font->n_cache_blocks; i++)
1889 bzero (w32_font->cached_metrics[i],
1890 CACHE_BLOCKSIZE * sizeof (struct font_metrics));
1893 struct font_driver w32font_driver =
1895 0, /* Qgdi */
1896 w32font_get_cache,
1897 w32font_list,
1898 w32font_match,
1899 w32font_list_family,
1900 NULL, /* free_entity */
1901 w32font_open,
1902 w32font_close,
1903 NULL, /* prepare_face */
1904 NULL, /* done_face */
1905 w32font_has_char,
1906 w32font_encode_char,
1907 w32font_text_extents,
1908 w32font_draw,
1909 NULL, /* get_bitmap */
1910 NULL, /* free_bitmap */
1911 NULL, /* get_outline */
1912 NULL, /* free_outline */
1913 NULL, /* anchor_point */
1914 NULL, /* otf_capability */
1915 NULL, /* otf_drive */
1916 NULL, /* start_for_frame */
1917 NULL, /* end_for_frame */
1918 NULL /* shape */
1922 /* Initialize state that does not change between invocations. This is only
1923 called when Emacs is dumped. */
1924 void
1925 syms_of_w32font ()
1927 DEFSYM (Qgdi, "gdi");
1928 DEFSYM (Quniscribe, "uniscribe");
1929 DEFSYM (QCformat, ":format");
1931 /* Generic font families. */
1932 DEFSYM (Qmonospace, "monospace");
1933 DEFSYM (Qserif, "serif");
1934 DEFSYM (Qsansserif, "sansserif");
1935 DEFSYM (Qscript, "script");
1936 DEFSYM (Qdecorative, "decorative");
1937 /* Aliases. */
1938 DEFSYM (Qsans_serif, "sans_serif");
1939 DEFSYM (Qsans, "sans");
1940 DEFSYM (Qmono, "mono");
1942 /* Fake foundries. */
1943 DEFSYM (Qraster, "raster");
1944 DEFSYM (Qoutline, "outline");
1945 DEFSYM (Qunknown, "unknown");
1947 /* Antialiasing. */
1948 DEFSYM (Qstandard, "standard");
1949 DEFSYM (Qsubpixel, "subpixel");
1950 DEFSYM (Qnatural, "natural");
1952 /* Languages */
1953 DEFSYM (Qja, "ja");
1954 DEFSYM (Qko, "ko");
1955 DEFSYM (Qzh, "zh");
1957 /* Scripts */
1958 DEFSYM (Qlatin, "latin");
1959 DEFSYM (Qgreek, "greek");
1960 DEFSYM (Qcoptic, "coptic");
1961 DEFSYM (Qcyrillic, "cyrillic");
1962 DEFSYM (Qarmenian, "armenian");
1963 DEFSYM (Qhebrew, "hebrew");
1964 DEFSYM (Qarabic, "arabic");
1965 DEFSYM (Qsyriac, "syriac");
1966 DEFSYM (Qnko, "nko");
1967 DEFSYM (Qthaana, "thaana");
1968 DEFSYM (Qdevanagari, "devanagari");
1969 DEFSYM (Qbengali, "bengali");
1970 DEFSYM (Qgurmukhi, "gurmukhi");
1971 DEFSYM (Qgujarati, "gujarati");
1972 DEFSYM (Qoriya, "oriya");
1973 DEFSYM (Qtamil, "tamil");
1974 DEFSYM (Qtelugu, "telugu");
1975 DEFSYM (Qkannada, "kannada");
1976 DEFSYM (Qmalayalam, "malayalam");
1977 DEFSYM (Qsinhala, "sinhala");
1978 DEFSYM (Qthai, "thai");
1979 DEFSYM (Qlao, "lao");
1980 DEFSYM (Qtibetan, "tibetan");
1981 DEFSYM (Qmyanmar, "myanmar");
1982 DEFSYM (Qgeorgian, "georgian");
1983 DEFSYM (Qhangul, "hangul");
1984 DEFSYM (Qethiopic, "ethiopic");
1985 DEFSYM (Qcherokee, "cherokee");
1986 DEFSYM (Qcanadian_aboriginal, "canadian-aboriginal");
1987 DEFSYM (Qogham, "ogham");
1988 DEFSYM (Qrunic, "runic");
1989 DEFSYM (Qkhmer, "khmer");
1990 DEFSYM (Qmongolian, "mongolian");
1991 DEFSYM (Qsymbol, "symbol");
1992 DEFSYM (Qbraille, "braille");
1993 DEFSYM (Qhan, "han");
1994 DEFSYM (Qideographic_description, "ideographic-description");
1995 DEFSYM (Qcjk_misc, "cjk-misc");
1996 DEFSYM (Qkana, "kana");
1997 DEFSYM (Qbopomofo, "bopomofo");
1998 DEFSYM (Qkanbun, "kanbun");
1999 DEFSYM (Qyi, "yi");
2000 DEFSYM (Qbyzantine_musical_symbol, "byzantine-musical-symbol");
2001 DEFSYM (Qmusical_symbol, "musical-symbol");
2002 DEFSYM (Qmathematical, "mathematical");
2003 DEFSYM (Qphonetic, "phonetic");
2004 DEFSYM (Qbalinese, "balinese");
2005 DEFSYM (Qbuginese, "buginese");
2006 DEFSYM (Qbuhid, "buhid");
2007 DEFSYM (Qcuneiform, "cuneiform");
2008 DEFSYM (Qcypriot, "cypriot");
2009 DEFSYM (Qdeseret, "deseret");
2010 DEFSYM (Qglagolitic, "glagolitic");
2011 DEFSYM (Qgothic, "gothic");
2012 DEFSYM (Qhanunoo, "hanunoo");
2013 DEFSYM (Qkharoshthi, "kharoshthi");
2014 DEFSYM (Qlimbu, "limbu");
2015 DEFSYM (Qlinear_b, "linear_b");
2016 DEFSYM (Qold_italic, "old_italic");
2017 DEFSYM (Qold_persian, "old_persian");
2018 DEFSYM (Qosmanya, "osmanya");
2019 DEFSYM (Qphags_pa, "phags-pa");
2020 DEFSYM (Qphoenician, "phoenician");
2021 DEFSYM (Qshavian, "shavian");
2022 DEFSYM (Qsyloti_nagri, "syloti_nagri");
2023 DEFSYM (Qtagalog, "tagalog");
2024 DEFSYM (Qtagbanwa, "tagbanwa");
2025 DEFSYM (Qtai_le, "tai_le");
2026 DEFSYM (Qtifinagh, "tifinagh");
2027 DEFSYM (Qugaritic, "ugaritic");
2029 w32font_driver.type = Qgdi;
2030 register_font_driver (&w32font_driver, NULL);
2032 #endif /* USE_FONT_BACKEND */
2034 /* arch-tag: 65b8a3cd-46aa-4c0d-a1f3-99e75b9c07ee
2035 (do not change this comment) */