1 /* Font backend for the Microsoft Windows API.
2 Copyright (C) 2007-2014 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"
40 /* Cleartype available on Windows XP, cleartype_natural from XP SP1.
41 The latter does not try to fit cleartype smoothed fonts into the
42 same bounding box as the non-antialiased version of the font.
44 #ifndef CLEARTYPE_QUALITY
45 #define CLEARTYPE_QUALITY 5
47 #ifndef CLEARTYPE_NATURAL_QUALITY
48 #define CLEARTYPE_NATURAL_QUALITY 6
51 /* VIETNAMESE_CHARSET and JOHAB_CHARSET are not defined in some versions
53 #ifndef VIETNAMESE_CHARSET
54 #define VIETNAMESE_CHARSET 163
57 #define JOHAB_CHARSET 130
61 Lisp_Object Quniscribe
;
62 static Lisp_Object QCformat
;
63 static Lisp_Object Qmonospace
, Qsansserif
, Qmono
, Qsans
, Qsans_serif
;
64 static Lisp_Object Qserif
, Qscript
, Qdecorative
;
65 static Lisp_Object Qraster
, Qoutline
, Qunknown
;
68 static Lisp_Object Qstandard
, Qsubpixel
, Qnatural
;
71 static Lisp_Object Qzh
;
74 static Lisp_Object Qgreek
, Qcoptic
, Qcyrillic
, Qarmenian
, Qhebrew
;
75 static Lisp_Object Qarabic
, Qsyriac
, Qnko
, Qthaana
, Qdevanagari
, Qbengali
;
76 static Lisp_Object Qgurmukhi
, Qgujarati
, Qoriya
, Qtamil
, Qtelugu
;
77 static Lisp_Object Qkannada
, Qmalayalam
, Qsinhala
, Qthai
, Qlao
;
78 static Lisp_Object Qtibetan
, Qmyanmar
, Qgeorgian
, Qhangul
, Qethiopic
;
79 static Lisp_Object Qcherokee
, Qcanadian_aboriginal
, Qogham
, Qrunic
;
80 static Lisp_Object Qkhmer
, Qmongolian
, Qbraille
, Qhan
;
81 static Lisp_Object Qideographic_description
, Qcjk_misc
, Qkana
, Qbopomofo
;
82 static Lisp_Object Qkanbun
, Qyi
, Qbyzantine_musical_symbol
;
83 static Lisp_Object Qmusical_symbol
, Qmathematical
, Qcham
, Qphonetic
;
84 /* Not defined in characters.el, but referenced in fontset.el. */
85 static Lisp_Object Qbalinese
, Qbuginese
, Qbuhid
, Qcuneiform
, Qcypriot
;
86 static Lisp_Object Qdeseret
, Qglagolitic
, Qgothic
, Qhanunoo
, Qkharoshthi
;
87 static Lisp_Object Qlimbu
, Qlinear_b
, Qold_italic
, Qold_persian
, Qosmanya
;
88 static Lisp_Object Qphags_pa
, Qphoenician
, Qshavian
, Qsyloti_nagri
;
89 static Lisp_Object Qtagalog
, Qtagbanwa
, Qtai_le
, Qtifinagh
, Qugaritic
;
91 /* W32 charsets: for use in Vw32_charset_info_alist. */
92 static Lisp_Object Qw32_charset_ansi
, Qw32_charset_default
;
93 static Lisp_Object Qw32_charset_symbol
, Qw32_charset_shiftjis
;
94 static Lisp_Object Qw32_charset_hangeul
, Qw32_charset_gb2312
;
95 static Lisp_Object Qw32_charset_chinesebig5
, Qw32_charset_oem
;
96 static Lisp_Object Qw32_charset_easteurope
, Qw32_charset_turkish
;
97 static Lisp_Object Qw32_charset_baltic
, Qw32_charset_russian
;
98 static Lisp_Object Qw32_charset_arabic
, Qw32_charset_greek
;
99 static Lisp_Object Qw32_charset_hebrew
, Qw32_charset_vietnamese
;
100 static Lisp_Object Qw32_charset_thai
, Qw32_charset_johab
, Qw32_charset_mac
;
102 /* Font spacing symbols - defined in font.c. */
103 extern Lisp_Object Qc
, Qp
, Qm
;
105 static void fill_in_logfont (struct frame
*, LOGFONT
*, Lisp_Object
);
107 static BYTE
w32_antialias_type (Lisp_Object
);
108 static Lisp_Object
lispy_antialias_type (BYTE
);
110 static Lisp_Object
font_supported_scripts (FONTSIGNATURE
*);
111 static int w32font_full_name (LOGFONT
*, Lisp_Object
, int, char *, int);
112 static void compute_metrics (HDC
, struct w32font_info
*, unsigned int,
113 struct w32_metric_cache
*);
115 static Lisp_Object
w32_registry (LONG
, DWORD
);
117 /* EnumFontFamiliesEx callbacks. */
118 static int CALLBACK
add_font_entity_to_list (ENUMLOGFONTEX
*,
121 static int CALLBACK
add_one_font_entity_to_list (ENUMLOGFONTEX
*,
124 static int CALLBACK
add_font_name_to_list (ENUMLOGFONTEX
*,
128 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
129 of what we really want. */
130 struct font_callback_data
132 /* The logfont we are matching against. EnumFontFamiliesEx only matches
133 face name and charset, so we need to manually match everything else
134 in the callback function. */
136 /* The original font spec or entity. */
137 Lisp_Object orig_font_spec
;
138 /* The frame the font is being loaded on. */
140 /* The list to add matches to. */
142 /* Whether to match only opentype fonts. */
146 /* Handles the problem that EnumFontFamiliesEx will not return all
147 style variations if the font name is not specified. */
148 static void list_all_matching_fonts (struct font_callback_data
*);
152 static BOOL g_b_init_get_outline_metrics_w
;
153 static BOOL g_b_init_get_text_metrics_w
;
154 static BOOL g_b_init_get_glyph_outline_w
;
155 static BOOL g_b_init_get_glyph_outline_w
;
156 static BOOL g_b_init_get_char_width_32_w
;
158 typedef UINT (WINAPI
* GetOutlineTextMetricsW_Proc
) (
161 LPOUTLINETEXTMETRICW lpotmw
);
162 typedef BOOL (WINAPI
* GetTextMetricsW_Proc
) (
164 LPTEXTMETRICW lptmw
);
165 typedef DWORD (WINAPI
* GetGlyphOutlineW_Proc
) (
173 typedef BOOL (WINAPI
* GetCharWidth32W_Proc
) (
179 /* Several "wide" functions we use to support the font backends are
180 unavailable on Windows 9X, unless UNICOWS.DLL is installed (their
181 versions in the default libraries are non-functional stubs). On NT
182 and later systems, these functions are in GDI32.DLL. The following
183 helper function attempts to load UNICOWS.DLL on Windows 9X, and
184 refuses to let Emacs start up if that library is not found. On NT
185 and later versions, it simply loads GDI32.DLL, which should always
188 w32_load_unicows_or_gdi32 (void)
190 return maybe_load_unicows_dll ();
193 /* The following 3 functions call the problematic "wide" APIs via
194 function pointers, to avoid linking against the non-standard
195 libunicows on W9X. */
197 get_outline_metrics_w(HDC hdc
, UINT cbData
, LPOUTLINETEXTMETRICW lpotmw
)
199 static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW
= NULL
;
200 HMODULE hm_unicows
= NULL
;
201 if (g_b_init_get_outline_metrics_w
== 0)
203 g_b_init_get_outline_metrics_w
= 1;
204 hm_unicows
= w32_load_unicows_or_gdi32 ();
206 s_pfn_Get_Outline_Text_MetricsW
= (GetOutlineTextMetricsW_Proc
)
207 GetProcAddress (hm_unicows
, "GetOutlineTextMetricsW");
209 eassert (s_pfn_Get_Outline_Text_MetricsW
!= NULL
);
210 return s_pfn_Get_Outline_Text_MetricsW (hdc
, cbData
, lpotmw
);
214 get_text_metrics_w(HDC hdc
, LPTEXTMETRICW lptmw
)
216 static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW
= NULL
;
217 HMODULE hm_unicows
= NULL
;
218 if (g_b_init_get_text_metrics_w
== 0)
220 g_b_init_get_text_metrics_w
= 1;
221 hm_unicows
= w32_load_unicows_or_gdi32 ();
223 s_pfn_Get_Text_MetricsW
= (GetTextMetricsW_Proc
)
224 GetProcAddress (hm_unicows
, "GetTextMetricsW");
226 eassert (s_pfn_Get_Text_MetricsW
!= NULL
);
227 return s_pfn_Get_Text_MetricsW (hdc
, lptmw
);
231 get_glyph_outline_w (HDC hdc
, UINT uChar
, UINT uFormat
, LPGLYPHMETRICS lpgm
,
232 DWORD cbBuffer
, LPVOID lpvBuffer
, const MAT2
*lpmat2
)
234 static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW
= NULL
;
235 HMODULE hm_unicows
= NULL
;
236 if (g_b_init_get_glyph_outline_w
== 0)
238 g_b_init_get_glyph_outline_w
= 1;
239 hm_unicows
= w32_load_unicows_or_gdi32 ();
241 s_pfn_Get_Glyph_OutlineW
= (GetGlyphOutlineW_Proc
)
242 GetProcAddress (hm_unicows
, "GetGlyphOutlineW");
244 eassert (s_pfn_Get_Glyph_OutlineW
!= NULL
);
245 return s_pfn_Get_Glyph_OutlineW (hdc
, uChar
, uFormat
, lpgm
, cbBuffer
,
250 get_char_width_32_w (HDC hdc
, UINT uFirstChar
, UINT uLastChar
, LPINT lpBuffer
)
252 static GetCharWidth32W_Proc s_pfn_Get_Char_Width_32W
= NULL
;
253 HMODULE hm_unicows
= NULL
;
254 if (g_b_init_get_char_width_32_w
== 0)
256 g_b_init_get_char_width_32_w
= 1;
257 hm_unicows
= w32_load_unicows_or_gdi32 ();
259 s_pfn_Get_Char_Width_32W
= (GetCharWidth32W_Proc
)
260 GetProcAddress (hm_unicows
, "GetCharWidth32W");
262 eassert (s_pfn_Get_Char_Width_32W
!= NULL
);
263 return s_pfn_Get_Char_Width_32W (hdc
, uFirstChar
, uLastChar
, lpBuffer
);
268 /* Cygwin doesn't support Windows 9X, and links against GDI32.DLL, so
269 it can just call these functions directly. */
270 #define get_outline_metrics_w(h,d,o) GetOutlineTextMetricsW(h,d,o)
271 #define get_text_metrics_w(h,t) GetTextMetricsW(h,t)
272 #define get_glyph_outline_w(h,uc,f,gm,b,v,m) \
273 GetGlyphOutlineW(h,uc,f,gm,b,v,m)
274 #define get_char_width_32_w(h,fc,lc,b) GetCharWidth32W(h,fc,lc,b)
279 memq_no_quit (Lisp_Object elt
, Lisp_Object list
)
281 while (CONSP (list
) && ! EQ (XCAR (list
), elt
))
283 return (CONSP (list
));
287 intern_font_name (char * string
)
289 Lisp_Object str
= DECODE_SYSTEM (build_string (string
));
290 int len
= SCHARS (str
);
291 Lisp_Object obarray
= check_obarray (Vobarray
);
292 Lisp_Object tem
= oblookup (obarray
, SDATA (str
), len
, len
);
293 /* This code is similar to intern function from lread.c. */
294 return SYMBOLP (tem
) ? tem
: Fintern (str
, obarray
);
297 /* w32 implementation of get_cache for font backend.
298 Return a cache of font-entities on FRAME. The cache must be a
299 cons whose cdr part is the actual cache area. */
301 w32font_get_cache (struct frame
*f
)
303 struct w32_display_info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
305 return (dpyinfo
->name_list_element
);
308 /* w32 implementation of list for font backend.
309 List fonts exactly matching with FONT_SPEC on FRAME. The value
310 is a vector of font-entities. This is the sole API that
311 allocates font-entities. */
313 w32font_list (struct frame
*f
, Lisp_Object font_spec
)
315 Lisp_Object fonts
= w32font_list_internal (f
, font_spec
, 0);
316 FONT_ADD_LOG ("w32font-list", font_spec
, fonts
);
320 /* w32 implementation of match for font backend.
321 Return a font entity most closely matching with FONT_SPEC on
322 FRAME. The closeness is determined by the font backend, thus
323 `face-font-selection-order' is ignored here. */
325 w32font_match (struct frame
*f
, Lisp_Object font_spec
)
327 Lisp_Object entity
= w32font_match_internal (f
, font_spec
, 0);
328 FONT_ADD_LOG ("w32font-match", font_spec
, entity
);
332 /* w32 implementation of list_family for font backend.
333 List available families. The value is a list of family names
336 w32font_list_family (struct frame
*f
)
338 Lisp_Object list
= Qnil
;
339 LOGFONT font_match_pattern
;
342 memset (&font_match_pattern
, 0, sizeof (font_match_pattern
));
343 font_match_pattern
.lfCharSet
= DEFAULT_CHARSET
;
345 dc
= get_frame_dc (f
);
347 EnumFontFamiliesEx (dc
, &font_match_pattern
,
348 (FONTENUMPROC
) add_font_name_to_list
,
350 release_frame_dc (f
, dc
);
355 /* w32 implementation of open for font backend.
356 Open a font specified by FONT_ENTITY on frame F.
357 If the font is scalable, open it with PIXEL_SIZE. */
359 w32font_open (struct frame
*f
, Lisp_Object font_entity
, int pixel_size
)
361 Lisp_Object font_object
362 = font_make_object (VECSIZE (struct w32font_info
),
363 font_entity
, pixel_size
);
364 struct w32font_info
*w32_font
365 = (struct w32font_info
*) XFONT_OBJECT (font_object
);
367 ASET (font_object
, FONT_TYPE_INDEX
, Qgdi
);
369 if (!w32font_open_internal (f
, font_entity
, pixel_size
, font_object
))
374 /* GDI backend does not use glyph indices. */
375 w32_font
->glyph_idx
= 0;
380 /* w32 implementation of close for font_backend. */
382 w32font_close (struct font
*font
)
384 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
388 /* Delete the GDI font object. */
389 DeleteObject (w32_font
->hfont
);
390 w32_font
->hfont
= NULL
;
392 /* Free all the cached metrics. */
393 if (w32_font
->cached_metrics
)
397 for (i
= 0; i
< w32_font
->n_cache_blocks
; i
++)
398 xfree (w32_font
->cached_metrics
[i
]);
399 xfree (w32_font
->cached_metrics
);
400 w32_font
->cached_metrics
= NULL
;
405 /* w32 implementation of has_char for font backend.
407 If FONT_ENTITY has a glyph for character C (Unicode code point),
408 return 1. If not, return 0. If a font must be opened to check
411 w32font_has_char (Lisp_Object entity
, int c
)
413 /* We can't be certain about which characters a font will support until
414 we open it. Checking the scripts that the font supports turns out
415 to not be reliable. */
419 Lisp_Object supported_scripts
, extra
, script
;
422 extra
= AREF (entity
, FONT_EXTRA_INDEX
);
426 supported_scripts
= assq_no_quit (QCscript
, extra
);
427 /* If font doesn't claim to support any scripts, then we can't be certain
429 if (!CONSP (supported_scripts
))
432 supported_scripts
= XCDR (supported_scripts
);
434 script
= CHAR_TABLE_REF (Vchar_script_table
, c
);
436 /* If we don't know what script the character is from, then we can't be
437 certain until we open it. Also if the font claims support for the script
438 the character is from, it may only have partial coverage, so we still
439 can't be certain until we open the font. */
440 if (NILP (script
) || memq_no_quit (script
, supported_scripts
))
443 /* Font reports what scripts it supports, and none of them are the script
444 the character is from. But we still can't be certain, as some fonts
445 will contain some/most/all of the characters in that script without
446 claiming support for it. */
451 /* w32 implementation of encode_char for font backend.
452 Return a glyph code of FONT for character C (Unicode code point).
453 If FONT doesn't have such a glyph, return FONT_INVALID_CODE.
455 For speed, the gdi backend uses Unicode (Emacs calls encode_char
456 far too often for it to be efficient). But we still need to detect
457 which characters are not supported by the font.
460 w32font_encode_char (struct font
*font
, int c
)
462 struct w32font_info
* w32_font
= (struct w32font_info
*)font
;
464 if (c
< w32_font
->metrics
.tmFirstChar
465 || c
> w32_font
->metrics
.tmLastChar
)
466 return FONT_INVALID_CODE
;
471 /* w32 implementation of text_extents for font backend.
472 Perform the size computation of glyphs of FONT and fillin members
473 of METRICS. The glyphs are specified by their glyph codes in
474 CODE (length NGLYPHS). Apparently metrics can be NULL, in this
475 case just return the overall width. */
477 w32font_text_extents (struct font
*font
, unsigned *code
,
478 int nglyphs
, struct font_metrics
*metrics
)
481 HFONT old_font
= NULL
;
488 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
492 memset (metrics
, 0, sizeof (struct font_metrics
));
493 metrics
->ascent
= font
->ascent
;
494 metrics
->descent
= font
->descent
;
496 for (i
= 0; i
< nglyphs
; i
++)
498 struct w32_metric_cache
*char_metric
;
499 int block
= *(code
+ i
) / CACHE_BLOCKSIZE
;
500 int pos_in_block
= *(code
+ i
) % CACHE_BLOCKSIZE
;
502 if (block
>= w32_font
->n_cache_blocks
)
504 if (!w32_font
->cached_metrics
)
505 w32_font
->cached_metrics
506 = xmalloc ((block
+ 1)
507 * sizeof (struct w32_metric_cache
*));
509 w32_font
->cached_metrics
510 = xrealloc (w32_font
->cached_metrics
,
512 * sizeof (struct w32_metric_cache
*));
513 memset (w32_font
->cached_metrics
+ w32_font
->n_cache_blocks
, 0,
514 ((block
+ 1 - w32_font
->n_cache_blocks
)
515 * sizeof (struct w32_metric_cache
*)));
516 w32_font
->n_cache_blocks
= block
+ 1;
519 if (!w32_font
->cached_metrics
[block
])
521 w32_font
->cached_metrics
[block
]
522 = xzalloc (CACHE_BLOCKSIZE
* sizeof (struct w32_metric_cache
));
525 char_metric
= w32_font
->cached_metrics
[block
] + pos_in_block
;
527 if (char_metric
->status
== W32METRIC_NO_ATTEMPT
)
531 /* TODO: Frames can come and go, and their fonts
532 outlive them. So we can't cache the frame in the
533 font structure. Use selected_frame until the API
534 is updated to pass in a frame. */
535 f
= XFRAME (selected_frame
);
537 dc
= get_frame_dc (f
);
538 old_font
= SelectObject (dc
, w32_font
->hfont
);
540 compute_metrics (dc
, w32_font
, *(code
+ i
), char_metric
);
543 if (char_metric
->status
== W32METRIC_SUCCESS
)
545 metrics
->lbearing
= min (metrics
->lbearing
,
546 metrics
->width
+ char_metric
->lbearing
);
547 metrics
->rbearing
= max (metrics
->rbearing
,
548 metrics
->width
+ char_metric
->rbearing
);
549 metrics
->width
+= char_metric
->width
;
552 /* If we couldn't get metrics for a char,
553 use alternative method. */
556 /* If we got through everything, return. */
561 /* Restore state and release DC. */
562 SelectObject (dc
, old_font
);
563 release_frame_dc (f
, dc
);
566 return metrics
->width
;
570 /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
571 fallback on other methods that will at least give some of the metric
574 /* Make array big enough to hold surrogates. */
575 wcode
= alloca (nglyphs
* sizeof (WORD
) * 2);
576 for (i
= 0; i
< nglyphs
; i
++)
578 if (code
[i
] < 0x10000)
582 DWORD surrogate
= code
[i
] - 0x10000;
584 /* High surrogate: U+D800 - U+DBFF. */
585 wcode
[i
++] = 0xD800 + ((surrogate
>> 10) & 0x03FF);
586 /* Low surrogate: U+DC00 - U+DFFF. */
587 wcode
[i
] = 0xDC00 + (surrogate
& 0x03FF);
588 /* An extra glyph. wcode is already double the size of code to
596 /* TODO: Frames can come and go, and their fonts outlive
597 them. So we can't cache the frame in the font structure. Use
598 selected_frame until the API is updated to pass in a
600 f
= XFRAME (selected_frame
);
602 dc
= get_frame_dc (f
);
603 old_font
= SelectObject (dc
, w32_font
->hfont
);
606 if (GetTextExtentPoint32W (dc
, wcode
, nglyphs
, &size
))
608 total_width
= size
.cx
;
611 /* On 95/98/ME, only some Unicode functions are available, so fallback
612 on doing a dummy draw to find the total width. */
616 rect
.top
= 0; rect
.bottom
= font
->height
; rect
.left
= 0; rect
.right
= 1;
617 DrawTextW (dc
, wcode
, nglyphs
, &rect
,
618 DT_CALCRECT
| DT_NOPREFIX
| DT_SINGLELINE
);
619 total_width
= rect
.right
;
622 /* Give our best estimate of the metrics, based on what we know. */
625 metrics
->width
= total_width
- w32_font
->metrics
.tmOverhang
;
626 metrics
->lbearing
= 0;
627 metrics
->rbearing
= total_width
;
630 /* Restore state and release DC. */
631 SelectObject (dc
, old_font
);
632 release_frame_dc (f
, dc
);
637 /* w32 implementation of draw for font backend.
639 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
640 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
641 fill the background in advance. It is assured that WITH_BACKGROUND
642 is false when (FROM > 0 || TO < S->nchars).
644 TODO: Currently this assumes that the colors and fonts are already
645 set in the DC. This seems to be true now, but maybe only due to
646 the old font code setting it up. It may be safer to resolve faces
647 and fonts in here and set them explicitly
651 w32font_draw (struct glyph_string
*s
, int from
, int to
,
652 int x
, int y
, bool with_background
)
655 HRGN orig_clip
= NULL
;
657 struct w32font_info
*w32font
= (struct w32font_info
*) s
->font
;
659 options
= w32font
->glyph_idx
;
661 if (s
->num_clips
> 0)
663 HRGN new_clip
= CreateRectRgnIndirect (s
->clip
);
665 /* Save clip region for later restoration. */
666 orig_clip
= CreateRectRgn (0, 0, 0, 0);
667 if (!GetClipRgn (s
->hdc
, orig_clip
))
669 DeleteObject (orig_clip
);
673 if (s
->num_clips
> 1)
675 HRGN clip2
= CreateRectRgnIndirect (s
->clip
+ 1);
677 CombineRgn (new_clip
, new_clip
, clip2
, RGN_OR
);
678 DeleteObject (clip2
);
681 SelectClipRgn (s
->hdc
, new_clip
);
682 DeleteObject (new_clip
);
685 /* Using OPAQUE background mode can clear more background than expected
686 when Cleartype is used. Draw the background manually to avoid this. */
687 SetBkMode (s
->hdc
, TRANSPARENT
);
692 struct font
*font
= s
->font
;
694 brush
= CreateSolidBrush (s
->gc
->background
);
696 rect
.top
= y
- font
->ascent
;
697 rect
.right
= x
+ s
->width
;
698 rect
.bottom
= y
+ font
->descent
;
699 FillRect (s
->hdc
, &rect
, brush
);
700 DeleteObject (brush
);
707 for (i
= 0; i
< len
; i
++)
708 ExtTextOutW (s
->hdc
, x
+ i
, y
, options
, NULL
,
709 s
->char2b
+ from
+ i
, 1, NULL
);
712 ExtTextOutW (s
->hdc
, x
, y
, options
, NULL
, s
->char2b
+ from
, len
, NULL
);
714 /* Restore clip region. */
715 if (s
->num_clips
> 0)
716 SelectClipRgn (s
->hdc
, orig_clip
);
719 DeleteObject (orig_clip
);
724 /* w32 implementation of free_entity for font backend.
725 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
726 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
728 w32font_free_entity (Lisp_Object entity);
731 /* w32 implementation of prepare_face for font backend.
732 Optional (if FACE->extra is not used).
733 Prepare FACE for displaying characters by FONT on frame F by
734 storing some data in FACE->extra. If successful, return 0.
735 Otherwise, return -1.
737 w32font_prepare_face (struct frame *f, struct face *face);
739 /* w32 implementation of done_face for font backend.
741 Done FACE for displaying characters by FACE->font on frame F.
743 w32font_done_face (struct frame *f, struct face *face); */
745 /* w32 implementation of get_bitmap for font backend.
747 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
748 intended that this method is called from the other font-driver
751 w32font_get_bitmap (struct font *font, unsigned code,
752 struct font_bitmap *bitmap, int bits_per_pixel);
754 /* w32 implementation of free_bitmap for font backend.
756 Free bitmap data in BITMAP.
758 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
760 /* w32 implementation of anchor_point for font backend.
762 Get coordinates of the INDEXth anchor point of the glyph whose
763 code is CODE. Store the coordinates in *X and *Y. Return 0 if
764 the operations was successful. Otherwise return -1.
766 w32font_anchor_point (struct font *font, unsigned code,
767 int index, int *x, int *y);
769 /* w32 implementation of otf_capability for font backend.
771 Return a list describing which scripts/languages FONT
772 supports by which GSUB/GPOS features of OpenType tables.
774 w32font_otf_capability (struct font *font);
776 /* w32 implementation of otf_drive for font backend.
778 Apply FONT's OTF-FEATURES to the glyph string.
780 FEATURES specifies which OTF features to apply in this format:
781 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
782 See the documentation of `font-drive-otf' for the detail.
784 This method applies the specified features to the codes in the
785 elements of GSTRING-IN (between FROMth and TOth). The output
786 codes are stored in GSTRING-OUT at the IDXth element and the
789 Return the number of output codes. If none of the features are
790 applicable to the input data, return 0. If GSTRING-OUT is too
793 w32font_otf_drive (struct font *font, Lisp_Object features,
794 Lisp_Object gstring_in, int from, int to,
795 Lisp_Object gstring_out, int idx,
796 bool alternate_subst);
799 /* Internal implementation of w32font_list.
800 Additional parameter opentype_only restricts the returned fonts to
801 opentype fonts, which can be used with the Uniscribe backend. */
803 w32font_list_internal (struct frame
*f
, Lisp_Object font_spec
, int opentype_only
)
805 struct font_callback_data match_data
;
808 match_data
.orig_font_spec
= font_spec
;
809 match_data
.list
= Qnil
;
810 XSETFRAME (match_data
.frame
, f
);
812 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
813 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
815 /* If the charset is unrecognized, then we won't find a font, so don't
816 waste time looking for one. */
817 if (match_data
.pattern
.lfCharSet
== DEFAULT_CHARSET
)
819 Lisp_Object spec_charset
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
820 if (!NILP (spec_charset
)
821 && !EQ (spec_charset
, Qiso10646_1
)
822 && !EQ (spec_charset
, Qunicode_bmp
)
823 && !EQ (spec_charset
, Qunicode_sip
)
824 && !EQ (spec_charset
, Qunknown
))
828 match_data
.opentype_only
= opentype_only
;
830 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
832 if (match_data
.pattern
.lfFaceName
[0] == '\0')
834 /* EnumFontFamiliesEx does not take other fields into account if
835 font name is blank, so need to use two passes. */
836 list_all_matching_fonts (&match_data
);
840 dc
= get_frame_dc (f
);
842 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
843 (FONTENUMPROC
) add_font_entity_to_list
,
844 (LPARAM
) &match_data
, 0);
845 release_frame_dc (f
, dc
);
848 return match_data
.list
;
851 /* Internal implementation of w32font_match.
852 Additional parameter opentype_only restricts the returned fonts to
853 opentype fonts, which can be used with the Uniscribe backend. */
855 w32font_match_internal (struct frame
*f
, Lisp_Object font_spec
, int opentype_only
)
857 struct font_callback_data match_data
;
860 match_data
.orig_font_spec
= font_spec
;
861 XSETFRAME (match_data
.frame
, f
);
862 match_data
.list
= Qnil
;
864 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
865 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
867 match_data
.opentype_only
= opentype_only
;
869 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
871 dc
= get_frame_dc (f
);
873 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
874 (FONTENUMPROC
) add_one_font_entity_to_list
,
875 (LPARAM
) &match_data
, 0);
876 release_frame_dc (f
, dc
);
878 return NILP (match_data
.list
) ? Qnil
: XCAR (match_data
.list
);
882 w32font_open_internal (struct frame
*f
, Lisp_Object font_entity
,
883 int pixel_size
, Lisp_Object font_object
)
888 HFONT hfont
, old_font
;
890 struct w32font_info
*w32_font
;
892 OUTLINETEXTMETRICW
* metrics
= NULL
;
894 w32_font
= (struct w32font_info
*) XFONT_OBJECT (font_object
);
895 font
= (struct font
*) w32_font
;
900 memset (&logfont
, 0, sizeof (logfont
));
901 fill_in_logfont (f
, &logfont
, font_entity
);
903 /* Prefer truetype fonts, to avoid known problems with type1 fonts, and
904 limitations in bitmap fonts. */
905 val
= AREF (font_entity
, FONT_FOUNDRY_INDEX
);
906 if (!EQ (val
, Qraster
))
907 logfont
.lfOutPrecision
= OUT_TT_PRECIS
;
909 size
= XINT (AREF (font_entity
, FONT_SIZE_INDEX
));
913 logfont
.lfHeight
= -size
;
914 hfont
= CreateFontIndirect (&logfont
);
919 /* Get the metrics for this font. */
920 dc
= get_frame_dc (f
);
921 old_font
= SelectObject (dc
, hfont
);
923 /* Try getting the outline metrics (only works for truetype fonts). */
924 len
= get_outline_metrics_w (dc
, 0, NULL
);
927 metrics
= (OUTLINETEXTMETRICW
*) alloca (len
);
928 if (get_outline_metrics_w (dc
, len
, metrics
))
929 memcpy (&w32_font
->metrics
, &metrics
->otmTextMetrics
,
930 sizeof (TEXTMETRICW
));
936 get_text_metrics_w (dc
, &w32_font
->metrics
);
938 w32_font
->cached_metrics
= NULL
;
939 w32_font
->n_cache_blocks
= 0;
941 SelectObject (dc
, old_font
);
942 release_frame_dc (f
, dc
);
944 w32_font
->hfont
= hfont
;
949 /* We don't know how much space we need for the full name, so start with
950 96 bytes and go up in steps of 32. */
953 while (name
&& w32font_full_name (&logfont
, font_entity
, pixel_size
,
960 font
->props
[FONT_FULLNAME_INDEX
]
961 = DECODE_SYSTEM (build_string (name
));
963 font
->props
[FONT_FULLNAME_INDEX
]
964 = DECODE_SYSTEM (build_string (logfont
.lfFaceName
));
967 font
->max_width
= w32_font
->metrics
.tmMaxCharWidth
;
968 /* Parts of Emacs display assume that height = ascent + descent...
969 so height is defined later, after ascent and descent.
970 font->height = w32_font->metrics.tmHeight
971 + w32_font->metrics.tmExternalLeading;
974 font
->space_width
= font
->average_width
= w32_font
->metrics
.tmAveCharWidth
;
976 font
->vertical_centering
= 0;
977 font
->baseline_offset
= 0;
978 font
->relative_compose
= 0;
979 font
->default_ascent
= w32_font
->metrics
.tmAscent
;
980 font
->pixel_size
= size
;
981 font
->driver
= &w32font_driver
;
982 font
->encoding_charset
= -1;
983 font
->repertory_charset
= -1;
984 /* TODO: do we really want the minimum width here, which could be negative? */
985 font
->min_width
= font
->space_width
;
986 font
->ascent
= w32_font
->metrics
.tmAscent
;
987 font
->descent
= w32_font
->metrics
.tmDescent
;
988 font
->height
= font
->ascent
+ font
->descent
;
992 font
->underline_thickness
= metrics
->otmsUnderscoreSize
;
993 font
->underline_position
= -metrics
->otmsUnderscorePosition
;
997 font
->underline_thickness
= 0;
998 font
->underline_position
= -1;
1001 /* For temporary compatibility with legacy code that expects the
1002 name to be usable in x-list-fonts. Eventually we expect to change
1003 x-list-fonts and other places that use fonts so that this can be
1004 an fcname or similar. */
1005 font
->props
[FONT_NAME_INDEX
] = Ffont_xlfd_name (font_object
, Qnil
);
1010 /* Callback function for EnumFontFamiliesEx.
1011 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */
1013 add_font_name_to_list (ENUMLOGFONTEX
*logical_font
,
1014 NEWTEXTMETRICEX
*physical_font
,
1015 DWORD font_type
, LPARAM list_object
)
1017 Lisp_Object
* list
= (Lisp_Object
*) list_object
;
1020 /* Skip vertical fonts (intended only for printing) */
1021 if (logical_font
->elfLogFont
.lfFaceName
[0] == '@')
1024 family
= intern_font_name (logical_font
->elfLogFont
.lfFaceName
);
1025 if (! memq_no_quit (family
, *list
))
1026 *list
= Fcons (family
, *list
);
1031 static int w32_decode_weight (int);
1032 static int w32_encode_weight (int);
1034 /* Convert an enumerated Windows font to an Emacs font entity. */
1036 w32_enumfont_pattern_entity (Lisp_Object frame
,
1037 ENUMLOGFONTEX
*logical_font
,
1038 NEWTEXTMETRICEX
*physical_font
,
1040 LOGFONT
*requested_font
,
1041 Lisp_Object backend
)
1043 Lisp_Object entity
, tem
;
1044 LOGFONT
*lf
= (LOGFONT
*) logical_font
;
1046 DWORD full_type
= physical_font
->ntmTm
.ntmFlags
;
1048 entity
= font_make_entity ();
1050 ASET (entity
, FONT_TYPE_INDEX
, backend
);
1051 ASET (entity
, FONT_REGISTRY_INDEX
, w32_registry (lf
->lfCharSet
, font_type
));
1052 ASET (entity
, FONT_OBJLIST_INDEX
, Qnil
);
1054 /* Foundry is difficult to get in readable form on Windows.
1055 But Emacs crashes if it is not set, so set it to something more
1056 generic. These values make xlfds compatible with Emacs 22. */
1057 if (lf
->lfOutPrecision
== OUT_STRING_PRECIS
)
1059 else if (lf
->lfOutPrecision
== OUT_STROKE_PRECIS
)
1064 ASET (entity
, FONT_FOUNDRY_INDEX
, tem
);
1066 /* Save the generic family in the extra info, as it is likely to be
1067 useful to users looking for a close match. */
1068 generic_type
= physical_font
->ntmTm
.tmPitchAndFamily
& 0xF0;
1069 if (generic_type
== FF_DECORATIVE
)
1071 else if (generic_type
== FF_MODERN
)
1073 else if (generic_type
== FF_ROMAN
)
1075 else if (generic_type
== FF_SCRIPT
)
1077 else if (generic_type
== FF_SWISS
)
1082 ASET (entity
, FONT_ADSTYLE_INDEX
, tem
);
1084 if (physical_font
->ntmTm
.tmPitchAndFamily
& 0x01)
1085 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_PROPORTIONAL
));
1087 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_CHARCELL
));
1089 if (requested_font
->lfQuality
!= DEFAULT_QUALITY
)
1091 font_put_extra (entity
, QCantialias
,
1092 lispy_antialias_type (requested_font
->lfQuality
));
1094 ASET (entity
, FONT_FAMILY_INDEX
,
1095 intern_font_name (lf
->lfFaceName
));
1097 FONT_SET_STYLE (entity
, FONT_WEIGHT_INDEX
,
1098 make_number (w32_decode_weight (lf
->lfWeight
)));
1099 FONT_SET_STYLE (entity
, FONT_SLANT_INDEX
,
1100 make_number (lf
->lfItalic
? 200 : 100));
1101 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
1103 FONT_SET_STYLE (entity
, FONT_WIDTH_INDEX
, make_number (100));
1105 if (font_type
& RASTER_FONTTYPE
)
1106 ASET (entity
, FONT_SIZE_INDEX
,
1107 make_number (physical_font
->ntmTm
.tmHeight
1108 + physical_font
->ntmTm
.tmExternalLeading
));
1110 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
1112 /* Cache Unicode codepoints covered by this font, as there is no other way
1113 of getting this information easily. */
1114 if (font_type
& TRUETYPE_FONTTYPE
)
1116 tem
= font_supported_scripts (&physical_font
->ntmFontSig
);
1118 font_put_extra (entity
, QCscript
, tem
);
1121 /* This information is not fully available when opening fonts, so
1122 save it here. Only Windows 2000 and later return information
1123 about opentype and type1 fonts, so need a fallback for detecting
1124 truetype so that this information is not any worse than we could
1125 have obtained later. */
1126 if (EQ (backend
, Quniscribe
) && (full_type
& NTMFLAGS_OPENTYPE
))
1127 tem
= intern ("opentype");
1128 else if (font_type
& TRUETYPE_FONTTYPE
)
1129 tem
= intern ("truetype");
1130 else if (full_type
& NTM_PS_OPENTYPE
)
1131 tem
= intern ("postscript");
1132 else if (full_type
& NTM_TYPE1
)
1133 tem
= intern ("type1");
1134 else if (font_type
& RASTER_FONTTYPE
)
1135 tem
= intern ("w32bitmap");
1137 tem
= intern ("w32vector");
1139 font_put_extra (entity
, QCformat
, tem
);
1145 /* Convert generic families to the family portion of lfPitchAndFamily. */
1147 w32_generic_family (Lisp_Object name
)
1149 /* Generic families. */
1150 if (EQ (name
, Qmonospace
) || EQ (name
, Qmono
))
1152 else if (EQ (name
, Qsans
) || EQ (name
, Qsans_serif
) || EQ (name
, Qsansserif
))
1154 else if (EQ (name
, Qserif
))
1156 else if (EQ (name
, Qdecorative
))
1157 return FF_DECORATIVE
;
1158 else if (EQ (name
, Qscript
))
1165 logfonts_match (LOGFONT
*font
, LOGFONT
*pattern
)
1167 /* Only check height for raster fonts. */
1168 if (pattern
->lfHeight
&& font
->lfOutPrecision
== OUT_STRING_PRECIS
1169 && font
->lfHeight
!= pattern
->lfHeight
)
1172 /* Have some flexibility with weights. */
1173 if (pattern
->lfWeight
1174 && ((font
->lfWeight
< (pattern
->lfWeight
- 150))
1175 || font
->lfWeight
> (pattern
->lfWeight
+ 150)))
1178 /* Charset and face should be OK. Italic has to be checked
1179 against the original spec, in case we don't have any preference. */
1183 /* Codepage Bitfields in FONTSIGNATURE struct. */
1184 #define CSB_JAPANESE (1 << 17)
1185 #define CSB_KOREAN ((1 << 19) | (1 << 21))
1186 #define CSB_CHINESE ((1 << 18) | (1 << 20))
1189 font_matches_spec (DWORD type
, NEWTEXTMETRICEX
*font
,
1190 Lisp_Object spec
, Lisp_Object backend
,
1193 Lisp_Object extra
, val
;
1195 /* Check italic. Can't check logfonts, since it is a boolean field,
1196 so there is no difference between "non-italic" and "don't care". */
1198 int slant
= FONT_SLANT_NUMERIC (spec
);
1201 && ((slant
> 150 && !font
->ntmTm
.tmItalic
)
1202 || (slant
<= 150 && font
->ntmTm
.tmItalic
)))
1206 /* Check adstyle against generic family. */
1207 val
= AREF (spec
, FONT_ADSTYLE_INDEX
);
1210 BYTE family
= w32_generic_family (val
);
1211 if (family
!= FF_DONTCARE
1212 && family
!= (font
->ntmTm
.tmPitchAndFamily
& 0xF0))
1217 val
= AREF (spec
, FONT_SPACING_INDEX
);
1220 int spacing
= XINT (val
);
1221 int proportional
= (spacing
< FONT_SPACING_MONO
);
1223 if ((proportional
&& !(font
->ntmTm
.tmPitchAndFamily
& 0x01))
1224 || (!proportional
&& (font
->ntmTm
.tmPitchAndFamily
& 0x01)))
1228 /* Check extra parameters. */
1229 for (extra
= AREF (spec
, FONT_EXTRA_INDEX
);
1230 CONSP (extra
); extra
= XCDR (extra
))
1232 Lisp_Object extra_entry
;
1233 extra_entry
= XCAR (extra
);
1234 if (CONSP (extra_entry
))
1236 Lisp_Object key
= XCAR (extra_entry
);
1238 val
= XCDR (extra_entry
);
1239 if (EQ (key
, QCscript
) && SYMBOLP (val
))
1241 /* Only truetype fonts will have information about what
1242 scripts they support. This probably means the user
1243 will have to force Emacs to use raster, PostScript
1244 or ATM fonts for non-ASCII text. */
1245 if (type
& TRUETYPE_FONTTYPE
)
1248 = font_supported_scripts (&font
->ntmFontSig
);
1249 if (! memq_no_quit (val
, support
))
1252 /* Avoid using non-Japanese fonts for Japanese, even
1253 if they claim they are capable, due to known
1254 breakage in Vista and Windows 7 fonts
1257 && (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
1258 || !(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
)))
1263 /* Return specific matches, but play it safe. Fonts
1264 that cover more than their charset would suggest
1265 are likely to be truetype or opentype fonts,
1267 if (EQ (val
, Qlatin
))
1269 /* Although every charset but symbol, thai and
1270 arabic contains the basic ASCII set of latin
1271 characters, Emacs expects much more. */
1272 if (font
->ntmTm
.tmCharSet
!= ANSI_CHARSET
)
1275 else if (EQ (val
, Qsymbol
))
1277 if (font
->ntmTm
.tmCharSet
!= SYMBOL_CHARSET
)
1280 else if (EQ (val
, Qcyrillic
))
1282 if (font
->ntmTm
.tmCharSet
!= RUSSIAN_CHARSET
)
1285 else if (EQ (val
, Qgreek
))
1287 if (font
->ntmTm
.tmCharSet
!= GREEK_CHARSET
)
1290 else if (EQ (val
, Qarabic
))
1292 if (font
->ntmTm
.tmCharSet
!= ARABIC_CHARSET
)
1295 else if (EQ (val
, Qhebrew
))
1297 if (font
->ntmTm
.tmCharSet
!= HEBREW_CHARSET
)
1300 else if (EQ (val
, Qthai
))
1302 if (font
->ntmTm
.tmCharSet
!= THAI_CHARSET
)
1305 else if (EQ (val
, Qkana
))
1307 if (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1310 else if (EQ (val
, Qbopomofo
))
1312 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
)
1315 else if (EQ (val
, Qhangul
))
1317 if (font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1318 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
)
1321 else if (EQ (val
, Qhan
))
1323 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
1324 && font
->ntmTm
.tmCharSet
!= GB2312_CHARSET
1325 && font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1326 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
1327 && font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1331 /* Other scripts unlikely to be handled by non-truetype
1336 else if (EQ (key
, QClang
) && SYMBOLP (val
))
1338 /* Just handle the CJK languages here, as the lang
1339 parameter is used to select a font with appropriate
1340 glyphs in the cjk unified ideographs block. Other fonts
1341 support for a language can be solely determined by
1342 its character coverage. */
1345 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1348 else if (EQ (val
, Qko
))
1350 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_KOREAN
))
1353 else if (EQ (val
, Qzh
))
1355 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_CHINESE
))
1359 /* Any other language, we don't recognize it. Only the above
1360 currently appear in fontset.el, so it isn't worth
1361 creating a mapping table of codepages/scripts to languages
1362 or opening the font to see if there are any language tags
1363 in it that the Windows API does not expose. Fontset
1364 spec should have a fallback, as some backends do
1365 not recognize language at all. */
1368 else if (EQ (key
, QCotf
) && CONSP (val
))
1370 /* OTF features only supported by the uniscribe backend. */
1371 if (EQ (backend
, Quniscribe
))
1373 if (!uniscribe_check_otf (logfont
, val
))
1385 w32font_coverage_ok (FONTSIGNATURE
* coverage
, BYTE charset
)
1387 DWORD subrange1
= coverage
->fsUsb
[1];
1389 #define SUBRANGE1_HAN_MASK 0x08000000
1390 #define SUBRANGE1_HANGEUL_MASK 0x01000000
1391 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
1393 if (charset
== GB2312_CHARSET
|| charset
== CHINESEBIG5_CHARSET
)
1395 return (subrange1
& SUBRANGE1_HAN_MASK
) == SUBRANGE1_HAN_MASK
;
1397 else if (charset
== SHIFTJIS_CHARSET
)
1399 return (subrange1
& SUBRANGE1_JAPANESE_MASK
) == SUBRANGE1_JAPANESE_MASK
;
1401 else if (charset
== HANGEUL_CHARSET
)
1403 return (subrange1
& SUBRANGE1_HANGEUL_MASK
) == SUBRANGE1_HANGEUL_MASK
;
1410 #define _strlwr strlwr
1411 #endif /* !WINDOWSNT */
1414 check_face_name (LOGFONT
*font
, char *full_name
)
1416 char full_iname
[LF_FULLFACESIZE
+1];
1418 /* Just check for names known to cause problems, since the full name
1419 can contain expanded abbreviations, prefixed foundry, postfixed
1420 style, the latter of which sometimes differs from the style indicated
1421 in the shorter name (eg Lt becomes Light or even Extra Light) */
1423 /* Helvetica is mapped to Arial in Windows, but if a Type-1 Helvetica is
1424 installed, we run into problems with the Uniscribe backend which tries
1425 to avoid non-truetype fonts, and ends up mixing the Type-1 Helvetica
1426 with Arial's characteristics, since that attempt to use TrueType works
1427 some places, but not others. */
1428 if (!xstrcasecmp (font
->lfFaceName
, "helvetica"))
1430 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1431 full_iname
[LF_FULLFACESIZE
] = 0;
1432 _strlwr (full_iname
);
1433 return strstr ("helvetica", full_iname
) != NULL
;
1435 /* Same for Helv. */
1436 if (!xstrcasecmp (font
->lfFaceName
, "helv"))
1438 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1439 full_iname
[LF_FULLFACESIZE
] = 0;
1440 _strlwr (full_iname
);
1441 return strstr ("helv", full_iname
) != NULL
;
1444 /* Since Times is mapped to Times New Roman, a substring
1445 match is not sufficient to filter out the bogus match. */
1446 else if (!xstrcasecmp (font
->lfFaceName
, "times"))
1447 return xstrcasecmp (full_name
, "times") == 0;
1453 /* Callback function for EnumFontFamiliesEx.
1454 * Checks if a font matches everything we are trying to check against,
1455 * and if so, adds it to a list. Both the data we are checking against
1456 * and the list to which the fonts are added are passed in via the
1457 * lparam argument, in the form of a font_callback_data struct. */
1459 add_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1460 NEWTEXTMETRICEX
*physical_font
,
1461 DWORD font_type
, LPARAM lParam
)
1463 struct font_callback_data
*match_data
1464 = (struct font_callback_data
*) lParam
;
1465 Lisp_Object backend
= match_data
->opentype_only
? Quniscribe
: Qgdi
;
1468 int is_unicode
= physical_font
->ntmFontSig
.fsUsb
[3]
1469 || physical_font
->ntmFontSig
.fsUsb
[2]
1470 || physical_font
->ntmFontSig
.fsUsb
[1]
1471 || physical_font
->ntmFontSig
.fsUsb
[0] & 0x3fffffff;
1473 /* Skip non matching fonts. */
1475 /* For uniscribe backend, consider only truetype or opentype fonts
1476 that have some Unicode coverage. */
1477 if (match_data
->opentype_only
1478 && ((!(physical_font
->ntmTm
.ntmFlags
& NTMFLAGS_OPENTYPE
)
1479 && !(font_type
& TRUETYPE_FONTTYPE
))
1483 /* Ensure a match. */
1484 if (!logfonts_match (&logical_font
->elfLogFont
, &match_data
->pattern
)
1485 || !font_matches_spec (font_type
, physical_font
,
1486 match_data
->orig_font_spec
, backend
,
1487 &logical_font
->elfLogFont
)
1488 || !w32font_coverage_ok (&physical_font
->ntmFontSig
,
1489 match_data
->pattern
.lfCharSet
))
1492 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
1493 We limit this to raster fonts, because the test can catch some
1494 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
1495 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
1496 therefore get through this test. Since full names can be prefixed
1497 by a foundry, we accept raster fonts if the font name is found
1498 anywhere within the full name. */
1499 if ((logical_font
->elfLogFont
.lfOutPrecision
== OUT_STRING_PRECIS
1500 && !strstr (logical_font
->elfFullName
,
1501 logical_font
->elfLogFont
.lfFaceName
))
1502 /* Check for well known substitutions that mess things up in the
1503 presence of Type-1 fonts of the same name. */
1504 || (!check_face_name (&logical_font
->elfLogFont
,
1505 logical_font
->elfFullName
)))
1508 /* Make a font entity for the font. */
1509 entity
= w32_enumfont_pattern_entity (match_data
->frame
, logical_font
,
1510 physical_font
, font_type
,
1511 &match_data
->pattern
,
1516 Lisp_Object spec_charset
= AREF (match_data
->orig_font_spec
,
1517 FONT_REGISTRY_INDEX
);
1519 /* iso10646-1 fonts must contain Unicode mapping tables. */
1520 if (EQ (spec_charset
, Qiso10646_1
))
1525 /* unicode-bmp fonts must contain characters from the BMP. */
1526 else if (EQ (spec_charset
, Qunicode_bmp
))
1528 if (!physical_font
->ntmFontSig
.fsUsb
[3]
1529 && !(physical_font
->ntmFontSig
.fsUsb
[2] & 0xFFFFFF9E)
1530 && !(physical_font
->ntmFontSig
.fsUsb
[1] & 0xE81FFFFF)
1531 && !(physical_font
->ntmFontSig
.fsUsb
[0] & 0x007F001F))
1534 /* unicode-sip fonts must contain characters in Unicode plane 2.
1535 so look for bit 57 (surrogates) in the Unicode subranges, plus
1536 the bits for CJK ranges that include those characters. */
1537 else if (EQ (spec_charset
, Qunicode_sip
))
1539 if (!(physical_font
->ntmFontSig
.fsUsb
[1] & 0x02000000)
1540 || !(physical_font
->ntmFontSig
.fsUsb
[1] & 0x28000000))
1544 /* This font matches. */
1546 /* If registry was specified, ensure it is reported as the same. */
1547 if (!NILP (spec_charset
))
1549 /* Avoid using non-Japanese fonts for Japanese, even if they
1550 claim they are capable, due to known breakage in Vista
1551 and Windows 7 fonts (bug#6029). */
1552 if (logical_font
->elfLogFont
.lfCharSet
== SHIFTJIS_CHARSET
1553 && !(physical_font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1556 ASET (entity
, FONT_REGISTRY_INDEX
, spec_charset
);
1558 /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
1559 fonts as Unicode and skip other charsets. */
1560 else if (match_data
->opentype_only
)
1562 if (logical_font
->elfLogFont
.lfCharSet
== ANSI_CHARSET
1563 || logical_font
->elfLogFont
.lfCharSet
== DEFAULT_CHARSET
)
1564 ASET (entity
, FONT_REGISTRY_INDEX
, Qiso10646_1
);
1569 /* Add this font to the list. */
1570 match_data
->list
= Fcons (entity
, match_data
->list
);
1575 /* Callback function for EnumFontFamiliesEx.
1576 * Terminates the search once we have a match. */
1578 add_one_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1579 NEWTEXTMETRICEX
*physical_font
,
1580 DWORD font_type
, LPARAM lParam
)
1582 struct font_callback_data
*match_data
1583 = (struct font_callback_data
*) lParam
;
1584 add_font_entity_to_list (logical_font
, physical_font
, font_type
, lParam
);
1586 /* If we have a font in the list, terminate the search. */
1587 return NILP (match_data
->list
);
1590 /* Old function to convert from x to w32 charset, from w32fns.c. */
1592 x_to_w32_charset (char * lpcs
)
1594 Lisp_Object this_entry
, w32_charset
;
1596 int len
= strlen (lpcs
);
1598 /* Support "*-#nnn" format for unknown charsets. */
1599 if (strncmp (lpcs
, "*-#", 3) == 0)
1600 return atoi (lpcs
+ 3);
1602 /* All Windows fonts qualify as Unicode. */
1603 if (!strncmp (lpcs
, "iso10646", 8))
1604 return DEFAULT_CHARSET
;
1606 /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */
1607 charset
= alloca (len
+ 1);
1608 strcpy (charset
, lpcs
);
1609 lpcs
= strchr (charset
, '*');
1613 /* Look through w32-charset-info-alist for the character set.
1614 Format of each entry is
1615 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1617 this_entry
= Fassoc (build_string (charset
), Vw32_charset_info_alist
);
1619 if (NILP (this_entry
))
1621 /* At startup, we want iso8859-1 fonts to come up properly. */
1622 if (xstrcasecmp (charset
, "iso8859-1") == 0)
1623 return ANSI_CHARSET
;
1625 return DEFAULT_CHARSET
;
1628 w32_charset
= Fcar (Fcdr (this_entry
));
1630 /* Translate Lisp symbol to number. */
1631 if (EQ (w32_charset
, Qw32_charset_ansi
))
1632 return ANSI_CHARSET
;
1633 if (EQ (w32_charset
, Qw32_charset_symbol
))
1634 return SYMBOL_CHARSET
;
1635 if (EQ (w32_charset
, Qw32_charset_shiftjis
))
1636 return SHIFTJIS_CHARSET
;
1637 if (EQ (w32_charset
, Qw32_charset_hangeul
))
1638 return HANGEUL_CHARSET
;
1639 if (EQ (w32_charset
, Qw32_charset_chinesebig5
))
1640 return CHINESEBIG5_CHARSET
;
1641 if (EQ (w32_charset
, Qw32_charset_gb2312
))
1642 return GB2312_CHARSET
;
1643 if (EQ (w32_charset
, Qw32_charset_oem
))
1645 if (EQ (w32_charset
, Qw32_charset_johab
))
1646 return JOHAB_CHARSET
;
1647 if (EQ (w32_charset
, Qw32_charset_easteurope
))
1648 return EASTEUROPE_CHARSET
;
1649 if (EQ (w32_charset
, Qw32_charset_turkish
))
1650 return TURKISH_CHARSET
;
1651 if (EQ (w32_charset
, Qw32_charset_baltic
))
1652 return BALTIC_CHARSET
;
1653 if (EQ (w32_charset
, Qw32_charset_russian
))
1654 return RUSSIAN_CHARSET
;
1655 if (EQ (w32_charset
, Qw32_charset_arabic
))
1656 return ARABIC_CHARSET
;
1657 if (EQ (w32_charset
, Qw32_charset_greek
))
1658 return GREEK_CHARSET
;
1659 if (EQ (w32_charset
, Qw32_charset_hebrew
))
1660 return HEBREW_CHARSET
;
1661 if (EQ (w32_charset
, Qw32_charset_vietnamese
))
1662 return VIETNAMESE_CHARSET
;
1663 if (EQ (w32_charset
, Qw32_charset_thai
))
1664 return THAI_CHARSET
;
1665 if (EQ (w32_charset
, Qw32_charset_mac
))
1668 return DEFAULT_CHARSET
;
1672 /* Convert a Lisp font registry (symbol) to a windows charset. */
1674 registry_to_w32_charset (Lisp_Object charset
)
1676 if (EQ (charset
, Qiso10646_1
) || EQ (charset
, Qunicode_bmp
)
1677 || EQ (charset
, Qunicode_sip
))
1678 return DEFAULT_CHARSET
; /* UNICODE_CHARSET not defined in MingW32 */
1679 else if (EQ (charset
, Qiso8859_1
))
1680 return ANSI_CHARSET
;
1681 else if (SYMBOLP (charset
))
1682 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset
)));
1684 return DEFAULT_CHARSET
;
1687 /* Old function to convert from w32 to x charset, from w32fns.c. */
1689 w32_to_x_charset (int fncharset
, char *matching
)
1691 static char buf
[32];
1692 Lisp_Object charset_type
;
1697 /* If fully specified, accept it as it is. Otherwise use a
1699 char *wildcard
= strchr (matching
, '*');
1702 else if (strchr (matching
, '-'))
1705 match_len
= strlen (matching
);
1711 /* Handle startup case of w32-charset-info-alist not
1712 being set up yet. */
1713 if (NILP (Vw32_charset_info_alist
))
1715 charset_type
= Qw32_charset_ansi
;
1717 case DEFAULT_CHARSET
:
1718 charset_type
= Qw32_charset_default
;
1720 case SYMBOL_CHARSET
:
1721 charset_type
= Qw32_charset_symbol
;
1723 case SHIFTJIS_CHARSET
:
1724 charset_type
= Qw32_charset_shiftjis
;
1726 case HANGEUL_CHARSET
:
1727 charset_type
= Qw32_charset_hangeul
;
1729 case GB2312_CHARSET
:
1730 charset_type
= Qw32_charset_gb2312
;
1732 case CHINESEBIG5_CHARSET
:
1733 charset_type
= Qw32_charset_chinesebig5
;
1736 charset_type
= Qw32_charset_oem
;
1738 case EASTEUROPE_CHARSET
:
1739 charset_type
= Qw32_charset_easteurope
;
1741 case TURKISH_CHARSET
:
1742 charset_type
= Qw32_charset_turkish
;
1744 case BALTIC_CHARSET
:
1745 charset_type
= Qw32_charset_baltic
;
1747 case RUSSIAN_CHARSET
:
1748 charset_type
= Qw32_charset_russian
;
1750 case ARABIC_CHARSET
:
1751 charset_type
= Qw32_charset_arabic
;
1754 charset_type
= Qw32_charset_greek
;
1756 case HEBREW_CHARSET
:
1757 charset_type
= Qw32_charset_hebrew
;
1759 case VIETNAMESE_CHARSET
:
1760 charset_type
= Qw32_charset_vietnamese
;
1763 charset_type
= Qw32_charset_thai
;
1766 charset_type
= Qw32_charset_mac
;
1769 charset_type
= Qw32_charset_johab
;
1773 /* Encode numerical value of unknown charset. */
1774 sprintf (buf
, "*-#%u", fncharset
);
1780 char * best_match
= NULL
;
1781 int matching_found
= 0;
1783 /* Look through w32-charset-info-alist for the character set.
1784 Prefer ISO codepages, and prefer lower numbers in the ISO
1785 range. Only return charsets for codepages which are installed.
1787 Format of each entry is
1788 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1790 for (rest
= Vw32_charset_info_alist
; CONSP (rest
); rest
= XCDR (rest
))
1793 Lisp_Object w32_charset
;
1794 Lisp_Object codepage
;
1796 Lisp_Object this_entry
= XCAR (rest
);
1798 /* Skip invalid entries in alist. */
1799 if (!CONSP (this_entry
) || !STRINGP (XCAR (this_entry
))
1800 || !CONSP (XCDR (this_entry
))
1801 || !SYMBOLP (XCAR (XCDR (this_entry
))))
1804 x_charset
= SDATA (XCAR (this_entry
));
1805 w32_charset
= XCAR (XCDR (this_entry
));
1806 codepage
= XCDR (XCDR (this_entry
));
1808 /* Look for Same charset and a valid codepage (or non-int
1809 which means ignore). */
1810 if (EQ (w32_charset
, charset_type
)
1811 && (!INTEGERP (codepage
) || XINT (codepage
) == CP_DEFAULT
1812 || IsValidCodePage (XINT (codepage
))))
1814 /* If we don't have a match already, then this is the
1818 best_match
= x_charset
;
1819 if (matching
&& !strnicmp (x_charset
, matching
, match_len
))
1822 /* If we already found a match for MATCHING, then
1823 only consider other matches. */
1824 else if (matching_found
1825 && strnicmp (x_charset
, matching
, match_len
))
1827 /* If this matches what we want, and the best so far doesn't,
1828 then this is better. */
1829 else if (!matching_found
&& matching
1830 && !strnicmp (x_charset
, matching
, match_len
))
1832 best_match
= x_charset
;
1835 /* If this is fully specified, and the best so far isn't,
1836 then this is better. */
1837 else if ((!strchr (best_match
, '-') && strchr (x_charset
, '-'))
1838 /* If this is an ISO codepage, and the best so far isn't,
1839 then this is better, but only if it fully specifies the
1841 || (strnicmp (best_match
, "iso", 3) != 0
1842 && strnicmp (x_charset
, "iso", 3) == 0
1843 && strchr (x_charset
, '-')))
1844 best_match
= x_charset
;
1845 /* If both are ISO8859 codepages, choose the one with the
1846 lowest number in the encoding field. */
1847 else if (strnicmp (best_match
, "iso8859-", 8) == 0
1848 && strnicmp (x_charset
, "iso8859-", 8) == 0)
1850 int best_enc
= atoi (best_match
+ 8);
1851 int this_enc
= atoi (x_charset
+ 8);
1852 if (this_enc
> 0 && this_enc
< best_enc
)
1853 best_match
= x_charset
;
1858 /* If no match, encode the numeric value. */
1861 sprintf (buf
, "*-#%u", fncharset
);
1865 strncpy (buf
, best_match
, 31);
1866 /* If the charset is not fully specified, put -0 on the end. */
1867 if (!strchr (best_match
, '-'))
1869 int pos
= strlen (best_match
);
1870 /* Charset specifiers shouldn't be very long. If it is a made
1871 up one, truncating it should not do any harm since it isn't
1872 recognized anyway. */
1875 strcpy (buf
+ pos
, "-0");
1883 w32_registry (LONG w32_charset
, DWORD font_type
)
1887 /* If charset is defaulted, charset is Unicode or unknown, depending on
1889 if (w32_charset
== DEFAULT_CHARSET
)
1890 return font_type
== TRUETYPE_FONTTYPE
? Qiso10646_1
: Qunknown
;
1892 charset
= w32_to_x_charset (w32_charset
, NULL
);
1893 return font_intern_prop (charset
, strlen (charset
), 1);
1897 w32_decode_weight (int fnweight
)
1899 if (fnweight
>= FW_HEAVY
) return 210;
1900 if (fnweight
>= FW_EXTRABOLD
) return 205;
1901 if (fnweight
>= FW_BOLD
) return 200;
1902 if (fnweight
>= FW_SEMIBOLD
) return 180;
1903 if (fnweight
>= FW_NORMAL
) return 100;
1904 if (fnweight
>= FW_LIGHT
) return 50;
1905 if (fnweight
>= FW_EXTRALIGHT
) return 40;
1906 if (fnweight
> FW_THIN
) return 20;
1911 w32_encode_weight (int n
)
1913 if (n
>= 210) return FW_HEAVY
;
1914 if (n
>= 205) return FW_EXTRABOLD
;
1915 if (n
>= 200) return FW_BOLD
;
1916 if (n
>= 180) return FW_SEMIBOLD
;
1917 if (n
>= 100) return FW_NORMAL
;
1918 if (n
>= 50) return FW_LIGHT
;
1919 if (n
>= 40) return FW_EXTRALIGHT
;
1920 if (n
>= 20) return FW_THIN
;
1924 /* Convert a Windows font weight into one of the weights supported
1925 by fontconfig (see font.c:font_parse_fcname). */
1927 w32_to_fc_weight (int n
)
1929 if (n
>= FW_EXTRABOLD
) return intern ("black");
1930 if (n
>= FW_BOLD
) return intern ("bold");
1931 if (n
>= FW_SEMIBOLD
) return intern ("demibold");
1932 if (n
>= FW_NORMAL
) return intern ("medium");
1933 return intern ("light");
1936 /* Fill in all the available details of LOGFONT from FONT_SPEC. */
1938 fill_in_logfont (struct frame
*f
, LOGFONT
*logfont
, Lisp_Object font_spec
)
1940 Lisp_Object tmp
, extra
;
1941 int dpi
= FRAME_RES_Y (f
);
1943 tmp
= AREF (font_spec
, FONT_DPI_INDEX
);
1948 else if (FLOATP (tmp
))
1950 dpi
= (int) (XFLOAT_DATA (tmp
) + 0.5);
1954 tmp
= AREF (font_spec
, FONT_SIZE_INDEX
);
1956 logfont
->lfHeight
= -1 * XINT (tmp
);
1957 else if (FLOATP (tmp
))
1958 logfont
->lfHeight
= (int) (-1.0 * dpi
* XFLOAT_DATA (tmp
) / 72.27 + 0.5);
1965 tmp
= AREF (font_spec
, FONT_WEIGHT_INDEX
);
1967 logfont
->lfWeight
= w32_encode_weight (FONT_WEIGHT_NUMERIC (font_spec
));
1970 tmp
= AREF (font_spec
, FONT_SLANT_INDEX
);
1973 int slant
= FONT_SLANT_NUMERIC (font_spec
);
1974 logfont
->lfItalic
= slant
> 150 ? 1 : 0;
1982 tmp
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
1984 logfont
->lfCharSet
= registry_to_w32_charset (tmp
);
1986 logfont
->lfCharSet
= DEFAULT_CHARSET
;
1990 /* Clip Precision */
1993 logfont
->lfQuality
= DEFAULT_QUALITY
;
1995 /* Generic Family and Face Name */
1996 logfont
->lfPitchAndFamily
= FF_DONTCARE
| DEFAULT_PITCH
;
1998 tmp
= AREF (font_spec
, FONT_FAMILY_INDEX
);
2001 logfont
->lfPitchAndFamily
= w32_generic_family (tmp
) | DEFAULT_PITCH
;
2002 if ((logfont
->lfPitchAndFamily
& 0xF0) != FF_DONTCARE
)
2003 ; /* Font name was generic, don't fill in font name. */
2004 /* Font families are interned, but allow for strings also in case of
2006 else if (SYMBOLP (tmp
))
2008 strncpy (logfont
->lfFaceName
,
2009 SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp
))), LF_FACESIZE
);
2010 logfont
->lfFaceName
[LF_FACESIZE
-1] = '\0';
2014 tmp
= AREF (font_spec
, FONT_ADSTYLE_INDEX
);
2017 /* Override generic family. */
2018 BYTE family
= w32_generic_family (tmp
);
2019 if (family
!= FF_DONTCARE
)
2020 logfont
->lfPitchAndFamily
= family
| DEFAULT_PITCH
;
2023 /* Set pitch based on the spacing property. */
2024 tmp
= AREF (font_spec
, FONT_SPACING_INDEX
);
2027 int spacing
= XINT (tmp
);
2028 if (spacing
< FONT_SPACING_MONO
)
2029 logfont
->lfPitchAndFamily
2030 = (logfont
->lfPitchAndFamily
& 0xF0) | VARIABLE_PITCH
;
2032 logfont
->lfPitchAndFamily
2033 = (logfont
->lfPitchAndFamily
& 0xF0) | FIXED_PITCH
;
2036 /* Process EXTRA info. */
2037 for (extra
= AREF (font_spec
, FONT_EXTRA_INDEX
);
2038 CONSP (extra
); extra
= XCDR (extra
))
2043 Lisp_Object key
, val
;
2044 key
= XCAR (tmp
), val
= XCDR (tmp
);
2045 /* Only use QCscript if charset is not provided, or is Unicode
2046 and a single script is specified. This is rather crude,
2047 and is only used to narrow down the fonts returned where
2048 there is a definite match. Some scripts, such as latin, han,
2049 cjk-misc match multiple lfCharSet values, so we can't pre-filter
2051 if (EQ (key
, QCscript
)
2052 && logfont
->lfCharSet
== DEFAULT_CHARSET
2055 if (EQ (val
, Qgreek
))
2056 logfont
->lfCharSet
= GREEK_CHARSET
;
2057 else if (EQ (val
, Qhangul
))
2058 logfont
->lfCharSet
= HANGUL_CHARSET
;
2059 else if (EQ (val
, Qkana
) || EQ (val
, Qkanbun
))
2060 logfont
->lfCharSet
= SHIFTJIS_CHARSET
;
2061 else if (EQ (val
, Qbopomofo
))
2062 logfont
->lfCharSet
= CHINESEBIG5_CHARSET
;
2063 /* GB 18030 supports tibetan, yi, mongolian,
2064 fonts that support it should show up if we ask for
2066 else if (EQ (val
, Qtibetan
) || EQ (val
, Qyi
)
2067 || EQ (val
, Qmongolian
))
2068 logfont
->lfCharSet
= GB2312_CHARSET
;
2069 else if (EQ (val
, Qhebrew
))
2070 logfont
->lfCharSet
= HEBREW_CHARSET
;
2071 else if (EQ (val
, Qarabic
))
2072 logfont
->lfCharSet
= ARABIC_CHARSET
;
2073 else if (EQ (val
, Qthai
))
2074 logfont
->lfCharSet
= THAI_CHARSET
;
2076 else if (EQ (key
, QCantialias
) && SYMBOLP (val
))
2078 logfont
->lfQuality
= w32_antialias_type (val
);
2085 list_all_matching_fonts (struct font_callback_data
*match_data
)
2088 Lisp_Object families
= w32font_list_family (XFRAME (match_data
->frame
));
2089 struct frame
*f
= XFRAME (match_data
->frame
);
2091 dc
= get_frame_dc (f
);
2093 while (!NILP (families
))
2095 /* Only fonts from the current locale are given localized names
2096 on Windows, so we can keep backwards compatibility with
2097 Windows 9x/ME by using non-Unicode font enumeration without
2098 sacrificing internationalization here. */
2100 Lisp_Object family
= CAR (families
);
2101 families
= CDR (families
);
2104 else if (SYMBOLP (family
))
2105 name
= SDATA (ENCODE_SYSTEM (SYMBOL_NAME (family
)));
2109 strncpy (match_data
->pattern
.lfFaceName
, name
, LF_FACESIZE
);
2110 match_data
->pattern
.lfFaceName
[LF_FACESIZE
- 1] = '\0';
2112 EnumFontFamiliesEx (dc
, &match_data
->pattern
,
2113 (FONTENUMPROC
) add_font_entity_to_list
,
2114 (LPARAM
) match_data
, 0);
2117 release_frame_dc (f
, dc
);
2121 lispy_antialias_type (BYTE type
)
2127 case NONANTIALIASED_QUALITY
:
2130 case ANTIALIASED_QUALITY
:
2133 case CLEARTYPE_QUALITY
:
2136 case CLEARTYPE_NATURAL_QUALITY
:
2146 /* Convert antialiasing symbols to lfQuality */
2148 w32_antialias_type (Lisp_Object type
)
2150 if (EQ (type
, Qnone
))
2151 return NONANTIALIASED_QUALITY
;
2152 else if (EQ (type
, Qstandard
))
2153 return ANTIALIASED_QUALITY
;
2154 else if (EQ (type
, Qsubpixel
))
2155 return CLEARTYPE_QUALITY
;
2156 else if (EQ (type
, Qnatural
))
2157 return CLEARTYPE_NATURAL_QUALITY
;
2159 return DEFAULT_QUALITY
;
2162 /* Return a list of all the scripts that the font supports. */
2164 font_supported_scripts (FONTSIGNATURE
* sig
)
2166 DWORD
* subranges
= sig
->fsUsb
;
2167 Lisp_Object supported
= Qnil
;
2169 /* Match a single subrange. SYM is set if bit N is set in subranges. */
2170 #define SUBRANGE(n,sym) \
2171 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
2172 supported = Fcons ((sym), supported)
2174 /* Match multiple subranges. SYM is set if any MASK bit is set in
2175 subranges[0 - 3]. */
2176 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
2177 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
2178 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
2179 supported = Fcons ((sym), supported)
2181 SUBRANGE (0, Qlatin
);
2182 /* The following count as latin too, ASCII should be present in these fonts,
2183 so don't need to mark them separately. */
2184 /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */
2185 SUBRANGE (4, Qphonetic
);
2186 /* 5: Spacing and tone modifiers, 6: Combining Diacritical Marks. */
2187 SUBRANGE (7, Qgreek
);
2188 SUBRANGE (8, Qcoptic
);
2189 SUBRANGE (9, Qcyrillic
);
2190 SUBRANGE (10, Qarmenian
);
2191 SUBRANGE (11, Qhebrew
);
2193 SUBRANGE (13, Qarabic
);
2194 SUBRANGE (14, Qnko
);
2195 SUBRANGE (15, Qdevanagari
);
2196 SUBRANGE (16, Qbengali
);
2197 SUBRANGE (17, Qgurmukhi
);
2198 SUBRANGE (18, Qgujarati
);
2199 SUBRANGE (19, Qoriya
);
2200 SUBRANGE (20, Qtamil
);
2201 SUBRANGE (21, Qtelugu
);
2202 SUBRANGE (22, Qkannada
);
2203 SUBRANGE (23, Qmalayalam
);
2204 SUBRANGE (24, Qthai
);
2205 SUBRANGE (25, Qlao
);
2206 SUBRANGE (26, Qgeorgian
);
2207 SUBRANGE (27, Qbalinese
);
2208 /* 28: Hangul Jamo. */
2209 /* 29: Latin Extended, 30: Greek Extended, 31: Punctuation. */
2210 /* 32-47: Symbols (defined below). */
2211 SUBRANGE (48, Qcjk_misc
);
2212 /* Match either 49: katakana or 50: hiragana for kana. */
2213 MASK_ANY (0, 0x00060000, 0, 0, Qkana
);
2214 SUBRANGE (51, Qbopomofo
);
2215 /* 52: Compatibility Jamo */
2216 SUBRANGE (53, Qphags_pa
);
2217 /* 54: Enclosed CJK letters and months, 55: CJK Compatibility. */
2218 SUBRANGE (56, Qhangul
);
2219 /* 57: Surrogates. */
2220 SUBRANGE (58, Qphoenician
);
2221 SUBRANGE (59, Qhan
); /* There are others, but this is the main one. */
2222 SUBRANGE (59, Qideographic_description
); /* Windows lumps this in. */
2223 SUBRANGE (59, Qkanbun
); /* And this. */
2224 /* 60: Private use, 61: CJK strokes and compatibility. */
2225 /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */
2226 /* 64: Combining half marks, 65: Vertical and CJK compatibility. */
2227 /* 66: Small forms, 67: Arabic Presentation B, 68: Half and Full width. */
2229 SUBRANGE (70, Qtibetan
);
2230 SUBRANGE (71, Qsyriac
);
2231 SUBRANGE (72, Qthaana
);
2232 SUBRANGE (73, Qsinhala
);
2233 SUBRANGE (74, Qmyanmar
);
2234 SUBRANGE (75, Qethiopic
);
2235 SUBRANGE (76, Qcherokee
);
2236 SUBRANGE (77, Qcanadian_aboriginal
);
2237 SUBRANGE (78, Qogham
);
2238 SUBRANGE (79, Qrunic
);
2239 SUBRANGE (80, Qkhmer
);
2240 SUBRANGE (81, Qmongolian
);
2241 SUBRANGE (82, Qbraille
);
2243 SUBRANGE (84, Qbuhid
);
2244 SUBRANGE (84, Qhanunoo
);
2245 SUBRANGE (84, Qtagalog
);
2246 SUBRANGE (84, Qtagbanwa
);
2247 SUBRANGE (85, Qold_italic
);
2248 SUBRANGE (86, Qgothic
);
2249 SUBRANGE (87, Qdeseret
);
2250 SUBRANGE (88, Qbyzantine_musical_symbol
);
2251 SUBRANGE (88, Qmusical_symbol
); /* Windows doesn't distinguish these. */
2252 SUBRANGE (89, Qmathematical
);
2253 /* 90: Private use, 91: Variation selectors, 92: Tags. */
2254 SUBRANGE (93, Qlimbu
);
2255 SUBRANGE (94, Qtai_le
);
2256 /* 95: New Tai Le */
2257 SUBRANGE (90, Qbuginese
);
2258 SUBRANGE (97, Qglagolitic
);
2259 SUBRANGE (98, Qtifinagh
);
2260 /* 99: Yijing Hexagrams. */
2261 SUBRANGE (100, Qsyloti_nagri
);
2262 SUBRANGE (101, Qlinear_b
);
2263 /* 102: Ancient Greek Numbers. */
2264 SUBRANGE (103, Qugaritic
);
2265 SUBRANGE (104, Qold_persian
);
2266 SUBRANGE (105, Qshavian
);
2267 SUBRANGE (106, Qosmanya
);
2268 SUBRANGE (107, Qcypriot
);
2269 SUBRANGE (108, Qkharoshthi
);
2270 /* 109: Tai Xuan Jing. */
2271 SUBRANGE (110, Qcuneiform
);
2272 /* 111: Counting Rods, 112: Sundanese, 113: Lepcha, 114: Ol Chiki. */
2273 /* 115: Saurashtra, 116: Kayah Li, 117: Rejang. */
2274 SUBRANGE (118, Qcham
);
2275 /* 119: Ancient symbols, 120: Phaistos Disc. */
2276 /* 121: Carian, Lycian, Lydian, 122: Dominoes, Mahjong tiles. */
2277 /* 123-127: Reserved. */
2279 /* There isn't really a main symbol range, so include symbol if any
2280 relevant range is set. */
2281 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol
);
2283 /* Missing: Tai Viet (U+AA80-U+AADF). */
2290 /* Generate a full name for a Windows font.
2291 The full name is in fcname format, with weight, slant and antialiasing
2292 specified if they are not "normal". */
2294 w32font_full_name (LOGFONT
* font
, Lisp_Object font_obj
,
2295 int pixel_size
, char *name
, int nbytes
)
2297 int len
, height
, outline
;
2299 Lisp_Object antialiasing
, weight
= Qnil
;
2301 len
= strlen (font
->lfFaceName
);
2303 outline
= EQ (AREF (font_obj
, FONT_FOUNDRY_INDEX
), Qoutline
);
2305 /* Represent size of scalable fonts by point size. But use pixelsize for
2306 raster fonts to indicate that they are exactly that size. */
2308 len
+= 11; /* -SIZE */
2313 len
+= 7; /* :italic */
2315 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2317 weight
= w32_to_fc_weight (font
->lfWeight
);
2318 len
+= 1 + SBYTES (SYMBOL_NAME (weight
)); /* :WEIGHT */
2321 antialiasing
= lispy_antialias_type (font
->lfQuality
);
2322 if (! NILP (antialiasing
))
2323 len
+= 11 + SBYTES (SYMBOL_NAME (antialiasing
)); /* :antialias=NAME */
2325 /* Check that the buffer is big enough */
2330 p
+= sprintf (p
, "%s", font
->lfFaceName
);
2332 height
= font
->lfHeight
? eabs (font
->lfHeight
) : pixel_size
;
2338 float pointsize
= height
* 72.0 / one_w32_display_info
.resy
;
2339 /* Round to nearest half point. floor is used, since round is not
2340 supported in MS library. */
2341 pointsize
= floor (pointsize
* 2 + 0.5) / 2;
2342 p
+= sprintf (p
, "-%1.1f", pointsize
);
2345 p
+= sprintf (p
, ":pixelsize=%d", height
);
2348 if (SYMBOLP (weight
) && ! NILP (weight
))
2349 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2352 p
+= sprintf (p
, ":italic");
2354 if (SYMBOLP (antialiasing
) && ! NILP (antialiasing
))
2355 p
+= sprintf (p
, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing
)));
2360 /* Convert a logfont and point size into a fontconfig style font name.
2361 POINTSIZE is in tenths of points.
2362 If SIZE indicates the size of buffer FCNAME, into which the font name
2363 is written. If the buffer is not large enough to contain the name,
2364 the function returns -1, otherwise it returns the number of bytes
2365 written to FCNAME. */
2367 logfont_to_fcname (LOGFONT
* font
, int pointsize
, char *fcname
, int size
)
2371 Lisp_Object weight
= Qnil
;
2373 len
= strlen (font
->lfFaceName
) + 2;
2374 height
= pointsize
/ 10;
2375 while (height
/= 10)
2382 len
+= 7; /* :italic */
2383 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2385 weight
= w32_to_fc_weight (font
->lfWeight
);
2386 len
+= SBYTES (SYMBOL_NAME (weight
)) + 1;
2392 p
+= sprintf (p
, "%s-%d", font
->lfFaceName
, pointsize
/ 10);
2394 p
+= sprintf (p
, ".%d", pointsize
% 10);
2396 if (SYMBOLP (weight
) && !NILP (weight
))
2397 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2400 p
+= sprintf (p
, ":italic");
2402 return (p
- fcname
);
2406 compute_metrics (HDC dc
, struct w32font_info
*w32_font
, unsigned int code
,
2407 struct w32_metric_cache
*metrics
)
2411 unsigned int options
= GGO_METRICS
;
2414 if (w32_font
->glyph_idx
)
2415 options
|= GGO_GLYPH_INDEX
;
2417 memset (&transform
, 0, sizeof (transform
));
2418 transform
.eM11
.value
= 1;
2419 transform
.eM22
.value
= 1;
2421 if (get_glyph_outline_w (dc
, code
, options
, &gm
, 0, NULL
, &transform
)
2424 metrics
->lbearing
= gm
.gmptGlyphOrigin
.x
;
2425 metrics
->rbearing
= gm
.gmptGlyphOrigin
.x
+ gm
.gmBlackBoxX
;
2426 metrics
->width
= gm
.gmCellIncX
;
2427 metrics
->status
= W32METRIC_SUCCESS
;
2429 else if (get_char_width_32_w (dc
, code
, code
, &width
) != 0)
2431 metrics
->lbearing
= 0;
2432 metrics
->rbearing
= width
;
2433 metrics
->width
= width
;
2434 metrics
->status
= W32METRIC_SUCCESS
;
2437 metrics
->status
= W32METRIC_FAIL
;
2440 DEFUN ("x-select-font", Fx_select_font
, Sx_select_font
, 0, 2, 0,
2441 doc
: /* Read a font name using a W32 font selection dialog.
2442 Return fontconfig style font string corresponding to the selection.
2444 If FRAME is omitted or nil, it defaults to the selected frame.
2445 If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts
2446 in the font selection dialog. */)
2447 (Lisp_Object frame
, Lisp_Object exclude_proportional
)
2449 struct frame
*f
= decode_window_system_frame (frame
);
2457 memset (&cf
, 0, sizeof (cf
));
2458 memset (&lf
, 0, sizeof (lf
));
2460 cf
.lStructSize
= sizeof (cf
);
2461 cf
.hwndOwner
= FRAME_W32_WINDOW (f
);
2462 cf
.Flags
= CF_FORCEFONTEXIST
| CF_SCREENFONTS
| CF_NOVERTFONTS
;
2464 /* If exclude_proportional is non-nil, limit the selection to
2465 monospaced fonts. */
2466 if (!NILP (exclude_proportional
))
2467 cf
.Flags
|= CF_FIXEDPITCHONLY
;
2471 /* Initialize as much of the font details as we can from the current
2473 hdc
= GetDC (FRAME_W32_WINDOW (f
));
2474 oldobj
= SelectObject (hdc
, FONT_HANDLE (FRAME_FONT (f
)));
2475 GetTextFace (hdc
, LF_FACESIZE
, lf
.lfFaceName
);
2476 if (GetTextMetrics (hdc
, &tm
))
2478 lf
.lfHeight
= tm
.tmInternalLeading
- tm
.tmHeight
;
2479 lf
.lfWeight
= tm
.tmWeight
;
2480 lf
.lfItalic
= tm
.tmItalic
;
2481 lf
.lfUnderline
= tm
.tmUnderlined
;
2482 lf
.lfStrikeOut
= tm
.tmStruckOut
;
2483 lf
.lfCharSet
= tm
.tmCharSet
;
2484 cf
.Flags
|= CF_INITTOLOGFONTSTRUCT
;
2486 SelectObject (hdc
, oldobj
);
2487 ReleaseDC (FRAME_W32_WINDOW (f
), hdc
);
2489 if (!ChooseFont (&cf
)
2490 || logfont_to_fcname (&lf
, cf
.iPointSize
, buf
, 100) < 0)
2493 return DECODE_SYSTEM (build_string (buf
));
2496 static const char *const w32font_booleans
[] = {
2500 static const char *const w32font_non_booleans
[] = {
2508 w32font_filter_properties (Lisp_Object font
, Lisp_Object alist
)
2510 font_filter_properties (font
, alist
, w32font_booleans
, w32font_non_booleans
);
2513 struct font_driver w32font_driver
=
2515 LISP_INITIALLY_ZERO
, /* Qgdi */
2516 0, /* case insensitive */
2520 w32font_list_family
,
2521 NULL
, /* free_entity */
2524 NULL
, /* prepare_face */
2525 NULL
, /* done_face */
2527 w32font_encode_char
,
2528 w32font_text_extents
,
2530 NULL
, /* get_bitmap */
2531 NULL
, /* free_bitmap */
2532 NULL
, /* anchor_point */
2533 NULL
, /* otf_capability */
2534 NULL
, /* otf_drive */
2535 NULL
, /* start_for_frame */
2536 NULL
, /* end_for_frame */
2539 NULL
, /* get_variation_glyphs */
2540 w32font_filter_properties
,
2541 NULL
, /* cached_font_ok */
2545 /* Initialize state that does not change between invocations. This is only
2546 called when Emacs is dumped. */
2548 syms_of_w32font (void)
2550 DEFSYM (Qgdi
, "gdi");
2551 DEFSYM (Quniscribe
, "uniscribe");
2552 DEFSYM (QCformat
, ":format");
2554 /* Generic font families. */
2555 DEFSYM (Qmonospace
, "monospace");
2556 DEFSYM (Qserif
, "serif");
2557 DEFSYM (Qsansserif
, "sansserif");
2558 DEFSYM (Qscript
, "script");
2559 DEFSYM (Qdecorative
, "decorative");
2561 DEFSYM (Qsans_serif
, "sans_serif");
2562 DEFSYM (Qsans
, "sans");
2563 DEFSYM (Qmono
, "mono");
2565 /* Fake foundries. */
2566 DEFSYM (Qraster
, "raster");
2567 DEFSYM (Qoutline
, "outline");
2568 DEFSYM (Qunknown
, "unknown");
2571 DEFSYM (Qstandard
, "standard");
2572 DEFSYM (Qsubpixel
, "subpixel");
2573 DEFSYM (Qnatural
, "natural");
2579 DEFSYM (Qlatin
, "latin");
2580 DEFSYM (Qgreek
, "greek");
2581 DEFSYM (Qcoptic
, "coptic");
2582 DEFSYM (Qcyrillic
, "cyrillic");
2583 DEFSYM (Qarmenian
, "armenian");
2584 DEFSYM (Qhebrew
, "hebrew");
2585 DEFSYM (Qarabic
, "arabic");
2586 DEFSYM (Qsyriac
, "syriac");
2587 DEFSYM (Qnko
, "nko");
2588 DEFSYM (Qthaana
, "thaana");
2589 DEFSYM (Qdevanagari
, "devanagari");
2590 DEFSYM (Qbengali
, "bengali");
2591 DEFSYM (Qgurmukhi
, "gurmukhi");
2592 DEFSYM (Qgujarati
, "gujarati");
2593 DEFSYM (Qoriya
, "oriya");
2594 DEFSYM (Qtamil
, "tamil");
2595 DEFSYM (Qtelugu
, "telugu");
2596 DEFSYM (Qkannada
, "kannada");
2597 DEFSYM (Qmalayalam
, "malayalam");
2598 DEFSYM (Qsinhala
, "sinhala");
2599 DEFSYM (Qthai
, "thai");
2600 DEFSYM (Qlao
, "lao");
2601 DEFSYM (Qtibetan
, "tibetan");
2602 DEFSYM (Qmyanmar
, "myanmar");
2603 DEFSYM (Qgeorgian
, "georgian");
2604 DEFSYM (Qhangul
, "hangul");
2605 DEFSYM (Qethiopic
, "ethiopic");
2606 DEFSYM (Qcherokee
, "cherokee");
2607 DEFSYM (Qcanadian_aboriginal
, "canadian-aboriginal");
2608 DEFSYM (Qogham
, "ogham");
2609 DEFSYM (Qrunic
, "runic");
2610 DEFSYM (Qkhmer
, "khmer");
2611 DEFSYM (Qmongolian
, "mongolian");
2612 DEFSYM (Qbraille
, "braille");
2613 DEFSYM (Qhan
, "han");
2614 DEFSYM (Qideographic_description
, "ideographic-description");
2615 DEFSYM (Qcjk_misc
, "cjk-misc");
2616 DEFSYM (Qkana
, "kana");
2617 DEFSYM (Qbopomofo
, "bopomofo");
2618 DEFSYM (Qkanbun
, "kanbun");
2620 DEFSYM (Qbyzantine_musical_symbol
, "byzantine-musical-symbol");
2621 DEFSYM (Qmusical_symbol
, "musical-symbol");
2622 DEFSYM (Qmathematical
, "mathematical");
2623 DEFSYM (Qcham
, "cham");
2624 DEFSYM (Qphonetic
, "phonetic");
2625 DEFSYM (Qbalinese
, "balinese");
2626 DEFSYM (Qbuginese
, "buginese");
2627 DEFSYM (Qbuhid
, "buhid");
2628 DEFSYM (Qcuneiform
, "cuneiform");
2629 DEFSYM (Qcypriot
, "cypriot");
2630 DEFSYM (Qdeseret
, "deseret");
2631 DEFSYM (Qglagolitic
, "glagolitic");
2632 DEFSYM (Qgothic
, "gothic");
2633 DEFSYM (Qhanunoo
, "hanunoo");
2634 DEFSYM (Qkharoshthi
, "kharoshthi");
2635 DEFSYM (Qlimbu
, "limbu");
2636 DEFSYM (Qlinear_b
, "linear_b");
2637 DEFSYM (Qold_italic
, "old_italic");
2638 DEFSYM (Qold_persian
, "old_persian");
2639 DEFSYM (Qosmanya
, "osmanya");
2640 DEFSYM (Qphags_pa
, "phags-pa");
2641 DEFSYM (Qphoenician
, "phoenician");
2642 DEFSYM (Qshavian
, "shavian");
2643 DEFSYM (Qsyloti_nagri
, "syloti_nagri");
2644 DEFSYM (Qtagalog
, "tagalog");
2645 DEFSYM (Qtagbanwa
, "tagbanwa");
2646 DEFSYM (Qtai_le
, "tai_le");
2647 DEFSYM (Qtifinagh
, "tifinagh");
2648 DEFSYM (Qugaritic
, "ugaritic");
2650 /* W32 font encodings. */
2651 DEFVAR_LISP ("w32-charset-info-alist",
2652 Vw32_charset_info_alist
,
2653 doc
: /* Alist linking Emacs character sets to Windows fonts and codepages.
2654 Each entry should be of the form:
2656 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))
2658 where CHARSET_NAME is a string used in font names to identify the charset,
2659 WINDOWS_CHARSET is a symbol that can be one of:
2661 w32-charset-ansi, w32-charset-default, w32-charset-symbol,
2662 w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312,
2663 w32-charset-chinesebig5, w32-charset-johab, w32-charset-hebrew,
2664 w32-charset-arabic, w32-charset-greek, w32-charset-turkish,
2665 w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,
2666 w32-charset-russian, w32-charset-mac, w32-charset-baltic,
2669 CODEPAGE should be an integer specifying the codepage that should be used
2670 to display the character set, t to do no translation and output as Unicode,
2671 or nil to do no translation and output as 8 bit (or multibyte on far-east
2672 versions of Windows) characters. */);
2673 Vw32_charset_info_alist
= Qnil
;
2675 DEFSYM (Qw32_charset_ansi
, "w32-charset-ansi");
2676 DEFSYM (Qw32_charset_symbol
, "w32-charset-symbol");
2677 DEFSYM (Qw32_charset_default
, "w32-charset-default");
2678 DEFSYM (Qw32_charset_shiftjis
, "w32-charset-shiftjis");
2679 DEFSYM (Qw32_charset_hangeul
, "w32-charset-hangeul");
2680 DEFSYM (Qw32_charset_chinesebig5
, "w32-charset-chinesebig5");
2681 DEFSYM (Qw32_charset_gb2312
, "w32-charset-gb2312");
2682 DEFSYM (Qw32_charset_oem
, "w32-charset-oem");
2683 DEFSYM (Qw32_charset_johab
, "w32-charset-johab");
2684 DEFSYM (Qw32_charset_easteurope
, "w32-charset-easteurope");
2685 DEFSYM (Qw32_charset_turkish
, "w32-charset-turkish");
2686 DEFSYM (Qw32_charset_baltic
, "w32-charset-baltic");
2687 DEFSYM (Qw32_charset_russian
, "w32-charset-russian");
2688 DEFSYM (Qw32_charset_arabic
, "w32-charset-arabic");
2689 DEFSYM (Qw32_charset_greek
, "w32-charset-greek");
2690 DEFSYM (Qw32_charset_hebrew
, "w32-charset-hebrew");
2691 DEFSYM (Qw32_charset_vietnamese
, "w32-charset-vietnamese");
2692 DEFSYM (Qw32_charset_thai
, "w32-charset-thai");
2693 DEFSYM (Qw32_charset_mac
, "w32-charset-mac");
2695 defsubr (&Sx_select_font
);
2697 w32font_driver
.type
= Qgdi
;
2698 register_font_driver (&w32font_driver
, NULL
);
2702 globals_of_w32font (void)
2705 g_b_init_get_outline_metrics_w
= 0;
2706 g_b_init_get_text_metrics_w
= 0;
2707 g_b_init_get_glyph_outline_w
= 0;
2708 g_b_init_get_char_width_32_w
= 0;