1 /* Font backend for the Microsoft W32 API.
2 Copyright (C) 2007-2011 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 of the License, or
9 (at your option) 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. If not, see <http://www.gnu.org/licenses/>. */
29 #include "dispextern.h"
30 #include "character.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
44 #ifndef CLEARTYPE_NATURAL_QUALITY
45 #define CLEARTYPE_NATURAL_QUALITY 6
48 /* VIETNAMESE_CHARSET and JOHAB_CHARSET are not defined in some versions
50 #ifndef VIETNAMESE_CHARSET
51 #define VIETNAMESE_CHARSET 163
54 #define JOHAB_CHARSET 130
58 Lisp_Object Quniscribe
;
59 static Lisp_Object QCformat
;
60 static Lisp_Object Qmonospace
, Qsansserif
, Qmono
, Qsans
, Qsans_serif
;
61 static Lisp_Object Qserif
, Qscript
, Qdecorative
;
62 static Lisp_Object Qraster
, Qoutline
, Qunknown
;
65 extern Lisp_Object Qnone
; /* reuse from w32fns.c */
66 static Lisp_Object Qstandard
, Qsubpixel
, Qnatural
;
69 static Lisp_Object Qzh
;
72 static Lisp_Object Qgreek
, Qcoptic
, Qcyrillic
, Qarmenian
, Qhebrew
;
73 static Lisp_Object Qarabic
, Qsyriac
, Qnko
, Qthaana
, Qdevanagari
, Qbengali
;
74 static Lisp_Object Qgurmukhi
, Qgujarati
, Qoriya
, Qtamil
, Qtelugu
;
75 static Lisp_Object Qkannada
, Qmalayalam
, Qsinhala
, Qthai
, Qlao
;
76 static Lisp_Object Qtibetan
, Qmyanmar
, Qgeorgian
, Qhangul
, Qethiopic
;
77 static Lisp_Object Qcherokee
, Qcanadian_aboriginal
, Qogham
, Qrunic
;
78 static Lisp_Object Qkhmer
, Qmongolian
, Qsymbol
, Qbraille
, Qhan
;
79 static Lisp_Object Qideographic_description
, Qcjk_misc
, Qkana
, Qbopomofo
;
80 static Lisp_Object Qkanbun
, Qyi
, Qbyzantine_musical_symbol
;
81 static Lisp_Object Qmusical_symbol
, Qmathematical
, Qcham
, Qphonetic
;
82 /* Not defined in characters.el, but referenced in fontset.el. */
83 static Lisp_Object Qbalinese
, Qbuginese
, Qbuhid
, Qcuneiform
, Qcypriot
;
84 static Lisp_Object Qdeseret
, Qglagolitic
, Qgothic
, Qhanunoo
, Qkharoshthi
;
85 static Lisp_Object Qlimbu
, Qlinear_b
, Qold_italic
, Qold_persian
, Qosmanya
;
86 static Lisp_Object Qphags_pa
, Qphoenician
, Qshavian
, Qsyloti_nagri
;
87 static Lisp_Object Qtagalog
, Qtagbanwa
, Qtai_le
, Qtifinagh
, Qugaritic
;
89 /* W32 charsets: for use in Vw32_charset_info_alist. */
90 static Lisp_Object Qw32_charset_ansi
, Qw32_charset_default
;
91 static Lisp_Object Qw32_charset_symbol
, Qw32_charset_shiftjis
;
92 static Lisp_Object Qw32_charset_hangeul
, Qw32_charset_gb2312
;
93 static Lisp_Object Qw32_charset_chinesebig5
, Qw32_charset_oem
;
94 static Lisp_Object Qw32_charset_easteurope
, Qw32_charset_turkish
;
95 static Lisp_Object Qw32_charset_baltic
, Qw32_charset_russian
;
96 static Lisp_Object Qw32_charset_arabic
, Qw32_charset_greek
;
97 static Lisp_Object Qw32_charset_hebrew
, Qw32_charset_vietnamese
;
98 static Lisp_Object Qw32_charset_thai
, Qw32_charset_johab
, Qw32_charset_mac
;
100 /* Font spacing symbols - defined in font.c. */
101 extern Lisp_Object Qc
, Qp
, Qm
;
103 static void fill_in_logfont (FRAME_PTR
, LOGFONT
*, Lisp_Object
);
105 static BYTE
w32_antialias_type (Lisp_Object
);
106 static Lisp_Object
lispy_antialias_type (BYTE
);
108 static Lisp_Object
font_supported_scripts (FONTSIGNATURE
*);
109 static int w32font_full_name (LOGFONT
*, Lisp_Object
, int, char *, int);
110 static void compute_metrics (HDC
, struct w32font_info
*, unsigned int,
111 struct w32_metric_cache
*);
113 static Lisp_Object
w32_registry (LONG
, DWORD
);
115 /* EnumFontFamiliesEx callbacks. */
116 static int CALLBACK
add_font_entity_to_list (ENUMLOGFONTEX
*,
119 static int CALLBACK
add_one_font_entity_to_list (ENUMLOGFONTEX
*,
122 static int CALLBACK
add_font_name_to_list (ENUMLOGFONTEX
*,
126 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
127 of what we really want. */
128 struct font_callback_data
130 /* The logfont we are matching against. EnumFontFamiliesEx only matches
131 face name and charset, so we need to manually match everything else
132 in the callback function. */
134 /* The original font spec or entity. */
135 Lisp_Object orig_font_spec
;
136 /* The frame the font is being loaded on. */
138 /* The list to add matches to. */
140 /* Whether to match only opentype fonts. */
144 /* Handles the problem that EnumFontFamiliesEx will not return all
145 style variations if the font name is not specified. */
146 static void list_all_matching_fonts (struct font_callback_data
*);
148 static BOOL g_b_init_is_w9x
;
149 static BOOL g_b_init_get_outline_metrics_w
;
150 static BOOL g_b_init_get_text_metrics_w
;
151 static BOOL g_b_init_get_glyph_outline_w
;
152 static BOOL g_b_init_get_glyph_outline_w
;
154 typedef UINT (WINAPI
* GetOutlineTextMetricsW_Proc
) (
157 LPOUTLINETEXTMETRICW lpotmw
);
158 typedef BOOL (WINAPI
* GetTextMetricsW_Proc
) (
160 LPTEXTMETRICW lptmw
);
161 typedef DWORD (WINAPI
* GetGlyphOutlineW_Proc
) (
170 /* Several "wide" functions we use to support the font backends are
171 unavailable on Windows 9X, unless UNICOWS.DLL is installed (their
172 versions in the default libraries are non-functional stubs). On NT
173 and later systems, these functions are in GDI32.DLL. The following
174 helper function attempts to load UNICOWS.DLL on Windows 9X, and
175 refuses to let Emacs start up if that library is not found. On NT
176 and later versions, it simply loads GDI32.DLL, which should always
179 w32_load_unicows_or_gdi32 (void)
181 static BOOL is_9x
= 0;
182 OSVERSIONINFO os_ver
;
184 if (g_b_init_is_w9x
== 0)
187 ZeroMemory (&os_ver
, sizeof (OSVERSIONINFO
));
188 os_ver
.dwOSVersionInfoSize
= sizeof (OSVERSIONINFO
);
189 if (GetVersionEx (&os_ver
))
190 is_9x
= (os_ver
.dwPlatformId
== VER_PLATFORM_WIN32_WINDOWS
);
194 ret
= LoadLibrary ("Unicows.dll");
199 button
= MessageBox (NULL
,
200 "Emacs cannot load the UNICOWS.DLL library.\n"
201 "This library is essential for using Emacs\n"
202 "on this system. You need to install it.\n\n"
203 "However, you can still use Emacs by invoking\n"
204 "it with the '-nw' command-line option.\n\n"
205 "Emacs will exit when you click OK.",
206 "Emacs cannot load UNICOWS.DLL",
207 MB_ICONERROR
| MB_TASKMODAL
208 | MB_SETFOREGROUND
| MB_OK
);
218 ret
= LoadLibrary ("Gdi32.dll");
222 /* The following 3 functions call the problematic "wide" APIs via
223 function pointers, to avoid linking against the non-standard
224 libunicows on W9X. */
226 get_outline_metrics_w(HDC hdc
, UINT cbData
, LPOUTLINETEXTMETRICW lpotmw
)
228 static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW
= NULL
;
229 HMODULE hm_unicows
= NULL
;
230 if (g_b_init_get_outline_metrics_w
== 0)
232 g_b_init_get_outline_metrics_w
= 1;
233 hm_unicows
= w32_load_unicows_or_gdi32 ();
235 s_pfn_Get_Outline_Text_MetricsW
= (GetOutlineTextMetricsW_Proc
)
236 GetProcAddress (hm_unicows
, "GetOutlineTextMetricsW");
238 if (s_pfn_Get_Outline_Text_MetricsW
== NULL
)
239 abort (); /* cannot happen */
240 return s_pfn_Get_Outline_Text_MetricsW (hdc
, cbData
, lpotmw
);
244 get_text_metrics_w(HDC hdc
, LPTEXTMETRICW lptmw
)
246 static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW
= NULL
;
247 HMODULE hm_unicows
= NULL
;
248 if (g_b_init_get_text_metrics_w
== 0)
250 g_b_init_get_text_metrics_w
= 1;
251 hm_unicows
= w32_load_unicows_or_gdi32 ();
253 s_pfn_Get_Text_MetricsW
= (GetTextMetricsW_Proc
)
254 GetProcAddress (hm_unicows
, "GetTextMetricsW");
256 if (s_pfn_Get_Text_MetricsW
== NULL
)
257 abort (); /* cannot happen */
258 return s_pfn_Get_Text_MetricsW (hdc
, lptmw
);
262 get_glyph_outline_w (HDC hdc
, UINT uChar
, UINT uFormat
, LPGLYPHMETRICS lpgm
,
263 DWORD cbBuffer
, LPVOID lpvBuffer
, const MAT2
*lpmat2
)
265 static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW
= NULL
;
266 HMODULE hm_unicows
= NULL
;
267 if (g_b_init_get_glyph_outline_w
== 0)
269 g_b_init_get_glyph_outline_w
= 1;
270 hm_unicows
= w32_load_unicows_or_gdi32 ();
272 s_pfn_Get_Glyph_OutlineW
= (GetGlyphOutlineW_Proc
)
273 GetProcAddress (hm_unicows
, "GetGlyphOutlineW");
275 if (s_pfn_Get_Glyph_OutlineW
== NULL
)
276 abort (); /* cannot happen */
277 return s_pfn_Get_Glyph_OutlineW (hdc
, uChar
, uFormat
, lpgm
, cbBuffer
,
282 memq_no_quit (Lisp_Object elt
, Lisp_Object list
)
284 while (CONSP (list
) && ! EQ (XCAR (list
), elt
))
286 return (CONSP (list
));
290 intern_font_name (char * string
)
292 Lisp_Object obarray
, tem
, str
;
295 str
= DECODE_SYSTEM (build_string (string
));
298 /* The following code is copied from the function intern (in lread.c). */
300 if (!VECTORP (obarray
) || ASIZE (obarray
) == 0)
301 obarray
= check_obarray (obarray
);
302 tem
= oblookup (obarray
, SDATA (str
), len
, len
);
305 return Fintern (str
, obarray
);
308 /* w32 implementation of get_cache for font backend.
309 Return a cache of font-entities on FRAME. The cache must be a
310 cons whose cdr part is the actual cache area. */
312 w32font_get_cache (FRAME_PTR f
)
314 struct w32_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
316 return (dpyinfo
->name_list_element
);
319 /* w32 implementation of list for font backend.
320 List fonts exactly matching with FONT_SPEC on FRAME. The value
321 is a vector of font-entities. This is the sole API that
322 allocates font-entities. */
324 w32font_list (Lisp_Object frame
, Lisp_Object font_spec
)
326 Lisp_Object fonts
= w32font_list_internal (frame
, font_spec
, 0);
327 FONT_ADD_LOG ("w32font-list", font_spec
, fonts
);
331 /* w32 implementation of match for font backend.
332 Return a font entity most closely matching with FONT_SPEC on
333 FRAME. The closeness is determined by the font backend, thus
334 `face-font-selection-order' is ignored here. */
336 w32font_match (Lisp_Object frame
, Lisp_Object font_spec
)
338 Lisp_Object entity
= w32font_match_internal (frame
, font_spec
, 0);
339 FONT_ADD_LOG ("w32font-match", font_spec
, entity
);
343 /* w32 implementation of list_family for font backend.
344 List available families. The value is a list of family names
347 w32font_list_family (Lisp_Object frame
)
349 Lisp_Object list
= Qnil
;
350 LOGFONT font_match_pattern
;
352 FRAME_PTR f
= XFRAME (frame
);
354 memset (&font_match_pattern
, 0, sizeof (font_match_pattern
));
355 font_match_pattern
.lfCharSet
= DEFAULT_CHARSET
;
357 dc
= get_frame_dc (f
);
359 EnumFontFamiliesEx (dc
, &font_match_pattern
,
360 (FONTENUMPROC
) add_font_name_to_list
,
362 release_frame_dc (f
, dc
);
367 /* w32 implementation of open for font backend.
368 Open a font specified by FONT_ENTITY on frame F.
369 If the font is scalable, open it with PIXEL_SIZE. */
371 w32font_open (FRAME_PTR f
, Lisp_Object font_entity
, int pixel_size
)
373 Lisp_Object font_object
374 = font_make_object (VECSIZE (struct w32font_info
),
375 font_entity
, pixel_size
);
376 struct w32font_info
*w32_font
377 = (struct w32font_info
*) XFONT_OBJECT (font_object
);
379 ASET (font_object
, FONT_TYPE_INDEX
, Qgdi
);
381 if (!w32font_open_internal (f
, font_entity
, pixel_size
, font_object
))
386 /* GDI backend does not use glyph indices. */
387 w32_font
->glyph_idx
= 0;
392 /* w32 implementation of close for font_backend.
393 Close FONT on frame F. */
395 w32font_close (FRAME_PTR f
, struct font
*font
)
398 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
400 /* Delete the GDI font object. */
401 DeleteObject (w32_font
->hfont
);
403 /* Free all the cached metrics. */
404 if (w32_font
->cached_metrics
)
406 for (i
= 0; i
< w32_font
->n_cache_blocks
; i
++)
408 xfree (w32_font
->cached_metrics
[i
]);
410 xfree (w32_font
->cached_metrics
);
411 w32_font
->cached_metrics
= NULL
;
415 /* w32 implementation of has_char for font backend.
417 If FONT_ENTITY has a glyph for character C (Unicode code point),
418 return 1. If not, return 0. If a font must be opened to check
421 w32font_has_char (Lisp_Object entity
, int c
)
423 /* We can't be certain about which characters a font will support until
424 we open it. Checking the scripts that the font supports turns out
425 to not be reliable. */
429 Lisp_Object supported_scripts
, extra
, script
;
432 extra
= AREF (entity
, FONT_EXTRA_INDEX
);
436 supported_scripts
= assq_no_quit (QCscript
, extra
);
437 /* If font doesn't claim to support any scripts, then we can't be certain
439 if (!CONSP (supported_scripts
))
442 supported_scripts
= XCDR (supported_scripts
);
444 script
= CHAR_TABLE_REF (Vchar_script_table
, c
);
446 /* If we don't know what script the character is from, then we can't be
447 certain until we open it. Also if the font claims support for the script
448 the character is from, it may only have partial coverage, so we still
449 can't be certain until we open the font. */
450 if (NILP (script
) || memq_no_quit (script
, supported_scripts
))
453 /* Font reports what scripts it supports, and none of them are the script
454 the character is from. But we still can't be certain, as some fonts
455 will contain some/most/all of the characters in that script without
456 claiming support for it. */
461 /* w32 implementation of encode_char for font backend.
462 Return a glyph code of FONT for character C (Unicode code point).
463 If FONT doesn't have such a glyph, return FONT_INVALID_CODE.
465 For speed, the gdi backend uses Unicode (Emacs calls encode_char
466 far too often for it to be efficient). But we still need to detect
467 which characters are not supported by the font.
470 w32font_encode_char (struct font
*font
, int c
)
472 struct w32font_info
* w32_font
= (struct w32font_info
*)font
;
474 if (c
< w32_font
->metrics
.tmFirstChar
475 || c
> w32_font
->metrics
.tmLastChar
)
476 return FONT_INVALID_CODE
;
481 /* w32 implementation of text_extents for font backend.
482 Perform the size computation of glyphs of FONT and fillin members
483 of METRICS. The glyphs are specified by their glyph codes in
484 CODE (length NGLYPHS). Apparently metrics can be NULL, in this
485 case just return the overall width. */
487 w32font_text_extents (struct font
*font
, unsigned *code
,
488 int nglyphs
, struct font_metrics
*metrics
)
491 HFONT old_font
= NULL
;
498 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
502 memset (metrics
, 0, sizeof (struct font_metrics
));
503 metrics
->ascent
= font
->ascent
;
504 metrics
->descent
= font
->descent
;
506 for (i
= 0; i
< nglyphs
; i
++)
508 struct w32_metric_cache
*char_metric
;
509 int block
= *(code
+ i
) / CACHE_BLOCKSIZE
;
510 int pos_in_block
= *(code
+ i
) % CACHE_BLOCKSIZE
;
512 if (block
>= w32_font
->n_cache_blocks
)
514 if (!w32_font
->cached_metrics
)
515 w32_font
->cached_metrics
516 = xmalloc ((block
+ 1)
517 * sizeof (struct w32_metric_cache
*));
519 w32_font
->cached_metrics
520 = xrealloc (w32_font
->cached_metrics
,
522 * sizeof (struct w32_metric_cache
*));
523 memset (w32_font
->cached_metrics
+ w32_font
->n_cache_blocks
, 0,
524 ((block
+ 1 - w32_font
->n_cache_blocks
)
525 * sizeof (struct w32_metric_cache
*)));
526 w32_font
->n_cache_blocks
= block
+ 1;
529 if (!w32_font
->cached_metrics
[block
])
531 w32_font
->cached_metrics
[block
]
532 = xmalloc (CACHE_BLOCKSIZE
* sizeof (struct w32_metric_cache
));
533 memset (w32_font
->cached_metrics
[block
], 0,
534 CACHE_BLOCKSIZE
* sizeof (struct w32_metric_cache
));
537 char_metric
= w32_font
->cached_metrics
[block
] + pos_in_block
;
539 if (char_metric
->status
== W32METRIC_NO_ATTEMPT
)
543 /* TODO: Frames can come and go, and their fonts
544 outlive them. So we can't cache the frame in the
545 font structure. Use selected_frame until the API
546 is updated to pass in a frame. */
547 f
= XFRAME (selected_frame
);
549 dc
= get_frame_dc (f
);
550 old_font
= SelectObject (dc
, w32_font
->hfont
);
552 compute_metrics (dc
, w32_font
, *(code
+ i
), char_metric
);
555 if (char_metric
->status
== W32METRIC_SUCCESS
)
557 metrics
->lbearing
= min (metrics
->lbearing
,
558 metrics
->width
+ char_metric
->lbearing
);
559 metrics
->rbearing
= max (metrics
->rbearing
,
560 metrics
->width
+ char_metric
->rbearing
);
561 metrics
->width
+= char_metric
->width
;
564 /* If we couldn't get metrics for a char,
565 use alternative method. */
568 /* If we got through everything, return. */
573 /* Restore state and release DC. */
574 SelectObject (dc
, old_font
);
575 release_frame_dc (f
, dc
);
578 return metrics
->width
;
582 /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
583 fallback on other methods that will at least give some of the metric
586 /* Make array big enough to hold surrogates. */
587 wcode
= alloca (nglyphs
* sizeof (WORD
) * 2);
588 for (i
= 0; i
< nglyphs
; i
++)
590 if (code
[i
] < 0x10000)
594 DWORD surrogate
= code
[i
] - 0x10000;
596 /* High surrogate: U+D800 - U+DBFF. */
597 wcode
[i
++] = 0xD800 + ((surrogate
>> 10) & 0x03FF);
598 /* Low surrogate: U+DC00 - U+DFFF. */
599 wcode
[i
] = 0xDC00 + (surrogate
& 0x03FF);
600 /* An extra glyph. wcode is already double the size of code to
608 /* TODO: Frames can come and go, and their fonts outlive
609 them. So we can't cache the frame in the font structure. Use
610 selected_frame until the API is updated to pass in a
612 f
= XFRAME (selected_frame
);
614 dc
= get_frame_dc (f
);
615 old_font
= SelectObject (dc
, w32_font
->hfont
);
618 if (GetTextExtentPoint32W (dc
, wcode
, nglyphs
, &size
))
620 total_width
= size
.cx
;
623 /* On 95/98/ME, only some Unicode functions are available, so fallback
624 on doing a dummy draw to find the total width. */
628 rect
.top
= 0; rect
.bottom
= font
->height
; rect
.left
= 0; rect
.right
= 1;
629 DrawTextW (dc
, wcode
, nglyphs
, &rect
,
630 DT_CALCRECT
| DT_NOPREFIX
| DT_SINGLELINE
);
631 total_width
= rect
.right
;
634 /* Give our best estimate of the metrics, based on what we know. */
637 metrics
->width
= total_width
- w32_font
->metrics
.tmOverhang
;
638 metrics
->lbearing
= 0;
639 metrics
->rbearing
= total_width
;
642 /* Restore state and release DC. */
643 SelectObject (dc
, old_font
);
644 release_frame_dc (f
, dc
);
649 /* w32 implementation of draw for font backend.
651 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
652 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
653 is nonzero, fill the background in advance. It is assured that
654 WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).
656 TODO: Currently this assumes that the colors and fonts are already
657 set in the DC. This seems to be true now, but maybe only due to
658 the old font code setting it up. It may be safer to resolve faces
659 and fonts in here and set them explicitly
663 w32font_draw (struct glyph_string
*s
, int from
, int to
,
664 int x
, int y
, int with_background
)
667 HRGN orig_clip
= NULL
;
669 struct w32font_info
*w32font
= (struct w32font_info
*) s
->font
;
671 options
= w32font
->glyph_idx
;
673 if (s
->num_clips
> 0)
675 HRGN new_clip
= CreateRectRgnIndirect (s
->clip
);
677 /* Save clip region for later restoration. */
678 orig_clip
= CreateRectRgn (0, 0, 0, 0);
679 if (!GetClipRgn (s
->hdc
, orig_clip
))
681 DeleteObject (orig_clip
);
685 if (s
->num_clips
> 1)
687 HRGN clip2
= CreateRectRgnIndirect (s
->clip
+ 1);
689 CombineRgn (new_clip
, new_clip
, clip2
, RGN_OR
);
690 DeleteObject (clip2
);
693 SelectClipRgn (s
->hdc
, new_clip
);
694 DeleteObject (new_clip
);
697 /* Using OPAQUE background mode can clear more background than expected
698 when Cleartype is used. Draw the background manually to avoid this. */
699 SetBkMode (s
->hdc
, TRANSPARENT
);
704 struct font
*font
= s
->font
;
706 brush
= CreateSolidBrush (s
->gc
->background
);
708 rect
.top
= y
- font
->ascent
;
709 rect
.right
= x
+ s
->width
;
710 rect
.bottom
= y
+ font
->descent
;
711 FillRect (s
->hdc
, &rect
, brush
);
712 DeleteObject (brush
);
719 for (i
= 0; i
< len
; i
++)
720 ExtTextOutW (s
->hdc
, x
+ i
, y
, options
, NULL
,
721 s
->char2b
+ from
+ i
, 1, NULL
);
724 ExtTextOutW (s
->hdc
, x
, y
, options
, NULL
, s
->char2b
+ from
, len
, NULL
);
726 /* Restore clip region. */
727 if (s
->num_clips
> 0)
728 SelectClipRgn (s
->hdc
, orig_clip
);
731 DeleteObject (orig_clip
);
736 /* w32 implementation of free_entity for font backend.
737 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
738 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
740 w32font_free_entity (Lisp_Object entity);
743 /* w32 implementation of prepare_face for font backend.
744 Optional (if FACE->extra is not used).
745 Prepare FACE for displaying characters by FONT on frame F by
746 storing some data in FACE->extra. If successful, return 0.
747 Otherwise, return -1.
749 w32font_prepare_face (FRAME_PTR f, struct face *face);
751 /* w32 implementation of done_face for font backend.
753 Done FACE for displaying characters by FACE->font on frame F.
755 w32font_done_face (FRAME_PTR f, struct face *face); */
757 /* w32 implementation of get_bitmap for font backend.
759 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
760 intended that this method is called from the other font-driver
763 w32font_get_bitmap (struct font *font, unsigned code,
764 struct font_bitmap *bitmap, int bits_per_pixel);
766 /* w32 implementation of free_bitmap for font backend.
768 Free bitmap data in BITMAP.
770 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
772 /* w32 implementation of get_outline for font backend.
774 Return an outline data for glyph-code CODE of FONT. The format
775 of the outline data depends on the font-driver.
777 w32font_get_outline (struct font *font, unsigned code);
779 /* w32 implementation of free_outline for font backend.
781 Free OUTLINE (that is obtained by the above method).
783 w32font_free_outline (struct font *font, void *outline);
785 /* w32 implementation of anchor_point for font backend.
787 Get coordinates of the INDEXth anchor point of the glyph whose
788 code is CODE. Store the coordinates in *X and *Y. Return 0 if
789 the operations was successful. Otherwise return -1.
791 w32font_anchor_point (struct font *font, unsigned code,
792 int index, int *x, int *y);
794 /* w32 implementation of otf_capability for font backend.
796 Return a list describing which scripts/languages FONT
797 supports by which GSUB/GPOS features of OpenType tables.
799 w32font_otf_capability (struct font *font);
801 /* w32 implementation of otf_drive for font backend.
803 Apply FONT's OTF-FEATURES to the glyph string.
805 FEATURES specifies which OTF features to apply in this format:
806 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
807 See the documentation of `font-drive-otf' for the detail.
809 This method applies the specified features to the codes in the
810 elements of GSTRING-IN (between FROMth and TOth). The output
811 codes are stored in GSTRING-OUT at the IDXth element and the
814 Return the number of output codes. If none of the features are
815 applicable to the input data, return 0. If GSTRING-OUT is too
818 w32font_otf_drive (struct font *font, Lisp_Object features,
819 Lisp_Object gstring_in, int from, int to,
820 Lisp_Object gstring_out, int idx,
821 int alternate_subst);
824 /* Internal implementation of w32font_list.
825 Additional parameter opentype_only restricts the returned fonts to
826 opentype fonts, which can be used with the Uniscribe backend. */
828 w32font_list_internal (Lisp_Object frame
, Lisp_Object font_spec
, int opentype_only
)
830 struct font_callback_data match_data
;
832 FRAME_PTR f
= XFRAME (frame
);
834 match_data
.orig_font_spec
= font_spec
;
835 match_data
.list
= Qnil
;
836 match_data
.frame
= frame
;
838 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
839 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
841 /* If the charset is unrecognized, then we won't find a font, so don't
842 waste time looking for one. */
843 if (match_data
.pattern
.lfCharSet
== DEFAULT_CHARSET
)
845 Lisp_Object spec_charset
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
846 if (!NILP (spec_charset
)
847 && !EQ (spec_charset
, Qiso10646_1
)
848 && !EQ (spec_charset
, Qunicode_bmp
)
849 && !EQ (spec_charset
, Qunicode_sip
)
850 && !EQ (spec_charset
, Qunknown
))
854 match_data
.opentype_only
= opentype_only
;
856 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
858 if (match_data
.pattern
.lfFaceName
[0] == '\0')
860 /* EnumFontFamiliesEx does not take other fields into account if
861 font name is blank, so need to use two passes. */
862 list_all_matching_fonts (&match_data
);
866 dc
= get_frame_dc (f
);
868 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
869 (FONTENUMPROC
) add_font_entity_to_list
,
870 (LPARAM
) &match_data
, 0);
871 release_frame_dc (f
, dc
);
874 return match_data
.list
;
877 /* Internal implementation of w32font_match.
878 Additional parameter opentype_only restricts the returned fonts to
879 opentype fonts, which can be used with the Uniscribe backend. */
881 w32font_match_internal (Lisp_Object frame
, Lisp_Object font_spec
, int opentype_only
)
883 struct font_callback_data match_data
;
885 FRAME_PTR f
= XFRAME (frame
);
887 match_data
.orig_font_spec
= font_spec
;
888 match_data
.frame
= frame
;
889 match_data
.list
= Qnil
;
891 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
892 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
894 match_data
.opentype_only
= opentype_only
;
896 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
898 dc
= get_frame_dc (f
);
900 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
901 (FONTENUMPROC
) add_one_font_entity_to_list
,
902 (LPARAM
) &match_data
, 0);
903 release_frame_dc (f
, dc
);
905 return NILP (match_data
.list
) ? Qnil
: XCAR (match_data
.list
);
909 w32font_open_internal (FRAME_PTR f
, Lisp_Object font_entity
,
910 int pixel_size
, Lisp_Object font_object
)
915 HFONT hfont
, old_font
;
916 Lisp_Object val
, extra
;
917 struct w32font_info
*w32_font
;
919 OUTLINETEXTMETRICW
* metrics
= NULL
;
921 w32_font
= (struct w32font_info
*) XFONT_OBJECT (font_object
);
922 font
= (struct font
*) w32_font
;
927 memset (&logfont
, 0, sizeof (logfont
));
928 fill_in_logfont (f
, &logfont
, font_entity
);
930 /* Prefer truetype fonts, to avoid known problems with type1 fonts, and
931 limitations in bitmap fonts. */
932 val
= AREF (font_entity
, FONT_FOUNDRY_INDEX
);
933 if (!EQ (val
, Qraster
))
934 logfont
.lfOutPrecision
= OUT_TT_PRECIS
;
936 size
= XINT (AREF (font_entity
, FONT_SIZE_INDEX
));
940 logfont
.lfHeight
= -size
;
941 hfont
= CreateFontIndirect (&logfont
);
946 /* Get the metrics for this font. */
947 dc
= get_frame_dc (f
);
948 old_font
= SelectObject (dc
, hfont
);
950 /* Try getting the outline metrics (only works for truetype fonts). */
951 len
= get_outline_metrics_w (dc
, 0, NULL
);
954 metrics
= (OUTLINETEXTMETRICW
*) alloca (len
);
955 if (get_outline_metrics_w (dc
, len
, metrics
))
956 memcpy (&w32_font
->metrics
, &metrics
->otmTextMetrics
,
957 sizeof (TEXTMETRICW
));
963 get_text_metrics_w (dc
, &w32_font
->metrics
);
965 w32_font
->cached_metrics
= NULL
;
966 w32_font
->n_cache_blocks
= 0;
968 SelectObject (dc
, old_font
);
969 release_frame_dc (f
, dc
);
971 w32_font
->hfont
= hfont
;
976 /* We don't know how much space we need for the full name, so start with
977 96 bytes and go up in steps of 32. */
980 while (name
&& w32font_full_name (&logfont
, font_entity
, pixel_size
,
987 font
->props
[FONT_FULLNAME_INDEX
]
988 = DECODE_SYSTEM (build_string (name
));
990 font
->props
[FONT_FULLNAME_INDEX
]
991 = DECODE_SYSTEM (build_string (logfont
.lfFaceName
));
994 font
->max_width
= w32_font
->metrics
.tmMaxCharWidth
;
995 /* Parts of Emacs display assume that height = ascent + descent...
996 so height is defined later, after ascent and descent.
997 font->height = w32_font->metrics.tmHeight
998 + w32_font->metrics.tmExternalLeading;
1001 font
->space_width
= font
->average_width
= w32_font
->metrics
.tmAveCharWidth
;
1003 font
->vertical_centering
= 0;
1004 font
->encoding_type
= 0;
1005 font
->baseline_offset
= 0;
1006 font
->relative_compose
= 0;
1007 font
->default_ascent
= w32_font
->metrics
.tmAscent
;
1008 font
->font_encoder
= NULL
;
1009 font
->pixel_size
= size
;
1010 font
->driver
= &w32font_driver
;
1011 /* Use format cached during list, as the information we have access to
1012 here is incomplete. */
1013 extra
= AREF (font_entity
, FONT_EXTRA_INDEX
);
1016 val
= assq_no_quit (QCformat
, extra
);
1018 font
->props
[FONT_FORMAT_INDEX
] = XCDR (val
);
1020 font
->props
[FONT_FORMAT_INDEX
] = Qunknown
;
1023 font
->props
[FONT_FORMAT_INDEX
] = Qunknown
;
1025 font
->props
[FONT_FILE_INDEX
] = Qnil
;
1026 font
->encoding_charset
= -1;
1027 font
->repertory_charset
= -1;
1028 /* TODO: do we really want the minimum width here, which could be negative? */
1029 font
->min_width
= font
->space_width
;
1030 font
->ascent
= w32_font
->metrics
.tmAscent
;
1031 font
->descent
= w32_font
->metrics
.tmDescent
;
1032 font
->height
= font
->ascent
+ font
->descent
;
1036 font
->underline_thickness
= metrics
->otmsUnderscoreSize
;
1037 font
->underline_position
= -metrics
->otmsUnderscorePosition
;
1041 font
->underline_thickness
= 0;
1042 font
->underline_position
= -1;
1045 /* For temporary compatibility with legacy code that expects the
1046 name to be usable in x-list-fonts. Eventually we expect to change
1047 x-list-fonts and other places that use fonts so that this can be
1048 an fcname or similar. */
1049 font
->props
[FONT_NAME_INDEX
] = Ffont_xlfd_name (font_object
, Qnil
);
1054 /* Callback function for EnumFontFamiliesEx.
1055 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */
1057 add_font_name_to_list (ENUMLOGFONTEX
*logical_font
,
1058 NEWTEXTMETRICEX
*physical_font
,
1059 DWORD font_type
, LPARAM list_object
)
1061 Lisp_Object
* list
= (Lisp_Object
*) list_object
;
1064 /* Skip vertical fonts (intended only for printing) */
1065 if (logical_font
->elfLogFont
.lfFaceName
[0] == '@')
1068 family
= intern_font_name (logical_font
->elfLogFont
.lfFaceName
);
1069 if (! memq_no_quit (family
, *list
))
1070 *list
= Fcons (family
, *list
);
1075 static int w32_decode_weight (int);
1076 static int w32_encode_weight (int);
1078 /* Convert an enumerated Windows font to an Emacs font entity. */
1080 w32_enumfont_pattern_entity (Lisp_Object frame
,
1081 ENUMLOGFONTEX
*logical_font
,
1082 NEWTEXTMETRICEX
*physical_font
,
1084 LOGFONT
*requested_font
,
1085 Lisp_Object backend
)
1087 Lisp_Object entity
, tem
;
1088 LOGFONT
*lf
= (LOGFONT
*) logical_font
;
1090 DWORD full_type
= physical_font
->ntmTm
.ntmFlags
;
1092 entity
= font_make_entity ();
1094 ASET (entity
, FONT_TYPE_INDEX
, backend
);
1095 ASET (entity
, FONT_REGISTRY_INDEX
, w32_registry (lf
->lfCharSet
, font_type
));
1096 ASET (entity
, FONT_OBJLIST_INDEX
, Qnil
);
1098 /* Foundry is difficult to get in readable form on Windows.
1099 But Emacs crashes if it is not set, so set it to something more
1100 generic. These values make xlfds compatible with Emacs 22. */
1101 if (lf
->lfOutPrecision
== OUT_STRING_PRECIS
)
1103 else if (lf
->lfOutPrecision
== OUT_STROKE_PRECIS
)
1108 ASET (entity
, FONT_FOUNDRY_INDEX
, tem
);
1110 /* Save the generic family in the extra info, as it is likely to be
1111 useful to users looking for a close match. */
1112 generic_type
= physical_font
->ntmTm
.tmPitchAndFamily
& 0xF0;
1113 if (generic_type
== FF_DECORATIVE
)
1115 else if (generic_type
== FF_MODERN
)
1117 else if (generic_type
== FF_ROMAN
)
1119 else if (generic_type
== FF_SCRIPT
)
1121 else if (generic_type
== FF_SWISS
)
1126 ASET (entity
, FONT_ADSTYLE_INDEX
, tem
);
1128 if (physical_font
->ntmTm
.tmPitchAndFamily
& 0x01)
1129 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_PROPORTIONAL
));
1131 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_CHARCELL
));
1133 if (requested_font
->lfQuality
!= DEFAULT_QUALITY
)
1135 font_put_extra (entity
, QCantialias
,
1136 lispy_antialias_type (requested_font
->lfQuality
));
1138 ASET (entity
, FONT_FAMILY_INDEX
,
1139 intern_font_name (lf
->lfFaceName
));
1141 FONT_SET_STYLE (entity
, FONT_WEIGHT_INDEX
,
1142 make_number (w32_decode_weight (lf
->lfWeight
)));
1143 FONT_SET_STYLE (entity
, FONT_SLANT_INDEX
,
1144 make_number (lf
->lfItalic
? 200 : 100));
1145 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
1147 FONT_SET_STYLE (entity
, FONT_WIDTH_INDEX
, make_number (100));
1149 if (font_type
& RASTER_FONTTYPE
)
1150 ASET (entity
, FONT_SIZE_INDEX
,
1151 make_number (physical_font
->ntmTm
.tmHeight
1152 + physical_font
->ntmTm
.tmExternalLeading
));
1154 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
1156 /* Cache Unicode codepoints covered by this font, as there is no other way
1157 of getting this information easily. */
1158 if (font_type
& TRUETYPE_FONTTYPE
)
1160 tem
= font_supported_scripts (&physical_font
->ntmFontSig
);
1162 font_put_extra (entity
, QCscript
, tem
);
1165 /* This information is not fully available when opening fonts, so
1166 save it here. Only Windows 2000 and later return information
1167 about opentype and type1 fonts, so need a fallback for detecting
1168 truetype so that this information is not any worse than we could
1169 have obtained later. */
1170 if (EQ (backend
, Quniscribe
) && (full_type
& NTMFLAGS_OPENTYPE
))
1171 tem
= intern ("opentype");
1172 else if (font_type
& TRUETYPE_FONTTYPE
)
1173 tem
= intern ("truetype");
1174 else if (full_type
& NTM_PS_OPENTYPE
)
1175 tem
= intern ("postscript");
1176 else if (full_type
& NTM_TYPE1
)
1177 tem
= intern ("type1");
1178 else if (font_type
& RASTER_FONTTYPE
)
1179 tem
= intern ("w32bitmap");
1181 tem
= intern ("w32vector");
1183 font_put_extra (entity
, QCformat
, tem
);
1189 /* Convert generic families to the family portion of lfPitchAndFamily. */
1191 w32_generic_family (Lisp_Object name
)
1193 /* Generic families. */
1194 if (EQ (name
, Qmonospace
) || EQ (name
, Qmono
))
1196 else if (EQ (name
, Qsans
) || EQ (name
, Qsans_serif
) || EQ (name
, Qsansserif
))
1198 else if (EQ (name
, Qserif
))
1200 else if (EQ (name
, Qdecorative
))
1201 return FF_DECORATIVE
;
1202 else if (EQ (name
, Qscript
))
1209 logfonts_match (LOGFONT
*font
, LOGFONT
*pattern
)
1211 /* Only check height for raster fonts. */
1212 if (pattern
->lfHeight
&& font
->lfOutPrecision
== OUT_STRING_PRECIS
1213 && font
->lfHeight
!= pattern
->lfHeight
)
1216 /* Have some flexibility with weights. */
1217 if (pattern
->lfWeight
1218 && ((font
->lfWeight
< (pattern
->lfWeight
- 150))
1219 || font
->lfWeight
> (pattern
->lfWeight
+ 150)))
1222 /* Charset and face should be OK. Italic has to be checked
1223 against the original spec, in case we don't have any preference. */
1227 /* Codepage Bitfields in FONTSIGNATURE struct. */
1228 #define CSB_JAPANESE (1 << 17)
1229 #define CSB_KOREAN ((1 << 19) | (1 << 21))
1230 #define CSB_CHINESE ((1 << 18) | (1 << 20))
1233 font_matches_spec (DWORD type
, NEWTEXTMETRICEX
*font
,
1234 Lisp_Object spec
, Lisp_Object backend
,
1237 Lisp_Object extra
, val
;
1239 /* Check italic. Can't check logfonts, since it is a boolean field,
1240 so there is no difference between "non-italic" and "don't care". */
1242 int slant
= FONT_SLANT_NUMERIC (spec
);
1245 && ((slant
> 150 && !font
->ntmTm
.tmItalic
)
1246 || (slant
<= 150 && font
->ntmTm
.tmItalic
)))
1250 /* Check adstyle against generic family. */
1251 val
= AREF (spec
, FONT_ADSTYLE_INDEX
);
1254 BYTE family
= w32_generic_family (val
);
1255 if (family
!= FF_DONTCARE
1256 && family
!= (font
->ntmTm
.tmPitchAndFamily
& 0xF0))
1261 val
= AREF (spec
, FONT_SPACING_INDEX
);
1264 int spacing
= XINT (val
);
1265 int proportional
= (spacing
< FONT_SPACING_MONO
);
1267 if ((proportional
&& !(font
->ntmTm
.tmPitchAndFamily
& 0x01))
1268 || (!proportional
&& (font
->ntmTm
.tmPitchAndFamily
& 0x01)))
1272 /* Check extra parameters. */
1273 for (extra
= AREF (spec
, FONT_EXTRA_INDEX
);
1274 CONSP (extra
); extra
= XCDR (extra
))
1276 Lisp_Object extra_entry
;
1277 extra_entry
= XCAR (extra
);
1278 if (CONSP (extra_entry
))
1280 Lisp_Object key
= XCAR (extra_entry
);
1282 val
= XCDR (extra_entry
);
1283 if (EQ (key
, QCscript
) && SYMBOLP (val
))
1285 /* Only truetype fonts will have information about what
1286 scripts they support. This probably means the user
1287 will have to force Emacs to use raster, PostScript
1288 or ATM fonts for non-ASCII text. */
1289 if (type
& TRUETYPE_FONTTYPE
)
1292 = font_supported_scripts (&font
->ntmFontSig
);
1293 if (! memq_no_quit (val
, support
))
1296 /* Avoid using non-Japanese fonts for Japanese, even
1297 if they claim they are capable, due to known
1298 breakage in Vista and Windows 7 fonts
1301 && (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
1302 || !(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
)))
1307 /* Return specific matches, but play it safe. Fonts
1308 that cover more than their charset would suggest
1309 are likely to be truetype or opentype fonts,
1311 if (EQ (val
, Qlatin
))
1313 /* Although every charset but symbol, thai and
1314 arabic contains the basic ASCII set of latin
1315 characters, Emacs expects much more. */
1316 if (font
->ntmTm
.tmCharSet
!= ANSI_CHARSET
)
1319 else if (EQ (val
, Qsymbol
))
1321 if (font
->ntmTm
.tmCharSet
!= SYMBOL_CHARSET
)
1324 else if (EQ (val
, Qcyrillic
))
1326 if (font
->ntmTm
.tmCharSet
!= RUSSIAN_CHARSET
)
1329 else if (EQ (val
, Qgreek
))
1331 if (font
->ntmTm
.tmCharSet
!= GREEK_CHARSET
)
1334 else if (EQ (val
, Qarabic
))
1336 if (font
->ntmTm
.tmCharSet
!= ARABIC_CHARSET
)
1339 else if (EQ (val
, Qhebrew
))
1341 if (font
->ntmTm
.tmCharSet
!= HEBREW_CHARSET
)
1344 else if (EQ (val
, Qthai
))
1346 if (font
->ntmTm
.tmCharSet
!= THAI_CHARSET
)
1349 else if (EQ (val
, Qkana
))
1351 if (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1354 else if (EQ (val
, Qbopomofo
))
1356 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
)
1359 else if (EQ (val
, Qhangul
))
1361 if (font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1362 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
)
1365 else if (EQ (val
, Qhan
))
1367 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
1368 && font
->ntmTm
.tmCharSet
!= GB2312_CHARSET
1369 && font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1370 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
1371 && font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1375 /* Other scripts unlikely to be handled by non-truetype
1380 else if (EQ (key
, QClang
) && SYMBOLP (val
))
1382 /* Just handle the CJK languages here, as the lang
1383 parameter is used to select a font with appropriate
1384 glyphs in the cjk unified ideographs block. Other fonts
1385 support for a language can be solely determined by
1386 its character coverage. */
1389 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1392 else if (EQ (val
, Qko
))
1394 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_KOREAN
))
1397 else if (EQ (val
, Qzh
))
1399 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_CHINESE
))
1403 /* Any other language, we don't recognize it. Only the above
1404 currently appear in fontset.el, so it isn't worth
1405 creating a mapping table of codepages/scripts to languages
1406 or opening the font to see if there are any language tags
1407 in it that the W32 API does not expose. Fontset
1408 spec should have a fallback, as some backends do
1409 not recognize language at all. */
1412 else if (EQ (key
, QCotf
) && CONSP (val
))
1414 /* OTF features only supported by the uniscribe backend. */
1415 if (EQ (backend
, Quniscribe
))
1417 if (!uniscribe_check_otf (logfont
, val
))
1429 w32font_coverage_ok (FONTSIGNATURE
* coverage
, BYTE charset
)
1431 DWORD subrange1
= coverage
->fsUsb
[1];
1433 #define SUBRANGE1_HAN_MASK 0x08000000
1434 #define SUBRANGE1_HANGEUL_MASK 0x01000000
1435 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
1437 if (charset
== GB2312_CHARSET
|| charset
== CHINESEBIG5_CHARSET
)
1439 return (subrange1
& SUBRANGE1_HAN_MASK
) == SUBRANGE1_HAN_MASK
;
1441 else if (charset
== SHIFTJIS_CHARSET
)
1443 return (subrange1
& SUBRANGE1_JAPANESE_MASK
) == SUBRANGE1_JAPANESE_MASK
;
1445 else if (charset
== HANGEUL_CHARSET
)
1447 return (subrange1
& SUBRANGE1_HANGEUL_MASK
) == SUBRANGE1_HANGEUL_MASK
;
1455 check_face_name (LOGFONT
*font
, char *full_name
)
1457 char full_iname
[LF_FULLFACESIZE
+1];
1459 /* Just check for names known to cause problems, since the full name
1460 can contain expanded abbreviations, prefixed foundry, postfixed
1461 style, the latter of which sometimes differs from the style indicated
1462 in the shorter name (eg Lt becomes Light or even Extra Light) */
1464 /* Helvetica is mapped to Arial in Windows, but if a Type-1 Helvetica is
1465 installed, we run into problems with the Uniscribe backend which tries
1466 to avoid non-truetype fonts, and ends up mixing the Type-1 Helvetica
1467 with Arial's characteristics, since that attempt to use TrueType works
1468 some places, but not others. */
1469 if (!xstrcasecmp (font
->lfFaceName
, "helvetica"))
1471 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1472 full_iname
[LF_FULLFACESIZE
] = 0;
1473 _strlwr (full_iname
);
1474 return strstr ("helvetica", full_iname
) != NULL
;
1476 /* Same for Helv. */
1477 if (!xstrcasecmp (font
->lfFaceName
, "helv"))
1479 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1480 full_iname
[LF_FULLFACESIZE
] = 0;
1481 _strlwr (full_iname
);
1482 return strstr ("helv", full_iname
) != NULL
;
1485 /* Since Times is mapped to Times New Roman, a substring
1486 match is not sufficient to filter out the bogus match. */
1487 else if (!xstrcasecmp (font
->lfFaceName
, "times"))
1488 return xstrcasecmp (full_name
, "times") == 0;
1494 /* Callback function for EnumFontFamiliesEx.
1495 * Checks if a font matches everything we are trying to check against,
1496 * and if so, adds it to a list. Both the data we are checking against
1497 * and the list to which the fonts are added are passed in via the
1498 * lparam argument, in the form of a font_callback_data struct. */
1500 add_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1501 NEWTEXTMETRICEX
*physical_font
,
1502 DWORD font_type
, LPARAM lParam
)
1504 struct font_callback_data
*match_data
1505 = (struct font_callback_data
*) lParam
;
1506 Lisp_Object backend
= match_data
->opentype_only
? Quniscribe
: Qgdi
;
1509 int is_unicode
= physical_font
->ntmFontSig
.fsUsb
[3]
1510 || physical_font
->ntmFontSig
.fsUsb
[2]
1511 || physical_font
->ntmFontSig
.fsUsb
[1]
1512 || physical_font
->ntmFontSig
.fsUsb
[0] & 0x3fffffff;
1514 /* Skip non matching fonts. */
1516 /* For uniscribe backend, consider only truetype or opentype fonts
1517 that have some Unicode coverage. */
1518 if (match_data
->opentype_only
1519 && ((!(physical_font
->ntmTm
.ntmFlags
& NTMFLAGS_OPENTYPE
)
1520 && !(font_type
& TRUETYPE_FONTTYPE
))
1524 /* Ensure a match. */
1525 if (!logfonts_match (&logical_font
->elfLogFont
, &match_data
->pattern
)
1526 || !font_matches_spec (font_type
, physical_font
,
1527 match_data
->orig_font_spec
, backend
,
1528 &logical_font
->elfLogFont
)
1529 || !w32font_coverage_ok (&physical_font
->ntmFontSig
,
1530 match_data
->pattern
.lfCharSet
))
1533 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
1534 We limit this to raster fonts, because the test can catch some
1535 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
1536 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
1537 therefore get through this test. Since full names can be prefixed
1538 by a foundry, we accept raster fonts if the font name is found
1539 anywhere within the full name. */
1540 if ((logical_font
->elfLogFont
.lfOutPrecision
== OUT_STRING_PRECIS
1541 && !strstr (logical_font
->elfFullName
,
1542 logical_font
->elfLogFont
.lfFaceName
))
1543 /* Check for well known substitutions that mess things up in the
1544 presence of Type-1 fonts of the same name. */
1545 || (!check_face_name (&logical_font
->elfLogFont
,
1546 logical_font
->elfFullName
)))
1549 /* Make a font entity for the font. */
1550 entity
= w32_enumfont_pattern_entity (match_data
->frame
, logical_font
,
1551 physical_font
, font_type
,
1552 &match_data
->pattern
,
1557 Lisp_Object spec_charset
= AREF (match_data
->orig_font_spec
,
1558 FONT_REGISTRY_INDEX
);
1560 /* iso10646-1 fonts must contain Unicode mapping tables. */
1561 if (EQ (spec_charset
, Qiso10646_1
))
1566 /* unicode-bmp fonts must contain characters from the BMP. */
1567 else if (EQ (spec_charset
, Qunicode_bmp
))
1569 if (!physical_font
->ntmFontSig
.fsUsb
[3]
1570 && !(physical_font
->ntmFontSig
.fsUsb
[2] & 0xFFFFFF9E)
1571 && !(physical_font
->ntmFontSig
.fsUsb
[1] & 0xE81FFFFF)
1572 && !(physical_font
->ntmFontSig
.fsUsb
[0] & 0x007F001F))
1575 /* unicode-sip fonts must contain characters in Unicode plane 2.
1576 so look for bit 57 (surrogates) in the Unicode subranges, plus
1577 the bits for CJK ranges that include those characters. */
1578 else if (EQ (spec_charset
, Qunicode_sip
))
1580 if (!(physical_font
->ntmFontSig
.fsUsb
[1] & 0x02000000)
1581 || !(physical_font
->ntmFontSig
.fsUsb
[1] & 0x28000000))
1585 /* This font matches. */
1587 /* If registry was specified, ensure it is reported as the same. */
1588 if (!NILP (spec_charset
))
1590 /* Avoid using non-Japanese fonts for Japanese, even if they
1591 claim they are capable, due to known breakage in Vista
1592 and Windows 7 fonts (bug#6029). */
1593 if (logical_font
->elfLogFont
.lfCharSet
== SHIFTJIS_CHARSET
1594 && !(physical_font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1597 ASET (entity
, FONT_REGISTRY_INDEX
, spec_charset
);
1599 /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
1600 fonts as Unicode and skip other charsets. */
1601 else if (match_data
->opentype_only
)
1603 if (logical_font
->elfLogFont
.lfCharSet
== ANSI_CHARSET
1604 || logical_font
->elfLogFont
.lfCharSet
== DEFAULT_CHARSET
)
1605 ASET (entity
, FONT_REGISTRY_INDEX
, Qiso10646_1
);
1610 /* Add this font to the list. */
1611 match_data
->list
= Fcons (entity
, match_data
->list
);
1616 /* Callback function for EnumFontFamiliesEx.
1617 * Terminates the search once we have a match. */
1619 add_one_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1620 NEWTEXTMETRICEX
*physical_font
,
1621 DWORD font_type
, LPARAM lParam
)
1623 struct font_callback_data
*match_data
1624 = (struct font_callback_data
*) lParam
;
1625 add_font_entity_to_list (logical_font
, physical_font
, font_type
, lParam
);
1627 /* If we have a font in the list, terminate the search. */
1628 return NILP (match_data
->list
);
1631 /* Old function to convert from x to w32 charset, from w32fns.c. */
1633 x_to_w32_charset (char * lpcs
)
1635 Lisp_Object this_entry
, w32_charset
;
1637 int len
= strlen (lpcs
);
1639 /* Support "*-#nnn" format for unknown charsets. */
1640 if (strncmp (lpcs
, "*-#", 3) == 0)
1641 return atoi (lpcs
+ 3);
1643 /* All Windows fonts qualify as Unicode. */
1644 if (!strncmp (lpcs
, "iso10646", 8))
1645 return DEFAULT_CHARSET
;
1647 /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */
1648 charset
= alloca (len
+ 1);
1649 strcpy (charset
, lpcs
);
1650 lpcs
= strchr (charset
, '*');
1654 /* Look through w32-charset-info-alist for the character set.
1655 Format of each entry is
1656 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1658 this_entry
= Fassoc (build_string (charset
), Vw32_charset_info_alist
);
1660 if (NILP (this_entry
))
1662 /* At startup, we want iso8859-1 fonts to come up properly. */
1663 if (xstrcasecmp (charset
, "iso8859-1") == 0)
1664 return ANSI_CHARSET
;
1666 return DEFAULT_CHARSET
;
1669 w32_charset
= Fcar (Fcdr (this_entry
));
1671 /* Translate Lisp symbol to number. */
1672 if (EQ (w32_charset
, Qw32_charset_ansi
))
1673 return ANSI_CHARSET
;
1674 if (EQ (w32_charset
, Qw32_charset_symbol
))
1675 return SYMBOL_CHARSET
;
1676 if (EQ (w32_charset
, Qw32_charset_shiftjis
))
1677 return SHIFTJIS_CHARSET
;
1678 if (EQ (w32_charset
, Qw32_charset_hangeul
))
1679 return HANGEUL_CHARSET
;
1680 if (EQ (w32_charset
, Qw32_charset_chinesebig5
))
1681 return CHINESEBIG5_CHARSET
;
1682 if (EQ (w32_charset
, Qw32_charset_gb2312
))
1683 return GB2312_CHARSET
;
1684 if (EQ (w32_charset
, Qw32_charset_oem
))
1686 if (EQ (w32_charset
, Qw32_charset_johab
))
1687 return JOHAB_CHARSET
;
1688 if (EQ (w32_charset
, Qw32_charset_easteurope
))
1689 return EASTEUROPE_CHARSET
;
1690 if (EQ (w32_charset
, Qw32_charset_turkish
))
1691 return TURKISH_CHARSET
;
1692 if (EQ (w32_charset
, Qw32_charset_baltic
))
1693 return BALTIC_CHARSET
;
1694 if (EQ (w32_charset
, Qw32_charset_russian
))
1695 return RUSSIAN_CHARSET
;
1696 if (EQ (w32_charset
, Qw32_charset_arabic
))
1697 return ARABIC_CHARSET
;
1698 if (EQ (w32_charset
, Qw32_charset_greek
))
1699 return GREEK_CHARSET
;
1700 if (EQ (w32_charset
, Qw32_charset_hebrew
))
1701 return HEBREW_CHARSET
;
1702 if (EQ (w32_charset
, Qw32_charset_vietnamese
))
1703 return VIETNAMESE_CHARSET
;
1704 if (EQ (w32_charset
, Qw32_charset_thai
))
1705 return THAI_CHARSET
;
1706 if (EQ (w32_charset
, Qw32_charset_mac
))
1709 return DEFAULT_CHARSET
;
1713 /* Convert a Lisp font registry (symbol) to a windows charset. */
1715 registry_to_w32_charset (Lisp_Object charset
)
1717 if (EQ (charset
, Qiso10646_1
) || EQ (charset
, Qunicode_bmp
)
1718 || EQ (charset
, Qunicode_sip
))
1719 return DEFAULT_CHARSET
; /* UNICODE_CHARSET not defined in MingW32 */
1720 else if (EQ (charset
, Qiso8859_1
))
1721 return ANSI_CHARSET
;
1722 else if (SYMBOLP (charset
))
1723 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset
)));
1725 return DEFAULT_CHARSET
;
1728 /* Old function to convert from w32 to x charset, from w32fns.c. */
1730 w32_to_x_charset (int fncharset
, char *matching
)
1732 static char buf
[32];
1733 Lisp_Object charset_type
;
1738 /* If fully specified, accept it as it is. Otherwise use a
1740 char *wildcard
= strchr (matching
, '*');
1743 else if (strchr (matching
, '-'))
1746 match_len
= strlen (matching
);
1752 /* Handle startup case of w32-charset-info-alist not
1753 being set up yet. */
1754 if (NILP (Vw32_charset_info_alist
))
1756 charset_type
= Qw32_charset_ansi
;
1758 case DEFAULT_CHARSET
:
1759 charset_type
= Qw32_charset_default
;
1761 case SYMBOL_CHARSET
:
1762 charset_type
= Qw32_charset_symbol
;
1764 case SHIFTJIS_CHARSET
:
1765 charset_type
= Qw32_charset_shiftjis
;
1767 case HANGEUL_CHARSET
:
1768 charset_type
= Qw32_charset_hangeul
;
1770 case GB2312_CHARSET
:
1771 charset_type
= Qw32_charset_gb2312
;
1773 case CHINESEBIG5_CHARSET
:
1774 charset_type
= Qw32_charset_chinesebig5
;
1777 charset_type
= Qw32_charset_oem
;
1779 case EASTEUROPE_CHARSET
:
1780 charset_type
= Qw32_charset_easteurope
;
1782 case TURKISH_CHARSET
:
1783 charset_type
= Qw32_charset_turkish
;
1785 case BALTIC_CHARSET
:
1786 charset_type
= Qw32_charset_baltic
;
1788 case RUSSIAN_CHARSET
:
1789 charset_type
= Qw32_charset_russian
;
1791 case ARABIC_CHARSET
:
1792 charset_type
= Qw32_charset_arabic
;
1795 charset_type
= Qw32_charset_greek
;
1797 case HEBREW_CHARSET
:
1798 charset_type
= Qw32_charset_hebrew
;
1800 case VIETNAMESE_CHARSET
:
1801 charset_type
= Qw32_charset_vietnamese
;
1804 charset_type
= Qw32_charset_thai
;
1807 charset_type
= Qw32_charset_mac
;
1810 charset_type
= Qw32_charset_johab
;
1814 /* Encode numerical value of unknown charset. */
1815 sprintf (buf
, "*-#%u", fncharset
);
1821 char * best_match
= NULL
;
1822 int matching_found
= 0;
1824 /* Look through w32-charset-info-alist for the character set.
1825 Prefer ISO codepages, and prefer lower numbers in the ISO
1826 range. Only return charsets for codepages which are installed.
1828 Format of each entry is
1829 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1831 for (rest
= Vw32_charset_info_alist
; CONSP (rest
); rest
= XCDR (rest
))
1834 Lisp_Object w32_charset
;
1835 Lisp_Object codepage
;
1837 Lisp_Object this_entry
= XCAR (rest
);
1839 /* Skip invalid entries in alist. */
1840 if (!CONSP (this_entry
) || !STRINGP (XCAR (this_entry
))
1841 || !CONSP (XCDR (this_entry
))
1842 || !SYMBOLP (XCAR (XCDR (this_entry
))))
1845 x_charset
= SDATA (XCAR (this_entry
));
1846 w32_charset
= XCAR (XCDR (this_entry
));
1847 codepage
= XCDR (XCDR (this_entry
));
1849 /* Look for Same charset and a valid codepage (or non-int
1850 which means ignore). */
1851 if (EQ (w32_charset
, charset_type
)
1852 && (!INTEGERP (codepage
) || XINT (codepage
) == CP_DEFAULT
1853 || IsValidCodePage (XINT (codepage
))))
1855 /* If we don't have a match already, then this is the
1859 best_match
= x_charset
;
1860 if (matching
&& !strnicmp (x_charset
, matching
, match_len
))
1863 /* If we already found a match for MATCHING, then
1864 only consider other matches. */
1865 else if (matching_found
1866 && strnicmp (x_charset
, matching
, match_len
))
1868 /* If this matches what we want, and the best so far doesn't,
1869 then this is better. */
1870 else if (!matching_found
&& matching
1871 && !strnicmp (x_charset
, matching
, match_len
))
1873 best_match
= x_charset
;
1876 /* If this is fully specified, and the best so far isn't,
1877 then this is better. */
1878 else if ((!strchr (best_match
, '-') && strchr (x_charset
, '-'))
1879 /* If this is an ISO codepage, and the best so far isn't,
1880 then this is better, but only if it fully specifies the
1882 || (strnicmp (best_match
, "iso", 3) != 0
1883 && strnicmp (x_charset
, "iso", 3) == 0
1884 && strchr (x_charset
, '-')))
1885 best_match
= x_charset
;
1886 /* If both are ISO8859 codepages, choose the one with the
1887 lowest number in the encoding field. */
1888 else if (strnicmp (best_match
, "iso8859-", 8) == 0
1889 && strnicmp (x_charset
, "iso8859-", 8) == 0)
1891 int best_enc
= atoi (best_match
+ 8);
1892 int this_enc
= atoi (x_charset
+ 8);
1893 if (this_enc
> 0 && this_enc
< best_enc
)
1894 best_match
= x_charset
;
1899 /* If no match, encode the numeric value. */
1902 sprintf (buf
, "*-#%u", fncharset
);
1906 strncpy (buf
, best_match
, 31);
1907 /* If the charset is not fully specified, put -0 on the end. */
1908 if (!strchr (best_match
, '-'))
1910 int pos
= strlen (best_match
);
1911 /* Charset specifiers shouldn't be very long. If it is a made
1912 up one, truncating it should not do any harm since it isn't
1913 recognized anyway. */
1916 strcpy (buf
+ pos
, "-0");
1924 w32_registry (LONG w32_charset
, DWORD font_type
)
1928 /* If charset is defaulted, charset is Unicode or unknown, depending on
1930 if (w32_charset
== DEFAULT_CHARSET
)
1931 return font_type
== TRUETYPE_FONTTYPE
? Qiso10646_1
: Qunknown
;
1933 charset
= w32_to_x_charset (w32_charset
, NULL
);
1934 return font_intern_prop (charset
, strlen (charset
), 1);
1938 w32_decode_weight (int fnweight
)
1940 if (fnweight
>= FW_HEAVY
) return 210;
1941 if (fnweight
>= FW_EXTRABOLD
) return 205;
1942 if (fnweight
>= FW_BOLD
) return 200;
1943 if (fnweight
>= FW_SEMIBOLD
) return 180;
1944 if (fnweight
>= FW_NORMAL
) return 100;
1945 if (fnweight
>= FW_LIGHT
) return 50;
1946 if (fnweight
>= FW_EXTRALIGHT
) return 40;
1947 if (fnweight
> FW_THIN
) return 20;
1952 w32_encode_weight (int n
)
1954 if (n
>= 210) return FW_HEAVY
;
1955 if (n
>= 205) return FW_EXTRABOLD
;
1956 if (n
>= 200) return FW_BOLD
;
1957 if (n
>= 180) return FW_SEMIBOLD
;
1958 if (n
>= 100) return FW_NORMAL
;
1959 if (n
>= 50) return FW_LIGHT
;
1960 if (n
>= 40) return FW_EXTRALIGHT
;
1961 if (n
>= 20) return FW_THIN
;
1965 /* Convert a Windows font weight into one of the weights supported
1966 by fontconfig (see font.c:font_parse_fcname). */
1968 w32_to_fc_weight (int n
)
1970 if (n
>= FW_EXTRABOLD
) return intern ("black");
1971 if (n
>= FW_BOLD
) return intern ("bold");
1972 if (n
>= FW_SEMIBOLD
) return intern ("demibold");
1973 if (n
>= FW_NORMAL
) return intern ("medium");
1974 return intern ("light");
1977 /* Fill in all the available details of LOGFONT from FONT_SPEC. */
1979 fill_in_logfont (FRAME_PTR f
, LOGFONT
*logfont
, Lisp_Object font_spec
)
1981 Lisp_Object tmp
, extra
;
1982 int dpi
= FRAME_W32_DISPLAY_INFO (f
)->resy
;
1984 tmp
= AREF (font_spec
, FONT_DPI_INDEX
);
1989 else if (FLOATP (tmp
))
1991 dpi
= (int) (XFLOAT_DATA (tmp
) + 0.5);
1995 tmp
= AREF (font_spec
, FONT_SIZE_INDEX
);
1997 logfont
->lfHeight
= -1 * XINT (tmp
);
1998 else if (FLOATP (tmp
))
1999 logfont
->lfHeight
= (int) (-1.0 * dpi
* XFLOAT_DATA (tmp
) / 72.27 + 0.5);
2006 tmp
= AREF (font_spec
, FONT_WEIGHT_INDEX
);
2008 logfont
->lfWeight
= w32_encode_weight (FONT_WEIGHT_NUMERIC (font_spec
));
2011 tmp
= AREF (font_spec
, FONT_SLANT_INDEX
);
2014 int slant
= FONT_SLANT_NUMERIC (font_spec
);
2015 logfont
->lfItalic
= slant
> 150 ? 1 : 0;
2023 tmp
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
2025 logfont
->lfCharSet
= registry_to_w32_charset (tmp
);
2027 logfont
->lfCharSet
= DEFAULT_CHARSET
;
2031 /* Clip Precision */
2034 logfont
->lfQuality
= DEFAULT_QUALITY
;
2036 /* Generic Family and Face Name */
2037 logfont
->lfPitchAndFamily
= FF_DONTCARE
| DEFAULT_PITCH
;
2039 tmp
= AREF (font_spec
, FONT_FAMILY_INDEX
);
2042 logfont
->lfPitchAndFamily
= w32_generic_family (tmp
) | DEFAULT_PITCH
;
2043 if ((logfont
->lfPitchAndFamily
& 0xF0) != FF_DONTCARE
)
2044 ; /* Font name was generic, don't fill in font name. */
2045 /* Font families are interned, but allow for strings also in case of
2047 else if (SYMBOLP (tmp
))
2048 strncpy (logfont
->lfFaceName
,
2049 SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp
))), LF_FACESIZE
);
2052 tmp
= AREF (font_spec
, FONT_ADSTYLE_INDEX
);
2055 /* Override generic family. */
2056 BYTE family
= w32_generic_family (tmp
);
2057 if (family
!= FF_DONTCARE
)
2058 logfont
->lfPitchAndFamily
= family
| DEFAULT_PITCH
;
2061 /* Set pitch based on the spacing property. */
2062 tmp
= AREF (font_spec
, FONT_SPACING_INDEX
);
2065 int spacing
= XINT (tmp
);
2066 if (spacing
< FONT_SPACING_MONO
)
2067 logfont
->lfPitchAndFamily
2068 = (logfont
->lfPitchAndFamily
& 0xF0) | VARIABLE_PITCH
;
2070 logfont
->lfPitchAndFamily
2071 = (logfont
->lfPitchAndFamily
& 0xF0) | FIXED_PITCH
;
2074 /* Process EXTRA info. */
2075 for (extra
= AREF (font_spec
, FONT_EXTRA_INDEX
);
2076 CONSP (extra
); extra
= XCDR (extra
))
2081 Lisp_Object key
, val
;
2082 key
= XCAR (tmp
), val
= XCDR (tmp
);
2083 /* Only use QCscript if charset is not provided, or is Unicode
2084 and a single script is specified. This is rather crude,
2085 and is only used to narrow down the fonts returned where
2086 there is a definite match. Some scripts, such as latin, han,
2087 cjk-misc match multiple lfCharSet values, so we can't pre-filter
2089 if (EQ (key
, QCscript
)
2090 && logfont
->lfCharSet
== DEFAULT_CHARSET
2093 if (EQ (val
, Qgreek
))
2094 logfont
->lfCharSet
= GREEK_CHARSET
;
2095 else if (EQ (val
, Qhangul
))
2096 logfont
->lfCharSet
= HANGUL_CHARSET
;
2097 else if (EQ (val
, Qkana
) || EQ (val
, Qkanbun
))
2098 logfont
->lfCharSet
= SHIFTJIS_CHARSET
;
2099 else if (EQ (val
, Qbopomofo
))
2100 logfont
->lfCharSet
= CHINESEBIG5_CHARSET
;
2101 /* GB 18030 supports tibetan, yi, mongolian,
2102 fonts that support it should show up if we ask for
2104 else if (EQ (val
, Qtibetan
) || EQ (val
, Qyi
)
2105 || EQ (val
, Qmongolian
))
2106 logfont
->lfCharSet
= GB2312_CHARSET
;
2107 else if (EQ (val
, Qhebrew
))
2108 logfont
->lfCharSet
= HEBREW_CHARSET
;
2109 else if (EQ (val
, Qarabic
))
2110 logfont
->lfCharSet
= ARABIC_CHARSET
;
2111 else if (EQ (val
, Qthai
))
2112 logfont
->lfCharSet
= THAI_CHARSET
;
2114 else if (EQ (key
, QCantialias
) && SYMBOLP (val
))
2116 logfont
->lfQuality
= w32_antialias_type (val
);
2123 list_all_matching_fonts (struct font_callback_data
*match_data
)
2126 Lisp_Object families
= w32font_list_family (match_data
->frame
);
2127 struct frame
*f
= XFRAME (match_data
->frame
);
2129 dc
= get_frame_dc (f
);
2131 while (!NILP (families
))
2133 /* Only fonts from the current locale are given localized names
2134 on Windows, so we can keep backwards compatibility with
2135 Windows 9x/ME by using non-Unicode font enumeration without
2136 sacrificing internationalization here. */
2138 Lisp_Object family
= CAR (families
);
2139 families
= CDR (families
);
2142 else if (SYMBOLP (family
))
2143 name
= SDATA (ENCODE_SYSTEM (SYMBOL_NAME (family
)));
2147 strncpy (match_data
->pattern
.lfFaceName
, name
, LF_FACESIZE
);
2148 match_data
->pattern
.lfFaceName
[LF_FACESIZE
- 1] = '\0';
2150 EnumFontFamiliesEx (dc
, &match_data
->pattern
,
2151 (FONTENUMPROC
) add_font_entity_to_list
,
2152 (LPARAM
) match_data
, 0);
2155 release_frame_dc (f
, dc
);
2159 lispy_antialias_type (BYTE type
)
2165 case NONANTIALIASED_QUALITY
:
2168 case ANTIALIASED_QUALITY
:
2171 case CLEARTYPE_QUALITY
:
2174 case CLEARTYPE_NATURAL_QUALITY
:
2184 /* Convert antialiasing symbols to lfQuality */
2186 w32_antialias_type (Lisp_Object type
)
2188 if (EQ (type
, Qnone
))
2189 return NONANTIALIASED_QUALITY
;
2190 else if (EQ (type
, Qstandard
))
2191 return ANTIALIASED_QUALITY
;
2192 else if (EQ (type
, Qsubpixel
))
2193 return CLEARTYPE_QUALITY
;
2194 else if (EQ (type
, Qnatural
))
2195 return CLEARTYPE_NATURAL_QUALITY
;
2197 return DEFAULT_QUALITY
;
2200 /* Return a list of all the scripts that the font supports. */
2202 font_supported_scripts (FONTSIGNATURE
* sig
)
2204 DWORD
* subranges
= sig
->fsUsb
;
2205 Lisp_Object supported
= Qnil
;
2207 /* Match a single subrange. SYM is set if bit N is set in subranges. */
2208 #define SUBRANGE(n,sym) \
2209 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
2210 supported = Fcons ((sym), supported)
2212 /* Match multiple subranges. SYM is set if any MASK bit is set in
2213 subranges[0 - 3]. */
2214 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
2215 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
2216 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
2217 supported = Fcons ((sym), supported)
2219 SUBRANGE (0, Qlatin
);
2220 /* The following count as latin too, ASCII should be present in these fonts,
2221 so don't need to mark them separately. */
2222 /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */
2223 SUBRANGE (4, Qphonetic
);
2224 /* 5: Spacing and tone modifiers, 6: Combining Diacritical Marks. */
2225 SUBRANGE (7, Qgreek
);
2226 SUBRANGE (8, Qcoptic
);
2227 SUBRANGE (9, Qcyrillic
);
2228 SUBRANGE (10, Qarmenian
);
2229 SUBRANGE (11, Qhebrew
);
2231 SUBRANGE (13, Qarabic
);
2232 SUBRANGE (14, Qnko
);
2233 SUBRANGE (15, Qdevanagari
);
2234 SUBRANGE (16, Qbengali
);
2235 SUBRANGE (17, Qgurmukhi
);
2236 SUBRANGE (18, Qgujarati
);
2237 SUBRANGE (19, Qoriya
);
2238 SUBRANGE (20, Qtamil
);
2239 SUBRANGE (21, Qtelugu
);
2240 SUBRANGE (22, Qkannada
);
2241 SUBRANGE (23, Qmalayalam
);
2242 SUBRANGE (24, Qthai
);
2243 SUBRANGE (25, Qlao
);
2244 SUBRANGE (26, Qgeorgian
);
2245 SUBRANGE (27, Qbalinese
);
2246 /* 28: Hangul Jamo. */
2247 /* 29: Latin Extended, 30: Greek Extended, 31: Punctuation. */
2248 /* 32-47: Symbols (defined below). */
2249 SUBRANGE (48, Qcjk_misc
);
2250 /* Match either 49: katakana or 50: hiragana for kana. */
2251 MASK_ANY (0, 0x00060000, 0, 0, Qkana
);
2252 SUBRANGE (51, Qbopomofo
);
2253 /* 52: Compatibility Jamo */
2254 SUBRANGE (53, Qphags_pa
);
2255 /* 54: Enclosed CJK letters and months, 55: CJK Compatibility. */
2256 SUBRANGE (56, Qhangul
);
2257 /* 57: Surrogates. */
2258 SUBRANGE (58, Qphoenician
);
2259 SUBRANGE (59, Qhan
); /* There are others, but this is the main one. */
2260 SUBRANGE (59, Qideographic_description
); /* Windows lumps this in. */
2261 SUBRANGE (59, Qkanbun
); /* And this. */
2262 /* 60: Private use, 61: CJK strokes and compatibility. */
2263 /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */
2264 /* 64: Combining half marks, 65: Vertical and CJK compatibility. */
2265 /* 66: Small forms, 67: Arabic Presentation B, 68: Half and Full width. */
2267 SUBRANGE (70, Qtibetan
);
2268 SUBRANGE (71, Qsyriac
);
2269 SUBRANGE (72, Qthaana
);
2270 SUBRANGE (73, Qsinhala
);
2271 SUBRANGE (74, Qmyanmar
);
2272 SUBRANGE (75, Qethiopic
);
2273 SUBRANGE (76, Qcherokee
);
2274 SUBRANGE (77, Qcanadian_aboriginal
);
2275 SUBRANGE (78, Qogham
);
2276 SUBRANGE (79, Qrunic
);
2277 SUBRANGE (80, Qkhmer
);
2278 SUBRANGE (81, Qmongolian
);
2279 SUBRANGE (82, Qbraille
);
2281 SUBRANGE (84, Qbuhid
);
2282 SUBRANGE (84, Qhanunoo
);
2283 SUBRANGE (84, Qtagalog
);
2284 SUBRANGE (84, Qtagbanwa
);
2285 SUBRANGE (85, Qold_italic
);
2286 SUBRANGE (86, Qgothic
);
2287 SUBRANGE (87, Qdeseret
);
2288 SUBRANGE (88, Qbyzantine_musical_symbol
);
2289 SUBRANGE (88, Qmusical_symbol
); /* Windows doesn't distinguish these. */
2290 SUBRANGE (89, Qmathematical
);
2291 /* 90: Private use, 91: Variation selectors, 92: Tags. */
2292 SUBRANGE (93, Qlimbu
);
2293 SUBRANGE (94, Qtai_le
);
2294 /* 95: New Tai Le */
2295 SUBRANGE (90, Qbuginese
);
2296 SUBRANGE (97, Qglagolitic
);
2297 SUBRANGE (98, Qtifinagh
);
2298 /* 99: Yijing Hexagrams. */
2299 SUBRANGE (100, Qsyloti_nagri
);
2300 SUBRANGE (101, Qlinear_b
);
2301 /* 102: Ancient Greek Numbers. */
2302 SUBRANGE (103, Qugaritic
);
2303 SUBRANGE (104, Qold_persian
);
2304 SUBRANGE (105, Qshavian
);
2305 SUBRANGE (106, Qosmanya
);
2306 SUBRANGE (107, Qcypriot
);
2307 SUBRANGE (108, Qkharoshthi
);
2308 /* 109: Tai Xuan Jing. */
2309 SUBRANGE (110, Qcuneiform
);
2310 /* 111: Counting Rods, 112: Sundanese, 113: Lepcha, 114: Ol Chiki. */
2311 /* 115: Saurashtra, 116: Kayah Li, 117: Rejang. */
2312 SUBRANGE (118, Qcham
);
2313 /* 119: Ancient symbols, 120: Phaistos Disc. */
2314 /* 121: Carian, Lycian, Lydian, 122: Dominoes, Mahjong tiles. */
2315 /* 123-127: Reserved. */
2317 /* There isn't really a main symbol range, so include symbol if any
2318 relevant range is set. */
2319 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol
);
2321 /* Missing: Tai Viet (U+AA80-U+AADF). */
2328 /* Generate a full name for a Windows font.
2329 The full name is in fcname format, with weight, slant and antialiasing
2330 specified if they are not "normal". */
2332 w32font_full_name (LOGFONT
* font
, Lisp_Object font_obj
,
2333 int pixel_size
, char *name
, int nbytes
)
2335 int len
, height
, outline
;
2337 Lisp_Object antialiasing
, weight
= Qnil
;
2339 len
= strlen (font
->lfFaceName
);
2341 outline
= EQ (AREF (font_obj
, FONT_FOUNDRY_INDEX
), Qoutline
);
2343 /* Represent size of scalable fonts by point size. But use pixelsize for
2344 raster fonts to indicate that they are exactly that size. */
2346 len
+= 11; /* -SIZE */
2351 len
+= 7; /* :italic */
2353 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2355 weight
= w32_to_fc_weight (font
->lfWeight
);
2356 len
+= 1 + SBYTES (SYMBOL_NAME (weight
)); /* :WEIGHT */
2359 antialiasing
= lispy_antialias_type (font
->lfQuality
);
2360 if (! NILP (antialiasing
))
2361 len
+= 11 + SBYTES (SYMBOL_NAME (antialiasing
)); /* :antialias=NAME */
2363 /* Check that the buffer is big enough */
2368 p
+= sprintf (p
, "%s", font
->lfFaceName
);
2370 height
= font
->lfHeight
? eabs (font
->lfHeight
) : pixel_size
;
2376 float pointsize
= height
* 72.0 / one_w32_display_info
.resy
;
2377 /* Round to nearest half point. floor is used, since round is not
2378 supported in MS library. */
2379 pointsize
= floor (pointsize
* 2 + 0.5) / 2;
2380 p
+= sprintf (p
, "-%1.1f", pointsize
);
2383 p
+= sprintf (p
, ":pixelsize=%d", height
);
2386 if (SYMBOLP (weight
) && ! NILP (weight
))
2387 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2390 p
+= sprintf (p
, ":italic");
2392 if (SYMBOLP (antialiasing
) && ! NILP (antialiasing
))
2393 p
+= sprintf (p
, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing
)));
2398 /* Convert a logfont and point size into a fontconfig style font name.
2399 POINTSIZE is in tenths of points.
2400 If SIZE indicates the size of buffer FCNAME, into which the font name
2401 is written. If the buffer is not large enough to contain the name,
2402 the function returns -1, otherwise it returns the number of bytes
2403 written to FCNAME. */
2405 logfont_to_fcname (LOGFONT
* font
, int pointsize
, char *fcname
, int size
)
2409 Lisp_Object weight
= Qnil
;
2411 len
= strlen (font
->lfFaceName
) + 2;
2412 height
= pointsize
/ 10;
2413 while (height
/= 10)
2420 len
+= 7; /* :italic */
2421 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2423 weight
= w32_to_fc_weight (font
->lfWeight
);
2424 len
+= SBYTES (SYMBOL_NAME (weight
)) + 1;
2430 p
+= sprintf (p
, "%s-%d", font
->lfFaceName
, pointsize
/ 10);
2432 p
+= sprintf (p
, ".%d", pointsize
% 10);
2434 if (SYMBOLP (weight
) && !NILP (weight
))
2435 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2438 p
+= sprintf (p
, ":italic");
2440 return (p
- fcname
);
2444 compute_metrics (HDC dc
, struct w32font_info
*w32_font
, unsigned int code
,
2445 struct w32_metric_cache
*metrics
)
2449 unsigned int options
= GGO_METRICS
;
2451 if (w32_font
->glyph_idx
)
2452 options
|= GGO_GLYPH_INDEX
;
2454 memset (&transform
, 0, sizeof (transform
));
2455 transform
.eM11
.value
= 1;
2456 transform
.eM22
.value
= 1;
2458 if (get_glyph_outline_w (dc
, code
, options
, &gm
, 0, NULL
, &transform
)
2461 metrics
->lbearing
= gm
.gmptGlyphOrigin
.x
;
2462 metrics
->rbearing
= gm
.gmptGlyphOrigin
.x
+ gm
.gmBlackBoxX
;
2463 metrics
->width
= gm
.gmCellIncX
;
2464 metrics
->status
= W32METRIC_SUCCESS
;
2467 metrics
->status
= W32METRIC_FAIL
;
2470 DEFUN ("x-select-font", Fx_select_font
, Sx_select_font
, 0, 2, 0,
2471 doc
: /* Read a font name using a W32 font selection dialog.
2472 Return fontconfig style font string corresponding to the selection.
2474 If FRAME is omitted or nil, it defaults to the selected frame.
2475 If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts
2476 in the font selection dialog. */)
2477 (Lisp_Object frame
, Lisp_Object exclude_proportional
)
2479 FRAME_PTR f
= check_x_frame (frame
);
2487 memset (&cf
, 0, sizeof (cf
));
2488 memset (&lf
, 0, sizeof (lf
));
2490 cf
.lStructSize
= sizeof (cf
);
2491 cf
.hwndOwner
= FRAME_W32_WINDOW (f
);
2492 cf
.Flags
= CF_FORCEFONTEXIST
| CF_SCREENFONTS
| CF_NOVERTFONTS
;
2494 /* If exclude_proportional is non-nil, limit the selection to
2495 monospaced fonts. */
2496 if (!NILP (exclude_proportional
))
2497 cf
.Flags
|= CF_FIXEDPITCHONLY
;
2501 /* Initialize as much of the font details as we can from the current
2503 hdc
= GetDC (FRAME_W32_WINDOW (f
));
2504 oldobj
= SelectObject (hdc
, FONT_HANDLE (FRAME_FONT (f
)));
2505 GetTextFace (hdc
, LF_FACESIZE
, lf
.lfFaceName
);
2506 if (GetTextMetrics (hdc
, &tm
))
2508 lf
.lfHeight
= tm
.tmInternalLeading
- tm
.tmHeight
;
2509 lf
.lfWeight
= tm
.tmWeight
;
2510 lf
.lfItalic
= tm
.tmItalic
;
2511 lf
.lfUnderline
= tm
.tmUnderlined
;
2512 lf
.lfStrikeOut
= tm
.tmStruckOut
;
2513 lf
.lfCharSet
= tm
.tmCharSet
;
2514 cf
.Flags
|= CF_INITTOLOGFONTSTRUCT
;
2516 SelectObject (hdc
, oldobj
);
2517 ReleaseDC (FRAME_W32_WINDOW (f
), hdc
);
2519 if (!ChooseFont (&cf
)
2520 || logfont_to_fcname (&lf
, cf
.iPointSize
, buf
, 100) < 0)
2523 return DECODE_SYSTEM (build_string (buf
));
2526 static const char *const w32font_booleans
[] = {
2530 static const char *const w32font_non_booleans
[] = {
2538 w32font_filter_properties (Lisp_Object font
, Lisp_Object alist
)
2540 font_filter_properties (font
, alist
, w32font_booleans
, w32font_non_booleans
);
2543 struct font_driver w32font_driver
=
2546 0, /* case insensitive */
2550 w32font_list_family
,
2551 NULL
, /* free_entity */
2554 NULL
, /* prepare_face */
2555 NULL
, /* done_face */
2557 w32font_encode_char
,
2558 w32font_text_extents
,
2560 NULL
, /* get_bitmap */
2561 NULL
, /* free_bitmap */
2562 NULL
, /* get_outline */
2563 NULL
, /* free_outline */
2564 NULL
, /* anchor_point */
2565 NULL
, /* otf_capability */
2566 NULL
, /* otf_drive */
2567 NULL
, /* start_for_frame */
2568 NULL
, /* end_for_frame */
2571 NULL
, /* get_variation_glyphs */
2572 w32font_filter_properties
,
2573 NULL
, /* cached_font_ok */
2577 /* Initialize state that does not change between invocations. This is only
2578 called when Emacs is dumped. */
2580 syms_of_w32font (void)
2582 DEFSYM (Qgdi
, "gdi");
2583 DEFSYM (Quniscribe
, "uniscribe");
2584 DEFSYM (QCformat
, ":format");
2586 /* Generic font families. */
2587 DEFSYM (Qmonospace
, "monospace");
2588 DEFSYM (Qserif
, "serif");
2589 DEFSYM (Qsansserif
, "sansserif");
2590 DEFSYM (Qscript
, "script");
2591 DEFSYM (Qdecorative
, "decorative");
2593 DEFSYM (Qsans_serif
, "sans_serif");
2594 DEFSYM (Qsans
, "sans");
2595 DEFSYM (Qmono
, "mono");
2597 /* Fake foundries. */
2598 DEFSYM (Qraster
, "raster");
2599 DEFSYM (Qoutline
, "outline");
2600 DEFSYM (Qunknown
, "unknown");
2603 DEFSYM (Qstandard
, "standard");
2604 DEFSYM (Qsubpixel
, "subpixel");
2605 DEFSYM (Qnatural
, "natural");
2611 DEFSYM (Qlatin
, "latin");
2612 DEFSYM (Qgreek
, "greek");
2613 DEFSYM (Qcoptic
, "coptic");
2614 DEFSYM (Qcyrillic
, "cyrillic");
2615 DEFSYM (Qarmenian
, "armenian");
2616 DEFSYM (Qhebrew
, "hebrew");
2617 DEFSYM (Qarabic
, "arabic");
2618 DEFSYM (Qsyriac
, "syriac");
2619 DEFSYM (Qnko
, "nko");
2620 DEFSYM (Qthaana
, "thaana");
2621 DEFSYM (Qdevanagari
, "devanagari");
2622 DEFSYM (Qbengali
, "bengali");
2623 DEFSYM (Qgurmukhi
, "gurmukhi");
2624 DEFSYM (Qgujarati
, "gujarati");
2625 DEFSYM (Qoriya
, "oriya");
2626 DEFSYM (Qtamil
, "tamil");
2627 DEFSYM (Qtelugu
, "telugu");
2628 DEFSYM (Qkannada
, "kannada");
2629 DEFSYM (Qmalayalam
, "malayalam");
2630 DEFSYM (Qsinhala
, "sinhala");
2631 DEFSYM (Qthai
, "thai");
2632 DEFSYM (Qlao
, "lao");
2633 DEFSYM (Qtibetan
, "tibetan");
2634 DEFSYM (Qmyanmar
, "myanmar");
2635 DEFSYM (Qgeorgian
, "georgian");
2636 DEFSYM (Qhangul
, "hangul");
2637 DEFSYM (Qethiopic
, "ethiopic");
2638 DEFSYM (Qcherokee
, "cherokee");
2639 DEFSYM (Qcanadian_aboriginal
, "canadian-aboriginal");
2640 DEFSYM (Qogham
, "ogham");
2641 DEFSYM (Qrunic
, "runic");
2642 DEFSYM (Qkhmer
, "khmer");
2643 DEFSYM (Qmongolian
, "mongolian");
2644 DEFSYM (Qsymbol
, "symbol");
2645 DEFSYM (Qbraille
, "braille");
2646 DEFSYM (Qhan
, "han");
2647 DEFSYM (Qideographic_description
, "ideographic-description");
2648 DEFSYM (Qcjk_misc
, "cjk-misc");
2649 DEFSYM (Qkana
, "kana");
2650 DEFSYM (Qbopomofo
, "bopomofo");
2651 DEFSYM (Qkanbun
, "kanbun");
2653 DEFSYM (Qbyzantine_musical_symbol
, "byzantine-musical-symbol");
2654 DEFSYM (Qmusical_symbol
, "musical-symbol");
2655 DEFSYM (Qmathematical
, "mathematical");
2656 DEFSYM (Qcham
, "cham");
2657 DEFSYM (Qphonetic
, "phonetic");
2658 DEFSYM (Qbalinese
, "balinese");
2659 DEFSYM (Qbuginese
, "buginese");
2660 DEFSYM (Qbuhid
, "buhid");
2661 DEFSYM (Qcuneiform
, "cuneiform");
2662 DEFSYM (Qcypriot
, "cypriot");
2663 DEFSYM (Qdeseret
, "deseret");
2664 DEFSYM (Qglagolitic
, "glagolitic");
2665 DEFSYM (Qgothic
, "gothic");
2666 DEFSYM (Qhanunoo
, "hanunoo");
2667 DEFSYM (Qkharoshthi
, "kharoshthi");
2668 DEFSYM (Qlimbu
, "limbu");
2669 DEFSYM (Qlinear_b
, "linear_b");
2670 DEFSYM (Qold_italic
, "old_italic");
2671 DEFSYM (Qold_persian
, "old_persian");
2672 DEFSYM (Qosmanya
, "osmanya");
2673 DEFSYM (Qphags_pa
, "phags-pa");
2674 DEFSYM (Qphoenician
, "phoenician");
2675 DEFSYM (Qshavian
, "shavian");
2676 DEFSYM (Qsyloti_nagri
, "syloti_nagri");
2677 DEFSYM (Qtagalog
, "tagalog");
2678 DEFSYM (Qtagbanwa
, "tagbanwa");
2679 DEFSYM (Qtai_le
, "tai_le");
2680 DEFSYM (Qtifinagh
, "tifinagh");
2681 DEFSYM (Qugaritic
, "ugaritic");
2683 /* W32 font encodings. */
2684 DEFVAR_LISP ("w32-charset-info-alist",
2685 Vw32_charset_info_alist
,
2686 doc
: /* Alist linking Emacs character sets to Windows fonts and codepages.
2687 Each entry should be of the form:
2689 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))
2691 where CHARSET_NAME is a string used in font names to identify the charset,
2692 WINDOWS_CHARSET is a symbol that can be one of:
2694 w32-charset-ansi, w32-charset-default, w32-charset-symbol,
2695 w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312,
2696 w32-charset-chinesebig5, w32-charset-johab, w32-charset-hebrew,
2697 w32-charset-arabic, w32-charset-greek, w32-charset-turkish,
2698 w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,
2699 w32-charset-russian, w32-charset-mac, w32-charset-baltic,
2702 CODEPAGE should be an integer specifying the codepage that should be used
2703 to display the character set, t to do no translation and output as Unicode,
2704 or nil to do no translation and output as 8 bit (or multibyte on far-east
2705 versions of Windows) characters. */);
2706 Vw32_charset_info_alist
= Qnil
;
2708 DEFSYM (Qw32_charset_ansi
, "w32-charset-ansi");
2709 DEFSYM (Qw32_charset_symbol
, "w32-charset-symbol");
2710 DEFSYM (Qw32_charset_default
, "w32-charset-default");
2711 DEFSYM (Qw32_charset_shiftjis
, "w32-charset-shiftjis");
2712 DEFSYM (Qw32_charset_hangeul
, "w32-charset-hangeul");
2713 DEFSYM (Qw32_charset_chinesebig5
, "w32-charset-chinesebig5");
2714 DEFSYM (Qw32_charset_gb2312
, "w32-charset-gb2312");
2715 DEFSYM (Qw32_charset_oem
, "w32-charset-oem");
2716 DEFSYM (Qw32_charset_johab
, "w32-charset-johab");
2717 DEFSYM (Qw32_charset_easteurope
, "w32-charset-easteurope");
2718 DEFSYM (Qw32_charset_turkish
, "w32-charset-turkish");
2719 DEFSYM (Qw32_charset_baltic
, "w32-charset-baltic");
2720 DEFSYM (Qw32_charset_russian
, "w32-charset-russian");
2721 DEFSYM (Qw32_charset_arabic
, "w32-charset-arabic");
2722 DEFSYM (Qw32_charset_greek
, "w32-charset-greek");
2723 DEFSYM (Qw32_charset_hebrew
, "w32-charset-hebrew");
2724 DEFSYM (Qw32_charset_vietnamese
, "w32-charset-vietnamese");
2725 DEFSYM (Qw32_charset_thai
, "w32-charset-thai");
2726 DEFSYM (Qw32_charset_mac
, "w32-charset-mac");
2728 defsubr (&Sx_select_font
);
2730 w32font_driver
.type
= Qgdi
;
2731 register_font_driver (&w32font_driver
, NULL
);
2735 globals_of_w32font (void)
2737 g_b_init_is_w9x
= 0;
2738 g_b_init_get_outline_metrics_w
= 0;
2739 g_b_init_get_text_metrics_w
= 0;
2740 g_b_init_get_glyph_outline_w
= 0;